If/else structure, Wait statement, On structure – Rockwell Automation 1398-PDM-xxx IQ Master Version 3.2.4 for IA-2000 and IQ-5000 Positioning Drive Modules, IQ-55 User Manual

Page 167: If/else structure wait statement on structure, Tutorial if/else structure

Advertising
background image

IQ Programming Structure • Program Structure Instructions

145

Publication 1398-PM601A-EN-P — October 2000

TUTORIAL

IF/ELSE Structure

The IF/ELSE statement is used to execute an instruction or a block of instructions one time if a condi-
tion is true and a different instruction or block of instructions if the condition is false. The simplified
syntax for the IF/ELSE instruction is:

IF condition

{

conditional statements

}

ELSE

{

conditional statements

}

Refer to Part 5

Language Reference for more detailed information. The following flowchart and code

segment illustrate the use of the IF/ELSE instruction.

WAIT Statement

The WAIT statement is used to suspend program execution until a condition is true. The simplified syn-
tax for the WAIT statement is:

WAIT condition

Refer to Part 5

Language Reference for more detailed information.

ON Structure

The ON instruction is used for multiple dimensional branching. The program can branch to as many dif-
ferent labels as required based on the value of a variable. Refer to Part 5

Language Reference for more

detailed information.

statements

If I1 = ON

{

O2 = OFF

MOVD = 3

}

ELSE

{

O2 = ON

MOVD = 4

}

statements

Is input 1 ON?

Start

Yes

No

Output 2 OFF

Move Distance 3 inches

End

Output 2 ON

Move Distance 4 inches

Advertising