LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple event structures using same boolean

Hello,

 

I am programming a motor to run various tasks, but to rerun a task / enter a different mode when commanded by a Boolean input on the front panel. In a state machine, two different states are action driven commands that enter the "Run" phase when the "Run" boolean is commanded. However, when the "Run" button is changed in the first state, the code runs, etc, then enters the next state, the "Run" change value prompts that state to automatically enter the "Run" state again. How can I use the same Boolean on the front panel, but have the action only affect the loop when it is changed in that state? Or is there a way the event structure can "forget" any previous value changes? Should I use a local variable or producer-consumer structure? Anything would be helpful. Thank you!

 

 

0 Kudos
Message 1 of 6
(3,028 Views)

 Can you post your code for this one? It's very hard to visualize with text only. Thank you

0 Kudos
Message 2 of 6
(3,007 Views)

Judging from the title of the thread I'd say the OP uses several event-structures with-in several states of a state machine - and links the same button to several event structures.

 

@kbaumann: Don't do this! Do not use several event-structures within 1 VI. Read the caveats and hints for usage of the event structure in the help file. To avoid any problems with possible lock-ups of the front-panel I usually recommend to use only 1 event-structure in 1 VI. Everything else just causes headaches at some point.

 

Regards, Jens

Kudos are welcome...
0 Kudos
Message 3 of 6
(2,976 Views)

In this situation, I like the idea of putting the case structure for the state machine inside of the timeout case of the Event Structure.  Then you are constantly checking for button presses and can react based on what state you were supposed to be going into.


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,954 Views)

jg69 wrote: 

Read the caveats and hints for usage of the event structure in the help file.


Here's the link:
Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help

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

@crossrulz wrote:

In this situation, I like the idea of putting the case structure for the state machine inside of the timeout case of the Event Structure.  Then you are constantly checking for button presses and can react based on what state you were supposed to be going into.


Ugh, that turns the event structure into a polling architecture. Whenever possible I try to avoid polling. It is hard to visualize what the OP is working with or trying to do but my first thought would be to define user events to be used in the state machines. One event structure would be dedicated to the UI actions and based on state information would fire the appropriate user events to trigger actions in the state machines. Queues could also be used. I'm not a fan of splitting up processing of the UI in multiple places, especially UI input events.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 6
(2,939 Views)