You are on page 1of 28

Contents – KRL syntax

Contents – KRL syntax

Variables and declarations ..................................................... S-3


Declaration of variables ................................................... S-3
Simple data types ............................................................ S-3
Arrays............................................................................... S-4
Structures – STRUC ........................................................ S-4
Enumeration type – ENUM .............................................. S-5
Data manipulation .................................................................. S-6
Arithmetic operators ......................................................... S-6
Geometric operator .......................................................... S-6
Relational operators ......................................................... S-6
Logic operators ................................................................ S-7
Bit operators..................................................................... S-7
Priority of operators.......................................................... S-7
Motion programming .............................................................. S-8
Coordinate systems ......................................................... S-8
Status and Turn ............................................................... S-8
Point-to-point motions (PTP)............................................ S-9
CP motions (LIN and CIRC)............................................. S-9
Computer advance run .................................................. S-10
Orientation control with linear motions........................... S-11
Orientation control with circular motions ........................ S-11
Program execution control ................................................... S-12
Conditional branch ......................................................... S-12
Switch............................................................................. S-12
Jump instruction ............................................................. S-12
General information regarding loops.............................. S-13
Counting loop ................................................................. S-13
Rejecting loop ................................................................ S-13
Non-rejecting loop .......................................................... S-14
Endless loop................................................................... S-14
Premature termination of loop execution ....................... S-14
KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-1
Contents – KRL syntax

Waiting for an event ....................................................... S-15


Wait times ...................................................................... S-15
Stopping the program .................................................... S-15
Inputs/outputs ....................................................................... S-16
Binary inputs/outputs ..................................................... S-16
Digital inputs/outputs – signal declaration...................... S-16
Pulse outputs ................................................................. S-17
Analog inputs/outputs .................................................... S-17
Subprograms and functions ................................................. S-19
Interrupt programming.......................................................... S-20
Stopping active motions ................................................. S-21
Canceling interrupt routines ........................................... S-21
Trigger – path-related switching actions............................... S-22
Switching functions at the start or end point of a path ... S-22
Switching function at any point on the path ................... S-23
Message programming......................................................... S-24
Important system variables .................................................. S-26
Timers ............................................................................ S-26
Flags and cyclical flags .................................................. S-26
$AXIS_ACT.................................................................... S-26
$AXIS_INT ..................................................................... S-27
$MODE_OP ................................................................... S-27
$NEAR_POSRET .......................................................... S-27
$NEARPATHTOL........................................................... S-27
$ON_PATH .................................................................... S-27
$OP_PRO ...................................................................... S-28
$POS_ACT .................................................................... S-28
$POS_INT...................................................................... S-28
$POS_RET .................................................................... S-28
$VEL_ACT ..................................................................... S-28

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-2 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Variables and declarations

Variables and declarations


Names in KRL:
ƒ can have a maximum length of 24 characters
ƒ can consist of letters (A-Z), numbers (0-9) and the special
characters ‘_’ and ‘$’
ƒ must not begin with a number
ƒ must not be a keyword.

As all system variables begin with the ‘$’ sign, this sign should not
be used as the first character in user-defined names.

Declaration of variables
Variable declarations always have the following syntax:
DECL Data_Type Variable_Name
ƒ Variables must be declared before the INI line.
ƒ In order to set syntax before the INI line, the DEF line must be
activated.

Simple data types

Data type Integer Real Boolean Character


Keyword INT REAL BOOL CHAR
Meaning Integer Floating- Logic state 1 character
point number
31 31
Range of -2 .. 2 -1 ±1.1E-38 .. TRUE, ASCII
values ±3.4E+38 FALSE characters
Example 32 1.43 TRUE “A”

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-3
Variables and declarations

Arrays
Arrays are used to group objects of the same data type to form a data
object. Syntax for declaration of an array:
DECL Data_Type Variable_Name[Number_Array_Elements]
Working with arrays: Value assignment
Variable_Name[Array_Index] = Value_Assignment
Example:
DECL INT OTTO[5] ; Declaration
OTTO[3] = 7 ; the third array element is assigned 7

ƒ An array may be of any data type.


ƒ The index always starts at 1.
ƒ Only integer data types are allowed for the index.
ƒ Besides constants and variables, arithmetic expressions are also
allowed.

