Programming

The loop condition is coupled to the real-time variable V.RTG.LOOP.ENABLED. The real-time loop is programmed by the following command.

Syntax:

#RT WHILE [ [MODULO] ]

 

#RT ENDWHILE

 

MODULO

(optional) at the end of the loop, the “dist_prog_start” function is reset to the start value of the real-time loop. If this parameter is not programmed, this variable is continuously incremented. See Comparison chart in display data.

The loop condition is programmed using the syntax of the real-time cycles.

Syntax:

#RT CYCLE [DEF] [[ ID =.. ] SCOPE =.. END_ACTION =..]

;…Instructions

#RT CYCLE END

DEF

Realtime cycle is only defined but not started yet.

ID=..

Unambiguous identifier of the realtime cycle, see Note.

SCOPE

For validity, see Validity.

Permissible identifiers are BLOCK, PROG or GLOBAL.

END_ACTION

Behaviour at end of the real-time cycle, see Action at end.

Permissible identifiers are MOVE_ABORT or MOVE_CONT.

In the following programming example, the loop condition is coupled to the value of the external variable V.E.RtLoopEnable in a real-time cycle.

In the parameter P-EXTV-00005 the external variable must be parameterised as synchronous.

Programming Example

Real-time loop with external variable as loop condition

%RtLoop
; RT WHILE condition
N0010 #RT CYCLE DELETE [ID = 4711 ]
N0020 #RT CYCLE [ID=4711 SCOPE = GLOBAL]
N0030   $IF V.E.RtLoopEnable != 0
N0040     V.RTG.LOOP.ENABLED = TRUE
N0050   $ELSE
N0060     V.RTG.LOOP.ENABLED = FALSE
N0070   $ENDIF
N0080 #RT CYCLE END
; start movement
N0090 X0 Y0 Z0
N0100 #BACKWARD STORAGE CLEAR
N0110 #DISTANCE PROG START CLEAR
N0120 Z33 G01 F100
N0130 Z0
;------------
; while until V.E.RtLoopEnable == 0
N0140 #RT WHILE
N0150 X100
N0160 Y100
N0170 X0
N0180 Y0
N0190 #RT ENDWHILE
;------------
N0200 X10
N0210 Y20
N0220 Z30
N0230 M30

Programming Example

Real-time loop with variable geometry

This example shows a real-time loop which has a variable geometry due to the command #OPTIONAL EXECUTION ON/OFF [SIMULATE]. The geometry in #OPTIONAL EXECUTION ON/OFF [SIMULATE] can be enabled or disabled by the simulate_motion control unit during machining. It is also possible to enable other NC commands such as M functions with #OPTIONAL EXECUTION ON/OFF [SIMULATE].

%RtLoop
; RT WHILE condition
N0010 #RT CYCLE DELETE [ID = 4711 ]
N0020 #RT CYCLE [ID=4711 SCOPE = GLOBAL]
N0030 $IF V.E.RtLoopEnable != 0
N0040     V.RTG.LOOP.ENABLED = TRUE
N0050   $ELSE
N0060     V.RTG.LOOP.ENABLED = FALSE
N0070   $ENDIF
N0080 #RT CYCLE END
; start movement
N0090 X0 Y0 Z0
N0100 #BACKWARD STORAGE CLEAR
N0110 #DISTANCE PROG START CLEAR
N0120 Z33 G01 F100
N0130 Z0
;------------
; while until V.E.RtLoopEnable == 0
N0140 #RT WHILE
N0150 X100
N0160 Y100
N0170 #OPTIONAL EXECUTION ON [SIMULATE]
N0180 Z100
N0190 Z0
N0200 #OPTIONAL EXECUTION OFF
N0210 X0
N0220 Y0
N0230 #RT ENDWHILE
;------------
N0240 X10
N0250 Y20
N0260 Z30
N0270 M30