Flexible NC programming
1.12 Check structures
Job planning
100 Programming Manual, 07/2010, 6FC5398-2BP40-0BA0
Significance
IF: Introduces the IF loop.
ELSE: Introduces the alternative program block.
ENDIF: Marks the end of the IF loop and results in a return jump to the
beginning of the loop.
<condition>: Condition that determines which program block is executed.
Example
Tool change subprogram
Program code Comments
PROC L6 ; Tool change routine
N500 DEF INT TNR_AKTUELL ; Variable for active T number
N510 DEF INT TNR_VORWAHL ; Variable for pre-selected
T number
; Determine current tool
N520 STOPRE
N530 IF $P_ISTEST ; In the program test mode ...
N540 TNR_AKTUELL = $P_TOOLNO ; ... the "current" tool is read
from the program context.
N550 ELSE ; Otherwise ...
N560 TNR_AKTUELL = $TC_MPP6[9998,1] ; ... the tool of the spindle is
read-out.
N570 ENDIF
N580 GETSELT(TNR_VORWAHL) ; Read the T number of the pre-
selected tool in the spindle.
N590 IF TNR_AKTUELL <> TNR_VORWAHL ; If the pre-selected tool is
still not the current tool,
then ...
N600 G0 G40 G60 G90 SUPA X450 Y300 Z300 D0 ; ... approach tool change
position ...
N610 M206 ; ... and execute a tool change.
N620 ENDIF
N630 M17