06-22-2010 08:51 PM
I have a multimeter VI with separate while loops to accomplish the different tasks of reading voltage, current, etc. Each while loop has a stop button, but I need a button that will have to be pressed in order for the while loop to even start. I tried putting another while loop around the present one, but it still has to run once before it will stop. I want the user to have to press the button before it runs, because they interfere with each other.
I am just learning so patience and your kind assistance is greatly appreciated!
ElectroKate
06-22-2010 10:31 PM
Place a case structure with a buton control. Inside the case structure keep the whileloop.
You can use an event structure also instead of a case structure.
06-22-2010 10:41 PM
@electrokate wrote:
I have a multimeter VI with separate while loops to accomplish the different tasks of reading voltage, current, etc. Each while loop has a stop button, but I need a button that will have to be pressed in order for the while loop to even start. I tried putting another while loop around the present one, but it still has to run once before it will stop. I want the user to have to press the button before it runs, because they interfere with each other.
I am just learning so patience and your kind assistance is greatly appreciated!
ElectroKate
Sorry, but that does not make any sense. As soon as you run the VI, a while loop will start - no buttons required. Separate while loops don't make much sense either. If you constanly want to take a series of measurements, chain them together in a single loop. They can't run in parallel.
06-23-2010 10:30 AM
Hello,
I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
-Zach
06-23-2010 10:55 AM
@iZACHdx wrote:
I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
Another sighting! In the wild!!!
06-23-2010 11:05 AM - edited 06-23-2010 11:08 AM
electrokate wrote:I am just learning so patience and your kind assistance is greatly appreciated!
Start with an event structure with an infinite (-1) timeout. The loop pauses.
Pressing start sets the timeout to a finite value so it spins at regular intervals.
Pressing stop would set the timeout back to infinite and the loop pauses again.
repeat....
Here's a sketch:
06-23-2010 11:09 AM - edited 06-23-2010 11:09 AM
@altenbach wrote:
@iZACHdx wrote:
I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
Another sighting! In the wild!!!
Altenbach,
Yes you are correct that this will consume CPU resources. The "more proper" way to code this would at least be to place softwate timing at a period of 200ms within the loop. It has been found that a loop at this rate is indistinguishable to the user when using a polling architecture.
-Zach
06-23-2010 01:40 PM - edited 06-23-2010 01:41 PM
@iZACHdx wrote:
Hello,
I'm not entirely clear with everything you have going on and what you want your final functionality to be, but you can use sequence structures to prevent a loop from starting until the user presses a button like this:
-Zach
I have to ask, why is an NI employee using examples using sequence frames? The same thing could be accomplished using data flow by simply wiring the value of the first stop button out of teh first while loop and connecting it to the second loop. This would then use data flow to control the sequence. Why show new users bad programming methods?
As to the original question I would concur with altenbach on using an event structure.
11-05-2019 03:13 AM
hello altenbach,
Can you send the VI of this start stop contion.
I want to save the data and monitor the data in same VI
So, I am thinking to do it in two parts one loop to start saving and stop saving the data(this can be strated again)
another part(Maybe in a loop) will monitor the data.
Regards
Vishal
11-05-2019 06:30 AM
@vishal231 wrote:
hello altenbach,
Can you send the VI of this start stop contion.
I want to save the data and monitor the data in same VI
So, I am thinking to do it in two parts one loop to start saving and stop saving the data(this can be strated again)
another part(Maybe in a loop) will monitor the data.
Regards
Vishal
Hi Vishal,
It sounds to me like you need to investigate a state machine architecture. What you want to do can likely be done in one loop.