LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loops - stopping

Hi, can anyone help?

I'm trying to add a stop boolean to my VI. The VI consists of a while loop (a true/false constant is wired to the conditional terminal, set to true), inside of which is a true/false case structure, inside which is a sequence structure. The case structure has a true/false boolean wired to it and is set to false as default. The sequence structure only appears in the false case and contains three frames. In the first frame there is a serial port write.vi along with a format into string function that sends a command to the pump to start. In the second case there is a wait millisecond timer. Then in the third case there is a while loop (a true/false constant is wired to the conditional terminal and is set to true)
, inside of which is another format into string function and a serial port write.vi which is inside the false case of another true/false case structure. This frame determines the speed of the pump (the flow rate). There is a shift register on the while loop which passes the current speed to a equal comparison function. This function compares the old speed with the new speed coming from the control and if false writes the new speed. In the true case of the outer case structure there is another serial port write and format into string which sends a stop command to the pump when the true/false boolean wired to this structure is pressed. Therein lies the problem. When I press the boolean (make true) it doesn't stop the pump. I'd greatly appreciate it if someone could explain where I'm going wrong. If it is an easier I can send you the VI.

Thanks in advance,

Adrian

ah2002@columbia.edu
0 Kudos
Message 1 of 6
(3,462 Views)
It would be alot easier if you could post the code for us to look at, but it sounds like your inner most loop is never stopping. You should have some condition that stops the loop, not a constant. Perhaps wire the stop button to its conditional terminal.

Brian Vibert
0 Kudos
Message 2 of 6
(3,462 Views)
Brian, if you are out there. Please find attached the VI to look at. Thanks,

Adrian
0 Kudos
Message 3 of 6
(3,462 Views)
Hi Brian, I agree with you. I think it's a problem of a continuous inner while loop. Therefore, I've created a local variable of the true/false boolean that is wired to the outer case structure, then dragged and wired it to the conditional terminal of the while loop inside the 'speed' frame of the sequence structure. I then right-clicked on this local variable and changed it to 'read' and it seems to have done the trick. However, as a new LabVIEW user I'm not sure if this is the best way around the problem.

Thanks for your help,

Adrian
0 Kudos
Message 4 of 6
(3,462 Views)
That will certainly work, although I usually try to avoid using local variables. I also like to stay away from sequences, most people find they make the code harder to follow.

I've modified your VI from your other post to make it, in my opinion, easier to follow.

Since national's site won't allow me to attach the vi to this message I will attach to another. Open it up and see if it makes sense to you.

Brian
0 Kudos
Message 5 of 6
(3,462 Views)
Here is that example I mentioned in the earlier post.

Brian
0 Kudos
Message 6 of 6
(3,462 Views)