LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limit action of the first itiration in while loop

I am using a while loop to move a motor through a serial port. The first iteration of the while loop always moves the motor one increment, even with the stop button latched. I haven't been able to see a way to limit this movement without using a relay to set the motion increment to a constant (0) when the stop button is latched. This is an easy solution but it seems like I might be missing some other simple solution. Any suggestions?
0 Kudos
Message 1 of 5
(3,045 Views)
It would be nice to take a look at the code, but, if I understood well, you can enclose the whole code inside while loop in a case structure (case False) and connect the Stop button to the case input. I'm not sure this is simpler than your solution, it only prevents the code to be uselessly executed. What do you mean with "the stop button is latched"?

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 5
(3,037 Views)
I am having a hard time visualizing what your code is doing, but I suspect that the "First Call?" function would help you a lot.
0 Kudos
Message 3 of 5
(3,031 Views)
Code in a while loop executes at least once. If you don't want the code to execute at all, conditionally skip the entire while loop by placing it inside a case structure.
 
Can you post a simple example of your program?
0 Kudos
Message 4 of 5
(3,030 Views)
Thanks folks, these are great comments and will help me much.
0 Kudos
Message 5 of 5
(3,010 Views)