04-23-2010 04:35 AM - edited 04-23-2010 04:37 AM
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
Solved! Go to Solution.
04-23-2010 04:42 AM
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
04-23-2010 04:42 AM
04-23-2010 04:45 AM - edited 04-23-2010 04:47 AM
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.
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
04-23-2010 08:34 AM
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
04-23-2010 11:36 AM
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.