01-17-2013 03:19 PM
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.
Solved! Go to Solution.
01-17-2013 03:28 PM
01-17-2013 03:29 PM
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.
01-17-2013 03:33 PM
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.
01-18-2013 06:49 AM
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.