LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

different event structures in a while loop

 

I am going to have two booleans so that when 1st one is hitted integer numbers be shown and when 2nd is hitted the qsuare of integers should be shown. I tried to have two event stuctures in a while loop like attached but as you see it does not work. Once I push the first boolean the code should show (i) until I push the second one and the squares are shown, while the it works only when I change the value of boolean (which makes sence as the event is value change). Can anyone help to fix this problem? I know it is silly but I am new in LV. Any help is appreciated.

 

Thanks,

Derm

0 Kudos
Message 1 of 4
(3,054 Views)

I don't really understand what you are saying in your message to know what it is you are trying to do, or what it is actually doing.  But let me comment on a few things.

 

1.  You say you have different event structures, then later two event structures in your while loop.  You don't.  You have a single event structure.  It happens to have multiple (3) event cases.  I don't see any problems there.

 

2.  While trying to run your code, I see you have two different mechanical actions on those boolean switches.  i-k is set to "Switch Until Released".  When you press, that is one value change, when you release, it bounces back and thats a separate value change.  The other is set to "Switch when pressed".  It switches and generates a value change event whenever you press down on the button.  When releasing, that does not switch the button and does not generate a value change event.

 

3.  I don't think either of these buttons look like, or actually have the mechanical properties for the type of button you want.  It seems you want a button that when you press it  (actually release it is the more typical windows behavior), it does something one time, then snaps back up on its own.  And that button should look like a button and not a slide switch which implies a change and leave behavior.  You really should have a button that looks like the OK button on the palettes.  And be sure that its mechanical action is set to "Latch When Released".  That will fire an event when you press down and let up (gives you the ability to slide the mouse off the button in the event you made a mistake), and then will pop back up on its own as soon as LabVIEW reads the value of the button from the terminal.

Message 2 of 4
(3,035 Views)

Thanks for your reply and suggestions. Sorry if my question was confusing.

 

 The only thing that I need is that when I click on "i-k" the code showes the integer numbers until I click on "i2-k". Now, as you may have seen, the integer number is printed only when the "i-k" button is changed (not always).

0 Kudos
Message 3 of 4
(3,025 Views)

It is working exactly how you programmed it.  i indicator is updated in the i-k value change event  whenever you press or release the i-k button.

 

The i2 indicator is updated in the i2-k value change event whenever you press the button.

 

Run on highlight execution and watch how the VI operates in slow motion while you are running it.

 

I don't know what you mean by "shows the integer numbers until I click i2-k button".   If you want something to run continuously without firing an event, then you should be relying on the event structure.

 

 

0 Kudos
Message 4 of 4
(2,999 Views)