System variables provide access to many of the CNC-related features available in custom macro B. Just about all current register settings within the CNC control are accessible, including all tool offset registers, fixture offset registers, current position (relative to the program zero point and relative to the zero return position), and current modal states. The implications of this accessibility are almost limitless. There are countless times when having access to register values—especially offset register values—will help CNC users make better use of their machines.
FANUC controls equipped with custom macro B enable users to read and write data from accessible registers when feasible. Values for tool wear and geometry can be read and entered— the only exceptions are the position displays.
There is also a G code—G10—that allows one-way communication with offsets. With G10, any offset register can be written. However, it is not possible with FANUC controls to read the data from offsets with G10. For applications that only require the ability to write data into offsets, I’m often asked whether it is wiser to use the G10 function or custom macro B system variables.
I’ll answer this question in this article—and I’ll try to provide some logic for my recommendations, as well.
Compatibility Among Machines
Generally speaking, I’d only recommend using G10 if you never anticipate the need to read data from offset registers. However, if programs are to be shared among machines, using G10 to write data into offset registers will ensure the greatest probability that all machines will be able to execute the programs. Though G10 is an optional feature, most machine tool builders make G10 a part of their standard package of FANUC options, meaning it is more likely that a machine will have G10 before it has custom macro B (you must, of course, confirm this). The more machines that are involved, the more likely it is that one or more of them will not be equipped with custom macro B.
Applications with Write and Read Capabilities
If your application needs the ability to read data from offset registers, all machines using the program must be equipped with custom macro B. In this case, I’d recommend using system variables for both purposes (read and write) to maintain consistency between the two functions. (This is my personal preference—there is nothing wrong with using G10 to write and system variables to read as long as all machines involved have both features.)
Handling Variations with System Variable Numbering
Admittedly, G10 provides a more elegant way to address offsets. An L word within G10 specifies the kind of offset being addressed (wear offset, geometry offset or fixture offset) and a P word specifies the offset number. Because there are several ways that offset tables can be equipped even with a given model of the FANUC product line, the L word value may vary from one machine to the next. L1, for example may specify that you are writing into wear offsets on one machine and L11 may do so for another. But once you know the appropriate L word(s) for your machine(s), a simple P word specifies the offset number into which data will be written.
It is a little more difficult if you use system variables to read and write data. A completely different series of system variables is used for each offset type—and, as with the L word of the G10 command, you must know which system variables are related for each machine. You can find this information in the custom macro B section of your programming manual as long as you know which offset option has been equipped with your machine.
Once you know the related system variables, accessing offset data can still be a bit challenging. Wear and geometry offsets are the easiest since the offset number will be part of the system variable number. For example, wear offset number one for a given control model may be specified with system variable #2001. #2002 will be wear offset number two. #2003 will be wear offset number three. Once you know the system variable series, you can easily address the data.
Here is a trick that allows you to specify the offset number to address offsets and will help you keep programs consistent from one machine to another: Use a permanent common variable as a system constant to specify the beginning value of the system variable series. For one machine, it may be set to 2000; for another, it may be set to 10000. For our example, we will place this value in permanent common variable #521.
For either machine, when you want to read the value of offset number one, you can give the command:
#100 = #[#521 + 1]
The value in brackets will be interpreted as either 2000 + 1 or 10000 + 1, depending on the machine being used. The pound sign (#) outside the brackets will create the expression as either #100 = #2001 or #100 = #10001, depending on the machine being used. Either way, the value of offset number one is placed into common variable #100. The same technique can also be used to write data. Consider the next example that writes the current value of #100 into offset number one.
#[#521 + 1] = #100
Similar techniques can be used with fixture offsets, though each fixture offset number will have its own series of system variables (for X, Y, Z, fourth, etc.). System variables for fixture offsets will be incremented by a constant value (usually 20). With one machine, for example, fixture offset number one begins at #5220, fixture offset number two begins at #5240, and so on. The X register of fixture offset number one is #5221, Y is #5222 and Z is #5223. The X register of fixture offset number two is #5241, Y is #5242 and Z is #5243.
You can make programs compatible even among machines that don’t use the same series of system variables for fixture offsets by using another permanent common variable system constant. With the machine just described, we set #522 to a value of 5200. With another, we may set it to a value of 2500. Either way, the following command will place the current X offset register value of fixture offset number two in common variable #101.
#101 = #[522 +21]