6.2.6 Macro Call


The command to call the macro is G65.


  • The difference between macro call and subroutine call


The differences between macro call (G65) and subroutine call (M98) are as follows:

  • You can use the G65 command to specify arguments (data to be sent to macros), but the M98 command cannot.
  • Using the G65 instruction will change the hierarchy of regional variables in the macro.


1. Simple call (G65)


With G65, the macro given by address P will be called and data (arguments) can be sent to this macro.


G65 Pp Ll <specify arguments>;

P     : The macro number to call

l     : repeat times

ArgumentsData to send to macros


Simple call (G65)


Explain:

calling

  • Specify the macro number to be called with P code after G65.
  • When repeated execution is required, the number 1 to 9999 is given in L code. When L is not specified, it is preset to 1 time.
  • By using an argument, you can specify a value for the corresponding intra-regional macro variable.


Argument specification

Two types of arguments are provided. Arguments specify that I use letters other than G, L, N, O, and P, and that only one letter can be used. Arguments specify II to use the letters A, B, C one each and I, J, K up to 10 times. The type specified by the argument will be determined by the letter used.


Argument specification I

The method specified by the argument is specified in English letters (addresses), as shown in the following table:


address

Variable number


address

Variable number


address

Variable number

A

B

C

D

E

F

H

#1

#2

#3

#7

#8

#9

#11


I

J

K

M

Q

R

S

#4

#5

#6

#13

#17

#18

#19


T

U

V

W

X

Y

Z

#20

#21

#22

#23

#24

#25

#26


  • The addresses G, L, N, O, P cannot be used to specify arguments.
  • Addresses that do not need to be specified can be omitted. The intraregional macro variable corresponding to the omitted address will be set to undefined.
  • The writing of addresses does not need to follow the order of the English letters. It only needs to follow the writing format of the address. However, if you use the addresses I, J, and K, you still need to write them alphabetically.


Example:

B_A_D_ … J_K_        correct

B_A_D_ … J_I_        wrong


Argument specification II

Argument specification II can use address A, B, C, and I, J, K up to 10 times, and it is used to send a value such as three-dimensional coordinate value as an argument.


address

Variable number


address

Variable number


address

Variable number

A

B

C

I1

J1

K1

I2

J2

K2

I3

J3

#1

#2

#3

#4

#5

#6

#7

#8

#9

#10

#11


K3

I4

J4

K4

I5

J5

K5

I6

J6

K6

I7

#12

#13

#14

#15

#16

#17

#18

#19

#20

#21

#22


J7

K7

I8

J8

K8

I9

J9

K9

I10

J10

K10

#23

#24

#25

#26

#27

#28

#29

#30

#31

#32

#33


Arguments specify mixed use of I and II

The CNC controller automatically recognizes arguments of the specified type I and II internally. If the argument specifies that both types I and II are used at the same time, the type is specified using the argument that is specified later.


Arguments specify mixed use of I and II


2. Continuous active call (G66)


The command to continue an active call is G66, and the macro defined by G66 will be called after the program line of the axis move instruction is executed. This state will continue until the G67 command cancels.


G66 Pp Ll <specify arguments>;

P        : The macro number to call

l        : Repeats (default is 1)

Arqument        : Data to send to macros


Continue active call (G66)


Explain:

Call

  • The P code after G66 specifies program number for calling.
  • How many times to call program will specify by L and from 1 to 9999.
  • Arguments will pass to macro same as G65


Cancel

G67 will abort G66 mode, and continue active call will not effect.


Multi levels calling

G65 and G66 can call other G65 or G66 for multi levels calling, but only max 4 levels allowing, but not including subprogram calling (M98).


Limit

  • G66 program can not call macro program.
  • G66 must before argument.
  • Except motion commands, can not call macro.
  • Variable of macro (argument) only can set on G66 block.