20 Custom Macro
If reference is made again to the same address in the subprogram started by code A, B or C, the subprogram will not be called again, but the value of the address will be transferred already to the PLC or interpolator.
If a call of a user G, M, S, T code is made in the subprogram, FGMAC=0, not enabled (executed as ordinary codes M, S, ... G) FGMAC=1, enabled, i.e. a new call is generated.
20.9 Differences Between the Call of a
–A macro call may include arguments, but a subprogram call may not.
–The call of a subprogram will only branch into the subprogram after the execution of other
commands programmed in the block; a macro call will branch only.
–A macro call will alter the levels of local variables, a subprogram call will not. For example, the value of #1 prior to the call of G65 is different from the one in the middle of macro body. The value of #1 before M98 is identical with that in the subprogram.
20.9.1 Multiple Calls
Another macro can be called again from a macro. Macro calls can be made in four levels of depth, including simple and modal ones. With the subprogram calls included, the maximum depth of the calls may cover 8 levels.
In the case of multiple calls of modal macros (type G66), first the latter specified macro will be called after execution of each interpolation block, from which the previously specified macros will be called in a backward sequence. Let us see the example below:
%O0001 |
|
|
| |
... |
|
|
|
|
N10 | G66 | P2 |
| |
N11 | G1 | G91 Z10 | ||
N12 | G66 | P3 |
| |
N13 | Z20 |
| ||
N14 | G67 |
| (canceling of call G66 P3...) | |
N15 | G67 |
| (canceling of call G66 P2 ...) | |
N16 |
| |||
... |
|
|
|
|
%O0002 |
|
|
| |
N20 | X4 |
|
| |
N21 | M99 |
|
| |
% |
|
|
|
|
%O0003 |
|
|
| |
N30 | Z2 |
|
| |
N31 | Z3 |
|
| |
N32 | M99 |
|
| |
% |
|
|
|
|
170