OFFSETS

From Industrial Robotics & Automation - Fanuc Teach Pendant Programming
Revision as of 12:52, 15 May 2019 by Mike138 (talk | contribs)

Offsets are the bridge between the math within teach pendant programs and the motion instructions themselves. With offsets, you can control the destination of a motion instruction depending on sensors, counters, math equations, user inputs, or virtually any variable available on your robot.

Offset PR[] Syntax

Line# Motion Type Position Type Position Number Speed Termination Type Motion Options
1 J P [1] Deg/sec Fine Offset,PR[]
2 L PR [2] 100% CNT50 Offset,PR[]

Results of Offset PR[]

Variables:

P[1] contains the following coordinates: 77, 121, 0, 0, 0, 90

PR[5] contains the following coordinates: 23, 0, 0, 0, 0, 4

Instructions:

The following instruction is reached: L P[1] 100mm/s Fine Offset PR[5]

Results:

The robot will move in a linear fashion at 100mm/s to reach the coordinates 100, 121, 0, 0, 0, 94

The contents of P[1] are unchanged.

The contents of PR[5] are unchanged.

The speed variable is unchanged.

The motion and termination types are unchanged.

Reasoning:

The motion option "Offset PR[5]" told the controller's processor the robot should go to the SUM of the coordinates in P[1] and PR[5].

When to Use Offset PR[]

The motion option is useful when working on a program requiring repetitive, predictable, or non-arbitrary motion instructions.

Example:

The back connector (black) is 40 pins going into the circuit board.

You are tasked with creating a drilling program for circuit boards. The back port as shown on the right requires 40 holes in a grid.


Without offsets, this would mean 40 drilling motion instructions, 40 removal motion instructions, and about 40 "move to the next hole" motion instructions. They wouldn't be perfect either, as teaching the points manually introduces human error that can compound line after line.


Using offsets, only two points would need to be taught, and only three motion instructions would be needed.

Approach the hole, drill the hole, then remove the drill.


J P[1] 10% Fine Offset PR[1]

L P[2] 100mm/s Fine Offset PR[1]

L P[1] 100mm/s Fine Offset PR[1]


(Since P[1] only differs from P[2] in Z height, the two points could be taught the same, and one of them edited to manually set the desired z height.)


These three motion instructions can be looped, changing the X and Y coordinates each time. If the connector is parallel with the X axis of the robot, we would have an instruction within the inner loop that adjusts the x axis each time.

LBL[1]

J P[1] 10% Fine Offset PR[1]

L P[2] 100mm/s Fine Offset PR[1]

L P[1] 100mm/s Fine Offset PR[1]

PR[1,1] = PR[1,1] + 2.54

JMP LBL[1]


Each time through the loop, it will drill the hole 2.54mm further (the distance to the next hole)


Now if this program were to run, it would never end and just keep drilling holes 2.54mm apart until it reached singularity. To give it a limit, we will change the JMP LBL[1] instruction to a conditional "IF" statement.


LBL[1]

J P[1] 10% Fine Offset PR[1]

L P[2] 100mm/s Fine Offset PR[1]

L P[1] 100mm/s Fine Offset PR[1]

PR[1,1] = PR[1,1] + 2.54

IF PR[1,1] < 50 JMP LBL[1]


After drilling the 20th hole, the position register's X element will contain 50.8 (because 20*2.54 is 50.8). We stop drilling more holes in that row by only looping if it is less than the value of the 21st hole's offset. (We used 50 because it is a simple number to choose, but any number between the 20th hole and projected 21st hole will do)


Once it has finished that row, we have to offset in the Y direction to start the next row.


This can be done with

PR[1,2] = PR[1,2] + 2.54


Note that we will want to start from the same X point as the previous row. It's currently at the offset value of 50.9. Let's just set it to zero.

PR[1,1] = 0

We're now ready to start the process again, with the new Y offset. To start again, we'll jump to the beginning.

JMP LBL[1]


This gives us a program that can do both rows.


LBL[1]

J P[1] 10% Fine Offset PR[1]

L P[2] 100mm/s Fine Offset PR[1]

L P[1] 100mm/s Fine Offset PR[1]

PR[1,1] = PR[1,1] + 2.54

IF PR[1,1] < 50 JMP LBL[1]

PR[1,2] = PR[1,2] + 2.54

PR[1,1] = 0

JMP LBL[1]


But wait! It'll continue doing row after row and never stop. We have to add another conditional statement to tell it we've finished the whole board and are ready for the next.

We'll do this by replacing that new JMP LBL[1] at the end again, with a conditional "IF" instruction.

IF PR[1,2] < 2.54 JMP LBL[1]


Now it will only jump if it hasn't already added the second row to the Y element. If it has, it will break out of the loop and continue on.

To make this program repeatable, we'll have to go to the top again, but we want to have it wait for an operator (or another robot) to tell it that the board has been changed out for another one that needs drilling.

We can do this with a WAIT instruction at the very top, after our new label for starting the whole program over.

LBL[2]

WAIT DI[101] = ON


Remember when we reset the X element of PR[1] to zero? We haven't done that yet for the Y element. Let's add it now, so the program will always start with a cleared position register.

PR[1] = PR[1] - PR[1]

This will ensure it will always start at the correct values.


Putting it all together gives us:


LBL[2:Begin]

WAIT DI[101:New_Board] = ON

PR[1:Drill_OFFSET] = PR[1:Drill_OFFSET] - PR[1:Drill_OFFSET]

LBL[1:Inner_Loop]

J P[1:Above_Hole] 10% Fine Offset PR[1:Drill_OFFSET]

L P[2:Inside_Hole] 100mm/s Fine Offset PR[1:Drill_OFFSET]

L P[1:Above_Hole] 100mm/s Fine Offset PR[1:Drill_OFFSET]

PR[1,1] = PR[1,1] + 2.54

IF PR[1,1] < 50 JMP LBL[1:Inner_Loop]

PR[1,2] = PR[1,2] + 2.54

PR[1,1] = 0

IF PR[1,2] < 2.54 JMP LBL[1:Inner_Loop]

JMP LBL[2:Begin]


END


What we have now is a clean 13 lines of code to loop with offsets with maximum precision instead of teaching the 120 points required to drill 40 holes. I've added comments to the variables to make them easier to identify.


If massive quantities were needed, additional outer loops could be added to do 5 or more boards at a time, move to another work area, and repeat there. While it is drilling the second work area boards, an operator could unload the finished ones in the first work area and load in new boards to drill, constantly alternating. This keeps the operator from being at risk of the robot's tool danger.


Try adding the outer loops yourself! Consider the second work area as an offset of 2000mm in the Y, and each board in the work areas to be 100mm apart.