FANUC position registers: PR vs P, offsets and PR math
How position registers differ from taught points and numeric registers on an R-30iB or R-30iB Plus controller, how to build offsets and do element math with them, and where they make a program easier or harder to support.
A FANUC position register is a position stored on the controller instead of inside one program. Any program can read it, write it, add to it or use it as an offset, which is what makes it powerful and what makes it risky. This guide covers how position registers differ from taught points and numeric registers, how to set them, offsets, element math, look-ahead, and the habits that keep shared registers from turning into a support problem.
In short
This follows FANUC’s operator’s manual for R-30iB and R-30iB Plus controllers (Basic Function, B-83284EN). The listings are short examples written for this guide, with placeholder numbers, comments and speeds.
P vs PR vs R on a FANUC robot
| P[ ] position | PR[ ] position register | R[ ] register | |
|---|---|---|---|
| Holds | X, Y, Z, W, P, R and configuration, or joint angles | The same | One integer or real number |
| Belongs to | One program | The whole controller | The whole controller |
| Frames | Records UF and UT; alarms on a mismatch | Stored as UF:F, UT:F, so uses the frames selected at the time | None |
| Provided as standard | Numbered within each program | 100 | 200 |
| Typical use | Pick, place and approach points | Home and perch positions, offsets, calculated or sent-in positions | Counts, part numbers, pitches, speeds |
The frame row matters most. A taught P[ ] checks its frame numbers against the active ones, and FANUC’s manual says the program won’t run on a mismatch. A PR[ ] has no such check. If a program selects user frame 2 and then moves to a PR taught in user frame 1, the robot goes to those coordinates in frame 2. Our user frame setup guide covers selecting frames at the top of each program.
How do you set a position register?
From the pendant: DATA (or MENU, 0 NEXT, 3 DATA), F1 TYPE, Position Reg. Jog to the position, cursor to the register and hold SHIFT while pressing F3 RECORD. An R beside the register means it holds a value, an asterisk means it doesn’t. F4 POSITION shows the values, and F5 REPRE switches between Cartesian and joint form.
From a program, the register instructions load a PR from other data:
| Instruction | Loads |
|---|---|
PR[1]=LPOS |
The current position, Cartesian |
PR[1]=JPOS |
The current position, joint angles |
PR[1]=P[3] |
A point from this program |
PR[1]=UFRAME[2] or PR[1]=UTOOL[1] |
A frame’s values |
PR[3]=PR[3]+PR[4] |
The sum or difference of two positions |
FANUC’s data screens carry a warning worth repeating. Registers are used by programs, so never change one before checking how the system uses it.
FANUC PR[i,j] element math
PR[i,j] is one element of register i. In Cartesian form, j is 1 to 6 for X, Y, Z, W, P and R. In joint form, j is the joint number. Element instructions take constants, registers, I/O values and other elements, with +, -, *, /, MOD and DIV.
A place point with an approach 100 mm above it, in user frame 1:
1: UFRAME_NUM=1
2: UTOOL_NUM=1
3: PR[10:APPROACH]=LPOS-LPOS
4: PR[10,3:APPROACH]=100
5:L P[1:PLACE] 500mm/sec CNT20 Offset,PR[10:APPROACH]
6:L P[1:PLACE] 100mm/sec FINE
7: CALL GRIP_OPEN
8:L P[1:PLACE] 500mm/sec CNT20 Offset,PR[10:APPROACH]
Line 3 sets the whole register to Cartesian zeros, so it has a known form before one element is written. Line 4 puts 100 mm in Z. Lines 5 and 8 go to the place point shifted by that register, in the selected user frame.
Values from a PLC work the same way, through group inputs, but check them before they reach a position:
1: R[20:PART HT]=GI[3:PART HT]
2: IF R[20:PART HT]>150,JMP LBL[90]
3: IF R[20:PART HT]<0,JMP LBL[90]
4: PR[12,3:PART OFS]=R[20:PART HT]
LBL[90] would post a user alarm and stop. A bad number from a network or a PLC program change should stop the robot with a message, not send it into the fixture. The PLC side of that exchange is covered in our EtherNet/IP with Allen-Bradley guide.
Offset, Tool_Offset and offsets from position registers
| Form | Shifts the point | In |
|---|---|---|
OFFSET CONDITION PR[1] then Offset on the motion line |
By PR[1] | The user frame named in the condition, or the selected one |
Offset,PR[1] on the motion line |
By PR[1], ignoring any offset condition | The selected user frame |
TOOL_OFFSET CONDITION PR[2] then Tool_Offset |
By PR[2] | The tool frame named, or the selected one |
Tool_Offset,PR[2] |
By PR[2] | The selected tool frame |
Offset moves along the user frame’s axes. Tool_Offset moves along the tool’s own axes, which is the usual way to back a gripper straight out of a part whatever angle it is at. FANUC’s manual notes that the offset register’s tool number and configuration are ignored, and that a tool offset on a joint-form point posts an alarm. FANUC’s Tech Transfer video on offsets covers how tool orientation changes what a tool offset does. The tool frame guide covers getting that orientation right.
Two behaviors catch people out:
- Teaching a line that has an offset. The pendant asks “Subtract offset data from current pos?” YES stores the jogged position minus the offset, so the robot comes back to where you jogged with the offset applied. NO stores the jogged position as it is, and the offset is added on top.
- Ignore settings. Under MENU, SETUP, General, Ignore Offset command and Ignore Tool_offset make the robot ignore offsets when set to ENABLED. Both are DISABLED as standard.
If an offset register is changed while the program is paused on an offset move, the new value is used when it resumes.
LOCK PREG and look-ahead
The controller normally reads ahead through motion lines to plan smooth paths, but it won’t read ahead into a line that uses a position register, because the register could change before the move runs. LOCK PREG locks every position register so look-ahead can continue, and UNLOCK PREG releases them. While they’re locked, a program that tries to write one posts INTP-128 and another function trying it posts VARS-037.
The lock clears automatically when the program that set it ends, but not when a called subprogram reaches its END. Pausing, moving the cursor and restarting also unlocks the registers. Do the math first, lock, run the moves, unlock. The palletizing example in our palletizing programming guide follows that order.
When position registers make a program easier to support
- One home or perch position shared by every program. Change it once and every program uses it.
- Approach and retract offsets kept in a few named registers, so a clearance change is a number, not a re-teach.
- Calculated positions for grids, pallets and trays, from a corner point and counts in registers.
- Positions found at run time, such as the high-speed skip form
Skip,LBL[10],PR[5]=LPOS, which stores where the robot was when the skip input came on. - Values sent from a PLC or HMI, range-checked as above.
Cautions with shared position registers
- They are global. Two programs using PR[10] for different things will break each other, and the failure shows up as a robot going somewhere odd. Reserve ranges by job and comment every register; a comment of up to 16 characters fits on each.
- They follow the active frame. A Cartesian PR moves if the user or tool frame changes under it. FANUC’s shift utilities, Program Shift and Frame Offset, convert taught points but leave position registers alone, so check them by hand after any shift.
- Other software can write them. Other programs, background logic and FANUC’s data transfer functions can all change a PR. Our background logic guide covers what runs there. Treat a PR another task writes as input, and check it.
- Multi-group systems. Teaching a position register records all axes in every group, and programs with a group mask only change the groups they own.
A good rule is to use position registers where a value is genuinely shared or calculated, and keep fixed points as P[ ] in the program that owns them, with comments on both. Our FANUC robot programming page covers how we write and tune robot programs.
Common questions
- What is the difference between P and PR in a FANUC program?
- A P[ ] point belongs to one program, is taught with the motion line, and records the user and tool frame numbers it was taught in. A PR[ ] position register belongs to the whole controller, can be written by any program, and plays back in whichever user and tool frames are selected when the line runs. Use P for fixed points in one program, PR for positions that are shared or calculated.
- How many position registers does a FANUC controller have?
- FANUC's R-30iB operator's manual lists 100 position registers and 200 numeric registers as provided. A FANUC Tech Transfer video shows how the counts can be raised on the controller. Before adding more, it is worth checking whether a program is using registers it doesn't need, because every extra shared register is one more thing the next programmer has to trace.
- What does PR[i,j] mean?
- It is one element of position register i. For a register in Cartesian form, j is 1 to 6 for X, Y, Z, W, P and R. For a register in joint form, j is the joint number, so PR[5,1] is J1, not X. Check the representation on the register's detail screen before writing element math, because the same line means something different in each form.
- Why does my FANUC offset not move the robot?
- Check the general settings first. Under MENU, SETUP, General, Ignore Offset command and Ignore Tool_offset both make the robot go to the taught position without the offset when set to ENABLED. Then check that the offset register holds what you expect, that the right user frame is selected for Offset, and that the point wasn't taught with the offset subtracted when you meant it not to be.
- What does LOCK PREG do?
- It locks every position register so the controller can read ahead through motion lines that use them, which it otherwise won't do because a register could change before the move runs. While locked, any attempt to write a position register posts INTP-128 from a program or VARS-037 from another function. UNLOCK PREG releases them, and they unlock automatically when the program that locked them ends.
Sources
- FANUC America: Robot support and manuals (R-30iB/R-30iB Plus Operator's Manual, Basic Function, B-83284EN: 4.3.2 Position Data, 4.3.5 Additional Motion Instructions, 4.5 Register Instructions, 4.11 to 4.13 Offset and Frame Instructions, 7.4 Position Registers, 9.4 Position Register Look-Ahead Execution; via the Customer Resource Center)
- FANUC Tech Transfer: Understanding OFFSETS in FANUC TP Code
- FANUC Tech Transfer: FANUC How to Add PR's, Frames, Registers
