10-09-2012 04:02 PM
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
10-09-2012 08:10 PM
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/).
10-10-2012 10:04 AM
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.
10-10-2012 10:12 AM
Build Array. It is a growable function. By default it has 2 terminals. It can be shrunk down to just 1 terminal.
10-10-2012 11:04 AM
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?
10-10-2012 11:21 AM
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).
10-10-2012 11:59 AM
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.
10-10-2012 12:30 PM - edited 10-10-2012 12:31 PM
@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.
10-10-2012 12:49 PM - edited 10-10-2012 01:11 PM
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.
10-10-2012 01:05 PM
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