Structures – STRUC
Structures in KRL:
ƒ A structure is a combination of different data types.
ƒ A structure is initialized with an aggregate.
ƒ Not all the parameters have to be specified in an aggregate.
ƒ The order of the parameters is not significant.
Working with structures: Declaration of a structure
STRUC Structure_Name Data_Type1 A, B, n, Data_Type
n …
Example of a predefined structure:
STRUC E6POS REAL X, Y, Z, A, B, C, E1, E2, E3, E4,
E5, E6, INT S, T
KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-4 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Variables and declarations

Example of value assignment with the point separator and an aggregate:


DECL POS POSITION ; Declaration Variable POSITION
POSITION.X = 34.4 ; Value assignment X component
POSITION.Y = -23.2 ; Value assignment Y component

POSITION = {X 34.4, Y -23.2} ; or with aggregate

Enumeration type – ENUM


Enumeration type in KRL:
ƒ An enumeration type consists of a limited number of constants.
ƒ The constants are freely definable names.
ƒ A variable of the enumeration type can only take on the values of
the constants.
Working with enumeration types: Declaration of an enumeration type
ENUM Enumeration_Type_Name Constant 1, Constant n
Example of a predefined enumeration type:
ENUM MODE_OP T1, T2, AUT, EX, INVALID
User-defined ENUM variables should end in ...TYPE!

Example:

ENUM PART_TYPE STRAIGHT, ANGLE, T_PIECE, STAR


; Declaration PART_TYPE
DECL PART_TYPE PART ; Declaration Variable PART
PART = #STRAIGHT ; Value assignment

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-5
Data manipulation

Data manipulation
Arithmetic operators

Operator Description
+ Addition or positive sign
- Subtraction or negative sign
* Multiplication
/ Division

Operands INT REAL


INT INT REAL
REAL REAL REAL

Geometric operator
The geometric operator “:” performs frame linkage.

Left operand Right operand


Operator Result
(Reference CS) (Target CS)
POS : POS POS
POS : FRAME FRAME
FRAME : POS POS
FRAME : FRAME FRAME

Relational operators

Operator Description Permissible data types


== equal to INT, REAL, CHAR, ENUM, BOOL
<> not equal to INT, REAL, CHAR, ENUM, BOOL
> greater than INT, REAL, CHAR, ENUM
< less than INT, REAL, CHAR, ENUM
>= greater than or equal to INT, REAL, CHAR, ENUM
<= less than or equal to INT, REAL, CHAR, ENUM

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-6 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Data manipulation

Logic operators

Operator Operand number Description


NOT 1 Inversion
AND 2 Logic AND
OR 2 Logic OR
EXOR 2 Exclusive OR

Bit operators

Operator Operand number Description


B_NOT 1 Bit-by-bit inversion
B_AND 2 Bit-by-bit AND operation
B_OR 2 Bit-by-bit OR operation
B_EXOR 2 Bit-by-bit exclusive OR operation

Priority of operators

Priority Operator
1 high NOT B_NOT
2 * /
3 + -
4 AND B_AND
5 EXOR B_EXOR
6 OR B_OR
7 low == <> < > >= <=

The following applies to all operators in KRL:


ƒ Bracketed expressions are processed first.
ƒ Non-bracketed expressions are evaluated in the order of their
priority.
ƒ Logic operations with operators of the same priority are executed
from left to right.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-7
Motion programming

Motion programming
Coordinate systems

Coordinate system System variable State


World coordinate system $WORLD Write-protected
Write-protected
Robot coordinate system $ROBROOT (can be changed in
$MASCHINE.DAT)
Tool coordinate system $TOOL Writable
Base coordinate system $BASE Writable

Working with coordinate systems: Tool and base selection


$TOOL = TOOL_DATA[n] ; n-Tool number 1..16
$BASE = BASE_DATA[n] ; n-Base number 1..32
ƒ On delivery, the base coordinate system corresponds to the world
coordinate system: $BASE = $WORLD
ƒ The robot controller normally carries out base-related
interpolation: $IPO_MODE = #BASE ; Standard
ƒ In the case of fixed tools, tool-related interpolation is carried
out: $IPO_MODE = #TCP
Status and Turn
ƒ The entries “S” and “T” in a POS structure serve to select a
specific, unambiguously defined robot position where several
different axis positions are possible for the same point in space.
ƒ The specification of Status and Turn is only evaluated for PTP
motions. For this reason, the first motion in a program must be a
PTP motion.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-8 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Motion programming

