LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using waveform chart or graph to view analog signal for some amount of time?

I'm new to LabVIEW and am still having trouble figuring out how to accomplish my task, although I think I'm pretty close and just looking for some help.

 

General goal: Essentially I am reading an analog signal using DAQmx from two different channels and conducting an experiment for 60 sec (not an exact value). During this time I want to sample the two analog signals at a frequency of 1 kHz. While this is going on I want all the values of the analog signals to be displayed on a graph/chart (such that values are not deleted). In other words, my graph would have 0 to ~60 seconds on the x-axis, and voltage values of the two signals on the y-axis. If the graph appears after the 60 seconds are over (rather than continuously showing new data during the 60 second period) that would be fine too, though not as ideal. Finally I want to export the data as a csv (or excel, table, etc.).

 

Specific problem: I've attached a file of what I have so far (based on a tutorial).

(1) For the timing function I'm confused on if I should set the sample mode to finite sampling or continuous. My experiments last about 60 seconds, but it would be easier if data is continuously collected until I press a stop button. And also would the samples per channel essentially be 60 times my frequency (in order to collect data for 60 sec)? 

 

(2) Then I'm not sure what to set the number of samples per channel within the read function, and whether the read function should be within a while loop or not.

 

(3) And finally, should the output of the read function be directly inputted into a chart or graph? Or should it be first put into array structure / array data converter of some sort?

 

Sorry for the long (and basic) post! Any help/resources on this would be much appreciated!

0 Kudos
Message 1 of 4
(1,179 Views)

Hi Fan,

 


@KnicksFan wrote:

(1) For the timing function I'm confused on if I should set the sample mode to finite sampling or continuous. My experiments last about 60 seconds, but it would be easier if data is continuously collected until I press a stop button. And also would the samples per channel essentially be 60 times my frequency (in order to collect data for 60 sec)? 

 

(2) Then I'm not sure what to set the number of samples per channel within the read function, and whether the read function should be within a while loop or not.

 

(3) And finally, should the output of the read function be directly inputted into a chart or graph? Or should it be first put into array structure / array data converter of some sort?


  1. When you don't know the exact number of samples to be acquired before starting the task you should use the "continuous" sampling mode! (Read the help for DAQmxTiming especially for that "continuous" mode, and then delete the "samples per channel" control!)
  2. The recommendation is to read about 1/10 of the sample rate, resulting in loop iteration rates of 10Hz. So at 1kS/s you would read 100 samples per DAQmxRead call…
  3. When reading 2 channels at 1kS/s for >=60s you will end up with >=120kS, which will need >=960kiB. Usually a modern computer can easily handle that amount of data, but it doesn't make any sense to plot so many samples in a chart/graph of only less than 200 pixels width! It will make more sense to save the samples directly into a file (DAQmx can do this for you!) and to plot only a decimated number of samples…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(1,132 Views)

Thanks for your help GerdW! I was able to implement most of the changes in the attached file, but am still unsure about a few things:

 

(1) For saving data, I directed the data into a build array function within the while loop, and then fed the output of the array into a TDMS write function that is outside the while loop. I believe this logic makes sense, but I'm getting an error about data types. Any idea what could be the issue?

 

(2) Is there an easy way to plot only a subset of the data?

0 Kudos
Message 3 of 4
(1,100 Views)

Hi Fan,

 


@KnicksFan wrote:

(1) For saving data, I directed the data into a build array function within the while loop, and then fed the output of the array into a TDMS write function that is outside the while loop. I believe this logic makes sense, but I'm getting an error about data types. Any idea what could be the issue?

 

(2) Is there an easy way to plot only a subset of the data?


1.

Why do you use the BuildArray in exactly this place?

Why is the output tunnel set to "last value" mode? Is that what is required to save to file?

That logic makes absolutely NO sense to me…

What do you want to save? When you want to save all the measurement data then the TDMSWrite should needs to be inside to the loop! (Or use the DAQmxDataLogging functionality, found in the DAQmx->Advanced palette…)

 

2.

Right now you plot a history of data in your chart and the current block of data in a graph.

When you want to show just a subset of the current block in your graph then you should use the ArraySubset function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(1,085 Views)