LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Skipping a step in while loop when boolean is switched

Solved!
Go to solution

Hey guys,

 

I have a program that controls a ventilator which pumps in gas at a certain rate. This whole process is executed in a while loop. When we switch gases by a toggle that's on the front panel, we'd like to skip one ventilating cycle immediately and then goes back to pumping gases at the previous rate, but we don't know how to realize this. Can you guys give any advices? Thank you!

 

Sincerely,

 

Le Z.

0 Kudos
Message 1 of 8
(3,431 Views)

Use a case structure.

 

(If you want more detailed help, show us your code.)

0 Kudos
Message 2 of 8
(3,429 Views)

Thanks for the suggestion. I've uploaded the code. The part I'm talking about is the case structure labeled with HP or N2

0 Kudos
Message 3 of 8
(3,424 Views)

Hello Le,

 

If I am reading this right, it sounds like you may want to change the mechanical action of your switch. Currently, it is set to "switch when released." This action will cause the button to output a "true" signal even after you click it. I would instead suggest using a latch when released mechanical action. One "true" signal will be sent to the case structure once the button is released. Then the button will return to it's default false position. Here is a KB that explains this in more detail:

 

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/changemechactofboolswitch/

 

-Erik S

Message 4 of 8
(3,375 Views)

Thanks for the suggestion, but maybe I didn't explain it very well. So let's say that it's now on N2 (hence false state),then I press the HP button, it will skip one iteration inside the case structure, then it will switch to the true state (HP), and it will stay there until next time HP button is pressed. Is there any way to achieve this?

0 Kudos
Message 5 of 8
(3,357 Views)

Make sure the mechanical action for the HP button is set to Latch When Released.  The button will automatcially reset when the terminal is read that way.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(3,333 Views)
Solution
Accepted by topic author lez

Hello Le,

 

A shift register in your loop may be able to achieve this type of functionality. If you wire the switch into the right shift register and wire the left shift register into the case structure, the loop should iterate one more time before switching to HP Gas. Here is a link to a tutorial on shift registers:

 

http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm#Shift Registers

 

-Erik S

Message 7 of 8
(3,294 Views)

Thank you all for your insights! Now it's working in the way we want it to

0 Kudos
Message 8 of 8
(3,261 Views)