Indice

3.3 Custom Macro calls

Custom macros are direct extensions of subroutines and subprograms.

As subroutines and subprograms:

Differently from subroutines and subprograms:

3.3.1 Non modal Macro calls

Non modal macro calls are initiated with G65 G-Code instead of M98 G-Code and they provide what are called “arguments”.
The values of the “arguments” are transferred to the Local Variables.
If an argument is not set the correspondent variable will be initialised to Null.

; Main program
T5 M6
G0 G90 G40 G21 G17 G94 G80
; Call subroutine O1000 as a macro passing the first three arguments
G65 P1000 A0 B35 C0.01
M30
 
; The following subroutine will be called as a macro by the G65
; A = #1 
; B = #2 
; C = #3
O1000
G1 x#1 y#2 z#3
M99

Modal macro calls are similar to non modal Macro calls but once the macro is enabled using G66 it will be executed automatically every time an X, Y, Z, A, B, C motion is programmed.

Modal macro calls can be used to obtain customised cycles. Indeed instead of performing the standard G81, G82, … cycles the user can specify all the operations performed by the cycle.

With parameter G10 L100 P5800 V<value> the motion mode used to perform the motion between two macro repetitions can be specified (#5800 = 0 → G0; #5800 = 1 → G1).

While a modal macro is active the parameter #5148 store the information about how many times the macro has been called.

Example

( © 2018 by RosettaCNC Motion        )
( file name: modal_macro_call.ngc    )
G90 G0 X0 Y0 Z0 F5000
G1 X100.0
; Enable the modal macro defined in O9110.ngc
G66 P9110 W5 Z10.0 F500
Y20.0
Y40.0
G67 ; Disable the macro
M30
( © 2018 by RosettaCNC Motion        )
( file name: o9110.ngc               )
O9110
#1=#5101 		(Stores G00/G01)
#3=#5103 		(Stores G90/G91)
#4=#5130 		(Stores the cutting feedrate)
#5=#5003 		(Stores Z coordinate at the start of drilling)
G00 G91 Z#26 	(Positioning at position delta R)
M98 P10
G0 Z-#26
G#1 G#3 F#4      (Restores modal information) 
M99
 
O10
G1 X#23
Y#23
X-#23
Y-#23
M99
 
G01 Z#26 F#9 		(Cutting feed to position Z)
IF[#5110 EQ 98]GOTO 1 	(Return to position I)
G00 Z#18 		(Positioning at position R)
GOTO 2
N1 G00 Z#5 		(Positioning at position I)
N2 G#1 G#3 F#4 	(Restores modal information)
M99

3.3.3 Support for encrypted macro files

It is also possible to use encrypted files. To generate these files, refer to the software documentation.

Please note that: