# What is the function of Fanuc programming

## The Development of KAREL Code

KAREL (pronounced “Carl”) was initially used as an educational tool to teach the elements of programming language to students studying robotics. KAREL has since become a primary FANUC programming language used with robots and robot controllers. This powerful CNC programming language has tremendous capabilities. Tri Star CNC Services works with FANUC machinery parts which rely on KAREL coding.

Here, we’ll cast broad strokes and explain how KAREL works to help you begin to grasp the intricacies of FANUC robot programming. Understanding KAREL can make it easier to troubleshoot your FANUC machinery or know when to get repairs from Tri Star.

### How Does FANUC Programming Language Work?

#### The KAREL World

KAREL is built upon a simple vocabulary of commands to accomplish specific programming tasks. The world – the “space” in which KAREL works – has intersections, walls and beepers to execute its programs within a defined space, made up of X and Y coordinates known as Streets (horizontal) and Avenues (vertical). If, for example, a KAREL program was comprised of 6 Streets and 5 Avenues, it would be written as:

World 6 5

#### Beepers Command

Within KAREL’s world there are also beepers, which are indicated in KAREL’s programming with the Beepers command. Beepers are small objects placed at intersections of the Streets and Avenues which the robot can sense, and they can be picked up, moved, and set down by the robot when given the proper commands. If, for example, there are 2 beepers at intersection {4, 3} in World 6 5, it would be written as:

World 6 5
Beepers 4 3 2

#### Robot Command

The robot which moves around in KAREL’s world is defined with the Robot command, and it can face North, East, South, or West, as indicated by the commands 1, 2, 3 and 4 respectively. If, for example, the robot in World 6 5 would have a starting position at intersection {4, 3} while facing North (1), and there would be 0 beepers at that intersection, the program would be written as:

World 6 5
Beepers 4 3 2
Robot 4 3 1 0

#### Wall Section Command

Wall sections can also be set up at various points in KAREL’s world, as defined by the Wall command. Walls are only one block long, and can either be north or west of an intersection (indicated by a 1 or 4 respectively). If, for example, you wanted to place a horizontal wall directly North (1) of the intersection {2, 3} within World 6 5, the program would be written as:

World 6 5
Beepers 4 3 2
Robot 4 3 1 0
Wall 2 3 1

### Running a KAREL Program on FANUC Machinery

These four commands define the world in which KAREL lives – running a program is a different story. After establishing KAREL’s world, every program must begin and end with the same lines in order for it to be valid:

Begin:

BEGINNING-OF-PROGRAM
BEGINNING OF EXECUTION

End:

END-OF-EXECUTION
END-OF-PROGRAM

KAREL robot programs only understand five basic instructions: move (moves by one square in the direction it is facing), turnLeft (turns 90° left), putBeeper (puts a beeper on the square it is standing at), pickBeeper (lifts a beeper off the square it is standing at), and turnoff (the program ends). The simplest KAREL program needs to have at least 5 lines in it for it to be valid.

Example program of how to turn a KAREL program off:

BEGINNING-OF-PROGRAM
BEGINNING-OF-EXECUTION
turnoff
END-OF-EXECUTION
END-OF-PROGRAM

If you’d like to learn more details about the KAREL language, check out the Computer Science Department of MTSU for a more in-depth analysis of KAREL and how it’s used in FANUC robotics.

### The Benefits of Working with KAREL in FANUC Robots

The fundamental commands explained above are the basics of KAREL programming language, and robotics engineers all over the world have utilized these commands to develop more intricate programs for FANUC robots. KAREL can be used for advanced FANUC applications involving Ethernet communications, advanced logic processing, and data file manipulation through automatic positioning and programmable acceleration.

### Replacement FANUC Parts or Repairs, Contact Tri Star CNC Services

FANUC robotics must operate with extreme precision, relying not only on clean code but on perfect operation of the physical components within the CNC controls. Tri Star CNC Services provides superior FANUC repair and maintenance here at our McHenry, IL facility—or provide free over-the-phone support.

There are plenty of reasons a FANUC part can fail. View our comprehensive list of FANUC alarm codes to start troubleshooting your machinery. With a nationwide field service network, we provide fast turnaround times on repairs.