LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple program. Need help wiring/writing tdms file.

I have attached a copy of my vi. It is in LavVIEW 8. It is a simple program that records the pressure from a pressure tranducer. All I need to do is log the pressure every second, along with the time, and write those two pieces of information to a tdms file until I stop the program. I am having trouble figuring out how to wire to the tdms write function. How do I get pressure AND time into one, and then into the data input of the write function? Thanks

Download All
0 Kudos
Message 1 of 14
(3,431 Views)

cramezl,

 

I make a simple VI example to show how to use TDMS Write. You might replace the "Random Number (0,1)" with your real pressure data. Attached "Write TDMS File.vi" is created by LabVIEW 2012 (http://www.ni.com/trylabview/).Write TDMS File.png

Message 2 of 14
(3,421 Views)

Thanks. I'm trying to replicate the example you posted. Can you tell me what the object wired just prior to the top terminal of the build waveform function is called? I'm in labVIEW 8 and I can't find it.

0 Kudos
Message 3 of 14
(3,399 Views)

Build Array.  It is a growable function.  By default it has 2 terminals.  It can be shrunk down to just 1 terminal.


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
Message 4 of 14
(3,396 Views)

Thanks crossrulz. Now I have everything wired, but the vi is still not functioning like I want. What I want it to do is take a reading every second, but only write to the file every minute (preferrably on the minute mark). And right now I can't get it to stop using the stop button. I think my loop within a loop with both stops wired to the same button, and two different time delay functions is screwing me up. Any suggestions for fixing this mess?

0 Kudos
Message 5 of 14
(3,389 Views)

I just started looking at it, but you do realize you have a 500 second wait in there (the delay before read is default to 500seconds).  You probably want this to be ms, so you need to throw in a divide by 1000.

 

Also, the second while loop is not needed.  What you should do is have a wait for 1 second in there (not connected to any data flow) to have the loop run at 1Hz.  You can then have a case structure to that you only write when the loop count is divisible by 60 (use Quotient and Remainder, write when remainder is 0).


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 6 of 14
(3,385 Views)

I would separate the acquisition into two parallel loops - one to acquire the data and the other to write the data to file.  The reason is that changing the delay time for the instument will affect the timing of your logging.  I would also remove the build array and replace it with an initialized array.  Please see attached.

0 Kudos
Message 7 of 14
(3,371 Views)

@Shoua wrote:

I would separate the acquisition into two parallel loops - one to acquire the data and the other to write the data to file.  The reason is that changing the delay time for the instument will affect the timing of your logging.  I would also remove the build array and replace it with an initialized array.  Please see attached.


No.  Using locals to communicate between loops is bad!  If anything, use a queue.  And at the rate of 1Hz, there really isn't a need to go to the Producer/Consumer architecture.  This setup will work just fine.

 


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
Message 8 of 14
(3,364 Views)

Yes, I agree that using local variables are bad.  But in this case, the loops are running slow and the code is not huge - so there is little overhead. The code provided above will not guarantee 60 seconds logging interval.  There are two delays - so using the remainder/quotient will not guarantee 1 minute of data.  It will only guarantee 1 minute data intervals if the while loop executes at exactly 1 second.

0 Kudos
Message 9 of 14
(3,355 Views)

Thanks for the example. Very helpful. I built what you posted in my vi as best I could. Unfortunately, now I have no pressure reading and I immediately get an Error 6 from the TDMS open

0 Kudos
Message 10 of 14
(3,351 Views)