LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

High speed data logging timestamp

I'm logging data at 500Hz into a spreadsheet file, and I want accurate timestamps for each point. I'm using the "Get Date/Time In Seconds" and "Format Date/Time String" functions to generate my time stamp. The fractional seconds field doesn't update every scan (I'll get ~7 or 8 samples with the same time stamp), but my data does change every scan, so the time stamp appears to be lying to me. This leads me to believe that the functions I'm using to extract the time stamp won't update that fast. Is there anything that I can do differently to remedy this?
0 Kudos
Message 1 of 11
(6,039 Views)

Hi morsejl,

how do you measure your data? Which hardware do you use? With DAQmx you can measure a block of samples and calculate the timestamp for each sample out of the first one.

Mike

0 Kudos
Message 2 of 11
(6,033 Views)
I'm using a USB-6008 module and measuring with DAQmx blocks (create channel/daqmx timing/daqmx start/daqmx read). The read/signal manipulation/write operations are taking place in a while loop where I'm using a shift register to shut down the operation after X number of samples (usually 33000, or just over a minutes worth of data). I scale the voltages, concatenate them with the time data, and write to the file using a Write to Spreadsheet File vi. Everything works perfectly except for the time stamp issue.
0 Kudos
Message 3 of 11
(6,003 Views)

Hi morsejl,

if you use DAQmx you can use the read vi with following function: Analog -> single channel -> multiple samples -> waveform. If you do that you get a timestamp, all values and a dt. With the delta t and the timestamp (which is the time for the first value) you can calculate the timestamp for all other values.

Mike

Message 4 of 11
(5,998 Views)
Thanks, that got me pointed in the right direction. I'm actually looking at a couple of channels so I set it to multiple channels. I'm using Get Waveform Components to get the timestamp from t0, which gives me a correct, updated timestamp (down to the fractional second) for every sample.
0 Kudos
Message 5 of 11
(5,981 Views)

Hi morsejl,

 

Do you have any examples of your work? I encountered the same problem as you and I need help badly.

Thanks a lot

0 Kudos
Message 6 of 11
(5,679 Views)

Hello,

 

The post above regarding using a waveform is the best way to correlate data acquisition with times. You would need to use the Get Waveform Components VI to extract these. In the picture below, the Y output is the Amplitudes, t0 is the first timestamp, and dt is the change in time between each sample. The dt will remain constant and thus you can calculate your times by adding to the timestamp. Your other option would be to assume that the first sample is taken at time t=0 and then add to that time instead of the timestamp.

Waveform Components.png

-Zach

Message 7 of 11
(5,642 Views)

iZACHdx wrote:

Hello,

 

The post above regarding using a waveform is the best way to correlate data acquisition with times. You would need to use the Get Waveform Components VI to extract these. In the picture below, the Y output is the Amplitudes, t0 is the first timestamp, and dt is the change in time between each sample. The dt will remain constant and thus you can calculate your times by adding to the timestamp. Your other option would be to assume that the first sample is taken at time t=0 and then add to that time instead of the timestamp.

Waveform Components.png

-Zach


The above illustrates the method I use most often. Note that if you are externally clocking the acquisition, you will have to use another approach.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 11
(5,639 Views)

Hi Zach,

 

Thanks for your reply.  

If I have N channels and N samples acquisition, does this method still apply? Coz currently I have three channels to measure at the speed of 500 samples/s. The application needs to export each data with respective timestamp to a text or Excel file.

 

Regards,

Kid 

0 Kudos
Message 9 of 11
(5,623 Views)

Hello,

 

If you have multiple channels, the analog read returns an array of waveforms. You will have to index the array and then use the get waveform components as before. Using the t0 and dt for each waveform is redundant because they should all share the same timestamp and dt, but you get the idea. See below:

Example.png

 

-Zach

 

Message 10 of 11
(5,605 Views)