Statements for influencing the NC program flow sequence
The syntax for control block statements is:
$<statement>
<statement> Control block string acc. to the following chapters. Note that between $ and <statement> no blank characters are permissible.
Statements for influencing the program flow (control-block) enable the realization of:
- Conditional jumps, to trigger for instance, an optional machining step depending upon a measured value,
- Incremental digital loops, to simplify programming of several repetitive machining steps, for instance, during line milling or during boring of hole-circles,
- Loops with run-condition, to allow to repetition of several machining steps till the abort condition is fulfilled. For instance, if the infeed of the tool and a machining operation should be carried out till a definite coordinate-value is reached. Loops could be programmed as endless-loops in case of missing or unfulfilled run-condition.
In the use of control-block-statements, the following rules are valid:
- In one NC-block, only one control-statement may be present!
- Nested control-block-statements are allowed. The nesting depth is firmly given.
- Only the block number and "/" may be programmed in front of the control-block-statement.
- In the invalid branch of a control-block-statement, a syntax-check is made for block-numbers and further (nested) control-block-statements (see example of IF-ELSE-branching).
Programming 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 because of nested control-block-)
(statement; Error message because of the unknown term)
N40 ...
N50 $ENDIF
N60 $ENDIF
N10 $IF 0
NXY (Syntax check of block number;)
(Error message because of unknown term)
N30 $ENDIF
Because of inaccuracy in the calculation and internal representation of parameters, comparative operations in control-block-statements, could lead to an erroneous result (see Chapter 2.6.1.3: "Arithmetical expressions"). Therefore, in doubtful cases, checking should be made not for precise value but for a tolerance range.
Programming 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 ... (can be unequal to 0.1, so that the $ELSE-)
N60 $ELSE (branch is executed)
N70 G04 X20
N80 $ENDIF
Correct:
N10 $FOR P1 = 0, 10, 1
N20 P2 = P2 + 0.01
N30 $ENDFOR
N40 $IF [P1 - 0.1] <= .000001 (Verification of a tolerance range non-)
(problematical for NC manufacture;)
N50 G04 X5 ($IF-branch will be executed)
N60 $ELSE
N70 ...
N80 $ENDIF