11-25-2011 02:16 PM
I've attached a word document here with a picture of the same while loop twice.
The first one is fine. The user inputs a value and the value is compared with another value until a condition is met(the input is greater than the 2nd value).
The second one I move the input that the user sends the value from outside the while loop. So the value comes into the while loop through a tunnel. Then this does not work. But it bugs me because when I was googling tutorials about while loops I'd come across example where the input was coming in from a tunnel. And i don't know whats different about mine. I've moved the output outside the while loop too via a tunnel which I saw in tutorials.
The reason I'm trying to figure this out is I wanted a value to be entered by the user, sent to a while loop where such and such is completed and when the inputed value reaches a certain value the while loop shuts off. The value inputted from the user is still sent into another while loop which turns on when that condition is met and then the second while loop is running. Hence the reason for wanting the input value outside the loop.
The grand aim for this is so I can do it in my project on a wind turbine. While speed(sent from DAQ) is low, ramp it up until speed reaches a certain value, then into another while loop with other formulas. I was told about using the sequences too but ultimately advised to use the while loops. But I can't even get a simple VI to take an input and use it in one while loop then send it to another when the first when the condition is met.
11-25-2011 02:25 PM
If you turn on execution highlighting (the light bulb icon on the block diagram) and watch your two programs executing, you'll see what the problem is.
In your second loop, your input is only read before your while starts executing. Once the while loop starts, it's not going to see any changes in value on your input. Also, your output on your second loop will only be updated or written to when the loop stops executing.
If your aim is to have your program do one thing until a certain condition is met, and then do a different thing until another condition is met, you should really look into a State Machine.