Point-to-point motions (PTP)


Syntax:
PTP {Point} ; Point-point name or aggregate
PTP_REL {Point} ; e.g. PTP_REL {A1 -45}
PTP {Point} C_PTP ; Approximation e.g. PTP P1 C_PTP

System variables Unit Function


$VEL_AXIS[Axis_No] % Max. axis velocity
$ACC_AXIS[Axis_No] % Max. axis acceleration
$APO.CPTP % Approximation of max. value

CP motions (LIN and CIRC)


Syntax:
LIN {Point} ; Point-point name or aggregate
LIN_REL {Point} ; e.g. LIN_REL {X 300, Z 1000}
CIRC {Auxiliary_Point}, {End_Point}, CA Angle
CIRC_REL {Auxiliary_Point}, {End_Point}, CA Angle

Max.
System variables Unit Function
value
$VEL.CP m/s 3 CP velocity
*1
$VEL.ORI1 °/s 400 Swivel velocity
*1
$VEL.ORI2 °/s 400 Rotational velocity
*2
$VEL_AXIS[4]-[6] % 100 Wrist axis velocity
2
$ACC.CP m/s 10 Path acceleration
*1 2
$ACC.ORI1 °/s 1000 Swivel acceleration
*1 2
$ACC.ORI2 °/s 1000 Rotational acceleration
*2
$ACC_AXIS[4]-[6] % 100 Wrist axis acceleration
*1
Required information for $ORI_TYPE = #CONSTANT or #VAR
*2
Required information for $ORI_TYPE = #JOINT

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-9
Motion programming

Approximate positioning with CP motions:

System variable Unit Description Keyword


$APO.CDIS mm Distance criterion C_DIS
$APO.CORI ° Orientation criterion C_ORI
$APO.CVEL % Velocity criterion C_VEL

Computer advance run


ƒ To make an approximation possible, a computer advance run of
at least 1 must be set: $ADVANCE = 1 (default value is 3,
maximum value is 5)
ƒ $ADVANCE = 0, approximation not possible, every point is
positioned exactly.
ƒ Instructions and data that influence the periphery trigger an
advance run stop. (e.g. HALT, WAIT, PULSE, ANIN ON/OFF,
ANOUT ON/OFF, $IN[x], $OUT[x], $ANIN[x], $ANOUT[x])
ƒ In applications where the advance run stop should be prevented,
the command CONTINUE must be programmed immediately
before the relevant instruction. This command only affects the
next program line (even if this line is empty).
ƒ As an alternative to modifying the variable $ADVANCE, the
advance run stop can be programmed with a wait time of 0
seconds: WAIT SEC 0
Default settings of $ADVANCE:

