Non-Motion Instructions Lab

From Industrial Robotics & Automation - Fanuc Teach Pendant Programming
Non-Motion Instructions Menu

What are Non-Motion Instructions?

In our programs so far, we have only created sequences of motion instructions that will run through without deviation. They aren’t adaptive and they aren’t very efficient.

It is important to remember that our robot is a computer and everything it does is based on data running through a processor. Processors work based on math instructions. The memory space that stores math variables and results are known as Registers.

Registers hold data that can be referenced in programs. On the FANUC controllers, registers hold numerical values.

Position Registers differ in that they hold six separate numerical values, called “Elements”. This is designed for holding the six possible cartesian coordinate values – X,Y,Z, Yaw, Pitch, and Roll.

*While we will not be exploring Joint in this lab, the position registers can also hold degree values for the Joint coordinate system.

Register instructions perform math operations on normal registers and position register elements such as addition, subtraction, division, multiplication, and setting them equal.

Conditional Statements are instructions that can do two separate actions, depending on if a math equation happens to be true.


Register Type Details
Register A single numerical value.
Position Register 6 separate numerical values, mostly used to store positional data.


Instruction Description
LBL[1] This is a label. We put down this instruction to label it as a point we wish to “jump” to later.
R[5] = 1 R[5] will now contain the numerical value 1.
R[5] = R[5] + 1 R[5] is equal to itself (1) plus the constant of 1. Result is 2.
PR[5,1] = 23 The first element of PR[5] is now equal to 23. This is the X value.
IF R[5] > 1 JMP LBL[1:Start] The math equation “R[5] > 1” is checked to see if it is true.

Since R[5] is indeed greater than 1, it will jump to LBL[1:Start].

If it wasn’t true, the program would continue to the next line as if nothing happened.

JMP LBL[2] This instruction is only reached if R[5] isn’t greater than 1. If it is reached, the processor will jump to LBL[2], somewhere else in the program.

Counters and Conditional Loops

When products are palletized, they are often wrapped in plastic before being loaded on trucks and shipped out. If you were to use a robot for wrapping the pallets, you would need to make many passes around it. Using loops, this can be done quickly without needing to teach a lot of similar points.

Prerequisite Knowledge:

  • Safety
  • Teach Pendant Navigation
  • Jogging and Clearing Alarms
  • Motion Instructions
  • Running Programs

Required Preliminary Setup:

  • Laser ON
  • A Free Register set to 0
  • Robot at HOME Position

Concepts Introduced or Reinforced:

  • Registers (DATA Page)
  • IF Statements
  • Jumps and Labels
  • Register Instructions
  • EDCMD (Insert)
  • Copying Programs (SELECT Page)

All labs assume HandlingTool software.

Start by hitting the DATA key on the teach pendant’s keypad. This will open the DATA page.

The DATA page will open on whatever type was last viewed. We want to get to the Registers page but it may not yet be selected.

If you do not see a list of registers (of any type) you may be viewing the specific details of a single position register. In this case, hit the PREV key.

In the example to the left, we are viewing the “Pallet Registers” page. To change to Registers, select the softkey [TYPE] and choose the first option, “Registers”.


Now we will be on the Registers page in the DATA screen. This page lets us view the registers available for use on the teach pendant, as well as their contents.

Notice a couple of them have already been used and commented with various names, such as counter or offset.

*By default there are 200 registers available for use, but this can be expanded through advanced changes to variables outside the scope of this lab.

Choose one of the registers on the first page and hit the ENTER key on the teach pendant’s keypad. This will prompt you to comment the register with a name. Using the keyboard as you have done before, name the register COUNTER.

REMEMBER which register number you chose.

Registers can be used without commenting them, but it is just easier to program when they have useful names.

We can also manually enter values into the register.

With your register selected, hit the RIGHT arrow key to move the cursor to the register’s value.

Type the number 9 on the keypad and then ENTER to confirm entry.

Your register now contains a value of 9.

*Data registers can contain values up to 10 to the power of 17, which comes out to be around 10 quadrillion.

Select your register’s contents once again. This time type -1 and hit ENTER.

*Registers can contain both positive and negative values.

We’re going to leave our register at -1 for the time being. Now it’s time go get to using them in a program.

Attached to the end of this lab is a template for a simple motion program you should create. For reference on how to create programs, look back to your “Motion Instructions” lab.

Name your program with the following syntax:

Semester Underscore MProg Underscore Your Initials
F19 _ MProg _ MRE

Add motion to your program that starts at home, reaches every point on the template sheet, and ends at home.

The program should look as follows:

J PR[1:HOME] 100% FINE

J P[1] 100% FINE

L P[2] 225mm/s FINE

L P[3] 225mm/s FINE

L P[4] 225mm/s FINE

L P[1] 225mm/s FINE

J PR[1:HOME] 100% FINE

Now we want to leave this program alone and make a copy of it for the next part of the lab.

