From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add measurement time to DAQmx logging

Hello,

Is it possible to add a column with measurement time values to the TDMS-file created with DAQmx logging configuration?

I'm working on a VI to measure a voltage signal with 150 kHz sample rate (see attached VI) and want to make sure that I don't loose any data, e.g. due to buffering. Therefore it would be nice to know the time distance between individual measurement values. I'm using DAQmx functions because I observed the loss of data packages while using the DAQ-assistant...

Do you have any ideas on how to additionally store time data?

0 Kudos
Message 1 of 3
(2,835 Views)

You are writing a 1D array of data using the built-in TDMS functions to save the data.  Why don't you try saving the data as a Waveform, which will give you a t0 value for each set of samples?  The hardware will ensure that all of the N samples have the same delta-t, so the only timing question is the time between the first set of N samples and the second -- is it N*delta-t?  Well, if N*delta-t = (t0(second) - t0(first)), you know you missed no data.

 

If, for some reason, this doesn't work, another thing you can do is to "unbundle" the TDMS write from the DAQmx functions and handle the writes yourself -- open the TDMS file outside the While, do a Write inside the While, and close afterwards.  The reason I mention this is if the Waveform idea isn't possible (I think that's the optimal solution), you can add an "extra point" to the end of your array that is the Dbl value of the Current Time (giving you N+1 points, with the last one "special" -- I already don't like this method!).  It would allow you to post-process, comparing these "Clock" entries to verify data integrity (if the data are good, you could rewrite the TDMS file, renaming it from "My Preliminary Data" to "My Good Data" and eliminating the Clock entries).

 

Sorry I mentioned that -- go with Method #1 (if it works).

 

Bob Schor

 

P.S. -- I used a variant of Method #2 in a project I was doing, but I was sampling N channels 1 sample in an RT situation and needed tomake sure that sampling loop ran at 1KHz, so I added a named "Clock" channel which held a millisecond clock that I could see "count up by 1".  Earlier (poorly-written) code that ran at 500Hz routinely missed 4-6 data points in a 1 minute run -- my routine never missed a point.

0 Kudos
Message 2 of 3
(2,823 Views)

@Aliom wrote:

I'm working on a VI to measure a voltage signal with 150 kHz sample rate (see attached VI) and want to make sure that I don't loose any data, e.g. due to buffering.


You would get an error from the DAQmx Read if you had a buffer overflow.  Otherwise, you have nothing to worry about.  The data is being logged at the driver level.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(2,799 Views)