6.1.9 MACRO Examples


1. Pocket machining cycle:


Pocket Machining Cycle


The pocket radius is set by the user via the variable itself; the tool radius is also set by the user via the variable itself. The flow chart looks like this:


Pocket flow chart


Pocket cycle program:

#2=0;

#3=#1-#0;

#2=#0+#2;

#4=#3>#2;

WHILE #4 P10;

G01 X#2 Y0 F400;

G02 I-#2 J0 F400;

#2=#2+#0;

N10 #4=#3>#2;

G01 X#3 Y0 F400;

G02 I-#3 J0 F400;

M30;


2. Matrix processing

Macro can be used for matrix arrangement processing, and each axial offset distance and matrix row and column can be freely set.


The program starts with the following:

;MARCO AND SUBPROGRAM

LIST

;#1:X OFFSET

;#2:Y OFFSET

;#3:LINE N

;#4:ROW  M                                DON'T SET

;#5:TOOL NUMBER                        DON'T SET

;#6:X G52 OFFSET POSITION                DON'T SET

;#7:Y G52 OFFSET POSITION                DON'T SET

;#8:SUBPROGRAM NO                        DON'T SET

;#20:TOOL COUNT REGEST

;#21:ROW COUNT REGEST

;O1111:MATRIX PROGRAM

;O0001:NO1 TOOL

;O0002:NO2 TOOL

;O0003:NO3 TOOL

;O0004:NO4 TOOL

;O0005:NO5 TOOL


The main program is as follows:

O2396(2011-11-01)                 ;MAIN PROGRAM

G90G54G17G80G40G49                 ;State initialization

G52XY

#6=0

#7=0

#20=0

#21=#4

#20=#5-1

#8=1;

WHILE #20 P5                        ;According to the number of tools to decide how many times to call the matrix subroutine

M97 P1111                        ;Call matrix subroutine

#8=#8+1                               ;Call the next subroutine

#20=#20-1                        ;Calling matrix times minus one

#21=#4                        ;Reload the value of ROW

N5

#6=0                          ;Initialize the state

#7=0

G52XY

M30                           ;program complete


The matrix subprogram is as follows:

O1111                         ;MATRIX SUBPROGRAM

WHILE #21 P100                ;The number of ROW executions

M97 P#8 L#3                   ;Call O000#8 subroutine

#6=0                          ;Return X to its original location

#7=#7+#2                      ;Y position plus Y offset

#21=#21-1                        ;ROW minus one

N100

G90G49G53X0.Y0.Z0.            ;Return to mechanical origin

#7=0                          ;Return Y to its original location

M99


Other subprogram are as follows:

O0001.....

M99


O0002....

M99


O0003...

M99


O0004...

….

M99


O0005...

M99