08-14-2023 12:14 PM - edited 08-14-2023 12:27 PM
Hi,
I'm working on a VI that will acquire data from a torque transducer and a tachometer, which are both read as analog inputs. I'd like to read the data at a fairly high rate (10kHz) and output the data to a file that has three columns. Column 1 should be the relative time of the acquisition, beginning at zero, and columns 2 and 3 should be the torque and speed data. I've written the attached VI, which acquires the data successfully and displays it on a waveform chart, but I'm a little bit stuck as to the best way to save this data to a file. I've done a lot of reading about various methods, including logging to a TDMS file and streaming using a producer-consumer setup, but I'm confused as to what would be the appropriate thing to do here.
Any help or suggestions would be very much appreciated.
Thanks,
Dan
08-14-2023 12:23 PM - edited 08-14-2023 12:30 PM
If you are acquiring data at a 10Khz rate then a Producer/Consumer would be my program architecture of choice.
The Producer/Consumer allows the acquisition (Producer loop) to run full speed placing data into the queue. Then the Consumer loop can takes it's time displaying, analyzing, and saving data without effecting the DAQ timing.
08-14-2023 12:24 PM
Unfortunately, no attachment. Easiest way here is DAQmx TDMS logging.
08-14-2023 12:27 PM
Sorry, somehow the attachment got lost in my original post. Here's the current VI.
08-14-2023 12:31 PM
I tried using the DAQmx TDMS logging approach, but I couldn't see a way to get timestamps into the file. Is there a way to do that?
Thanks very much for the suggestion.
Dan
08-14-2023 01:47 PM
Hi Dan,
@dasselin wrote:
I tried using the DAQmx TDMS logging approach, but I couldn't see a way to get timestamps into the file. Is there a way to do that?
As DAQmx TDMS logging is writing waveforms you get timestamps for free…
08-14-2023 03:49 PM
Hi GerdW,
Thanks for your reply; attached is a version of my VI with TDMS logging enabled. When I run this version, I don't get a time column in the resulting file. Am I doing something wrong? Apologies if this is a very basic question--I've never used this functionality in LabVIEW before.
Thanks,
Dan
08-15-2023 01:00 AM
Hi dasselin,
I prefer LV2019, so please use File->Save for previous on your VI…
@dasselin wrote:
When I run this version, I don't get a time column in the resulting file. Am I doing something wrong?
How do you examine that TDMS file? I hope you are not using Excel to do so…
Did you try out the TDMSFileViewer yet?
08-16-2023 08:43 PM
If your data are really Waveforms, NI's compact data structure for sampled data (where the data points are guaranteed to occur at equally-spaced-in-time "times"), then if you have 1000 data points saved as an array of (time, Y), you would require 2 x 1000 = 2000 data points, with the time "boring", being (t0, t0+dt, t0+2dt, ...), whereas if you saved it as a Waveform, you would only need 1002 points, as you'd save t0, dt, and the Y array.
I don't (personally) have a lot of experience with TDMS, but one of the ways to speed up I/O would be to "write less", and the difference between a Waveform cluster and an XY array of time and value is a factor of 2, a big "win" in terms of Time and Space.
Bob Schor
08-16-2023 10:54 PM - edited 08-16-2023 11:04 PM
@dasselin wrote:
Hi GerdW,
Thanks for your reply; attached is a version of my VI with TDMS logging enabled. When I run this version, I don't get a time column in the resulting file. Am I doing something wrong? Apologies if this is a very basic question--I've never used this functionality in LabVIEW before.
Thanks,
Dan
No need to apologize! The EXACT humdiggory inside DAQmx Logging and TDMS structure takes a bit of getting used to if you have tolerated flat data for too long. TDMS should have been born a generation earlier!
Your acquisition should use that DAQmx Read.vi 1D Wfm (array of waveforms) polymorphic instance. Refer to the detailed Help for DAQmx Read.vi. That will Log an array of timestamps with the data. If you chose the 2D(dbl).you can still recreate the relative time to t0 since the sample rate for each DAQmx Task is logged as a Group Attribute in the TDMS File.