06-29-2021 08:43 PM - edited 06-29-2021 08:45 PM
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!
06-30-2021 01:39 AM - edited 06-30-2021 01:40 AM
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?
06-30-2021 04:18 PM
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?
07-01-2021 01:30 AM
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…