12-08-2014 07:07 AM
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.
Solved! Go to Solution.
12-08-2014 07:44 AM
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
12-08-2014 07:51 AM
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.
12-08-2014
07:54 AM
- last edited on
06-16-2025
01:58 PM
by
Content Cleaner
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.
12-08-2014 08:36 AM
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.
12-08-2014 08:42 AM
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.
12-08-2014 09:02 AM
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.