LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TDMS with timestamp and configurable channels

I am trying to figure out a good way to determine how to line up data in a TDMS file with corresponding timestamps when the user in my application adds channels.

 

Here's the scenario,

Lets say I've been recording 10 channels (called Ch0,Ch1...Ch9) in a group called 'Data'. My data appears as follows in the TDMS file:

 

(10 Ch's, 3 Samples) 

Timestamp Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch9
12:00:01 AM 100 200 300 400 500 600 700 800 900 1000
12:00:02 AM 100 200 300 400 500 600 700 800 900 1000
12:00:03 AM 100 200 300 400 500 600 700 800 900 1000

 

Let's say now the user decides to add an additional channel to the group. The TDMS write function will add the channel, but the new data does not line up with the corresponding timestamp, instead it start writing to the first row as follows:

 

(11 Ch's, 6 samples, 3 new channel samples)

Timestamp Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch9 Ch10
12:00:01 AM 100 200 300 400 500 600 700 800 900 1000 1100
12:00:02 AM 100 200 300 400 500 600 700 800 900 1000 1100
12:00:03 AM 100 200 300 400 500 600 700 800 900 1000 1100
12:00:04 AM 100 200 300 400 500 600 700 800 900 1000  
12:00:05 AM 100 200 300 400 500 600 700 800 900 1000

  

12:00:06 AM 100 200 300 400 500 600 700 800 900 1000

  

 

I would want it to appear as follows:

Timestamp Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch9 Ch10
12:00:01 AM 100 200 300 400 500 600 700 800 900 1000
12:00:02 AM 100 200 300 400 500 600 700 800 900 1000
12:00:03 AM 100 200 300 400 500 600 700 800 900 1000
12:00:04 AM 100 200 300 400 500 600 700 800 900 1000 1100
12:00:05 AM 100 200 300 400 500 600 700 800 900 1000

1100

12:00:06 AM 100 200 300 400 500 600 700 800 900 1000

1100

  

Other than just starting a brand new TDMS file, can anyone think of a way to line the data up with its corresponding timestamp in this scenario? Or if there is a way to determine what the corresponding timestamp is when I read in the TDMS file.

 

Any help is appreciated

Thanks,

-CAC

0 Kudos
Message 1 of 4
(2,598 Views)

Any suggestions...?

0 Kudos
Message 2 of 4
(2,579 Views)

Can you post your block diagram ? I´m still new in Labview, I´m having trouble with the header, how to edit the header in the tdms file ?

 

 

dt (ms) channel 0 channel 1 channel 2
0 1 2 3
0,1 4 5 6
0,2 7 8 9
0,3 10 11 12
0 Kudos
Message 3 of 4
(2,565 Views)

From your description that the channel values have their corresponding timestamp, I assume that you are writing the waveform data rather than those basic data type(integer, double, etc.) which do not have any timestamp related information.

 

 

The reason that the new data in Ch10 does not line up with the same timestamp data in other channels is because:

  • When writing data to a channel, it cannot leave the first several positions vacant, and start writing from the nthe position.
  • From the view of TDMS as a file format, it should only be responsible for data logging, and not assume any relationship between channels.

 

In your case, the new data in Ch10 channel should have the timestamp starting from 12:00:04 AM to 12:00:06 AM, these data are definitely stored from the first position of Ch10, and .tdms file format cannot do anything to line up the data between channels.

Timestamp Ch0 Ch1 Ch2 Ch3 Ch4 Ch5 Ch6 Ch7 Ch8 Ch9 Ch10
12:00:01 AM 100 200 300 400 500 600 700 800 900 1000 1100 (12:00:04 AM)
12:00:02 AM 100 200 300 400 500 600 700 800 900 1000 1100 (12:00:05 AM)
12:00:03 AM 100 200 300 400 500 600 700 800 900 1000 1100 (12:00:06 AM)
12:00:04 AM 100 200 300 400 500 600 700 800 900 1000  
12:00:05 AM 100 200 300 400 500 600 700 800 900 1000

  

12:00:06 AM 100 200 300 400 500 600 700 800 900 1000  

 

 

For your second question, there is a approach to determine the corresponding timestamp of each channel data read out from .tdms file. The waveform data type is stored in .tdms file in the form of three components:

  1. Value array value[ ]
  2. Starting time stamp t0, which is the base timestamp of a channel (or the timestamp of the first value in this channel)
  3. Time increment dt, the time interval between two data samples. (e.g. one sample per second, dt=1.0; four samples per second, then dt=0.25)

So it's very easy to calculate the Timestamp of value[index] = t0 + (dt * index)  (0 <= index < num of samples in value[])

 

Here is a VI in the attachment that demonstrates how to get the timestamp of each value in the channel.

 

Regards,

Tianbin

0 Kudos
Message 4 of 4
(2,548 Views)