Technical Article

Introduction to FANUC Robot Programming

March 08, 2022 by Shawn Dietrich

FANUC has a wide variety of different product lines to accommodate nearly any automation environment, with its own flavor of structured text programming language.

FANUC Lineup

Figure 1. A selection of some of the FANUC robot models. Image used courtesy of FANUC America

Part 3 of a series about robot programming.

Check out the previous articles: Introduction to ABB Robots and ABB Robot Programming Example.

 

FANUC Robot Lineup

FANUC is a very well-known name throughout the industrial robot world. It’s not unheard of to have an entire automotive assembly line comprised entirely of FANUC robots. Because of this popularity, FANUC has a wide variety of different product lines to accommodate nearly any automation environment. Many robot manufacturers produce similar product lines, and these were shown in more depth in a previous ABB robotics article.

 

Articulating Robots - FANUC’s line of 6 axis articulating robots is quite extensive. This is the most common industrial robot architecture and FANUC’s extensive catalog ensures they have the solution you’re looking for.

Delta Robot - Faunc has four models with payloads ranging from 1kg all the way up to 12 kg. Delta robots usually have a limited reach but the DR-3iB series has a 1.6m reach.

SCARA Robot - FANUC has eight different models of SCARA robots all with varying payloads and reaches. The largest is the SR-20iA with a 20kg payload and 1.1m reach.

Collaborative Robots - Just like most other robot manufacturers FANUC has introduced a line of collaborative robots, now with 11 different models in various sizes.

 

Desktop Programming

Figure 2. Teach pendant programming takes place on the shop floor - but simulation can happen on a desktop well before installation. Image used courtesy of ffstop on Unsplash

 

FANUC TP Programming Language

Just like all other robot manufacturers, FANUC has its own flavor of structured text programming language. With FANUC, there are two programming languages: teach pendant (TP) and Karel. The TP language is the code that can be seen on the teach pendant and must be used on every robot application. Karel is a compiled language similar to Pascal that runs in the background and is capable of some advanced routines that are unavailable in the TP language.

The TP language is a textual language that has many similarities to common structured text. If compared to ABB RAPID language, the TP language is very stripped down and does not offer many of the features available from the RAPID language. During initial tests before final runtime, the TP code can be stepped through one line at a time.

TP Programming vs Structured Text

FANUC’s TP programming language uses some of the features from a typical structured text language but ultimately deviates to accommodate some specific robot function. Both languages use a textual base and have some structured statements, like an IF statement or FOR loop. While the syntax and program flow during the program design phase are similar, there are some distinct differences, explained below.

 

XKCD Goto Code

Figure 3. Only one of our favorite comic strips of all time. Image used courtesy of XKCD. Please go check them out!

 

Jump to Label

In the programming world, it’s important to keep your program flow clear and concise, so the general untold rule is to not use jumps or GoTo’s within your code. However, in the FANUC world, there is no WHILE loop so jumps to labels are the only option to jump over different sections of code that you don’t want to execute, or to return to a previous line. In this way, the jumps and labels form the program flow that is normally performed by a WHILE loop.

Interrupt or Skips

Most robot applications require the program flow to be interrupted because of an event that has occurred in the physical world. In the FANUC world, these interruptions are called “Skip”. When a skip is called during a movement, and the skip condition is satisfied, the program jumps to another section of code. This is similar to a jump to label command, except that the skip command can occur during a move command. Interrupts are an important feature of any robot program because they allow for the program to stop what it’s doing and do something else in the event of a physical signal.

Declaration of Variables

Typically with programming software, variables are defined at the top of the program before any kind of main loop. FANUC uses registers to store data and positional information, in addition to the input and output signals. For example, say you have a digital input indicating whether the gripper is currently open. Usually, you would define a boolean variable then map that variable to a input terminal. The mapped variable can then be used in the code with the same name as it was defined, instead of using the input terminal number directly, and it may look something like this:

GripOpen = DI[1:Gripper Open]

IF GripOpen = ON

JMP LBL[10]

ENDIF

With FANUC using the digital input directly instead of variables, the same code would be written as follows:

IF DI[1:Gripper Open] = ON, JMP LBL[10]

As you can see above the FANUC code is a drastic deviation from the structured text style. There are two main types of registers; data (numeric) and position registers. Standard data registers have the structure of R[x], and store normal integers for counting loop repetitions and storing sizing information for various payloads, among other uses. Position registers PR[x] store x-y-z positional information accessible across every program, useful for robot Home and Safe positions which should not change between programs.

There are also several less common registers, like string and offset registers, and several that are included with additional software, such as iR vision add-ons. All of the registers are configured on the teach pendant and manipulated through the code.

 

FANUC Arc Mate

Figure 4. Many manufacturing operations, including welding, are simplified with teach pendant programming. Image used courtesy of FANUC America

 

Summary

While FANUC TP programming looks different than most structured text, if you are familiar with ST as a programming language, you should be able to understand and quickly grasp the concept of the TP language. The hardest part of this programming is often simply getting used to frequent jumps to labels for navigation. As long as you are careful to comment (in FANUC, this is actually called a remark) all instances of these jumps, and to use special characters and blank lines to divide the code into smaller sections, an end user should be able to follow the flow quite easily.