LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer control to keep writing to external labview measurement file

Hi all,
 
  I have a question regarding using LabVIEW to write data to disk for a certain time stop writing.
 
  Right now i have a continuous data acquisition setup in Labview, and to write the acquired data to disk, I use the "Write Labview measurement File" express VI to write to disk. I activate this VI manually by having a control pushbutton on the front panel, so that whenever I want to record the data to disk, I click on the button which is wired to the "enable" input of the "Write Labview measurement File" express VI.
 
  Now that I'd like to keep writing for up to say, 5 seconds. I've experiemented with "Time Delay", "Elapsed Time" VIs with no success... the problem is that I'm not too sure how to involve a timer to change the status of the enabled input to the "Write Labview measurement File"  express VI once it's activated.
 
  Please see the attached .vi file. Thanks very much for your time.
 
Jeff
 
 

Message Edited by schumia on 11-07-2005 10:35 PM

0 Kudos
Message 1 of 5
(3,117 Views)
Use the express VI Elapsed Time set the target time to 5 seconds then wire the Time Has Elapsed terminal to the enable terminal to the Enable terminal of the write file vi. Depending on where the code is executing when the Time Elapsed goes true the interval between file writes may no be exactly 5 seconds.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
0 Kudos
Message 2 of 5
(3,101 Views)

Hi Andrew,

  Thanks for your response, and I did try your suggestion. However, I needed to make some modifications since I wanted Labview Write vi to start writing RIGHT AWAY, for 5 secs, and then stop, which is exactly opposite so I used an "inverter" to invert the boolean logic coming out of the "time elapsed" vi to turn on the Labview Write vi.

   One thing about this "time elapsed" vi that puzzles me is that it needs to be put into a While loop for it to work, if don't do that, then the elapsed time stays at "0" for some reason meaning it's not counting time at all!! So I had to enclose it within a While-Loop. I have a couple of questions.
 
  1. Why does the "time elapsed" vi need to be working in a while loop? I've tried running the LabView program in a "Run Continuously" mode as opposed to "Run" mode, the elapsed time simply stays at zero.. don't know why..
  2. What's the difference running a Labview code at "Run Continuously" mode or just enclose everything inside a while loop and "Run" ?
 
  I've attached my modified script that'll correctly write to file for 5 sec and turn off. It seems so verbose for such a simple task.
 
 
Jeff
0 Kudos
Message 3 of 5
(3,083 Views)
1. The elapsed time vi must be in the while loop in order to run on every iteration of the while loop. When the while loop is executing only the functions inside the loop are run, any thing outside the loop will not execute until the while loop exits. Labview works on data dependency, in other words an operation will not execute until all of its inputs are present. You can see how the vi works by turning on the highlight execution an watching the block diagram. Place the elapsed time outside of the while loop and you will see that it only executes when the run arrow is clicked. Once it provides a value to the tunnel it is never executed again and the value at the tunnel does not change. Learn the function of using the Error In and Error Out to control the execution flow of your programs. This will save you from using sequence structures where they are not required and all they end up doing is hiding code.
 
2. The only way to stop the continuous run functionality of labview is with the stop button in the tool bar. You can pragmatically control the execution of the while loop. For example you can run the while loop until two values are equal, when this condition occurs the while loop will stop. Your while loop is basically performing the same function as if you had used the continuous run with out the while loop.
 
Hope this helps.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
0 Kudos
Message 4 of 5
(3,073 Views)
When something is not in a while loop, the program runs once and stops. Nothing is happening when your program is stopped. The timer isn't running, the daq isn't running, etc. If you click the run continuous button, the program runs once, stops, restarts, and on and on. Each time the program starts, the timer starts again. Since the Elapsed time function only takes a few microseconds to execute and it starts immediately, 0 is the expected result when you only run it once. With a while loop, the timer starts and keeps running until the while loop finishes. It does not reset itself with each iteration of the while loop. All programming languages work this way.
0 Kudos
Message 5 of 5
(3,072 Views)