Statements for influencing NC program flow

A complete list of G functions is contained in the overview of commands in the Appendix under Control block statements ($..).

The syntax for control block statements is:

$<statement>

<statement>

Control block strings as described in Section Conditional jumps. Note that between $ and <statement> no blank characters are permissible.

Statements for influencing program flow (control blocks) permit the implementation of:

The following rules apply for the use of control blocks:

Programing Example

prg_example

Syntax check in an invalid branch:

N10 $IF 0

N20 XY           (Here no syntax check takes place)

N30 $ENDIF

N10 $IF 0

N20 ...

N30 $IF XY       (Syntax check due to nested control block statement;)

                 (error message due to unknown term)

N40 ...

N50 $ENDIF

N60 $ENDIF

N10 $IF 0

NXY              (Syntax check of block number;)

                 (error message due to unknown term)

N30 $ENDIF

Due to inaccuracies in the calculation and the internal representation of parameters, comparative operations (see Section Arithmetical expressions <expr>) in control block statements may lead to an erroneous result. Therefore in cases of doubt, check for a tolerance range instead of for precise values.

Programing Example

prg_example

WRONG:

N10 $FOR P1 = 0, 10, 1

N20 P2 = P2 + 0.01

N30 $ENDFOR

N40 $IF P2 == 0.1                (Due to inaccuracies of calculation P2)

N50 ...                          (may be unequal to 0.1 so that the $ELSE)

N60 $ELSE                        (branch is executed)

N70 G04 X20

N80 $ENDIF

RIGHT:

N10 $FOR P1 = 0, 10, 1

N20 P2 = P2 + 0.01

N30 $ENDFOR

N40 $IF ABS[P1 – 0.1] <= .000001 (Check a tolerance range for)

N50 G04 X5                       (unproblematic NC machining)

N60 $ELSE                        ($IF branch is)

N70 ...                          (executed)

N80 $ENDIF