How to Change Unit Height on Fanuc Robots via PLC

In this article, we will be using PalletTool Turbo II to change the height of a unit load using the PTSETVAR program. If you ever need to modify the height of a unit load due to inconsistencies, then changing the height using the PLC would be a good option.
Before we start, if you want to learn about Fanuc robots and PalletTool Turbo II, check out the course Fanuc Robot Training 9: Advanced Pallet Data Techniques.
Let’s open the program and make some sense of the syntax.
Press SELECT.
Move the cursor down until you see the program PTSETVAR.
Press ENTER.

Let’s make the screen wider so it’s easier to read the whole program.
Hold the SHIFT button and press DISP.
Press 5 for Single Wide.

Now we can see what all of the arguments are.
Notice that lines 4–7 are the arguments that will need to be set up in order to change the variable and run the program.

For your reference, lines 15–24 are used as an example for the number of drops.

This program is very similar to PTGETVAR, but it has some differences that I will explain later.
Create a program
For now, let’s create a program for changing the unit load height.
Press SELECT.
Press F2 for CREATE.
Move the cursor down to Options/Keybd and press F5 for KEYBOARD.
For this example, I will call the name of this program ChangeHeight. Press EXIT.

Press F2 for DETAIL.
Press F1 for END. Press the NEXT button.
Press F1 for [INST].
Move the cursor down to 6 CALL.
Press 1 for CALL program.
Press F2 for MACRO.
Use the up arrow key to scroll up, which will save you some button presses.
Move the cursor up until you see the PTSETVAR program highlighted. Press the ENTER key.
Press F4 for [CHOICE].
Press 3 for String.
Press F5 for STRINGS.
Move the cursor down to Options/Keybd and press F5 for KEYBOARD.
Now, depending on which unit load you want to change, you will change the number at the end of the program. The program is called PMUL00x; the x denotes the number of the unit load. So, if I’m using unit load 1, the program would be PMUL001.
If I wanted to change the unit load to 10 the program would be called PMUL010.
I will be using PMUL001 for the purposes of this article.
Type PMUL001 and press EXIT.
Press F4 for [CHOICE].
Move the cursor down to 3 String and press ENTER.
Press F5 for STRINGS.
Move the cursor down to Options/Keybd and press F5 for KEYBOARD.
Type UL and press EXIT.
Press F4 for [CHOICE].
Move the cursor down to 2 Constant and press ENTER.
Type 0 and press ENTER.
Press F4 for [CHOICE].
Move the cursor down to 2 Constant and press ENTER.
Type 2 to indicate the variable is a REAL value. Then press ENTER.
Press F4 for [CHOICE].
Move the cursor down to 3 String and press ENTER.
Press F5 for STRINGS.
Move the cursor down to Options/Keybd and press F5 for KEYBOARD.
Type UNIT.HGT and press EXIT.
Press F4 for [CHOICE].
Move the cursor down to 3 String and press ENTER.
Press F5 for STRINGS.
Move the cursor down to Options/Keybd and press F5 for KEYBOARD.
Type 0 and press EXIT.
Now, we have a choice to make: we can either directly type the value in decimal format or we can use a numeric register. For the purposes of this article, we will use a numeric register so we can change the value while the robot is running.
Press F4 for [CHOICE].
Move the cursor to 1 R [ ] and press ENTER.
Pick a register and press ENTER. I will be using numeric register 191 for this article.

Now, let’s open a triple window to see if our code works.
Hold the SHIFT key and press the DISP key.
Move the cursor down to 3 Triple and press ENTER.
Let’s use the top right screen for the register value.
Either press the DISP key until the top screen header is in black or, if you have a touch screen, you can press the spot on the screen.
Press the DATA key.
Move down to line 191.
Give the register a description.
Give the register a value. I will set this value to 150mm.
Now, we will set the bottom right screen to be the Karel variable so that we can see if it changes correctly.
Press the DISP key until the header is black, or click on the bottom right screen.
Press the SELECT key.
Move the cursor down until you see the until load you are wanting to change the height of. Press ENTER. I will be changing unit load 001.
Now press the DATA key. Select F1 for Type. Choose KAREL Vars.
Put the cursor on line 1 UL and press ENTER.
Move the cursor down to line 4 UNIT and press ENTER.
This is the variable we will be changing.

Test the program
Now, let’s run the program and see if the HGT variable changes correctly.
Unfortunately, the variable didn’t change correctly.

Our error is that we need it in decimal format. Change the numeric register to 150.001 and run it again.
Notice that it changed correctly. This is because the robot doesn’t like it due to not having a decimal point 150.0. The robot just converts this to an integer. So we need to give it a value that will work. Hence 150.001.

If you're interested in working with Fanuc robots, you can check out the Fanuc Robot Training course series. Start with the basics and work your way up to the advanced level.
Upload the program to Roboguide
Now, we need to upload this program to Roboguide if you are using PalletPro.
Click on File then upload.

Change Upload From: to Workcell Robot Controller.
While PMUL001 is selected, click upload. Then click OK.

Now, let’s call our program in the main loop.
Press SELECT.
Move the cursor down to the MAIN program and press ENTER.
Move the cursor down to line 8 and insert a blank line using the EDCMD.
Use the [ INST ] key to call our new program.
Move the cursor down to the CHANGEHEIGHT and press ENTER.

Run the program
Now, let’s run the cell.
Play with numeric register 191 to see that the height of the box changes. You should note that the graphics will not change dynamically. This is just to illustrate the change. You should exercise caution if you are ever-changing this value on the fly.
Notice the height change.

When you restart the cell, the graphics will update to the last value you changed.
Summary
In this article, we learned how to change the height of a unit load using the PTSETVAR program in PalletTool Turbo II.
If you want to learn more about robotics, we have several courses for you. Check out realpars.com/courses and under Skill Paths, filter for Robotics.
If you're a plant manager and think your team could benefit from robotics training, check out realpars.com/business. Add your contact info, and our team will quickly get in touch to see how we can help your team develop their skills.
Frequently asked questions
PTSETVAR is a Fanuc robot command in PalletTool Turbo II used to set variables, such as unit height, directly from a PLC. It ensures precise and dynamic adjustments during robotic operations.
On the robot’s teach pendant, select a numeric register (e.g., R[191]) and enter the desired decimal value. This register feeds the new height value into PTSETVAR.
Yes, by using a numeric register in PTSETVAR, you can alter the height value without stopping the robot’s operation, allowing for continuous production.
Fanuc robots interpret whole numbers as integers. Using a decimal format (e.g., 150.001) ensures the height is treated as a real number for accurate positioning.
PTSETVAR writes a new value to a specified variable (e.g., unit height), while PTGETVAR retrieves the current value of that variable.
Learn from Industry Experts
With a 7-day trial, then €35/month