Programs

From Industrial Robotics & Automation - Fanuc Teach Pendant Programming

Teach pendant programs are generally simplistic, following much of the same structure as other programming languages.

It's a good idea to break your program into sections as listed below, to help organize your code.


Setup Section

The first lines of a program should be your setup instructions. This often means zeroing registers and setting constants to be used later. It's also a good idea to set all your outputs to ideal conditions. We just happen to be using PR[10] in this program, but you may not know what you're going to use until you reach it. You can always insert lines at the beginning of your program to setup the registers later on when you know which registers you will use.

We can zero entire position registers easily using a single register instruction.

Examples:

PR[10]=PR[10]-PR[10]


Intro Motion

It can be useful to include motion instructions that take your robot to a known position, in case of power failure or a prior program leaving off in a weird place. Use a Joint move to ensure you don't enter singularity.

J P[1:Home] 20% FINE


Loop

Since when looping, you aren't likely to want it to go home every single time and don't want to zero your registers each time, we will begin our loop here. We will jump to this label later in the program, with JMP LBL[1]

LBL[1]

Everything inside the loop will occur over and over. In this example, we only want it to repeat when we press a "Start" button.

WAIT DI[104] = ON

Configuration

Depending on program state, input values, counts, times, and other variables - you can set up configuration data to match. This lets you run short, efficient motion instructions with few or no special sections. In this example, an analog input, AI[1] is read and applied to the Z element (element 3) of our position register. Note that this part isn't reached until someone presses that "Start" button above, so the technician will set the analog value with a knob and THEN press start.

PR[10, 3] = AI[1]

Any changes to the knob after starting won't affect the motion until the next loop, so the technician could actually begin entering the next value on the knob immediately.

Motion

Your motion lines should be efficient and minimalist. Anything that can be done with a new tool frame, user frame, offset, and registers should be, instead of having lots of similar motion lines.

J P[1] 100% Fine

L P[2] 222mm/s Fine OFFSET PR[10]

L P[5] R[11] Fine OFFSET PR[10]

L P[3] 222mm/s Fine OFFSET PR[10]

C P[8] OFFSET PR[10]

... P[6] R[11] 222mm/s Fine OFFSET PR[10]


Notes

The program listed above could have been done much more simply with a group input and a SELECT instruction. It was left as IF statements for simplicity in understanding.