LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timestamps with TDMS Writing

Hello,

 

I am writing some data into a TDMS file using the OPEN/WRITE/CLOSE tdms sequence and then I am reading it back using the OPEN/CLOSE/READ sequence but I dont know how to insert a timestamp of the absolute time and date when I write and recover it back when I read.

Any help would be appreciated!

 

0 Kudos
Message 1 of 8
(6,840 Views)

You have three options.

  1. If you use a waveform datatype for your data, the time and date are encoded in the timestamp portion of the waveform.  If you got the data as a waveform from something like a DAQ device, the timestamp will be the absolute time the data was taken (subject to the accuracy of the timing source).  If you create the waveform yourself, you need to set the timestamp.  You can find methods of creating timestamps in the  Timing palette.
  2. You can use TDMS Set Properties to set a timestamp property on your data.  Use TDMS Get Properties to retrieve it.  Create the timestamp as in option 1.
  3. Save a timestamp as a data set.
Note that the first two options are specific to data sets, while the second is global.  Let us know if you need further assistance.
0 Kudos
Message 2 of 8
(6,802 Views)

Hello DFGray,

 

Thanks  for the reply.

 

Now the data I am writing is some manipulated data from a daq signal and is writen as a dynamic data type (which i think has time in it as well).

 

When I read it back using the open/read/close sequence I get waveform of the data I read but the time axis starts from zero, even though its not correct (i.e. if i write for 50 s the time axis when I read it back not only starts from zero but its only 20 or so seconds).

 

Basically the data type out of the read tdms is 1D array DBL, so its not a dynamic type (for which i am guessing the problem is).

 

I am very very new to LabView so your further help would be appriecated.

 

 

 

 

0 Kudos
Message 3 of 8
(6,797 Views)
You are correct that a 1D DBL array has no timing information.  You need a waveform datatype (WDT) for timing information.  Dynamic data types (DDTs) can also contain timing, but may not.  Given you are fetching data from a DAQ device, the DDT you stored should contain timing.  TDMS Read has a data type input.  Wire a WDT constant to this input so you are reading a WDT (newer versions of LabVIEW have a WDT constant in the palettes, you can create one on older versions by creating a constant from any subVI with a WDT input or output).  This should give you the timing information you want.  If this doesn't work, post your code so we can debug it.
0 Kudos
Message 4 of 8
(6,781 Views)

Hello,

 

I understand your explanation in fact I was trying it yesterday but couldn’t sort it out completely!

 

Anyhow (because things are strange and unforeseen) I am using again the write and read to measurement file and with the use of align & resample and select signals vi (in parallel for comparison) I think I am getting the time axis right.

 

So the problem was easier than i thought.

 

I am planning a bit later though to (because we have to record measurements for up to seven days continuously in one case) to discard some data ( for example not to write to file when current is very small, but I would preferably want to have the time information written on the file), so I was wondering if you have any ready files I can see on how to do that. 

 

I know I can use the enable setting of the write to measurement file with probably a comparison sign but maybe you know better ways of doing it.

 

 

Thank you for help.

 

Regards 

 

0 Kudos
Message 5 of 8
(6,773 Views)

Hi Tony,

 

Thats it exactly, by using the comparison that should allow you to only save to file when you have met your trigger settings.

 

Regards,

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
0 Kudos
Message 6 of 8
(6,754 Views)

Tony,

 

I am unsure, from your post, whether you want to store single points or waveforms when your current is above a certain threshold.  I also do not know how fast you are acquiring data.  The solution will differ depending on these items.  You may also want to check the LabVIEW help for data logging example (Help >> Find Examples...).  For waveforms (fast data collection), all you need to do is store a WDT.  This will timestamp the data.  For single points (slow data collection), save a timestamp and the data as a data pair (in TDMS, this would be data and attribute).

 

Let us know if you need more info.

0 Kudos
Message 7 of 8
(6,741 Views)

Hello,

 

So far we are taking measurements correctly thank you for your replies.

 

As James said the best way to do it  is to use a comparison vi for enabling the write to meaurament file.

 

I guess the latest will probably do the job for us if we plan to take very long time measuraments and discarding some data (hopefully it must have the time information).

 

{@DFGray - I am sampling at 1k Hz and reading 200 samples. I am measuring current, voltage at 50 Hz (mains) as well as unperiodic voltage from thermistors which is then translated to temperature (at the same rate as I want the readings at the same time).}

 

So for the moment we are not encountering any problems yet!

 

If we encounter any problems Ill let you know gentleman.

 

Thank You!

 

0 Kudos
Message 8 of 8
(6,731 Views)