LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read last value of a large TDMS file

Solved!
Go to solution

Hello everyone!!

 

I hope someone can help me out with this one.

 

I'm trying to set up a program capable of reading the last value of one of the channels of different large TDMS files but I just can´t find a way to do that.

 

I would really appreciate any help with my little problem.

 

Thank you very much in advance for your support.

 

Kasim.

0 Kudos
Message 1 of 10
(4,420 Views)

There is a property 'NI_ChannelLength' (or something like that) that shows you the number of elements in a channel.

 

You can use that to get the offset you need to read.

 

Ton 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 10
(4,405 Views)

Hi Ton!

 

Thank you very much for your help!

 

My TDMS file doesn't have the property NI_ChannelLength. Is that a property I have to initialize when creating the TDMS file?

0 Kudos
Message 3 of 10
(4,397 Views)

It's a channel property (every channel and group can have different lengths). I think it's added by the TDMS API of LabVIEW.

 

Ton 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 10
(4,383 Views)
Solution
Accepted by Mephistofeliz

Hi,

 

You can use the TDMS Set Next Read Position function included in the TDMS API.  This function receives a parameter called "from (0:start)", which can be set to 1 to access the end of the file.  This way, you can read the last value written to the TDMS file. 

 

Hope this helps!

 

Anuar Rojas

Anuar R.
National Instruments México y Latinoamérica
Ingeniería de Aplicaciones
www.ni.com/soporte
0 Kudos
Message 5 of 10
(4,356 Views)

GREAT!!!

 

Thank you very much Anuar!!! It works!!!

 

Kasim.

0 Kudos
Message 6 of 10
(4,345 Views)

I'm glad I could help!!

 

You're welcome!!

 

Anuar Rojas

Anuar R.
National Instruments México y Latinoamérica
Ingeniería de Aplicaciones
www.ni.com/soporte
0 Kudos
Message 7 of 10
(4,342 Views)

Reviving this thread since I also am attempting to read the last value in a TDMS file, but have a detail question ... I made this work by setting the 'from (0:start)' input of the Set Next Read Position Advanced TDMS VI to "end", and then setting the 'offset' input on the same VI to minus 1.

 

This appears to work, however, using the 'offset' to read the last five values (setting offset to -5) provides garbled data for all but the last value.  Am I using this VI correctly?

 

The file was not created using the Advanced TDMS VIs, just TDMS VIs from the basic palette.  Does this matter? (the file is closed between writes and reads).

 

When I set a Group and single Channel designation on the Set Next Read Position VI, the Advanced Read VI seems to return multiple Channel values if the designated Channel was not the last Channel defined when creating the file.  Can I depend on this behavior?  The Advanced Read does not provide the 'Return Values in File Order' control allowed by the basic Read VI.

 

To make this work I had to set both 'Disable Buffering' and 'Enable Async' to True, on the Advanced TDMS Open VI.  False values on either generated errors.

 

I am using LV 2011.  Thanks.

0 Kudos
Message 8 of 10
(4,251 Views)

It's more safe to use TDMS Standard APIs if you are not familiar with Advanced APIs.

For example, to get the last N samples of a channel you can make a VI like that:

 

example.png

Message 9 of 10
(4,244 Views)

Thank You.  The online help did not indicate what parameters can be read.  The clue was NI_ChannelLength.

0 Kudos
Message 10 of 10
(4,220 Views)