How to use loops in MachineLogic
What are loops used for in MachineLogic?
- Run a child sequence repeatably
- Run the sequence a set number of times, infinitely or based on condition
In this discussion, we will see how we can:
- Create a loop
- Use the while condition based on a sensor input
The example will be based on a pick and place application in MachineLogic.
1. Add the loop instruction
2. Choose the "While" loop
3. Select the variable that stores the sensor value
4. Set the desired value of the sensor that will allow you to keep looping
5. Select the sequence that you want to loop
Now we have to read the sensor and update the value of the variable
6. Go to the end of your looped sequence
7. Add a "set variable" instruction
8. Select to set variable from device
9. Choose the sensor value variable
10. Choose the sensor input from the list of configured inputs.