LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read specific channels from an existing TDMS file

Solved!
Go to solution

Dear Lab View users,

 

I would like to seek help in using the TDMS read Vi to read specific channels in existing TDMS files.  I know to use the "TDMS list content" vi to list the group and channel names, but I don't know how then to use this information to read the specific channels identified.

 

the problem I am trying to work around is to read a TDMS file with data from two channels, each having a different amount of data taken at different rates. I would like to read a block of data from only one channel.  However, this block of data has more elements that the other channel. Thus, I am encountering end of file errors almost every time because the TDMS read Vi tries to read that block of data for every channel.

 

How do I specify the channel to the TDMS read VI?  I tried creating a constant and attaching it to the "channel name" node on the TDMS read VI, but this gave an error.  I presume I don't know how to format it.

 

attached is the VI I am trying to implement

A sample file is too large to attach.

 

Thanks for any advice

 

 

 

A. Lopez
0 Kudos
Message 1 of 12
(8,246 Views)

Some points about you programming style:

  • Use ther error in/out of functions.
  • Don't use static VI paths
  • There is no reason to use a sequence structure, the wire dependency will take care of possible race conditions
  • Use wires instead of value property nodes, property nodes are slow


About the 'Get Channel names' you use that without providing a Group name, if I were you I would only look for channels inside a specific group.

The array returned will always contain an 'empty string' representing the file/group itself, so you can remove that one, then you will get an array of all the channels inside a group. To read specific channels also connect the group name!

 

If you save a channel also connect a group name, since you have waveforms the name of the channel will be captioned inside the waveform.

 

good luck,

 

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 12
(8,228 Views)

Ton,

 

thank you for the suggestions.  I will implement.

 

further about your statements.  Do I need to name the channels during data acquisition before I can call them specifically? 

 

I thought if the group name on 'get channel names' vi was left unwired the Vi would return all valid channel names.  If I don't  know the group name how do I get the channels.   this is a main idea that I am not understanding. Perhaps I am confusing what a channel is and what individual data streams are?

 

The TDMS files I am reading did not have channel names assigned to them that I know off.  It is the channel name captured in the waveform that I would like to know so I can call it individually. I thought the ' get channel names' vi was the way to go, but I obviously am missing a step with this too.

 

Thank you.

A. Lopez
0 Kudos
Message 3 of 12
(8,201 Views)

If you don't set group or channel names during acquisition, LabVIEW will default the group name to "Untitled". If you are using waveforms for acquisition, LabVIEW might be able to determine the channel names from the waveforms. Otherwise, or if you are using numeric arrays, the channel names will default to "Untitled", "Untitled 1" and so forth.

 

If you want to see the exact names in your files, you can use the TDMS File Viewer from the TDM Streaming palette. You can also use the "TDMS List Contents" function to read out the names programmatically.

 

Hope that helps, 

Herbert 

 

0 Kudos
Message 4 of 12
(8,188 Views)

Herbert,

 

After thinking about a work around, I have edited the vi to show me the groups/channels.

 

I have selected what I think is the proper group channel, but am still getting end of file errors.

 

Attached is a screen shot of the indicator showing my group/channels. I have two.  there is a heading for all of them "measurement data" which I believe comes from a sub vi used before data acquisition.

 

Attempted to pull the channel directly from the TDMS list by using an index array command. However, none of the row column combinations I tried worked.

 

Does this mean I am dead in the water?

 

summary: my problem is to pull a chunk of data from the first channel, which was acquired at a much higher rate.  My theory is I am encountering end of file errors because when the TDMS read vi tries to get data from the second channel, it encounters the end of file and does not know what to do. I am attempting to tell the TDMS read vi which channel to specifically read.

 

thank you again

 

Alfonso

A. Lopez
Download All
0 Kudos
Message 5 of 12
(8,111 Views)

When the TDM Streaming API was designed, we got a lot of requests for a default behavior similar to regular File I/O, meaning that if you open the file and repeatedly read, we sequentially iterate through the file. What TDMS Read does now is that everytime you call it without specifying a group name, it will read the next available group. Once you "run out of groups", it outputs eof=true. If you call it again, you'll get the EOF error.

 

Long story short, if you wire up the group names to TDMS Read, you should be fine.

 

Hope that helps - and sorry for the inconvenience,

Herbert 

0 Kudos
Message 6 of 12
(8,099 Views)

Herbert,

 

Thanks for the explanation,

 

If the channel is wired, I am still obtaining an error, though it has changed to saying I have an invalid TDMS reference.

 

The channel is passed directly from the TDMS list command. 

 

I even tried using a dummy file only with the high frequency data. Still getting end of file errors using the while loop. However I do not get errors if I do a manual approach without the loop.

 

Will try opening a help request .

 

thanks for all the comments.

A. Lopez
0 Kudos
Message 7 of 12
(8,082 Views)

This error means that the tdms file reference going into this function is "not a refnum". Why exactly are you using a property node for this, instead of just wiring it to the output of "TDMS Open"? Note that, while you have a data dependency between "TDMS Open" and your while loop, this data reference doesn't include the "tdms file out" indicator, so the indicator might be updated after you read the value from the property node. I would suggest a direct wire, you can also move the indicator into the sequence structure.

 

Hope that helps,

Herbert 

Message 8 of 12
(8,048 Views)

Herbert,

 

thanks for your reply,

 

By using a property node, I thought it would make the structure a little more readable by not having as many wires crossed.

 

After TCPlomp suggested I wire the read function directly, I did try this but continued obtaining the same error so I continued to use the property node.  I will try to wire a shift register to feed back the TDMA reference for every loop iteration. However, I thought the read function used the initial reference unless it was changed during the while loop?

 

I have attached the version of the VI with a direct wire.  the error indicating an invalid TDMA reference still shows up during the second loop iteration.

 

thanks again

 

Alfonso

A. Lopez
0 Kudos
Message 9 of 12
(7,998 Views)
Solution
Accepted by lopez

I think the problem may be that you are closing the original TDMS reference in every iteration of your loop, try moving it outside as shown in the snippet.

 

Note I have not really gone through the logic for the rest of your code.

 

edit.png

0 Kudos
Message 10 of 12
(7,990 Views)