LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

time loop and events (again)

Good morning,
I still have problems with time loops and events.
I have an event structure based on run time menu (two buttons: start stop).
When I push start, an automatic sequence is started made of a state machine (so a while loop).
I want to stop the process by means of presing stop in the run time menu. The problem is that the system doesn't respond when I press the button (it's not locked since I unchecked the option to stop front panel acitivity in the event structure configuration). I see that the pression of the stop command is made, but the code inside the event structure is not executed.
How can I avoid this?
Thank you,
 
Fede
0 Kudos
Message 1 of 7
(3,359 Views)
Ciao zio,
it's hard to say without taking a look at your code. Did you put the event case in its own while loop? If not, events will be handled only once.
If you post code, please save it for 7.1 before (Save with options).

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 7
(3,348 Views)

Ciao Pincpanter (and all the people that want help me),

I attach  the zipped VI.

I'd like to stop the process (started with the pression of the Start Measurement) once clicked the Stop Measurement in the run time menu, but the pression doesn't seem to have any effect. Can you explain me how to do?

Thank you very much, I need someone's help, I am going crazy!!!

Fede

0 Kudos
Message 3 of 7
(3,329 Views)

The behavior you see is normal and fully documented. Quote from the online help on "Get Menu Selection":


Note  If you use this function with an Event structure configured to handle the same menu item, the Event structure takes precedence and LabVIEW ignores the Get Menu Selection function. In any given VI, use the Event structure or the Get Menu Selection function.

In general, you should always avoid placing loops inside event cases, because the gum ip the gears and block events. You can use the outer while loop for your purpose. See the attached modified version of your VI.

 

0 Kudos
Message 4 of 7
(3,325 Views)
Dear altenbach,
your answer was very useful. I understand that the code must be executed in the timeout event. However if the code is a state machine type code, the system doesn't work as I want. I would like to stop the development of the time machine by setting a global variable to FALSE in the stop measurement button, but the event seems not to be accepted.
Can anyone help me?
Thank you,
 
Fede
0 Kudos
Message 5 of 7
(3,304 Views)

Events don't react to changes in local and global varables, and that's usually a good thing. 😉

To trigger an event programmatically, you should write to a signaling property of the control assigned to the event, and the event will fire (even if the value does not actually change). 😄

Attached is a simple modification of my example that forces a stop of any ongoing measurments every 10 seconds using the above method.

0 Kudos
Message 6 of 7
(3,284 Views)

THANK YOU!!!

Even though it's not exactly what I was searching for, the idea of the two loops allowed me to achieve what I want you. Your help has been very useful.

Fede

0 Kudos
Message 7 of 7
(3,267 Views)