If

Text Language Definition

Not Applicable

Description

The If block examines a condition and performs the enclosed block list if the condition is true. If the condition is not true the program skips the block list and continues from the end of the if block.

Escapes

The If block does not produce any escapes.

Examples

This list of blocks checks if a tank is low on fluid and fills it prior to performing a spraying operation. If there is enough fluid in the tank the filling action is bypassed:

Although Events are available to detect inputs another method of responding to inputs is a looping "dispatcher" the recognizes intention and performs actions. This block list loops checking for the presence of an input and performs the corresponding action.

Usually it is necessary to "debounce" a switch with a time delay after first sensing an input. The mechanical contact inside the switch can literally bounce causing an on-off-on effect in the millisecond time frame. The controller can sample faster than a millisecond time frame so switch bounce could be misconstrued as several seperate intentional switch operations. To prevent this it is normally important to have a delay after responding to the initial switch event so that the switch can settle to a stable signal before continuing. In this particular case the "off" condition is not checked and telling the motor to jog several times or begin stopping several times is not detrimental so the bounce does not need to be managed.

Related Topics

If Else
While
Repeat Until