While

Text Language Definition

Not Applicable

Description

The While block iterates over a list of blocks as long as a condition is true. The condition is checked at the beginning of the loop. If the condition is not initially true then the loop will not be done at all. When the condition becomes false, failing the test, the program leaves the block at the bottom. If nothing else is to be done while waiting the Wait Until block is a convenient alternative.

Escapes

The While block does not produce any escapes.

Examples

This list of blocks detects a contact sensor, measures the duration of contact and reports the duration in seconds:

This block list commences and is sustained when a button is pressed. While the button is pressed the speed of a motor is adjusted based on an analog speed reference.

The Delay block within the While block reduces the block frequency to about 50 Hz. The Jog command reprofiles the move every time it is invoked and should be used at frequencies lower than the controller sample rate. For applications where the speed needs to be adjusted every controller sample period the Set Profile Velocity command can be used along with some other tools to create custom profiles.

This block list fills a tank checking for an overflow condition while filling. If an overflow occurs the incoming flow is turned off and an exception is indicated:

Related Topics

Loop
Repeat Until
Yield