Fanuc work offset parameters – G54–G59 via macro variables

Read and write Fanuc work offsets G54 to G59 via macro variables: variable tables #5221–#5325, the G54.1 P1–P48 formula and practical G-code examples.

On Fanuc controls, the work offsets G54 to G59 can be read and written through macro variables. The tables below list the variable numbers per axis; for the extended work offsets G54.1 P1 to P48, the variable number is calculated. For an overview of all G-codes, see the Fanuc G-code reference.

G54 to G59

G54

Variable numberAxis
#5221X
#5222Y
#5223Z
#52244
#52255

G55

Variable numberAxis
#5241X
#5242Y
#5243Z
#52444
#52455

G56

Variable numberAxis
#5261X
#5262Y
#5263Z
#52644
#52655

G57

Variable numberAxis
#5281X
#5282Y
#5283Z
#52844
#52855

G58

Variable numberAxis
#5301X
#5302Y
#5303Z
#53044
#53055

G59

Variable numberAxis
#5321X
#5322Y
#5323Z
#53244
#53255

G54.1 P1 to G54.1 P48

The workpiece zero point data for P1 to P48 is stored in the variable numbers #7001 to #7945. It is best to calculate the matching variable number:

Calculation

Variable number = 7000 + (P number - 1) * 20 + axis number

Example for G54.1 P33

The following lines show the variable numbers produced by the formula – this is not runnable NC code:

#1 = 33
#[7001 + [[#1 - 1] * 20]] (X)
#[7002 + [[#1 - 1] * 20]] (Y)
#[7003 + [[#1 - 1] * 20]] (Z)
#[7004 + [[#1 - 1] * 20]] (1)
#[7005 + [[#1 - 1] * 20]] (2)

Explanation

To make the code easier to reuse, the work offset number is first stored in variable #1. The axis number is already included in the values 7001 to 7005 and is not added again.

Worked example: writing

Writing values to G54.1 P33:

#1 = 33
#[7001 + [[#1 - 1] * 20]] = 55.32 (X)
#[7002 + [[#1 - 1] * 20]] = 352.887 (Y)
#[7003 + [[#1 - 1] * 20]] = -487.995 (Z)

Worked example: reading

Reading the values of G54.1 P33 and storing them in variables #11, #12 and #13:

#1 = 33
#11 = #[7001 + [[#1 - 1] * 20]] (X)
#12 = #[7002 + [[#1 - 1] * 20]] (Y)
#13 = #[7003 + [[#1 - 1] * 20]] (Z)