Hit the SELECT button to get to the SELECT screen, showing all available programs.

Highlight the program you just created. Hit the NEXT button to cycle the softkey selection right, showing the COPY function.

Hit the COPY softkey. You will be prompted to name the new copied file. Name it with the following syntax:

Semester Underscore RProg Underscore Your Initials
F19 _ RProg _ MRE

When prompted with “Copy OK?” hit YES.

You will be returned to the SELECT screen. Find the newly copied program and select it.

Hit ENTER to open the editor for the new program.

This is an exact copy of the original motion program, and any changes we make to it won’t affect the original.

The first thing we want to do is make this program loop. We’ll be using registers next to count the loops, and then add conditional instructions after that to stop after a certain number of loops through the program.

Cycle right on the softkeys with the NEXT button. This reveals our non-motion instruction key, [INST] and our general editing key EDCMD.

Scroll to the bottom of your program and select the line that contains the Joint move to HOME. We don’t want this home instruction inside our loop, so we’ll add a blank line above it.

To insert a blank line, hit the EDCMD softkey and select INSERT. You will be prompted about how many lines you wish to add, but we only need one for now. Hit enter and a blank line will be added above the selected line.

Inside that blank line, we want to add a JMP LBL[] instruction. To do so, hit the [INST] softkey and select JMP/LBL. Then you select “JMP LBL[]” and it will place that instruction into your blank line.

You will need to tell it which label specifically to use. We will use LBL[1]. Type 1 and hit enter.

When this instruction is reached, it will jump to whatever line LBL[1] is on. We haven’t put LBL[1] on any lines yet, so it won’t work. We’ll do that next.

Repeat the same process of adding a blank line and the non-motion instruction to place a LBL[] between the home instruction and our first point on line 2. Make sure to select the LBL[] instruction instead of JMP LBL []. When prompted, enter the value of 1 and hit ENTER.

*Labels are treated as blank lines to the processor when reached. They don’t do anything unless something else jumps to them, such as our JMP LBL[1] instruction

Select the first line of your program, clear all alarms, make sure the Step indicator at the top left is green, then hold SHIFT and press FWD.

Your robot should go home, then begin tracing your square. Notice the last instruction, a Joint move to HOME, is never reached, and the first instruction to HOME isn’t happening again. These instructions are outside our loop, so the processor never sees them.

This is an unconditional loop. It will just continue forever, until you stop the program, or something errors out.

Next we will make it conditional.

Select that JMP LBL[1] line toward the end of your program.

Normally when we add instructions, we need to insert a blank line first to prevent overwriting of existing lines. In this instance, we do want to overwrite the JMP LBL [1] so no blank line is necessary.

Add a new instruction with [INST], this time selecting IF/SELECT.

It will give you a list of possible relational operators. For this we want the less than symbol, <

Select it.

Next it will prompt you for the first variable to compare. We’ll be using your register for this, so select R[ ]. It will prompt you for the register number. Type the number of the register you chose earlier and hit ENTER.

Next is the rightmost variable. This is what the IF statement is checking to see if your register is less than.

This will be the count of how many times you wish it to loop before stopping, which is a constant number.

Hit CONSTANT, and then type 3 on the keypad. Hit ENTER.

Next it will prompt you for what action to take. Select JMP LBL [] and enter the value of 1 in the lbl. Remember to hit enter after typing 1.

This will cause it to loop so long as your register is less than 3.

Now if we ran this program, it would be the same as before. Since your register contained -1, and -1 is certainly less than 3, it will loop. Nothing in the program changes what is in register 3, so it will again loop forever.

We need to add a register instruction to increment the register by 1 each time through the loop.

This incrementing needs to be inside the loop to happen, so put it right before the IF statement. Remember to insert a blank line first.

The register instruction is in [INST] under register.

You will make it equal to itself, plus the constant of one.

R[9] = R[9] + 1

Now each time through the loop, your register’s value will go up by one. Eventually it will no longer be less than 3, and the program will no longer loop, simply ending with that last Joint move to HOME.

If you ran it now from the beginning (feel free to do so) it will actually go more than 3 times. This is because the register started at -1. Our program requires it to start at zero.

Additionally, if you ran the program a second time, it wouldn’t loop at all. The first run left the register at 3, and nothing told it to go back to zero.

So lets add that instruction at the beginning, to “set up” our register.

R[9] = 0

Since anything outside the loop only runs once, it will only set it equal to zero once when you first run your program.

This tidies up the variables so no matter what is in the register before you run the program, it will be a consistent, predictable value when you do.

Go ahead and run your program through from the beginning. It should run 3 times and then go home. STEP through the program to see what is happening too. You can switch to dual-view to watch it happen in real time by hitting the top right icon (far right on the blue bar), selecting the screen that isn’t your program, and hitting DATA.

Congratulations, you’ve created a counted loop program!

Take the robot back to HOME position, turn the teach pendant off, press in both emergency stop buttons, and hang up your teach pendant.