LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restarting a wile with different values inputs

Kind of new to Labview... The examples and models that are included in the Labview have the setting being applied before the VI goes into a wile loop. For example, the Sample Rates of a DAQ is set before entering a while loop where the data from the DAQ is read or a file must have its file path set and read before going into a while loop to process the values which the file reader provides.

What I want to do is restart the VI. Set a different Sampling rate or a new file path during while it's running. Is there a way to change the file path or sampling rate while the loop is running. Stopping the loop and restarting it with the new values. Thanks.


Message Edited by d1sturbanc3 on 02-26-2008 12:06 PM
0 Kudos
Message 1 of 7
(3,028 Views)
Put the VI inside another while loop as a subVI. Then on every iteration of the outer loop the VI is called again with the values of the controls as set in the outer loop. If you do not want it to run again as soon as it finishes, put the VI inside a case structure (inside the while loop). Control which case runs with a boolean.

Lynn
0 Kudos
Message 2 of 7
(3,015 Views)
Thanks for the reply. But I have attempted to do this already. I think the problem is that my outer loop will never go to it's next iteration. As I understand it, the while loop will not go onto the next iteraction until every processes within the the iteraction is complete. Since the subVI will run until a reference for stop button being pushed, the outer loop will never run.
If I were to stop the subVI, and the outer loops runs, the I can't get the subVI to start again.
Right now I have two major while loop. One while loops sends the settins to DAQ via a notifier based on current time. It sucessfully chooses the correct settings and sends it. The DAQ loop never respond to the values b/c it never completes it's infinite while loop. The only time it completes is when the user presses stop, and it stops never to start again.
0 Kudos
Message 3 of 7
(3,009 Views)

You can use the event structure and shift registers as shown below.  The DAQ code is only partial code.  You would have to stop the DAQ before you changed its rate, then restart again.  Use shift registers to pass the task ID and put the stop and restart code in the refresh event case.  I'll leave the coding up to you.  Good exercise.

OOOOPS.  Mistake.  You need to put a local variable of the rate control inside the refresh case and wire it to the right tunnel.  Don't 'put the straight wire like is shown above.  I didn't want to recreate the picture, I'm lazy today.



Message Edited by tbob on 02-26-2008 01:02 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 7
(3,002 Views)

Off my lazy butt.  Like this:

And don't put the DAQ timer vi inside the timeout event or it will execute every 100 mS.  I just don't have it together today.  Maybe I'll try again if you don't get the picture.  Just let me know.



Message Edited by tbob on 02-26-2008 01:04 PM

Message Edited by tbob on 02-26-2008 01:06 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 7
(2,995 Views)
Thanks.. I knew this was going to involve an event structure sooner or later.

Just let me make sure I understand you correctly. Whenever rate changes, the event structure will stop the DAQ. Update the rate value and send it to the shift register for the next iteration of the while loop. When the variable doesn't change the shift register provides the value to the DAQ.

Currently... I have a while loop in the reading or sampling DAQmx which reads the values from DAQ and pushes it onto a queue. Would I need to that while loop into the event structure such that when the rate changes reading of data from DAQ stops also. After the rate change event finished, will the sampling DAQmx have the setting set?

I've attached a screen shot of my subVI. Will the event structure cover the entire VI or just the setting portion?




Message Edited by d1sturbanc3 on 02-26-2008 02:23 PM
0 Kudos
Message 6 of 7
(2,979 Views)

Why do you stop the DAQ inside your loop?  When the loop iterates a 2nd time, the DAQ is stopped and you will get an error or a timeout, then the loop will exit.

You could move the contents of your loop into the timeout case of an event structure (without the DAQ stop).  In the refresh event case, put the DAQ stop, followed by the DAQ Timer with input from a front panel variable (or local variable, no shift register needed actually), then restart the DAQ.  Event is fired and the loop iteration finishes.  Next loop, the timeout event will fire and the DAQ will gather data at a new rate.  The refresh case would look like this:



Message Edited by tbob on 02-26-2008 01:59 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 7
(2,965 Views)