top of page

Creating user defined M codes

Custom macro B allows you to create your own G and M codes. That is, when a G or M code having the number you create is commanded, the machine will execute a special program – commonly a custom macro program (though it doesn’t have to include any custom macro commands).

In the G Code Primer article of this issue, we provided a technique that makes machines having different M codes for similar functions more compatible. We said the trick to making it work is finding and setting two of the user-created M code parameters.

For a 16 series control (16M or 16T), for example, the parameters happen to be 6071 and 6072. If parameter 6071 is set to a value of 41, for example, program O9001 will be executed whenever an M41 is read. If parameter 6072 is set to 42, program 09002 will be executed whenever an M42 is read. For our example involving spindle range selection, this would be how you’d set the parameters for the machine that uses M23 and M25 for low and high spindle range.

From this point on, when the machine reads an M41, it will execute program O9001, which as is shown in the example for this machine, contains an M23 – and of course, the desired spindle range will be selected.

As always, remember that parameter numbers vary from one control model to another – even among the Fanuc product line. This means you’ll have to find the related parameters. The easiest way to do so is to look in the Fanuc Operator’s Manual in the description of custom macro B – and in the section related to user-defined M codes.

1,546 views0 comments

Recent Posts

See All


bottom of page