M-Series Operator’s Manual 4/9/15
Macro M functions (custom M functions)
Most M-Series CNC M functions from 0 through 90 can be fully customized. Exceptions are M2, M6, and M25
that can be customized, but will always move the 3rd (Z) axis to the home position before executing the macro M
function commands. No M functions above 90 may be customized with macros. The default action listed will be
performed unless that M function has been customized.
To create a macro for an M-function, a file must be created in the C:\cncm directory. The file's name must be
mfuncXX.mac where XX is the M function number used to call the macro. M functions 0-9 must use single digits
in the filename (e.g. Use mfunc3.mac, not mfunc03.mac). The contents of the file may be any valid M and G
codes.
Each time the M function is encountered in a program, the macro file will be processed line by line.
* NOTE: Nesting of macro M functions is allowed. Recursive calls are not: if a macro M function calls itself, the
default action of the function will be executed.
Example: Turn on spindle with variable frequency drive and wait for "at speed" response. This example depends
on M94/M95 1 being used for the Spindle Enable signal and input 5 being the spindle at speed signal in the PLC
program.
Create file c:\cncm\mfunc3.mac with contents as follows:
M94/1 ; request spindle start
M101/50005 ; wait for up to speed signal
M2, M6, and M25 always move the Z-axis to the home position before any other motion. All other M functions are
performed after the motion of the current line is complete.
The M and G codes in a macro M function are not usually displayed on the screen as they are executed, and are all
treated as one operation in block mode. If you wish to see or step through macro M functions (e.g. for testing
purposes), set parameter #10 as follows:
0 Don't display or step through macro M functions
1 Display macro M functions, but don't step through them
2 Display and step through macro M functions
* NOTE: You cannot use block mode to step through a macro M function called using the G81 transformation (see
Chapter 12); the action timer will expire before you can press CYCLE START.
NOTE: Only one M function per line is permitted.
* NOTE: Unlike subprograms invoked with G65, macro arguments passed into a macro M function are passed in
by reference. This means local changes to #1 through #33 or #A through #Z will change the their values upon
return from the macro M function.