Blog

CNC-Related Features of Custom Macro | Modern Machine Shop

CNC-related features of custom macro are separated into two topics: system variables and user-defined G and M codes. This column explores both. #cnctechtalk

Last month’s column described computer-programming-related features of custom macro. This column address CNC-related features of custom macro, which are separated into two topics: system variables and user-defined G and M codes. Cnc Machine For Metal

CNC-Related Features of Custom Macro |               Modern Machine Shop

System variables are specified with variables numbered 1,000 and larger. Each type of system variable has its own group of system variable numbers. All provide access to CNC functions that are not available in normal G-code programming. This column goes through some of them, not sequentially, but in order of popularity.

It can be difficult to appreciate the importance of system variables and think of implications as to when they can be helpful. Below are a few simple examples, but they just scratch the surface of what’s possible.

Some system variable numbering varies among various FANUC CNCs (especially related to offset registers), so you must reference custom macro documentation for your CNC to determine which system variables are involved. Also, newer FANUC CNCs provide system variable names as well as numbers. We show the numbers since they work on all FANUC CNCs.

Custom macro enables users to write and read to and from offset registers (ranging in the #2000 and #10000 series). With tool length compensation, for example, #2001 provides access to the value stored in tool length compensation geometry offset register number one. #2002 provides access to offset two — and so on.

An example that sets offsets 1-50 to zero:

Custom macro also provides access to alarm generation and stop with message (#3000 and #3006). Alarm generation gives users the ability to set error traps. Stop with message is like a program stop command (M00), but a message will be displayed to tell the operator why the program has stopped.

The number to the left of the parentheses (100 in our case) is the alarm or message number. This message will be displayed if the alarm or message command is executed. Consider this command:

The alarm generation command will only be executed if the value in tool length compensation geometry offset register number one is less than 3.0. If true, the machine will go into alarm state and this message will be displayed on the display screen:

Users also can access axis position (ranging in the #5000 series). These system variables are read-only, letting you access the current position of each axis in several ways. Here are three ways for the X-, Y- and Z-axes:

Example using an edge finder as a touch probe:

When the machine stops and the message is displayed at the #3006 command, the operator will switch from automatic to handwheel mode, bring the edge finder flush with the left side of the part, reselect the automatic mode and restart the cycle. The surface location will then be stored in common variable #101. This could be the program zero surface which can now be placed in the X-axis register of the fixture offset.

With user-defined G and M codes, users can create new G and M codes or redefine the way current G- and M-codes work. Doing so involves parameter settings, and the involved parameter numbers vary among FANUC CNC models. The user must reference custom macro documentation for their CNC.

In essence, you will be setting up a kind of cross reference table so that when the CNC comes across the user-defined G or M code in a program, it will execute a predetermined custom macro.

Example that redefines the function of the M06 tool change command:

For a popular FANUC CNC model, parameter number 6071 is used to specify the M-code number that will call program number O9001. We will set this parameter to a value of 6. From then on, whenever the CNC reads an M06, it will execute program O9001. Instead of just making a tool change, change the function of M06 so that it first moves the machine axes to the tool change position and orients the spindle:

User-defined G codes work much the same way, though a different group of parameters and program numbers is involved. With user-defined G codes, you can include arguments in the calling command. You can also create modal user-defined G codes.

What we have shown is basic. You should be starting to see, however, how CNC-related features might help in your own applications.

If you want to streamline production and be competitive in the industry, you will need far more than a standard three-axis CNC mill or two-axis CNC lathe and a few measuring tools.

The way a G-code program is formatted directly affects the productivity of the CNC people who use them. Design CNC programs that make CNC setup people and operators’ jobs easier.

CNC-Related Features of Custom Macro |               Modern Machine Shop

Cnc Precision Milling From cobots to machine monitoring, this Top Shop honoree shows that machining technology is about more than the machine tool.