04-15-2016 07:22 AM
You are right. However this still hasn't solved my original issue.
Each time the main loop iteration finishes, the sensor compares its reading with the desired one. If the case does not change (highly likely in one second) then it re-enters the same case and re-executes the loop. Therefore my stepper motor keeps turning 90 degrees every second.
How can I execute the For loop when the case is first selected, and then not execute it again until a new case is selected and different motors have to turn?
04-15-2016 07:44 AM
04-15-2016 01:50 PM
@simos wrote:Thanks for your suggestion. Unfortunately following your example does not seem to execute the For loop just once and then move on. Single stepping completes the loop, and then does not exit the case structure, it reruns the For loop.
It runs the loop as many times as you tell it to. That is the point of a FOR loop. Not until all of the iterations have executed does it let the case structure end and then the program moves on in the dataflow.