LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a start/stop button for each separate while loop within my program, when each of them does a different task?

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

 

0 Kudos
Message 1 of 20
(23,532 Views)

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.

0 Kudos
Message 2 of 20
(23,527 Views)

 


@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.

 


 

 

Message 3 of 20
(23,523 Views)

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:

17239i8DAE662B3642B004

 

-Zach

0 Kudos
Message 4 of 20
(23,501 Views)

 


@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!!!


 

 

(Details)

 

0 Kudos
Message 5 of 20
(23,492 Views)

 


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:

 

 

0 Kudos
Message 6 of 20
(23,485 Views)

@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!!!


 

 

(Details)

 


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

 

0 Kudos
Message 7 of 20
(23,481 Views)

 


@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:

17239i8DAE662B3642B004

 

-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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 20
(23,465 Views)

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 

0 Kudos
Message 9 of 20
(11,170 Views)

@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.

0 Kudos
Message 10 of 20
(11,146 Views)