LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview event problem

Hi guys

 

I have a problem with the event case. I have a Button called "CON". This Button have to start two deferent Event Structurs by change his value, but not on the same time.

Between the Event Structurs i have two Case structurs with other stuff. Wehn i first press the button, it will be make the stuff twice (like i press the button twice). I have no idea why.

 

thanks for Help

 

0 Kudos
Message 1 of 6
(2,796 Views)

Because each event structure has its own event queue.  So when you press the button, all event structures that are registered for that value change event will have it queued up.  So your first event structure sees the event and runs that event case.  The second event structure can't run yet due to data flow, but it has the event queued up.  So when that second event structure is reached, it can run that event case.

 

In general, your VI should only have 1 event structure.  This makes handling events A LOT simpler.  Look into the state machine.  That will help you handle your events properly and in a central location.


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 2 of 6
(2,790 Views)

What is the mechanical action of the button set to? Latch or switch? Right click the button and look at the options for the 'mechanical action'.

 

If it's switch, the event structure will fire an event when the mouse is clicked down on the button and when it is released (read: read on the block diagram), hence why you get 2 events. If you set the button to latch then you will only get one event.

 

If you have multiple event structures in one loop then you should remove them to avoid blocking your code from running - as per the NI documentation here: http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/twoevntstrctonelp/

 

It would be better if you would post your code but I suspect that might be the problem.

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 6
(2,785 Views)

Sam_Sharp wrote:

If it's switch, the event structure will fire an event when the mouse is clicked down on the button and when it is released (read: read on the block diagram), hence why you get 2 events. If you set the button to latch then you will only get one event.


Not exactly.  You will get two events if the mechanical action is set to Switch UNTIL RELEASED.  You will only get one toggle event with the other two (Switch When Pressed and Switch When Released).


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 4 of 6
(2,773 Views)

Thank you

 

I deleted the first event structur and now it works.

0 Kudos
Message 5 of 6
(2,772 Views)

This is such a common problem that LabVIEW R&D has had discussions about limiting the block diagram to one event structure.

 

https://lavag.org/topic/17781-suppose-we-limited-1-event-structure-per-block-diagram/

 

Having more than one event structure doesn't always mean bad things, but a majority of the time it causes problems when the user is unaware of the way LabVIEW will behave.

0 Kudos
Message 6 of 6
(2,692 Views)