LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I have multiple event structures with the same event cases?

Solved!
Go to solution

Hello, 

 

I'm doing an application that reproduces the front panel of the HP6675A power supply. To achieve this, I have done a state machine with different states

(initialize, measures, voltage, current, ocp, ov, store, recall, etc). In each state, should have an event structure that catches the events of the buttons, like for example: if the current state is the Voltage mode and the user press the current button the next state will be the Current mode. For this in each state of the state machine should be the same event structure with the same events.

 

My problem is that the Vi doesn't work properly when I have multiple event structures with the same event cases. There are some possibily to do this, and how? Or is impossible to have multiple events? I have been reading some posts, but I don't find solutions. 

 

Any help is appreciated.

 

Thank you very much.

0 Kudos
Message 1 of 7
(6,164 Views)

Slightly confused about what you are trying to achieve, but if its a single button press change operation in 2 loops, then my suggestion is to use 1 event handler case, 2 Queues, and 2 consumer loops. 

 

From the event case, Queue cmd data to each separate loop.

 

If I'm mistaken, please provide clarification or post vi.

 

- P

0 Kudos
Message 2 of 7
(6,147 Views)
Solution
Accepted by topic author luisi

In general, you should have 1 event structure in your VI.  In your state machine, this event structure should be in the "Idle" state.  So you will probably start out in the Initialize state and then transition to Idle.  Then the user presses the Current button.  So your state machine should then go to the Current state and then back to Idle.



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
Message 3 of 7
(6,141 Views)

If you have multiple parallel loops, you are okay having multiple event structures with the same events.  But I wouldn't recommend that to anyone unless they truly understood how to program with events and all the caveats.

 

Since you didn't attach a VI or a screenshot, I don't have the benefit of knowing what you are trying to do except by deciphering your description.  And it sounds to me that you have event structures buried in different cases of a case structure.  If so, DON'T.  All event structures are capable of getting events even if they aren't currently in the line of execution.  They will queue them up (and possibly lock up the front panel depending on how you have that checkbox set in the event structure), and won't get around to processing them until the event structure is finally in the path of execution.

Message 4 of 7
(6,137 Views)

As you say, I have an event structure in different cases of a case structure. If you say that this is not possible, then I suppose that I have to implement more states in the state machine.

 

Sorry for my explanation, I have attached the Vi to help the understanding. As you can see, the number buttons (1,2,3 ...8,9) can be pressed in the state "Voltage" and "Current", so I have used different event structure. If multiple event is not possible, then I have to think other diagram of the state machine with a "idle" state where the event structure catches the events of the buttons, no?

 

Thank you for your responses. 

0 Kudos
Message 5 of 7
(6,120 Views)

If you're wanting the current state to change, such as Voltage before Current, why not just make a case "Wait for Events" and let that handle the events?

 

Or as others mentioned, make two parallel loops.  In one loop, have your state machine.  In the other, have just the Event Handler.  Pass the events from the handler to the state machine by way of queues.

0 Kudos
Message 6 of 7
(6,117 Views)

natasftw wrote:

Or as others mentioned, make two parallel loops.  In one loop, have your state machine.  In the other, have just the Event Handler.  Pass the events from the handler to the state machine by way of queues.


A proper state machine will not need the second loop.  The "Wait For Event" or "Idle" state (whatever you want to call it) is all you really need in order to catch the user button presses.  The setup is almost there.  Maybe add a shift register to keep track of which state to go to in the case of a timeout on the Event Structure.



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