PVC

PVC

Introduction to FANUC Karel Programming

Karel programming is an extremely powerful tool that can be used with FANUC robots. All of FANUC’s built-in packages, like singularity detection, are programs written in Karel that run in the background.

This tutorial will show how to write a simple “Hello World” Karel program in RoboGuide and how to run the program from the Teach pendant.

Step 1: Opening the Karel Text Editor in RoboGuide

  • Open the drop down menus on the left side of the screen (like shown below)
  • You should be able to see the “Files” drop down

Figure 1

Right Click on “Files” –> Select “New File” –> Select “Karel source (.kl)

Figure 2

This will open the Karel Editor (this is the IDE)

Figure 3

Step 2: Writing the “Hello World” Program:

1
2
3
4
5
PROGRAM hello_world
 
BEGIN
WRITE TPERROR('Hello World', CR);
END hello_world;

The WRITE statement will default write to the user screen on the Teach Pendant unless otherwise specified.

The “CR” is a character return (new line command)

In this example we will write to the error line of the Teach Pendant.

To put this program into a format the robot can read, it must be converted to a binary file. This can be done right in RoboGuide using the “Build” icon in the upper right corner of the text editor. (highlighted below)

Figure 4

The “Build” Icon will convert the file from a .kl to a .pc file.

If there are no program errors, you will see the pop up below:

Step 3: Running the Karel Program from the Teach Pendant

  • Create a new TP program
  • Call the Karel program “Hello_World”

Now you can run the program like you would any other program (Shift – FWD)

This is a very simple example of the capabilities of Karel. This shows how you can implement warnings within your Karel code so that the user can see what is going on.

Once Karel programs are written and loaded into the controller, they can be thought of as “Black Boxes”. You are not able to see what is actually going on in the program which is why it’s important you incorporate WRITE statements to help the trouble shooting process.

April 9, 2022     Pete VanCamp 

Shopping Basket