Showing results for 
Search instead for 
Did you mean: 

Event structure + while loop


HI THERE! Need help! What it is necessary to add, that the while loop at the clamped button into event structure continued to work?Smiley Sad

0 Kudos
Message 1 of 7

Boolean Controls, because they can be switches (which tend to "stay put" when changed) or buttons (which can be "momentary", like a door bell, or can be "Push to turn on, push to turn off"), have a property called a "Mechanical Action".  On the Control Palette, most of the buttons have the "Switch when Pressed" Action, but the three "Square" buttons, "OK", "Cancel", and "Stop", have Latch when Released.


What Latch when Released means is that when you push the Button, it will "latch" (stay in the "pushed", or "on", position) until you read its value, at which point it will "unlatch" and return to its default ("off", or False) state.  These buttons seem to be "always off" (when the code is being run) as they are frequently read as soon as they are pushed (a Stop Button in a While Loop is a good example of this). 


For Event structures, one usually puts the Control inside a Value Change Event.  If the Control was in its default "Off" position, when you push it on, it becomes "True", and you can read (and save) its True Value.  But the act of reading it pops it back to the default False position.  This probably explains the "strange" behavior you see in your code -- it is supposed to do that.


To change a Mechanical Action, right-click on the Control and choose Mechanical Action.  I suggest you play with your example, changing the Mechanical Action of OK and Stop to other values until you understand how they all work.


Bob Schor

0 Kudos
Message 2 of 7

Everything continues to "work" as programmed. In your case, the while loop only spins if an event occurs, the it will wait again forever at the beginning of the next iteration.


For example of you also want to react to the "stop" button, you need an event for that, containing the stop button terminal.


The 100ms wait serves no purpose and only provides a lower limit, because the loop rate is entirely determined by the event structure. If you want to also run the while loop at regular intervals (There is no need here!), you could create a timeout event.


And yes, as bob already said, you need to learn about mechanical action settings of boolean controls. Since you only show a picture, we have no idea what they are. Chances are they are at the default for the given control, i.e. latch action for the OK button, but who knows.


If you want help, please attach the VI. Also please use standard characters for file names. Your picture does not open in windows 10 unless I rename it to something else (using english windows 10).


In summary:

Attach your VI so we can analyze it. We cannot debug a picture because many things are hidden (mechanical action settings, contents of other event cases, etc.)

LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 3 of 7

Thank you. But I changed the mechanical action of the button. It remains clamped after power-up and outputs a logic signal.  If I press a button, the cycle will work once. But it is clamped. How to make the cycle work continuously when the button is pressed.

0 Kudos
Message 4 of 7

Please explain what you mean by "clamped", "cycle", "power-up" and "continuously", etc..


  • How do you operate the VI when running?
  • What do you observe?
  • What do you expect to observe instead?
  • Be as detailed as possible.

LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 5 of 7

See if this can give you some ideas ...

LabVIEW Champion Do more with less code and in less time
Message 6 of 7

thank you!

0 Kudos
Message 7 of 7