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 number | Axis |
|---|---|
| #5221 | X |
| #5222 | Y |
| #5223 | Z |
| #5224 | 4 |
| #5225 | 5 |
G55
| Variable number | Axis |
|---|---|
| #5241 | X |
| #5242 | Y |
| #5243 | Z |
| #5244 | 4 |
| #5245 | 5 |
G56
| Variable number | Axis |
|---|---|
| #5261 | X |
| #5262 | Y |
| #5263 | Z |
| #5264 | 4 |
| #5265 | 5 |
G57
| Variable number | Axis |
|---|---|
| #5281 | X |
| #5282 | Y |
| #5283 | Z |
| #5284 | 4 |
| #5285 | 5 |
G58
| Variable number | Axis |
|---|---|
| #5301 | X |
| #5302 | Y |
| #5303 | Z |
| #5304 | 4 |
| #5305 | 5 |
G59
| Variable number | Axis |
|---|---|
| #5321 | X |
| #5322 | Y |
| #5323 | Z |
| #5324 | 4 |
| #5325 | 5 |
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:
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)