in the system by BAS(#INITMOV,0)


$ADVANCE 0 3

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-10 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Motion programming

Orientation control with linear motions

Variable Value Description


The orientation
remains constant
#CONSTANT during the CP motion.
The programmed
orientation is disregarded for the end point.
During the CP motion
the orientation
$ORI_TYPE #VAR changes continuously
to the orientation of
the end point.
During the path motion, the orientation of
the tool changes continuously from the
#JOINT start position to the end position. This is
done by linear transformation of the wrist
axis angles.

Orientation control with circular motions

Variable Value Description


The orientation remains constant during
#CONSTANT the circular motion. The programmed
orientation is disregarded for the end point.
$ORI_TYPE
During the circular motion the orientation
#VAR changes continuously to the orientation of
the end point.
Space-related orientation control during
#BASE
*1 the circular motion
$CIRC_TYPE
Path-related orientation control during the
#PATH
circular motion
*1
$CIRC_TYPE is meaningless if $ORI_TYPE = #JOINT.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-11
Program execution control

Program execution control


Conditional branch
Syntax: IF Execution_Condition THEN
Statements Execution
No
ELSE ; optional condition
Statements
ENDIF Yes

Statements Statements
Example:
IF $IN[10] == FALSE THEN
PTP HOME
ENDIF
Switch
Syntax: SWITCH Switch_Condition
CASE 1
Statements Selection 1 Statements

CASE n
Statements
DEFAULT
Statements Selection n Statements
ENDSWITCH

Jump instruction
Syntax: GOTO Marker

Since GOTO statements very quickly lead to a lack of structure and


loss of clarity within a program, they should be avoided if at all
possible. Every GOTO statement can be replaced by a different loop
instruction.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-12 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Program execution control

General information regarding loops


ƒ Loops are required for repeating program sections.
ƒ A distinction is made between counting loops and conditional
loops.
ƒ A jump into the loop from outside is not allowed and is refused by
the controller.
ƒ The nesting of loops is a further programming technique.

Counting loop
Syntax: FOR Counter = Start TO End STEP Increment
Statements
ENDFOR

Example:
INT COUNTER
...
Statements
FOR COUNTER = 6 TO 1 STEP -1
$VEL_AXIS[I] = 100 Counter value
No
reached?
ENDFOR
Yes

Rejecting loop
Syntax: WHILE Condition
Statements Statements

ENDWHILE Condition met? Yes

Example:
WHILE $IN[4] == TRUE No

$OUT[2] = TRUE
PTP POS_2
ENDWHILE

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-13
Program execution control

Non-rejecting loop
Syntax: REPEAT
Statements
UNTIL Condition Statements
No

Example:
REPEAT Condition met?
$OUT[2] = TRUE
PTP POS_2
UNTIL $IN[4] == TRUE Yes

Endless loop
Syntax: LOOP
Statements
Statement 1
ENDLOOP
Statement n

Premature termination of loop execution


Syntax: EXIT

Example:
DEF EXIT_PRO()
PTP HOME
LOOP ; Start endless loop
PTP POS_1
PTP POS_2
IF $IN[1] == TRUE THEN
EXIT ; Terminate when input True
ENDIF
CIRC HELP_1, POS_3
PTP POS_4
ENDLOOP ; End endless loop
PTP HOME
END

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-14 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Program execution control

Waiting for an event


Syntax: WAIT FOR Condition

Example:
WAIT FOR $IN[5] ; waits until input 5 is TRUE
WAIT FOR $OUT[5] == FALSE

ƒ If the logic expression (Condition) is already TRUE when WAIT


is called, program execution is not halted. The advance run stop
is nonetheless triggered.
ƒ If the expression is FALSE, program execution is stopped until it
takes the value TRUE.

Wait times
Syntax: WAIT SEC Time

ƒ Time is an arithmetic REAL expression specifying the program


interruption in seconds. If the value is negative, the program does
not wait.

Stopping the program


The HALT statement is used to stop programs. The last motion instruction to
be executed will be completed. The program can be resumed by pressing
the START key.

Syntax: HALT

Special case: In an interrupt routine, program execution is only


stopped after the advance run has been completely executed.
Exception: In the case of a BRAKE statement, program execution is
stopped immediately.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-15
Inputs/outputs

Inputs/outputs
Binary inputs/outputs
Syntax: $OUT[No] = Value or $IN[No]
Setting outputs at the end point:
Syntax: $OUT_C[No] = Value

Argument Type Function


Input/output number [1..1024, 2048 or 4096
No INT
depending on $SET_IO_SIZE]
TRUE: Input/output is set
Value BOOL
FALSE: Input/output is reset

Digital inputs/outputs – signal declaration


ƒ Inputs/outputs can be assigned names. The signal declaration
must be located in the declaration section.
ƒ Signal declarations must be specified without gaps and in
ascending sequence.
ƒ A maximum of 32 inputs or outputs can be combined.
ƒ An output may appear in more than one signal declaration.
Syntax: SIGNAL Variable $OUT[No] TO $OUT[No] or
SIGNAL Variable $IN[No] TO $IN[No]

Argument Type Function


No INT Input/output number [1..4096]
Variable Name Name of the declared signal variable

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-16 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Inputs/outputs

Pulse outputs
Syntax: PULSE ( $OUT[No], Value, Time )

Argument Type Function


No INT Input/output number [1..4096]
TRUE: Output is set
Value BOOL
FALSE: Output is reset
31
Range of values: 0.012 s...2 s (increment:
Time REAL 0.1 s, the controller rounds values to the
nearest tenth of a second)

Analog inputs/outputs
Syntax: $ANOUT[No] = Value or $ANIN[No]

Argument Type Function


No INT Analog input/output [1..32]
Analog output voltage [-1.0 .. +1.0],
Value REAL
corresponds to ±10 V

Starting cyclical analog output:


Syntax: ANOUT ON Signal_Name = Factor *
Control_Element <±Offset> <DELAY = Time>
<MINIMUM = u1> <MAXIMUM = u2>
Ending cyclical analog output:
Syntax: ANOUT OFF Signal_Name

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-17
Inputs/outputs

Argument Type Function


Signal_Name Name Analog output declared with SIGNAL
Factor REAL Any factor, as variable, signal or constant
Control_ Influence analog voltage with variable or
Element REAL
signal
Offset REAL Optional offset as constant
Time REAL Positive or negative delay
u1 REAL Minimum voltage
u2 REAL Maximum voltage

Starting cyclical reading of an analog input:


Syntax: ANIN ON Value = Factor * Signal_Name <±Offset>
Ending cyclical reading of an analog input:
Syntax: ANIN OFF Signal_Name

Argument Type Function


Store the result of the reading to a variable or
Value REAL
signal
Factor REAL Any factor, as variable, signal or constant
Signal_Name REAL Analog input declared with SIGNAL
Offset REAL Optional offset as constant, variable or signal

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-18 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Subprograms and functions

Subprograms and functions


Local subprograms:
ƒ A KRL file can consist of up to 255 local subprograms.
ƒ The maximum nesting depth for subprograms is 20.
ƒ Local subprograms are located after the main program and are
identified by
DEF Sub_Program_Name() and
END.
ƒ Local subprograms can be called repeatedly.
ƒ Point coordinates are saved in the corresponding DAT list and are
available in the entire program.
ƒ Once the local subprogram has been executed, the program
jumps back to the command after the subprogram call.
Global subprograms:
ƒ Global subprograms consist of a separate SRC file.
ƒ Variables declared in global subprograms are not recognized in
the main program.
ƒ Variables declared in the main program are not recognized in the
global subprogram.
Functions:
ƒ A function returns a certain value to the main program.
ƒ Functions are identified by
DEFFCT Data_Type Function_Name() and
ENDFCT.
ƒ The program name is also the variable name of a certain data
type.
ƒ The value to be transferred must be returned by means of the
RETURN(x) statement before the ENDFCT statement.
ƒ Example: DEFFCT INT SQUARE(NUMBER:IN)
INT NUMBER
NUMBER = NUMBER * NUMBER
RETURN(NUMBER)
ENDFCT

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-19
Interrupt programming

Interrupt programming
ƒ The interrupt declaration is an instruction. It must not, therefore,
be located in the declaration section!
ƒ A declaration may be overwritten by another at any time.
ƒ A maximum of 32 interrupts may be declared simultaneously.
ƒ A maximum of 16 interrupts may be enabled simultaneously.
ƒ Priorities 1...39 and 81...128 are available. The values 40...80 are
reserved by the system.
ƒ Priority level 1 is the highest possible priority.

Declaration of an interrupt:
Syntax: INTERRUPT DECL Priority WHEN Event DO
Subprogram

Argument Type Function


Arithmetic expression specifying the priority
Priority INT
of the interrupt.
Logic expression defining the interrupt
event:
ƒ Boolean constant
Event BOOL
ƒ Boolean variable
ƒ Signal
ƒ Comparison
The name of the interrupt program to be
Subprogram Name
executed.

Switching interrupts on and off:


Syntax: INTERRUPT ON Number
INTERRUPT OFF Number

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-20 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Interrupt programming

Disabling and enabling interrupts:

Syntax: INTERRUPT DISABLE Number


INTERRUPT ENABLE Number

Stopping active motions


The BREAK statement brakes the robot motion. The robot motion is
resumed as soon as the interrupt routine has been completed.
Syntax: BRAKE ; brakes the robot motion
BRAKE F ; brakes with maximum values

The BRAKE statement may only be used in interrupt programs. In


other programs it leads to an error-induced stop.

After returning to the interrupted program, a motion stopped by


means of BRAKE or BRAKE F in the interrupt program is resumed!

Cancelling interrupt routines


The RESUME statement cancels all running interrupt programs and
subprograms up to the level at which the current interrupt was declared.
Syntax: RESUME

ƒ The RESUME statement may only be used in interrupt programs.


In other programs it leads to an error-induced stop.
ƒ When the RESUME statement is activated, the advance run pointer
must not be at the level where the interrupt was declared, but at
least one level lower.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-21
Trigger – path-related switching actions

Trigger – path-related switching actions


Switching functions at the start or end point of a path

Syntax: TRIGGER WHEN DISTANCE = Switching_Point


DELAY = Time DO Statement <PRIO = Priority>

Argument Type Function


In the case of individual blocks, DISTANCE
= 0 designates the start point and DISTANCE
= 1 the end point of the following motion. In
the case of approximate positioning
Switching_ blocks, DISTANCE = 1 signifies the middle
Point INT
of the following approximate positioning arc. If
the previous block is already an approximate
positioning block, DISTANCE = 0 signifies
the end point of the preceding approximate
positioning arc.
Using the DELAY statement, it is possible to
delay or advance the switching point by a
certain amount of time. The switching point
Time INT
can, however, only be delayed or advanced
insofar as it still remains in the block
concerned. The unit is milliseconds.
Subprogram call, value assignment to a
Statement
variable or OUT statement
Every TRIGGER statement with a subprogram
call must be assigned a priority. Values from
1...39 and 81...128 are permissible. The
Priority INT
values 40...80 are reserved for automatic
priority allocation by the system. For this,
program PRIO = -1.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-22 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Trigger – path-related switching actions

Switching function at any point on the path

Syntax: TRIGGER WHEN PATH = Distance


DELAY = Time DO Statement <PRIO = Priority>

Argument Type Function


Distance from programmed end point. End
point is an approximate positioning point:
desired distance of the switching action from
the position in the approximate positioning
range closest to the end point. The switching
point can be shifted back as far as the start
point by entering a negative value for
Distance INT Distance.
Start point is an approximate positioning
point: the switching point can be shifted as
far as the start of the approximate positioning
range. By entering a positive value for
Distance, a shift as far as the next exact
positioning point programmed after the trigger
is possible. The unit is millimeters.
DELAY can be used to shift the switching
point in time relative to PATH. The switching
Time INT point can only ever be shifted within the
switching range specified above, however.
The unit is milliseconds.
Subprogram call, value assignment to a
Statement
variable or OUT statement
Every TRIGGER statement with a subprogram
call must be assigned a priority. Values from
1...39 and 81...128 are permissible. The
Priority INT
values 40...80 are reserved for automatic
priority allocation by the system. For this,
program PRIO = -1.

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-23
Message programming

Message programming
Syntax: DECL MSG_T Message_Name = { VALID FALSE,
RELEASE FALSE, TYP #NOTIFY, MODUL[] ” ”,
KEY[] ” ”, PARAM_TYP #VALUE, PARAM[] ” ”,
DLG_FORMAT[] ” ”, ANSWER 0 }

Element Type
Function/elements
TRUE generates message, FALSE
VALID BOOL
retains message
TRUE deletes message of TYP
RELEASE BOOL (type) #STATE and #QUIT; FALSE
allows message
#NOTIFY – Notification message
#STATE – Status message
TYP MSG_TYP
#QUIT – Ackn. message
#DIALOG – Dialog message
MODUL[] CHAR[12] Originator of the message
KEY[] CHAR[40] Displayed message text
#VALUE – customized texts
PARAM_TYP[] MSG_PRM_TYP #WORDS – ignores PARAM[]
#KEY – messages from database
Parameter can be inserted in KEY[]
PARAM[] CHAR[20] with %1. Only with PARAM_TYP of
type #VALUE.
DLG_FORMAT[] CHAR[70] Softkey labels, separated by |.
ANSWER INT Number of the softkey pressed

Examples:
DECL INT ANSWER
DECL MSG_T EMPTY_MSG
EMPTY_MSG = { MSG_T: VALID FALSE, RELEASE FALSE, TYP
#NOTIFY, MODUL[] ” ”, KEY[] ” ”, PARAM_TYP #VALUE,
PARAM[] ” ”, DLG_FORMAT[] ” ”, ANSWER 0 }

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-24 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Message programming

;----------ACKNOWLEDGEMENT MESSAGE----------
$MSG_T = EMPTY_MSG ; Reinitialization
$MSG_T.MODUL[] = ”USER” ; Text for originator
$MSG_T.KEY[] = ”No water!”
$MSG_T.PARAM_TYP = #VALUE
$MSG_T.TYP = #QUIT ; Acknowledgement message
$MSG_T.VALID = TRUE ; Trigger
WHILE $MSG_T.VALID ; Wait for acknowledgement
WAIT SEC 0.05
ENDWHILE
;----------DIALOG MESSAGE----------
$MSG_T = EMPTY_MSG ; Reinitialization
$MSG_T.MODUL[] = ”USER” ; Text for originator
$MSG_T.KEY[] = ”What part?”
$MSG_T.PARAM_TYP = #VALUE
$MSG_T.TYP = #DIALOG ; Dialog message
$MSG_T.VALID = TRUE ; Trigger
$MSG_T.DLG_FORMAT[] = ”Part x|Part y|Part z|End”
WHILE $MSG_T.VALID ; Wait for response
WAIT SEC 0.05
ENDWHILE
ANSWER = $MSG_T.ANSWER ; Number of selected key
;----------NOTIFICATION MESSAGE----------
$MSG_T = EMPTY_MSG ; Reinitialization
$MSG_T.MODUL[] = ”USER” ; Text for originator
$MSG_T.KEY[] = ”No vacuum!”
$MSG_T.PARAM_TYP = #VALUE
$MSG_T.TYP = #NOTIFY ; Notification message
$MSG_T.VALID = TRUE ; Trigger
WHILE $MSG_T.VALID
WAIT SEC 0.05
ENDWHILE
;----------Status message----------
$MSG_T = EMPTY_MSG ; Reinitialization
$MSG_T.MODUL[] = ”USER” ; Text for originator
$MSG_T.KEY[] = ”Compressed air fault!”
$MSG_T.PARAM_TYP = #VALUE
$MSG_T.TYP = #STATE ; Acknowledgement message
$MSG_T.VALID = TRUE ; Trigger
WAIT FOR $IN[8] == TRUE ; Wait until compressed air OK
$MSG_T.RELEASE = TRUE ; Delete status message

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-25
Important system variables

Important system variables


Timers
The system variables $TIMER[1] … $TIMER[16] serve the purpose of
measuring time sequences. A timing process is started and stopped by
means of the system variables $TIMER_STOP[1] ... $TIMER_STOP[16].
Syntax: $TIMER_STOP[No] = Value

Argument Type Function


No INT Timer number, range of values: 1...16
Value Bool FALSE: start, TRUE: stop

Flags and cyclical flags


Static and cyclical flags are 1-bit memories and are used as global markers.
Syntax: $FLAG[No] = Value
$CYCFLAG[No] = Value

Argument Type Function


Flag number, range of values: 1…1024
No INT
Cyclical flag number, range of values: 1…32
Value BOOL FALSE: reset, TRUE: set

$AXIS_ACT

Meaning/function: Current axis-specific robot position


Data type: Structure
Range of values/unit: [mm, °]

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-26 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en
Important system variables

$AXIS_INT

Meaning/function: Axis-specific position in the case of an interrupt


Data type: Structure
Range of values/unit: [mm, °]

$MODE_OP

Meaning/function: Display current operating mode


Data type: ENUM
Range of values/unit: #T1, #T2, #AUT, #EX

$NEAR_POSRET

Meaning/function: Robot within sphere about $POS_RET


Data type: Signal declaration
Range of values: Declared output

$NEARPATHTOL

Meaning/function: Radius of the sphere about $POS_RET


Data type: REAL
Range of values: [mm]

$ON_PATH

Meaning/function: The robot is on the programmed path


Data type: Signal declaration
Range of values: Declared output

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
© Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en S-27
Important system variables

$OP_PRO

Meaning/function: Program override


Data type: INTEGER
Range of values/unit: 0 .. 100 [%]

$POS_ACT

Meaning/function: Current Cartesian robot position


Data type: Structure
Range of values/unit: [mm, °]

$POS_INT

Meaning/function: Cartesian position in the case of an interrupt


Data type: Structure
Range of values: [mm, °]

$POS_RET

Meaning/function: Cartesian position when leaving the path


Data type: Structure
Range of values: [mm, °]

$VEL_ACT

Meaning/function: Current CP velocity


Data type: REAL
Range of values/unit: >0 .. $VEL_MA.CP [m/s]

KUKA Roboter GmbH, Hery-Park 3000, D-86368 Gersthofen, Tel.: +49 (0)821 4533 1906, Fax: +49 (0)821 4533 2340
S-28 © Copyright KUKA Roboter GmbH – College / Quickguide KRL V5.x 06.04.01 en

You might also like