LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to capture data (serial and analog input) non-stop, to view it on the front panel, then save it to file only when the "save" is pushed, using a case structure and a for loop, with # of iterations controlled from front panel

The application is shown below.  I want to control 2 Mass Flow Controllers, and read their respective indicated flow rates (voltage) and the serial output of an Alcatel Detector.  I want to monitor these values non-stop whenever I run the vi.  Then I want to be able to hit a "save" button connected to a case statement.  Inside the true case, I want to place a for loop whose iteration number is controlled by a combination of front panel controls, as shown.  What happens is that whenever I press the save button, the data from the while loop stops, and the vi is inop, because I just save the same data over and over.  I believe I need to use global variables in order to run the two loops simultaneously, but I'm not sure of the details.  I'm also not sure if I need to put the for loop inside the case structure, or the case structure inside the for loop.  ANY help is, as always, greatly appreciated.  Thanks, and MERRY CHRISTMAS!!!
0 Kudos
Message 1 of 6
(3,505 Views)
I am not completely clear on what the for loop is doing other than very slowly formatting the data you want to save.

Parallel loops can be used for this kind of work. The acquistion loop acquires the data and passes it to the save loop (also a while loop) via a queue or a functional global. The save loop waits until the save button is pressed and then saves the current data. The queue can also pass the stop command so both loops stop when the stop button is pressed.

Look for "Producer/consumer" in examples and archives of the Forum.

Lynn
0 Kudos
Message 2 of 6
(3,495 Views)
You seem to stop the while loop to run the following code, then the program ends. Are you running this using the "continuous run" button????
 
 
You need one big while loop containing the acquisition, then you build up the history data in a shift register. Clicking "save" will save the data, but not stop the loop.
 
Why did you place a time-control in the FOR loop??? This is just post-processing so it should just do it without any delays. I don't understand the logic in the FOR loop. You are appending arrays, but then you delete the first element at each iteraction constantly trimming data from the beginning of the appended array. Then you autoindex at the output tunnel heavily duplicating all data. Ths make s no sense!
 
Can you explain how you want you data saved?

Message Edited by altenbach on 12-16-2005 11:20 AM

0 Kudos
Message 3 of 6
(3,491 Views)

Lynn, the purpose of the FOR loop is simply to tell the vi how many data points (iterations) I want it to save.  The delay is set up for one second.  This is controlled by the front panel "interval" control.  So if the operator sets the front panel controls for a 2 minute duration and a one second interval, the FOR loop will execute 121 times ((2 x 60)+1) to provide 2 minutes' worth of saved data, once the "save" button on the front panel is pressed.  This way, I can monitor the values on the front panel until I decide they are stable enough, and then hit "save", and capture the next two minutes' worth of data.  I hope this makes sense.  ALSO, I have no idea what to do with a queue or functional global.

0 Kudos
Message 4 of 6
(3,489 Views)


@DanNatCorning wrote:

So if the operator sets the front panel controls for a 2 minute duration and a one second interval, the FOR loop will execute 121 times ((2 x 60)+1) to provide 2 minutes' worth of saved data, once the "save" button on the front panel is pressed. 


THe acquisition rate is entirely controlled inside the while loop. Placing a delay inside the FOR loop does not do anything except delaying the samve operation. The data is already in an array and does not have any time information. If you want a determined amount of history data, you only need to control the iteration count.

You just need to generate the correct timestamp as first element, this can be done mathematically.

0 Kudos
Message 5 of 6
(3,484 Views)
It sounds like you only need one loop. Acquire the data and put it in the shift register as Altenbach said. When you push the save button, calculate the future time when the desired amount of data will be available. At that time use the Array subset function to get the set of data and save it.

Lynn
0 Kudos
Message 6 of 6
(3,479 Views)