LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write Waveform Data to File with Timestamps

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

0 Kudos
Message 1 of 12
(1,429 Views)

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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 12
(1,420 Views)

Unfortunately, no attachment. Easiest way here is DAQmx TDMS logging.

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 3 of 12
(1,417 Views)

Sorry, somehow the attachment got lost in my original post. Here's the current VI.

0 Kudos
Message 4 of 12
(1,406 Views)

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

0 Kudos
Message 5 of 12
(1,398 Views)

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…

Best regards,
GerdW


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

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

0 Kudos
Message 7 of 12
(1,349 Views)

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?

Best regards,
GerdW


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

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

0 Kudos
Message 9 of 12
(1,279 Views)

@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. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 12
(1,271 Views)