How to Improve G10

G10 provides the ability to enter data into various registers within the control, including offset data and parameters. For CNC users, having the ability to enter data into offsets can play an important role in improving a machine’s performance.


Facebook Share Icon LinkedIn Share Icon Twitter Share Icon Share by EMail icon Print Icon

G10 has one severe limitation (at least on FANUC controls): It can only write data into registers; it cannot read from them. If a machine is equipped with custom macro B, it is possible to read data from offset registers using a series of system variables. However, system variables are difficult to work with because the numbering differs among FANUC control models and can even vary within one control model based on the offset option.
An easier way to read offset data with system variables is to create a user-defined G code. In order to leave the G10 function intact, we need to pick a different G-code number, say G110. The value 110 will be placed in the parameter for the first (of 10) available user-defined G codes. Look in the custom macro B section of your programming manual to find the parameter numbers for user-defined G codes. This parameter will correspond to a program number (like O9011). Once this parameter is properly set, whenever the control reads a G110, it will automatically execute the related program (we’ll use O9011).
The calling command could look something like this: N050 G110 T1.0 R10.0 V101.0
G110 will make the control execute program O9011. The T argument will specify the type of data being read. For our example, T1.0 will be for tool offsets and T2.0 will be for fixture offsets. R will specify the offset register number (10, in our example). V will specify the common variable number into which the offset value will be placed. In this example, the value of offset number 10 will be placed in common variable #101. So V lets us specify the common variable into which we want the value stored, enabling easy access to multiple offset values with more G110 commands. And since common variables are retained until at least the M30 of the main program, this common variable will be available for whatever purpose we require after the G110 command has been executed.
Here is our first attempt at program O9011. It can only access tool offsets and is not even referencing the T argument (yet).
O9011 (Data reading custom macro)
(T:#20, R:#18, V:#22)
#[#22] = #[2000 +#18] (Place offset value into common variable)
We’re assuming the system variables related to tool offsets are in the #2000 series, meaning the value of offset number 10 will be in #2010. The (only) command in this custom macro places the value of #2010 (again, offset 10) in common variable #101. If you have more than one machine, and if they use a different series of system variables to access tool offsets, you will need a different custom macro for each machine. The calling command will remain the same from machine to machine.
To gain additional access to fixture offsets, we will need to add more G110 arguments. We’ll add X, Y and Z to correspond to the various fixture offset registers. This will enable us to specify which fixture offset registers will be read. Consider this new command: N050 G110 T2.0 R3.0 V101.0 X1.0 Y1.0
If included, X, Y and/or Z specify which registers we want to read. If any are left out, the corresponding register value will not be read. In our example, we want to read the X and Y register values of fixture offset number three. The X register value will be placed in common variable #101. Though it is not specified, the Y value will be placed in common variable #102 (one variable number higher that the variable number specified with V. If Z is included in the G110 command, it will be placed in variable #103 (two higher than the value of V).
Here is the completed custom macro program.
O9011 (Data reading custom macro)
(T:#20, R:#18, V:#22, X:#24, Y:#25, Z:#26)
IF [#20 EQ 1.0] GOTO 10 (Tool offset)
IF [#20 EQ 2.0] GOTO 20 (Fixture offset)
#3000 = 100 (BAD VALUE FOR T)
N10 #[#22] = #[2000 +#18] (Place offset value into common variable)
GOTO 99 (Exit)
N20 (Begin fixture offset access)
#33 = 0 (Initialize flag to missing input)
IF [#24 EQ #0] GOTO 22 (Test for X)
#[#22] = #[5201 + 20*#18] (Read X register)
#33 = 1.0 (Missing input flag is satisfied)
N22 IF[#25 EQ #0] GOTO 24 (Test for Y)
#[#22+1] = #[5202 + 20*#18] (Read Y register)
#33 = 1.0 (Missing input flag is satisfied)
N24 IF [#26 EQ #0] GOTO 26 (Test for Z)
#[#22+2] = #[5203 + 20*#18] (Read Z register)
#33 = 1.0 (Missing input flag is satisfied)
N26 IF[#33 EQ 1.0] GOTO 99 (Test if XYZ are not missing)
#3000 = 101 (MISSING X, Y, OR Z)
N99 M99
We’re assuming that system variables range in the 5200 series for this machine. If your machines use a different set of variables, reference the custom macro section of your programming manual.
This technique enables your main program to remain consistent from machine to machine. If each machine has an appropriate O9011 program, a given G110 command will work the same on all machines. Once this program is verified for each machine, you won’t have to rummage through programming manuals to find the appropriate system variables every time you need to read an offset value.