LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TDMS Timestamp Decoding - Help!!

I am in need of help with decoding the timestamp in TDMS files.  Specifically in the properties section.  The following (very vague documentation) provides limited details:
 
 
Specifically looking for bit definition of the "tdstimestamp" type.  As an example I extract the following hex values from a TDMS file:
 
44 00 00 00 EA D8 C5 AC 4F 9E 56 BC C2 2F F3 C3 00 00 00 00
 
I know that the first four bytes (44 00 00 00) signify the timestamp datatype, but how do I decode the remaining bytes.    The approximate time of above is 11:55:41AM on March 4, 2008.
 
Thanks for any help!
0 Kudos
Message 1 of 42
(9,719 Views)

Are you trying to read in values to C?

LabVIEW has a Get and Set Properties VI as well as a TDMS File Viewer VI that may help.

Or are you looking to actually decode manually (via C or some other language) the hex code and be able to interpret the proper time?

David_B
Applications Engineer
National Instruments
0 Kudos
Message 2 of 42
(9,670 Views)
I have it partially figured out.

The bytes are in reverse order.  The 0x0000 0000 appears to be unused and doesn't change.

the 0xC3F3 2FC2 is a DBL correspoding to the number of secs since 12:00 a.m., Friday, January 1, 1904.  In your case 3,287,494,594, which is 11:56:34 AM on 3/4/2008.  The other bytes represent the milliseconds, but I have not determined yet how to use them.
Message 3 of 42
(9,661 Views)

Matt,  Thanks!  I verified this works.  I'll take a look at the milliseconds. 

Dave , I have a .tdms to .mat (MATLAB) file translator written.   This by the way was VERY frustrating as the documentation on the page above is very vague/ambious and I hope does not represent internal documentation standards at NI.  Why does diadem have a .mat file conversion but LabView does not?

 

 

0 Kudos
Message 4 of 42
(9,657 Views)
Finally had a chance to look at the ms part.  The remaining data (in your case 0xBC56 9E4F ACC5 D8EA) is the numerator of the fractional seconds.  Divide that 64-bit number by 0xFFFF FFFF FFFF FFFF and you get the franctional seconds.

So, in your case:

13,571,208,592,165,820,650 / 18,446,744,073,709,551,615 = 0.735697s

Matthew


0 Kudos
Message 5 of 42
(9,615 Views)

I don't know if you've checked into using a data plugin (you may be writing your own), but we do have one available for .MAT files on our website:  DataPlugins: Supported Data Formats.

Additional resources that you may find helpful would include Reading and Writing TDM/TDMS Files that contains links to a number of guides regarding the TDMS file format as well as interfacing with third-party data files.  There are also two examples found here: Loading Data with a DataPlugin Within LabVIEW that illustrate how to read data into LabVIEW using a data plugin.

David_B
Applications Engineer
National Instruments
0 Kudos
Message 6 of 42
(9,598 Views)
Matt - Thanks, that works great!!
 
Dave,  I see that the MATLAB pluggin was just updated to include MATLAB 2008b.  We take data in our labratory using the TDMS format.  When we distribute this to other researchers, they often use MATLAB (and of course Labview). 
 
For about a year now, the Matlab pluggin has been out of date and would not work with the last 3 releases of MATLAB.  Since it is a compiled C library, we're stuck and can not modify it.  As the internal TDMS format is not changing and only low level matlab commands are required to read it, I believe that Matlab users have been looking for a simple Matlab function to just take a tdms file and make a similar .mat file (not a dll).  This is what I have done (and thanks to Matt for the timestamp help).
 
The Excel TDMS add-in is very nice and is a good reason to use the TDMS format (in addition to its good support in VI libraries), but I often have to fend off requests to write large ASCII or flat binary files (in addition to our TDMS files) so that they can be read in MATLAB.  I don't want to have the burden of making/distributing a LV executable that makes this interim file format and then creates a .mat file.   
0 Kudos
Message 7 of 42
(9,585 Views)
bradh,

Are you able to post or submit the matlab script that auto-converts TDMS to .mat?  Were you able to do it generically?  Or do you have to hardcode some of the properties, channel names, etc.?

There have been a few threads where people (myself included) have been having trouble with just this sort of conversion...

-Kevin P.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 42
(9,560 Views)
Yes, I am just about done with it. I will upload it probably later today.  It is generic and does not require any other information than the file name.  It works with TDMS files as generated on our systems.  We write waveform data types to the  high speed G TDMS blocks which are optimized for speed but seem to write some repetitive property infomation.  It would be great if you could try the code with some of your tdms files and let me know how they work.  I would like to make sure the code is robust to changes in methods of writing to TDMS files. 
0 Kudos
Message 9 of 42
(9,550 Views)

A copy of the MATLAB conversion function is attached.  On a first glance, it looks overly complicated but was done so to maximize speed (we convert 100MB tdms files in about 2 minutes).  I would love to get feedback from other users on it's compatibilty with other TDMS structures. 

(Had to change the file extention to .txt as .m was not allowed - needs to be changed back)

Thanks again to Matthew K on decoding the timestamp.

0 Kudos
Message 10 of 42
(9,525 Views)