01-05-2015 07:59 AM
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
01-05-2015 08:12 AM
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.
01-05-2015 08:18 AM - edited 01-05-2015 08:29 AM
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.
01-05-2015 08:31 AM
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).
01-05-2015 08:31 AM
Thank you
I deleted the first event structur and now it works.
01-06-2015 09:49 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord