beautypg.com

4 if structure, 5 if/else structure, Programming – Lenze PM94P01C User Manual

Page 47

background image

PM94P01C

45

Programming

2.9.4 IF Structure

The “IF” statement is used to execute an instruction or block of instructions one time if a condition is true. The simplified
syntax for the IF statement is:

IF condition

…statement(s)

ENDIF

The flowchart and code segment in Figure 17 illustrate the use of the IF statement.

…statements

IF IN_A2

OUT2 = 1

MOVED 3

ENDIF

..statements

Start

Set Output 2 ON

Move Distance 3

units

End

Yes

NO

Input A2 ON?

Figure 17: IF Code and Flowchart

2.9.5 IF/ELSE Structure

The IF/ELSE statement is used to execute a statement or a block of statements one time if a condition is true and a
different statement or block of statements if condition is false.

The simplified syntax for the IF/ELSE statement is:

IF

…statement(s)

ELSE

…statement(s)

ENDIF
The flowchart and code segment in Figure 18 illustrate the use of the IF/ELSE instruction.

…statements

IF IN_A2

OUT2=1

MOVED 3

ELSE

OUT2=0

MOVED 5

ENDIF

..statements

Start

Input A2 ON?

Set Output 2 ON

Move Distance 3

units

End

Yes

Set Output 2 OFF

Move Distance 5

units

No

Figure 18: IF/ELSE Code and Flowchart