LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with program flow and timing a loop please

I'm working on an application that will display vibration data on several tabs.  1 tab displays the time waveform, another a running RMS value, another an FFT etc.
On another tab I want the user to have the option of streaming the data to disk for 'x' number of seconds.
 
I created a sub-vi with a flat sequence structure.
The first frame open/creates a file.  The second frame gets the current time in seconds and adds 'x' seconds to it.  The third frame  contains a while loop with a "Get Current Time in Seconds" and a  "Write to Binary File" which executes while the current time is less than the "previous current time plus 'x'".
 
This sub-vi is in a while loop that is called when a "capture data" button is pressed.
 
My problem is that the rest of the program (waveform, RMS, FFT displays) stops executing when the while loop / sub-vi is executing.
This can be seen via the "TEST" indicator that doesn't update.
When the program flow goes back to the rest of the program I get an error 'cause the buffer has over-flown (ed)
 
I'm really new at this so any help is greatly appreciated.
 
I've attached images of the main vi (Project3.pdf) and the sub-vi containing the Flat Sequence (WriteToDisk.pdf)
I can attach the actual vis if it helps.
 
 
Thanks,
Erik
Download All
0 Kudos
Message 1 of 2
(2,666 Views)
The behavior you're seeing is by design. There are two solutions to your problem:
  • Place the write to file in a separate loop that runs in parallel to your main loop. Thus, your "Project3" VI would have two loops. One is the data acquisition, the other is the streaming to file. You should not create data dependencies between the loops that would cause one loop to wait until the other is done. You want both running in parallel. You can stop both loops with the same stop button. With this method you can use local variables to get the Time Waveform data as you're doing now.
  • Launch the stream to file VI dynamically. This basically uses the VI Server to start a subVI and then immediately return to the caller. The subVI is then running on its own. There are examples that ship with LabVIEW that show you how to do this. You would have to have the subVI monitor something to determine if it should stop should the main program stop.
The first option would be the easiest to implement in your case. The second is more complex, but leaves you with one loop.
0 Kudos
Message 2 of 2
(2,659 Views)