LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can tdms operations change the tdms file reference?

Solved!
Go to solution

Flush written TDMS data from examplesFlush written TDMS data from examples

I wonder whether tdms operations can change the tdms file reference. When writing to tdms in a while loop, do I need shift registers to have the file reference stored for the next iteration or can I just use a tunnel? See the above example (shipped with the LabVIEW examples.

This becomes relevant when using a state machine where in one state I open a tdms file, write in another state and close the reference in yet another state (when exiting the vi).

I need to store the tdms file reference anyway, so it's not an issue to "overwrite" it whenever I write to the tdms file. In fact, that's what I've always done in the past.

However, I recently updated my state machine and removed all tdms references coming out of the tdms write vi. Is this ok or not?

tdms write in state machine.png

Write to tdms (and flush) in state machine. TDMS reference out is not wired. Is this ok?

 

 

 

 

0 Kudos
Message 1 of 4
(2,617 Views)
Solution
Accepted by topic author donkdonk

@donkdonk wrote:

 

I wonder whether tdms operations can change the tdms file reference. When writing to tdms in a while loop, do I need shift registers to have the file reference stored for the next iteration or can I just use a tunnel? See the above example (shipped with the LabVIEW examples.

 

No, the file-refnum will not change. In your special case with a for loop that is executed at least once it would not make a differnce if you did not use a shift register. But it is still very good practice to use a shift register. Here is an example where is does make a difference:

 

 grafik.png

With an for-loop with autoindexing, wires with a shift-register retain their value, even if the for-loop is executed zero times. Wires use their value.


Write to tdms (and flush) in state machine. TDMS reference out is not wired. Is this ok?


I'd say: yes, that's ok.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 2 of 4
(2,609 Views)
Solution
Accepted by topic author donkdonk

In your State Machine setup, you should be fine.  In the FOR loop, I recommend always having the reference in a shift register due to a condition where the loop runs 0 times.  Yes, the happens a lot, especially with autoindexing tunnels and an empty array suddenly comes around.  In that case, a tunnel will output the default value and your reference is gone.  But a shift register uses the same memory location on both sides of the loop, so what you initialize the shift register as is what will come out.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(2,605 Views)

Thanks a lot for the prompt replies!

Now I can conclude that tdms operations do not change the tdms file reference and therefore my state machine setup is ok.

(BTW, I have been using my SM for a while and I did not run into problems, justed wanted to know for sure).

 

Very good for pointing out what might happen when using for loops!

Of course, easiest thing to do is just use shift registers. Everywhere. Probably no noticable drawback by doing just that.

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