LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping Two Simultaneous While Loops In Sequence

Solved!
Go to solution

I'm running two while loops simultaneously. One while loop is being used to output a square wave using the NI DAQ USB-6343. The other while loop contains my main code. I need to make sure that my square wave while loop stops after the main while loop is completed. I used the "Highlight Excution" feature to see if my code was excuting in order and how I expected it to and it seems to do that but when I hit the stop button the square wave while loop stops while the main while loop is still finishing excuation. The main while loop takes a series of measurements using the DAQ box, so I need to make sure the square wave is being outputted while the mian loop is running.

 

Currently to get around this problem I wired a numberic constant (101) inside the main while loop to a numberic indicator oustide. And I used a "Equal" codition check in the square wave while loop and set it so that that loop stops when it sees the value. This seems to work and makes sure that my square wave still excutes while the main loop is finishing excuting. Even though this way works I want to see if there is a better way. Attached are a couple of screenshot of the loops.

Download All
0 Kudos
Message 1 of 5
(2,751 Views)
0 Kudos
Message 2 of 5
(2,730 Views)

It would be a lot easier to use a boolean instead of a random numeric value.

 

For a simple VI, a local variable like this is a common solution. Other possibilities include a functional global variable, or a notifier.

0 Kudos
Message 3 of 5
(2,726 Views)

I was going to use a boolean but I forgot why I didn't... I think I will just use a boolean and a local variable.

0 Kudos
Message 4 of 5
(2,719 Views)
Solution
Accepted by ashifulk

I vote for using a notifier.  You need to command the loop to end.  Making a front panel indicator just to stop a loop is not a good practice.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(2,676 Views)