08-18-2015 07:43 AM - last edited on 08-24-2015 10:45 AM by dcarva
I have different controls for some pumps.
I want to stop all of them with an Emergency Stop button.
I use Event Structures to handle all the user's commands.
In the previous version of my code, I was registering all the events statically in the same vi. But in order to make the program compact and modular, in the attached version of the code I use the references of the controls and I pass them to a subvi. In the subvi I register the events of these references and I link the "event registration refnum" to the Dynamic Events terminal of the Events Structure.
Everything works, except for the Emergency Stop.
I cannot use a reference of the Emergency Stop button to trigger the event, because the Emergency Stop opens other vi files for further confirmation of the user.
When the Emergency Stop is confirmed by the user, I use the Value Signaling property to trigger the Stop Event of all the Event structures of the sub-VIs that control the pumps.
Previously I had only one Value Signaling to trigger multiple events, but I saw that I create race condition and the first Event Structure that handles the event, it deletes it from the queue and the other Event Structures cannot get the event.
So, I use as many boolean's Value Signaling as many pumps I have.
But it still does not trigger all the events.
Another detail is that I don't use the "Unregister for events function" in all the sub-VIs that have the Event Structures. I didn't see any difference with this function or without it..
Apparently, I am missing a clue of a general principle of LabVIEW.
I attach the whole project for demonstation.
The main.vi starts the program.
Solved! Go to Solution.
08-18-2015 12:31 PM
Sadly, this code is anything but "compact and modular". Nothing fits on a single screen (I estimate I would need 5 across by 10 tall monitors to see your Main VI block diagram), there are multiple unclustered wires and controls all over the place, and it is accordingly too tiring to try to follow the logic.
Here are some suggestions.
Try simplifying, and come back (if necessary) with something that fits on at most 4 screens (you should be able to get it down to a single screen -- don't be afraid to use Clusters and Arrays for bundling wires, and sub-VIs to encapsulate code).
Bob Schor
08-20-2015 06:26 PM - last edited on 08-25-2015 02:38 PM by dcarva
Thank you very much for your suggestions.
My time is limited though, so for the time being I attach again the project with the same architecture but simplified to one pump.
I use the Event Inspector Window to see the events that are created (attached screenshot in zip file).
I see that the problem is not only for the Emergency Stop, but for all the buttons. When I press the buttons fast and continuously, I see that some events are "flushed", so they are not handled.
If the vi has a lot more controls, this happens more often, so the buttons need to be pressed twice or more.
Why this happens ?
How can I ensure that every single event that is generated, is handled by the Event Structure ?
08-20-2015 07:56 PM
Emergency Stop means "Everything Shuts Down, Now, No Questions Asked!"'.
Do you know about the Mechanical Actions of Boolean Controls? Almost all Stop Buttons (and most Start Buttons) should have the Latch When Released action. They should (and, indeed, if they were latched, could) never be part of a Value Property Node (nor a Local Variable). Try to avoid Value Property Nodes. Instead, rely on setting default values properly (you can consider using the Reinitialize All to Default Method on the Main VI).
I don't understand all of your loops. What, in particular, is the Timied Loop doing?
I recommend that you write a brief (1-2 pages) description what you are trying to do. Don't worry about how to do it, just concentrate on what. Also, I'll note that you obviously never opened the code you attached, as i doubt you would have omitted some of the TypeDefs.
Bob Schor
08-21-2015 03:47 AM
The logic that I want to implement is the control of the pump through the Start, Stop, Plus & Minus buttons, in an event structure.
The events of these buttons are handled by different event cases which set the value (setpoint) of the Analogue Output .
In order to have a ramp for the pump's control, the module's Analogue Output channel is not changed by the Start, Stop, Plus or Minus buttons but from the Timeout of the Event Strucure. The Timeout case is able to identify how much time has passed and it changes the value of the Analogue Output slightly, until it reaches the setpoint.
The Mechanical Actions of the Boolean Controls are set to "Switch" and not to "Latch" because I want to show in the interface that they are pressed till the process is finished. So I want to control the value property.
The Timed Loop is the main loop of the main.vi that has all the controls. If I don't store the controls in a while loop, I cannot change their value more than once.
My question is why in the Event Inspector Window I see that some events are flushed?
Let's focus on the events that are generated by the Plus & Minus buttons.
The events are handled by the Event Structure that is in the subvi PumpAO-control.vi
I pass the references of the controls to the subvi, I connect them to the "Register for Events Function" and the output of this function is connected to the "Dynamically Registered Events" terminal of the Events Structure.
If I delete the "Unregister for Events Function" on the right side of the subvi's Event Structure, then the events are neved flushed, but the click of a button can generate the same event in multiple queues.
The code version 2 that I attached is the simplified version, in which I deleted everything and I left only the controls of one pump. It has only one TypeDef, the one that has the references of the pump's controls.
Regards,
Nikos
08-21-2015 11:26 AM - last edited on 08-24-2015 10:47 AM by dcarva
In my previous attachment, I forgot to delete some unused clusters indeed.
I attach again the sample code.
I attach also another screenshot of the Event Inspector Window that shows an event in multiple queues, when the "Unregister For Events" Function is not used on the right terminal of the "Dynamic Events".
08-25-2015 09:39 AM
The problem of this thread is re-posted more clearly and it is solved here: