LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event controll: How to stop a running while loop inside a event structure

Solved!
Go to solution

Hello,

 

I have some problems with controlling a while loop inside a event structure (see attached VI).

 

I habe 3 buttons ("Start Measurement, Stop Measurement, Quit Program"). When a measurement is running, it should be possible to stop the measurement by clicking on "Stop Measurement", but this does not work.

 

Has anyone an idea?

 

Thanks a lot and best regards,

Michael

Message Edited by MichaGue_01 on 04-23-2010 04:37 AM
0 Kudos
Message 1 of 6
(2,973 Views)
Solution
Accepted by MichaGue_01

Hi Michael,

create a parallel process for your measurement. You can use the "Producer/Consumer with Events" design pattern. You'll find it with "File -> New...".

Another possibility would be to remove the "lock frontpanel" sign, in the Start Measurement event case. 

 

Mike

Message 2 of 6
(2,967 Views)

Hi,

 

the default of a event case, is to lock the frontpanel until the event code is done.

Deselect the "Lock Frontpanel..." here: then it should work.

 

EventLockFrontpanel.jpg

 

But, maybe another architecture would better fit your needs.

Have a look at the shipped templates of LV

Select File -> New... and choose from the "From template..." -> "Design Pattern"  the event based producer consumer architecture.

 

 And also remeber the infos here:

http://zone.ni.com/reference/en-XX/help/371361F-01/lvhowto/caveatsrecmndtnsevnts/

 

Stefan

 

 

Message Edited by SK@NIG on 04-23-2010 04:47 AM
Message 4 of 6
(2,963 Views)

Hello,

 

Try not to use while loops inside a Event structure.

My approach is using two While loops (one will have only the Event structure).

I had to use to Flag buttons that make it a bit more complicated but i am sure somebody will come up with a better idea, or you might want to have a think about it yourself.

 

Have a look on the modified version on the attachment.

 

Once you are happy how it works then you can Hide the 2 flag buttons from the Front Pannel by going to Block diagram right-click the indicators and choose option "Hide Indicators/Controls"

 

I did it in LV 8.6 so i hope you can open it on your PC if not i can downgrade it.

 

If you have any problem let us know.

 

Regards

 

Dimitrios

 

Test Systems Computing Engineer

Cummins Turbo-Technologies

 

 

 

 

Message 5 of 6
(2,924 Views)

I've found one more problem with the original VI.  Even after fixing by unchecking the Wait until event completes checkbox, there is still a bug.  Clicking Start Measurement starts the measurement,  clicking Stop Measurement stops the measurement, then clicking Start Measurement again just resets the meaurement to 0 and ends the loop.  I found that the Stop Measurement button mechanical action was set to Latch Until Released.  This caused the Stop button to remained latched in the loop, and the next time start was called, the loop saw a True on the stop button and just iterated one time, then the stop button latch was released.  Change the stop action to Latch When Released to fix this problem.

 

The problem still exists in Dimitrios' solution.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 6
(2,899 Views)