From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why this while loop can be stopped in the event strucure?

Normally, you can not stop while loop inside a event structure. But the vi attached here can do it...

If you create a new vi: drag a new event structure but copy the while loop from the vi attached, you won't be able to stop the loop.

 

Can anyone tell what's going on?

 

Thanks

0 Kudos
Message 1 of 17
(2,727 Views)

By default, event structure lock the front panel until the event completes.

 

Here this option is uchecked in the event configuration, allowing reading of the cancel button.

 

It is still not a good idea to trap event structures with an inner loop.

0 Kudos
Message 2 of 17
(2,725 Views)

Thank you,

0 Kudos
Message 3 of 17
(2,711 Views)
Sorry, forgot to attach the file...
0 Kudos
Message 4 of 17
(2,710 Views)

Hi wbcat,

do you mean the only loop you have in your code? Without this loop you can execute only one event. You need the loop to run your program. Why don´t you want the loop running? If you need a counter for some special events, then create a shift register and add one in your specified event.

 

Hope it helps.

Mike 

0 Kudos
Message 5 of 17
(2,707 Views)

Well, the outer loop MUST run in order to service the event. No way around that.

 

Your VI has several problems:

  1. The timeout is zero by default, meaning the outer loop spins like crazy for the timeout case until one of the buttons is pressed.
  2. There is no reason at all to use a FP indicator and value properties. This is very inefficient. All you need is a shift register, initialized with -1.
  3. Again, if you want something that only increments in some of the cases, use a shift register with an indicator and add a +1 in some of the event cases.
0 Kudos
Message 6 of 17
(2,706 Views)

I no longer have LabVIEW 7.1, but here's a quick draft. Use similar code for the otehr cases, e.g. add a "+1" to the timout case, etc.

 

Message Edited by altenbach on 08-13-2008 11:46 AM
0 Kudos
Message 7 of 17
(2,702 Views)

Thanks,

>>The timeout is zero by default

you are right. But if you set the default as -1, it works

0 Kudos
Message 8 of 17
(2,701 Views)

wbcat wrote:

Thanks,

>>The timeout is zero by default

you are right. But if you set the default as -1, it works


Yes, but is still very clumsy code. Don't abuse front panel objects as "variables".

0 Kudos
Message 9 of 17
(2,696 Views)

I agree, altenbach

 

by the way, thank MikeS81 for your concern

 

More questions for your guys:

the real code inside the loop is a single laser pulse, while the "others" are different laser setups, like voltage, etc...

I plan to  set every single setup and then run the laser pulse loop to check how the laser works.

But I hate laser fires without control: when I set "others", it will fire once. I donot like that

 

0 Kudos
Message 10 of 17
(2,681 Views)