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: 

2 parallel whiles and delay

Hi I'm learning about the use of parallel whiles for my program. Just can someone explain me why in the attached example, the delayed leds do not behave as they should. For example, if LED 1 has 500ms delay and LED 2 1000ms delay, LED 2 turns off first. But if LED 1 delay is higher than LED 2 delay, it works properly.

If I use single stepping it works properly.

 

 

0 Kudos
Message 1 of 3
(2,193 Views)

You have a race condition, because the upper loop will run a second time most of the time (after turning off the LED for a nanosecond) because the lower loop takes twice as long before resetting the switch. If you increase the upper delay to e.g. 600ms, your VI will work more reliably.

 

What is the purpose of the outer while loop?

0 Kudos
Message 2 of 3
(2,183 Views)

I probably would use event structures for this, see attached simple example (LV 2010).

 

0 Kudos
Message 3 of 3
(2,181 Views)