LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuously 2chan daqmx display

Solved!
Go to solution

Hi,

 

I'm trying to create a program which can read and continuously display two channels ( force and acceleration).
I'm using a DAQ card NI PXI-4472B.

Please take a look at the attached file. ( It's made in Labview 8.5.1).

 

The problem which occurs is the following:
If I connect my laptop to the NI DAQ equipment and I run the program, both of the graphs do not continuously show the acquired data.

Every 6 seconds they update and show a plot with the data acquired in those 6 seconds.

 

Now I would like that from the moment the trigger level is reached, both of the graphs start displaying the data in continuously. ( So whenever a force or acceleration is measured it has to be displayed on the Force-graph).

All of the acquired data has to remain in the graphic for about 10-15 seconds. After those 15 seconds the program should automatically stop.

 

Any hints of tips how I can do this?

Btw, did I set the right properties for the DAQmx trigger? 'Force' is connected to ai0, 'Acceleration' to ai1

 

 

Thanks!

Dries

 

0 Kudos
Message 1 of 11
(3,507 Views)
Solution
Accepted by topic author DriesM

The reason you get an update every 6 seconds is that the way you have programmed it. You have a sample rate of 10000 samples per seconds and then request 60000 samples. Basic arithmetic says 60000 Samples/10000 Samples/sec equals 6 seconds. So, decide how fast you really want the display to update and set the number of samples based on that. You are also using a graph incorrectly if you want the previous samples to remain on the screen. The graph discards old data with every write to it. You want to use a chart and you will need to set the history (right click option) to the number of samples you will be taking. If you want the acquisition to automatically stop, you can use the Elapsed Time function.

 

 

Message 2 of 11
(3,498 Views)

Hi,

 

Thank you for your very fast reply.
I've made the following modifications:

- Change Graph to Chart

- Rate = 10000Hz

- Number of samples per channel = 10000

 

If I'm right, this means that the device will read 10000 samples per second and the DAQmx read needs 10000 samples before they will be plotted in the chart?

I also changed the 'Chart History Length' from 1024 to 60000. If I'm right this means that the chart will be able to 'remember' up to 60000 samples?

 

So this would mean, that if I start the DAQmx device, it will read 10000 samples per second, displays them at once in the chart and the next 10000 samples will be added to the chart as well, without overriding the previous 10000 samples?

 

However, if I start the program it reads 10000 samples and displays them at once, but when the second measurement is done ( samples 10001 - 20000) the chart overrides the first 10000 samples and displays only the samples 10001 - 20000.
I hope you understand what I'm trying to say and that you can help me out.

I've added the .vi file in attachment.

 

Many thanks,

Dries

 

I also have a question about triggering. Can I post it in here or should I create a new topic?

0 Kudos
Message 3 of 11
(3,471 Views)

I got rid of the evil conversion to dynamic data by just using an index array function and the plotting seems correct.

0 Kudos
Message 4 of 11
(3,467 Views)

Could you post that solution for me, please?

 

Thanks.

0 Kudos
Message 5 of 11
(3,441 Views)

Wire an Index Array function to the 2D array. Drag it down to get an output for each channel. You can also change the data type from the DAQmx Read to 1D Waveform Array.

Message 6 of 11
(3,435 Views)

Okay, thanks a lot 🙂

And what do I have to take as 'Index' then?

 

 

Can I also use the 1D Waveform if I want to add some more code to the program which will allow me to save the measured data to a .mat ( matlab) file?

0 Kudos
Message 7 of 11
(3,425 Views)

You really don't have to specify an index number. If you just drag it down, the first output is index 0, the second output is index 1, etc.

 

The waveform datatype has all of the information that the 1D/2D array has with the addition of t0 and dt so it is much better for exporting. I don't know what specific format that your .m file requires but you can get individual components with the Get Waveform Components function.

0 Kudos
Message 8 of 11
(3,418 Views)

Now the vi should be able to plot 60.000 samples next to each other ( at a 10.000Hz rate) ?

 

I have two more questions:

 

1) If I change the sample mode from 'continuous samples' to 'finite samples', will the vi automatically stop after plotting the 60.000 samples or not? If not, how can I make the vi to stop after reading and displaying those 60.000 samples?

 


2) I would like to involve a trigger into the vi. The trigger should activate the program whenever the Force ( channel 0) exceeds 1 Newton.

I've already tried to connect the DAQmx trigger vi between the Timing and the Start Task DAQmx vi's ( see attachment) but for some reason the triggering does not work properly. ( I don't know if the Trigger knows that Force is connected to channel 0 and that he must trigger on that channel?)
I've seen some programs which make use of a DAQmx Trigger Property Node but I don't really understand how that works. I've tried to search for some good tutorials on Triggering, but I haven't found any I can use...

 

I'll try this setup asap 🙂

Thanks, again!

0 Kudos
Message 9 of 11
(3,409 Views)

No, it will not automatically terminate if you have it inside a while loop. You can use a for loop with either finite or continuous sampling.

 

Your VI does not have a source for the trigger (i.e. Dev1/ai).

Message 10 of 11
(3,403 Views)