Reference Manual Functions and Data Types
Reference Manual Functions and Data Types
BaseWare
RAPID reference part 2, Functions and data types A-Z
RobotWare-OS 4.0
RAPID reference manual
3HAC 7774-1
Revision B
BaseWare
RAPID reference part 2, Functions and data types A-Z Table of contents
RobotWare-OS 4.0
Functions A-Z
Index
Except as may be expressly stated anywhere in this manual, nothing herein shall be construed as any kind of guar-
antee or warranty by ABB for losses, damages to persons or property, fitness for a specific purpose or the like.
This manual and parts thereof must not be reproduced or copied without ABB's written permission, and contents
thereof must not be imparted to a third party nor be used for any unauthorized purpose. Contravention will be pros-
ecuted.
Additional copies of this manual may be obtained from ABB at its then current charge.
IsVar - Is variable...................................................................................................................... 95
MaxRobSpeed - Maximum robot speed.................................................................................. 97
MirPos - Mirroring of a position ............................................................................................. 99
ModTime - Get time of load for a loaded module ................................................................ 101
NOrient - Normalise orientation............................................................................................ 103
NumToStr - Converts numeric value to string ..................................................................... 105
Offs - Displaces a robot position ............................................................................................ 107
OpMode - Read the operating mode ..................................................................................... 109
OrientZYX - Builds an orient from euler angles...................................................................111
ORobT - Removes a program displacement from a position.............................................. 113
PoseInv - Inverts the pose....................................................................................................... 115
PoseMult - Multiplies pose data............................................................................................. 117
PoseVect - Applies a transformation to a vector .................................................................. 119
Pow - Calculates the power of a value................................................................................... 121
Present - Tests if an optional parameter is used ................................................................... 123
ReadBin - Reads a byte from a file or serial channel........................................................... 125
ReadMotor - Reads the current motor angles ...................................................................... 129
ReadNum - Reads a number from a file or serial channel .................................................. 131
ReadStr - Reads a string from a file or serial channel......................................................... 135
ReadStrBin - Reads a string from a binary serial channel or file ...................................... 141
RelTool - Make a displacement relative to the tool .............................................................. 145
RobOS - Check if execution is on RC or VC ........................................................................ 147
Round - Round is a numeric value ........................................................................................ 149
RunMode - Read the running mode ...................................................................................... 151
Sin - Calculates the sine value ................................................................................................ 153
Sqrt - Calculates the square root value ................................................................................. 155
StrFind - Searches for a character in a string ...................................................................... 157
StrLen - Gets the string length............................................................................................... 159
StrMap - Maps a string........................................................................................................... 161
StrMatch - Search for pattern in string ................................................................................ 163
StrMemb - Checks if a character belongs to a set ................................................................ 165
StrOrder - Checks if strings are ordered .............................................................................. 167
StrPart - Finds a part of a string............................................................................................ 169
StrToByte - Converts a string to a byte data ........................................................................ 171
StrToVal - Converts a string to a value ................................................................................. 175
Tan - Calculates the tangent value......................................................................................... 177
TestAndSet - Test variable and set if unset ........................................................................... 179
TestDI - Tests if a digital input is set...................................................................................... 183
Example
reg1 := Abs(reg2);
Arguments
Abs (Input)
Input Data type: num
Example
TPReadNum no_of_parts, "How many parts should be produced? ";
no_of_parts := Abs(no_of_parts);
The operator is asked to input the number of parts to be produced. To ensure that
the value is greater than zero, the value given by the operator is made positive.
Syntax
Abs ’(’
[ Input ’:=’ ] < expression (IN) of num > ’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num angle;
VAR num value;
.
.
angle := ACos(value);
Return value
ACos Data type: num
Arguments
ACos (Value)
Value Data type: num
Syntax
Acos’(’
[Value ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
IF AOutput(ao4) > 5 THEN ...
If the current value of the signal ao4 is greater than 5, then ...
The current value is scaled (in accordance with the system parameters) before it is read
by the RAPID program. See Figure 1.
MAX SIGNAL
MAX PROGRAM
MIN SIGNAL
Arguments
AOutput (Signal)
Signal Data type: signalao
Syntax
AOutput ’(’
[ Signal ’:=’ ] < variable (VAR) of signalao > ’)’
Related information
Described in:
Input/Output instructions RAPID Summary -
Input and Output Signals
Input/Output functionality in general Motion and I/O Principles -
I/O Principles
Configuration of I/O User’s Guide - System Parameters
Example
VAR num angle;
VAR num value;
.
.
angle := ASin(value);
Arguments
ASin (Value)
Value Data type: num
Syntax
ASin’(’
[Value ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num angle;
VAR num value;
.
.
angle := ATan(value);
Arguments
ATan (Value)
Value Data type: num
Syntax
ATan’(’
[Value ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Arc tangent with a return value in the Functions - ATan2
range [-180, 180]
Example
VAR num angle;
VAR num x_value;
VAR num y_value;
.
.
angle := ATan2(y_value, x_value);
The value will be equal to ATan(y/x), but in the range [-180, 180], since the function
uses the sign of both arguments to determine the quadrant of the return value.
Arguments
ATan2 (Y X)
Y Data type: num
Syntax
ATan2’(’
[Y ’:=’] <expression (IN) of num> ’,’
[X ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Arc tangent with only one argument Functions - ATan
Example
VAR string con_data_buffer{5};
VAR byte data1 := 122;
con_data_buffer{1} := ByteToStr(data1);
The content of the array component con_data_buffer{1} will be "122" after the
ByteToStr ... function.
con_data_buffer{2} := ByteToStr(data1\Hex);
The content of the array component con_data_buffer{2} will be "7A" after the
ByteToStr ... function.
con_data_buffer{3} := ByteToStr(data1\Okt);
The content of the array component con_data_buffer{3} will be "172" after the
ByteToStr ... function.
con_data_buffer{4} := ByteToStr(data1\Bin);
con_data_buffer{5} := ByteToStr(data1\Char);
The content of the array component con_data_buffer{5} will be "z" after the
ByteToStr ... function.
Return value
ByteToStr Data type: string
(*) If non-writable ASCII char, the return format will be RAPID character code
format (e.g. “\07” for BEL control character).
Arguments
ByteToStr (BitData [\Hex] | [\Okt] | [\Bin] | [\Char])
BitData Data type: byte
If the optional switch argument is omitted, the data will be converted in decimal (Dec)
format.
Limitations
The range for a data type byte is 0 to 255 decimal.
Syntax
ByteToStr’(’
[BitData ’:=’] <expression (IN) of byte>
[’\’ Hex ] | [’\’ Okt] | [’\’ Bin] | [’\’ Char]
’)’ ’;’
Related information
Described in:
Convert a string to a byte data Instructions - StrToByte
Other bit (byte) functions RAPID Summary - Bit Functions
Other string functions RAPID Summary - String Functions
The input robtarget data should be specified in the same coordinate system as specified
in argument for Tool, WObj and at execution time active program displacement
(ProgDisp) and external axes offset (EOffs).
The returned jointtarget data is expressed in the calibration coordinate system.
Example
VAR jointtarget jointpos1;
CONST robtarget p1 := [...];
The values for the external axes, in mm for linear axes, in degrees for rotational axes.
Arguments
CalcJointT ( Rob_target Tool [\WObj] )
Rob_target Data type: robtarget
The position of the robot and external axes in the outermost coordinate system,
related to the specified tool and work object and at execution time active
program displacement (ProgDisp) and/or external axes offset (EOffs).
The work object (coordinate system) to which the robot position is related.
Program execution
The returned jointtarget is calculated from the input robtarget.
To calculate the robot joint angles, the specified Tool, WObj (including coordinated
user frame) and the ProgDisp active at execution time, are taken into consideration.
To calculate the external axis position at the execution time, active EOffs is taken into
consideration.
The calculation always selects the robot configuration according to the specified con-
figuration data in the input robtarget data. Instructions ConfL and ConfJ do not affect
this calculation principle. When wrist singularity is used, robot axis 4 will be set to 0
degrees.
If there is any active program displacement (ProgDisp) and/or external axis offset
(EOffs) at the time the robtarget is stored, then the same program displacement and/or
external axis offset must be active when CalcJointT is executed.
Error handling
If at least one axis is outside the working area or the limits are exeeded for at least one
coupled joint, the system variable ERRNO is set to ERR_ROBLIMIT and the execu-
tion continues in the error handler.
Syntax
CalcJointT’(’
[Rob_target ’:=’] <expression (IN) of robtarget> ‘,’
[Tool ’:=’ ] <persistent (PERS) of tooldata>
[’\’WObj ’:=’ <persistent (PERS) of wobjdata>] ’)’
Related information
Described in:
Calculate robtarget from jointtarget Functions - CalcRobT
Definition of position Data Types - robtarget
Definition of joint position Data Types - jointtarget
Definition of tools Data Types- tooldata
Definition of work objects Data Types - wobjdata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Program displacement coordinate system Instructions - PDispOn
External axis offset coordinate system Instructions - EOffsOn
This function returns a robtarget value with position (x, y, z), orientation (q1 ... q4),
robot axes configuration and external axes position.
The input jointtarget data should be specified in the calibration coordinate system.
The returned robtarget data is expressed in the outermost coordinate system, taking the
specified tool, work object and at execution time active program displacement
(ProgDisp) and external axis offset (EOffs) into consideration.
Example
VAR robtarget p1;
CONST jointtarget jointpos1 := [...];
If there is no active ProgDisp, the robot position is expressed in the object coordinate
system.
If there are no active EOffs, the external axis position is expressed in the calibration
coordinate system.
Arguments
CalcRobT ( Joint_target Tool [\WObj] )
Joint_target Data type: jointtarget
The joint position for the robot axes and external axes related to the calibration
coordinate system.
The work object (coordinate system) to which the robot position returned by the
function is related.
Program execution
The returned robtarget is calculated from the input jointtarget.
To calculate the cartesian robot position, the specified Tool, WObj (including coordi-
nated user frame) and at the execution time active ProgDisp are taken into consider-
ation.
To calculate the external axes position, the EOffs active at execution time is taken into
consideration.
Syntax
CalcRobT’(’
[Joint_target ’:=’ ] <expression (IN) of jointtarget> ‘,’
[Tool ’:=’ ] <persistent (PERS) of tooldata>
[’\’WObj ’:=’ <persistent (PERS) of wobjdata>] ’)’
Related information
Described in:
Calculate jointtarget from robtarget Functions - CalcJointT
Definition of position Data Types - robtarget
Definition of joint position Data Types - jointtarget
Definition of tools Data Types- tooldata
Definition of work objects Data Types - wobjdata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Program displacement coordinate system Instructions - PDispOn
External axes offset coordinate system Instructions - EOffsOn
Description
The definition of a user frame for a rotational external axis requires that the turntable
(or similar mechanical structure) on the external axis has a marked reference point.
Moreover the master robot’s base frame and TCP must be calibrated. The calibration
procedure consists of a number of positionings for the robot’s TCP on the reference
point when the turntable is rotated to different angles. See Figure 2.
Axis of rotation
Turntable run by
single external axis
Position 2 l z
y
Position 3 Position 1
l l
x
l Reference point
on turntable
z Position 4
World x
The user coordinate system for the rotational axis has its origin in the centre of the turn-
table. The z direction coincides with the axis of rotation and the x axis goes through
the reference point. Figure 3 shows the user coordinate system for two different posi-
tionings of the turntable (turntable seen from above).
y
y
x
l
l
x
Example
CONST robtarget pos1 := [...];
CONST robtarget pos2 := [...];
CONST robtarget pos3 := [...];
CONST robtarget pos4 := [...];
VAR robtarget targetlist{10};
VAR num max_err := 0;
VAR num mean_err := 0;
VAR pose resFr:=[...];
PERS tooldata tMyTool:= [...];
! Instructions for creating/ModPos pos1 - pos4 with TCP pointing at the turntable.
MoveJ pos1, v10, fine, tMyTool;
MoveJ pos2, v10, fine, tMyTool;
MoveJ pos3, v10, fine, tMyTool;
MoveJ pos4, v10, fine, tMyTool;
Four positions, pos1 - pos4, are created/modposed so that the robots tool tMyTool
points to the same reference point on the external axis STN_1 but with different
external axis rotation. The points are then used for calculating the external axis
base frame, resFr, in relation to the world coordinate system. Finally, the frame
is written to the configuration file and a warmstart is made to let the change to
take effect.
Return value
CalcRotAxisFrame Data type: pose
Arguments
CalcRotAxisFrame (MechUnit [\AxisNo] TargetList TargetsInList
MaxErr MeanErr)
MechUnit Data type: mecunit
Optional argument defining the axis number for which a frame should be deter-
mined. Default value is 1 applying to single rotational axis. For mechanical units
with several axes, the axis number should be supplied with this argument.
Array of robtargets holding the positions defined by pointing out the turntable.
Minimum number of robtargets is 4, maximum 10.
Error handling
If the positions don’t have the required relation or are not specified with enough accu-
racy, the system variable ERRNO is set to ERR_FRAME. This error can then be han-
dled in an error handler.
Syntax
CalcRotAxisFrame’(’
[MechUnit ’:=’] <variable (VAR) of mecunit>
[\AxisNo ’:=’ <expression (IN) of num> ]’,’
[TargetList ’:=’] <array {*} (IN) of robtarget> ’,’
[TargetsInList ’:=’] <expression (IN) of num> ’,’
[MaxErr ’:=’] <variable (VAR) of num> ’,’
[MeanErr ’:=’] <variable (VAR) of num>’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
This function can be used to present the current date to the operator on the teach pen-
dant display or to paste the current date into a text file that the program writes to.
Example
VAR string date;
date := CDate();
Example
date := CDate();
TPWrite “The current date is: “+date;
Write logfile, date;
The current date is written to the teach pendant display and into a text file.
Syntax
CDate ’(’ ’)’
Related information
Described in:
Time instructions RAPID Summary - System & Time
Setting the system clock User’s Guide - Service
Example
VAR jointtarget joints;
joints := CJointT();
The current angles of the axes for the robot and external axes are stored in joints.
The current values for the external axes, in mm for linear axes, in degrees for rotational
axes.
Syntax
CJointT’(’’)’
Related information
Described in:
Definition of joint Data Types - jointtarget
Reading the current motor angle Functions - ReadMotor
Example
reg1:=ClkRead(clock1);
The clock clock1 is read and the time in seconds is stored in the variable reg1.
Argument
ClkRead (Clock)
Clock Data type: clock
Program execution
A clock can be read when it is stopped or running.
Once a clock is read it can be read again, started again, stopped, or reset.
Error handling
If the clock runs for 4,294,967 seconds (49 days 17 hours 2 minutes 47 seconds) it
becomes overflowed and the system variable ERRNO is set to ERR_OVERFLOW.
Syntax
ClkRead ’(’
[ Clock ’:=’ ] < variable (VAR) of clock > ’)’
Related information
Described in:
Clock instructions RAPID Summary - System & Time
Clock overflow Data Types - clock
More examples Instructions - ClkStart
Example
VAR num angle;
VAR num value;
.
.
value := Cos(angle);
Arguments
Cos (Angle)
Angle Data type: num
Syntax
Cos’(’
[Angle ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
This function returns the x, y, and z values of the robot TCP as data of type pos. If the
complete robot position (robtarget) is to be read, use the function CRobT instead.
Example
VAR pos pos1;
The current position of the robot TCP is stored in variable pos1. The tool tool1
and work object wobj0 are used for calculating the position.
Note that the robot is standing still before the position is read and calculated.
This is achieved by using the stop point fine within position accuracy inpos50 in
the preceding movement instruction.
Arguments
CPos ([\Tool] [\WObj])
[\Tool] Data type: tooldata
The work object (coordinate system) to which the current robot position returned
by the function is related.
It is very sensible to always specify the arguments \Tool and \WObj during program-
ming. The function will then always return the wanted position even if some other tool
or work object has been activated manually.
Program execution
The coordinates returned represent the TCP position in the ProgDisp coordinate sys-
tem.
Example
VAR pos pos2;
VAR pos pos3;
VAR pos pos4;
The x, y, and z position of the robot is captured at two places within the program
using the CPos function. The tool grip3 and work object fixture are used for cal-
culating the position. The x, y and z distances travelled between these positions
are then calculated and stored in the pos variable pos4.
Syntax
CPos ’(’
[’\’Tool ’:=’ <persistent (PERS) of tooldata>]
[’\’WObj ’:=’ <persistent (PERS) of wobjdata>] ’)’
Related information
Described in:
Definition of position Data Types - pos
Definition of tools Data Types- tooldata
Definition of work objects Data Types - wobjdata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Reading the current robtarget Functions - CRobT
This function returns a robtarget value with position (x, y, z), orientation (q1 ... q4),
robot axes configuration and external axes position. If only the x, y, and z values of the
robot TCP (pos) are to be read, use the function CPos instead.
Example
VAR robtarget p1;
The current position of the robot and external axes is stored in p1. The tool tool1
and work object wobj0 are used for calculating the position.
Note that the robot is standing still before the position is read and calculated.
This is achieved by using the stop point fine within position accuracy inpos50 in
the preceding movement instruction.
Arguments
CRobT ([\Tool] [\WObj])
[\Tool] Data type: tooldata
The work object (coordinate system) to which the current robot position returned
by the function is related.
It is very sensible to always specify the arguments \Tool and \WObj during program-
ming. The function will then always return the wanted position even if some other tool
or work object has been activated manually.
Program execution
The coordinates returned represent the TCP position in the ProgDisp coordinate sys-
tem. External axes are represented in the ExtOffs coordinate system.
Example
VAR robtarget p2;
The current position in the object coordinate system (without any ProgDisp or
ExtOffs) of the robot and external axes is stored in p2. The tool grip3 and work
object fixture are used for calculating the position.
Syntax
CRobT’(’
[’\’Tool ’:=’ <persistent (PERS) of tooldata>]
[’\’WObj ’:=’ <persistent (PERS) of wobjdata>] ’)’
Related information
Described in:
Definition of position Data Types - robtarget
Definition of tools Data Types- tooldata
Definition of work objects Data Types - wobjdata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
ExtOffs coordinate system Instructions - EOffsOn
Reading the current pos (x, y, z only) Functions - CPos
Note! Must not be mixed up with the argument Override in the RAPID instruction
VelSet.
Example
VAR num myspeed;
myspeed := CSpeedOverride();
Syntax
CSpeedOverride’(’’)’
Related information
Described in:
Changing the Override Speed Users Guide Programming and Test-
ing Production Running
This function can be used to present the current time to the operator on the teach pen-
dant display or to paste the current time into a text file that the program writes to.
Example
VAR string time;
time := CTime();
Example
time := CTime();
TPWrite “The current time is: “+time;
Write logfile, time;
The current time is written to the teach pendant display and written into a text
file.
Syntax
CTime ’(’ ’)’
Related Information
Described in:
Time and date instructions RAPID Summary - System & Time
Setting the system clock User’s Guide - System Parameters
Example
PERS tooldata temp_tool:= [ TRUE, [ [0, 0, 0], [1, 0, 0 ,0] ],
[0.001, [0, 0, 0.001], [1, 0, 0, 0], 0, 0, 0] ];
temp_tool := CTool();
The value returned represents the TCP position and orientation in the wrist centre coor-
dinate system, see tooldata.
Syntax
CTool’(’’)’
Related information
Described in:
Definition of tools Data Types- tooldata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Example
PERS wobjdata temp_wobj;
temp_wobj := CWObj();
The value of the current work object is stored in the variable temp_wobj.
The value returned represents the work object position and orientation in the world
coordinate system, see wobjdata.
Syntax
CWObj’(’’)’
Related information
Described in:
Definition of work objects Data Types- wobjdata
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Description
A frame can be defined when a set of targets are known at two different locations.
Thus, the same physical positions are used but expressed differently.
Consider it in two different approaches:
Three targets are enough to define a frame, but to improve accuracy several
points should be used.
Example
pWCS{1}:=p6;
....
pWCS{5}:=p10;
Five positions p1- p5, related to an object, have been stored. The five positions
are also stored in relation to world coordinate system as p6-p10. From these 10
positions the frame, frame1, between the object and the world coordinate system
is calculated. The frame will be the CAD frame expressed in the world coordinate
system. If the input order of the targetlists is exchanged, i.e.
DefAccFrame(pWCS, pCAD....) the world frame will be expressed in the CAD
coordinate system.
Return value
DefAccFrame Data type: pose
Arguments
DefAccFrame (TargetListOne TargetListTwo TargetsInList
MaxErr MeanErr)
TargetListOne Data type: robtarget
Array of robtargets holding the positions defined in coordinate system one. Min-
imum number of robtargets is 3, maximum 10
Array of robtargets holding the positions defined in coordinate system two. Min-
imum number of robtargets is 3, maximum 10.
Error handling
If the positions don’t have the required relation or are not specified with enough accu-
racy, the system variable ERRNO is set to ERR_FRAME. This error can then be han-
dled in an error handler.
Syntax
DefAccFrame’(’
[TargetListOne ’:=’] <array {*} (IN) of robtarget> ’,’
[TargetListTwo ’:=’] <array {*} (IN) of robtarget> ’,’
[TargetsInList ’:=’] <expression (IN) of num> ’,’
[MaxErr ’:=’] <variable (VAR) of num> ’,’
[MeanErr ’:=’] <variable (VAR) of num>’)’
Related information
Described in:
Calculating a frame from three positions Functions - DefFrame
Calculate a displacement frame Functions - DefDFrame
Example
p3
p6
p5
p4
p1 p2 the new plane
Three positions p1- p3, related to an object in an original position, have been
stored. After a displacement of the object, three new positions are searched for
and stored as p4-p6. The displacement frame is calculated from these six posi-
tions. Then the calculated frame is used to displace all the stored positions in the
program.
Arguments
DefDFrame (OldP1 OldP2 OldP3 NewP1 NewP2 NewP3)
OldP1 Data type: robtarget
The first displaced position. The difference between OldP1 and NewP1 will
define the translation part of the frame and must be measured and determined
with great accuracy.
The second displaced position. The line NewP1 ... NewP2 will define the rotation
of the old line OldP1 ... OldP2.
The third displaced position. This position will define the rotation of the plane,
e.g. it should be placed on the new plane of NewP1, NewP2 and NewP3.
Error handling
If it is not possible to calculate the frame because of bad accuracy in the positions, the
system variable ERRNO is set to ERR_FRAME. This error can then be handled in the
error handler.
Syntax
DefDFrame’(’
[OldP1 ’:=’] <expression (IN) of robtarget> ’,’
[OldP2 ’:=’] <expression (IN) of robtarget> ’,’
[OldP3 ’:=’] <expression (IN) of robtarget> ’,’
[NewP1 ’:=’] <expression (IN) of robtarget> ’,’
[NewP2 ’:=’] <expression (IN) of robtarget> ’,’
[NewP3 ’:=’] <expression (IN) of robtarget> ’)’
Related information
Described in:
Activation of displacement frame Instructions - PDispSet
Manual definition of displacement frame User’s Guide - Calibration
Example
y
z p3
z
x
p2
y
frame1
p1
object frame x
Three positions, p1- p3, related to the object coordinate system, are used to define the
new coordinate system, frame1. The first position, p1, is defining the origin of frame1,
the second position, p2, is defining the direction of the x-axis and the third position,
p3, is defining the location of the xy-plane. The defined frame1 may be used as a dis-
placement frame, as shown in the example below:
Arguments
DefFrame (NewP1 NewP2 NewP3 [\Origin])
NewP1 Data type: robtarget
The first position, which will define the origin of the new frame.
The second position, which will define the direction of the x-axis of the new
frame.
The third position, which will define the xy-plane of the new frame. The position
of point 3 will be on the positive y side, see the figure above.
Optional argument, which will define how the origin of the frame will be placed.
Origin = 1, means that the origin is placed in NewP1, i.e. the same as if this argu-
ment is omitted. Origin = 2 means that the origin is placed in NewP2, see the fig-
ure below.
z z y
New P3
x
y New P2
Origin = 3 means that the origin is placed on the line going through NewP1 and NewP2
and so that NewP3 will be placed on the y axis, see the figure below.
z y
z New P3
x
y New P2
Limitations
The three positions p1 - p3, defining the frame, must define a well shaped triangle. The
most well shaped triangle is the one with all sides of equal length.
p2
p3
θ
p1
The triangle is not considered to be well shaped if the angle θ a is too small. The angle
θ is too small if:
–4
cos Θ <1 – 10
The triangle p1, p2, p3 must not be too small, i.e. the positions cannot be too close. The
distances between the positions p1 - p2 and p1 - p3 must not be less than 0.1 mm.
Error handling
If the frame cannot be calculated because of the above limitations, the system variable
ERRNO is set to ERR_FRAME. This error can then be handled in the error handler.
Syntax
DefFrame’(’
[NewP1 ’:=’] <expression (IN) of robtarget> ’,’
[NewP2 ’:=’] <expression (IN) of robtarget> ’,’
[NewP3 ’:=’] <expression (IN) of robtarget>
[’\’Origin ’:=’ <expression (IN) of num> ]’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Activation of displacement frame Instructions - PDispSet
Example
PROC arrmul(VAR num array{*}, num factor)
ENDPROC
Arguments
Dim (ArrPar DimNo)
ArrPar (Array Parameter) Data type: Any type
Example
PROC add_matrix(VAR num array1{*,*,*}, num array2{*,*,*})
ENDPROC
Two matrices are added. If the size of the matrices differs, the program stops and
an error message appears.
This procedure can take any three-dimensional arrays of data type num as an
input.
Syntax
Dim ’(’
[ArrPar’:=’] <reference (REF) of any type> ’,’
[DimNo’:=’] <expression (IN) of num> ’)’
A REF parameter requires that the corresponding argument be either a constant, a vari-
able or an entire persistent. The argument could also be an IN parameter, a VAR param-
eter or an entire PERS parameter.
Related information
Described in:
Array parameters Basic Characteristics - Routines
Array declaration Basic Characteristics - Data
Example
y
p2
x
p1
z
The distance in space between the points p1 and p2 is calculated and stored in
the variable dist.
Arguments
Distance (Point1 Point2)
Point1 Data type: pos
Program execution
Calculation of the distance between the two points:
y
x2, y2, z2
x
x1,y1,z1
z
distance = ( x – x ) 2 + ( y – y ) 2 + ( z – z ) 2
1 2 1 2 1 2
Syntax
Distance’(’
[Point1 ’:=’] <expression (IN) of pos> ’,’
[Point2 ’:=’] <expression (IN) of pos>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Definition of pos Data Type - pos
Example
B
θAB
A
B cos θAB A
The dot or scalar product of two vectors A and B is a scalar, which equals the products
of the magnitudes of A and B and the cosine of the angle between them.
A ⋅ B = A B cos θAB
The vectors are described by the data type pos and the dot product by the data type
num:
Arguments
DotProd (Vector1 Vector2)
Vector1 Data type: pos
Syntax
DotProd’(’
[Vector1 ’:=’] <expression (IN) of pos> ’,’
[Vector2 ’:=’] <expression (IN) of pos>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
IF DOutput(do2) = 1 THEN . . .
Arguments
DOutput (Signal)
Signal Data type: signaldo
Program execution
The value read depends on the configuration of the signal. If the signal is inverted in
the system parameters, the value returned by this function is the opposite of the true
value of the physical channel.
Example
IF DOutput(auto_on) <> active THEN . . .
If the current value of the system signal auto_on is not active, then ..., i.e. if the
robot is in the manual operating mode, then ... Note that the signal must first be
defined as a system output in the system parameters.
Syntax
DOutput ’(’
[ Signal ’:=’ ] < variable (VAR) of signaldo > ’)’
Related information
Described in:
Input/Output instructions RAPID Summary - Input and Output
Signals
Input/Output functionality in general Motion and I/O Principles - I/O Princi-
ples
Configuration of I/O User’s Guide - System Parameters
Example
VAR num anglex;
VAR num angley;
VAR num anglez;
VAR pose object;
.
.
anglex := EulerZYX(\X, object.rot);
angley := EulerZYX(\Y, object.rot);
anglez := EulerZYX(\Z, object.rot);
Arguments
EulerZYX ([\X] | [\Y] | [\Z] Rotation)
The arguments \X, \Y and \Z are mutually exclusive. If none of these are specified, a
run-time error is generated.
Syntax
EulerZYX’(’
['\'X ’,’] | ['\'Y ’,’] | ['\'Z ’,’]
[Rotation ’:=’] <expression (IN) of orient>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num x;
VAR num value;
.
.
value:= Exp( x);
Arguments
Exp (Exponent)
Exponent Data type: num
Syntax
Exp’(’
[Exponent ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
Load "HOME:/notmymod.mod";
WHILE TRUE DO
! Call some routine in notmymod
notmymodrout;
IF FileTime("HOME:/notmymod.mod" \ModifyTime)
> ModTime("notmymod") THEN
UnLoad "HOME:notmymod.mod";
Load "HOME:notmymod.mod";
ENDIF
ENDWHILE
This program reloads a module if there is a newer at the source. It uses the
ModTime to retrieve the latest loading time for the specified module, and to com-
pare it to the FileTime\ModifyTime at the source. Then, if the source is newer,
the program unloads and loads the module again.
Arguments
FileTime ( Path [\ModifyTime] | [\AccessTime] | [\StatCTime] )
Path Data type: string
Program execution
This function returns a numeric that specifies the time since the last:
- Modification
- Access
- File status change
Example
This is a complete example that implements an alert service for maximum 10 files.
PROC alertFree()
IDelete timeint;
ENDPROC
Error handling
If the file does not exist, the system variable ERRNO is set to ERR_FILEACC. This
error can then be handled in the error handler.
Syntax
FileTime ’(’
[ Path ’:=’ ] < expression (IN) of string>
[ '\'ModifyTime] |
[ '\'AccessTime] |
[ '\'StatCTime] ’)’
Related information
Described in:
Last time a module was loaded Functions - ModTime
Examples
VAR num listno := 0;
VAR string name := "";
The name of all mechanical units available in the system, will be displayed on the
Teach Pendant.
Arguments
GetNextMechUnit ( ListNumber UnitName )
ListNumber Data type: num
This specifies which items in the list of mechanical units are to be retrieved. At
return, this variable is always incremented by one to make it easy to access the
next unit in the list.
The first mechanical unit in the list has index 0.
Example
VAR num listno := 4;
VAR string name := "";
VAR bool found := FALSE;
If found equal to TRUE, the name of mechanical unit number 4 will be in the vari-
able name, else name contains only an empty string.
Syntax
GetNextMechUnit ’(’
[ ListNumber’:=’ ] < variable (VAR) of num> ’,’
[ UnitName’:=’ ] < variable (VAR) of string> ’)’
Related information
Described in:
Mechanical unit Data Types - mecunit
Activating/Deactivating mechanical units Instructions - ActUnit, DeactUnit
Configuration of mechanical units User’s Guide - System Parameters
Characteristics of non-value data types Basic Characteristics - Data Types
Example
VAR datapos block;
VAR string name;
VAR bool truevar:=TRUE;
...
SetDataSearch “bool” \Object:=”^my” \InMod:=”mymod”\LocalSym;
WHILE GetNextSym(name,block) DO
SetDataVal name\Block:=block,truevar;
ENDWHILE
This session will set all local bool data objects that begin with my in the mod-
ule
mymod to TRUE.
Arguments
GetNextSym Object Block [\Recursive]
Object Data type: string
Variable (VAR or PERS) to store the name of the data object that will be
retrieved.
This will force the search to enter the block below, e.g. if the search session has
begun at the task level, it will also search modules and routines below the task.
Syntax
GetNextSym
[ Object ’:=’ ] < variable or persistent (INOUT) of string > ’,’
[ Block ’:=’] <variable (VAR) of datapos>
[’\’Recursive ] ’;’
Related information
Described in:
Define a symbol set in a search session Instructions - SetDataSearch
Get the value of a data object Instructions - GetDataVal
Set the value of a data object Instructions - SetDataVal
Set the value of many data objects Instructions - SetAllDataVal
The related data type datapos Data Types - datapos
Example
VAR string mytaskname;
VAR num mytaskno;
mytaskname:=GetTaskName(\TaskNo:=mytaskno);
The current task name is stored in the variable mytaskname. The numerical iden-
tity of the task is stored in mytaskno.
Arguments
GetTaskName ( [\TaskNo] )
[\TaskNo] Data type: num
The identity of the task represented as a numeric value. The numbers returned
will be in the range 1-10 where 1 is the identity of the main task.
Syntax
GetTaskName’(’
[ \TaskNo ’:=’ ] < variable (VAR) of num > ’)’
Related information
Described in:
Multitasking RAPID Overview - RAPID Summary
Multitasking, Basic Characteristics
Multitasking.
Example
hour := GetTime(\Hour);
Argument
GetTime ( [\WDay] | [\Hour] | [\Min] | [\Sec] )
[\WDay] Data type: switch
One of the arguments must be specified, otherwise program execution stops with an
error message.
Example
weekday := GetTime(\WDay);
hour := GetTime(\Hour);
IF weekday < 6 AND hour >6 AND hour < 16 THEN
production;
ELSE
maintenance;
ENDIF
If it is a weekday and the time is between 7:00 and 15:59 the robot performs pro-
duction. At all other times, the robot is in the maintenance mode.
Syntax
GetTime ’(’
[’\’ WDay ]
| [ ’\’ Hour ]
| [ ’\’ Min ]
| [ ’\’ Sec ] ’)’
Related information
Described in:
Time and date instructions RAPID Summary - System & Time
Setting the system clock User’s Guide - System Parameters
Example
IF GOutput(go2) = 5 THEN ...
The values of each signal in the group are read and interpreted as an unsigned binary
number. This binary number is then converted to an integer.
The value returned lies within a range that is dependent on the number of signals in the
group.
Arguments
GOutput (Signal)
Signal Data type: signalgo
Syntax
GOutput ’(’
[ Signal ’:=’ ] < variable (VAR) of signalgo > ’)’
Related information
Described in:
Input/Output instructions RAPID Summary - Input and Output
Signals
Input/Output functionality in general Motion and I/O Principles - I/O Princi-
ples
Configuration of I/O User’s Guide - System Parameters
Example
IF IsMechUnitActive(SpotWeldGun) CloseGun SpotWeldGun;
Arguments
IsMechUnitActive ( MechUnit )
Syntax
IsMechUnitActive ’(’
[MechUnit ’:=’ ] < variable (VAR) of mecunit>
’)’
Related information
Described in:
Activating mechanical units Instructions - ActUnit
Deactivating mechanical units Instructions - DeactUnit
Mechanical units Data Types - mecunit
IsPers - Is persistent
IsPers is used to test if a data object is a persistent variable or not.
Example
PROC procedure1 (INOUT num parameter1)
IF IsVar(parameter1) THEN
! For this call reference to a variable
...
ELSEIF IsPers(parameter1) THEN
! For this call reference to a persistent variable
...
ELSE
! Should not happen
EXIT;
ENDIF
ENDPROC
The procedure procedure1 will take different actions depending on whether the
actual parameter parameter1 is a variable or a persistent variable.
Arguments
IsPers (DatObj)
DatObj (Data Object) Data type: any type
Syntax
IsPers’(’
[ DatObj ’:=’ ] < var or pers (INOUT) of any type > ’)’
Related information
Described in:
Test if variable Function - IsVar
Types of parameters (access modes) RAPID Characteristics - Routines
Example
IF NOT IsSysId("6400-1234") THEN
ErrWrite "System identity fault","Faulty system identity for
this program";
EXIT;
ENDIF
The program is made for a special robot system and can’t be used of another one.
FALSE = The system identity is not the same as specified in the test.
Arguments
IsSysId ( SystemId)
SystemId Data type: string
Syntax
IsSysId ’(’
[ SystemId’:=’ ] < expression (IN) of string> ’)’
IsVar - Is variable
IsVar is used to test whether a data object is a variable or not.
Example
PROC procedure1 (INOUT num parameter1)
IF IsVAR(parameter1) THEN
! For this call reference to a variable
...
ELSEIF IsPers(parameter1) THEN
! For this call reference to a persistent variable
...
ELSE
! Should not happen
EXIT;
ENDIF
ENDPROC
The procedure procedure1 will take different actions, depending on whether the
actual parameter parameter1 is a variable or a persistent variable.
Arguments
IsVar (DatObj)
DatObj (Data Object) Data type: any type
Syntax
IsVar’(’
[ DatObj ’:=’ ] < var or pers (INOUT) of any type > ’)’
Related information
Described in:
Test if persistent Function - IsPers
Types of parameters (access modes) RAPID Characteristics - Routines
Example
TPWrite “Max. TCP speed in mm/s for my robot = “ \Num:=MaxRobSpeed();
The message “Max. TCP speed in mm/s for my robot = 5000” is written on the
Teach Pendant.
If use of extreme big TCP values in tool frame, create own speeddata with
bigger TCP speed than returned by MaxRobSpeed.
Syntax
MaxRobSpeed ’(’ ’)’
Related information
Described in:
Definition of velocity Data Types - speeddata
Definition of maximum velocity Instructions - VelSet
Example
CONST robtarget p1;
VAR robtarget p2;
PERS wobjdata mirror;
.
.
p2 := MirPos(p1, mirror);
p1 is a robtarget storing a position of the robot and an orientation of the tool. This
position is mirrored in the xy-plane of the frame defined by mirror, relative to
the world coordinate system. The result is new robtarget data, which is stored in
p2.
Arguments
MirPos (Point MirPlane [\WObj] [\MirY])
Point Data type: robtarget
The input robot position. The orientation part of this position defines the current
orientation of the tool coordinate system.
The work object data defining the mirror plane. The mirror plane is the xy-plane
of the object frame defined in MirPlane. The location of the object frame is
defined relative to the user frame, also defined in MirPlane, which in turn is
defined relative to the world frame.
The work object data defining the object frame, and user frame, relative to which
the input position, Point, is defined. If this argument is left out, the position is
defined relative to the World coordinate system.
Note. If the position is created with a work object active, this work object must
be referred to in the argument.
If this switch is left out, which is the default rule, the tool frame will be mirrored
as regards the x-axis and the z-axis. If the switch is specified, the tool frame will
be mirrored as regards the y-axis and the z-axis.
Limitations
No recalculation is done of the robot configuration part of the input robtarget data.
Syntax
MirPos’(’
[ Point ’:=’ ] < expression (IN) of robtarget>’,’
[MirPlane ’:=’] <expression (IN) of wobjdata> ’,’
[’\’WObj ’:=’ <expression (IN) of wobjdata> ]
[’\’MirY ]’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
MODULE mymod
VAR num mytime;
PROC printMyTime()
mytime := ModTime("mymod");
TPWrite "My time is "+NumToStr(mytime,0);
ENDPROC
Arguments
ModTime ( Object )
Object Data type: string
Program execution
This function return a numeric that specify the time when the module was loaded.
Example
This is a complete example that implements an “update if newer” service.
MODULE updmod
PROC callrout()
Load "HOME:/mymod.mod";
WHILE TRUE DO
! Call some routine in mymod
mymodrout;
IF FileTime("HOME:/mymod.mod" \ModifyTime)
> ModTime("mymod") THEN
UnLoad "HOME:/mymod.mod";
Load "HOME:/mymod.mod";
ENDIF
ENDWHILE
ENDPROC
ENDMODULE
This program reloads a module if there is a newer one at the source. It uses the Mod-
Time to retrieve the latest loading time for the specified module, and compares it to the
FileTime\ModifyTime at the source. Then, if the source is newer, the program unloads
and loads the module again.
Syntax
ModTime ’(’
[ Object ’:=’ ] < expression (IN) of string>’)’
Related information
Described in:
Retrieve time info. about a file Functions - FileTime
Description
An orientation must be normalised, i.e. the sum of the squares must
equal 1:
q 12 + q 22 + q 32 + q 42 = 1
2 2 2 2
ABS ( q 1 + q 2 + q 3 + q 4 – 1 ) = normerr
Example
We have a slightly unnormalised position ( 0.707170, 0, 0, 0.707170 )
2 2 2 2
ABS ( 0.707170 + 0 + 0 + 0.707170 – 1 ) = 0.0000894
Arguments
NOrient (Rotation)
Orient Data type: orient
Syntax
NOrient’(’
[Rotation ’:=’] <expression (IN) of orient>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR string str;
str := NumToStr(0.38521,3);
reg1 := 0.38521
Arguments
NumToStr (Val Dec [\Exp])
Val (Value) Data type: num
To use exponent.
Syntax
NumToStr’(’
[ Val ’:=’ ] <expression (IN) of num> ’,’
[ Dec ’:=’ ] <expression (IN) of num>
[ \Exp ]
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Examples
MoveL Offs(p2, 0, 0, 10), v1000, z50, tool1;
The robot is moved to a point 10 mm from the position p2 (in the z-direction).
Arguments
Offs (Point XOffset YOffset ZOffset)
Point Data type: robtarget
Example
PROC pallet (num row, num column, num distance, PERS tooldata tool,
PERS wobjdata wobj)
ENDPROC
A routine for picking parts from a pallet is made. Each pallet is defined as a work
object (see Figure 4). The part to be picked (row and column) and the distance
between the parts are given as input parameters.
Incrementing the row and column index is performed outside the routine.
Columns
Y-axis
O O O O O O O O O O
O O O O O O O O O O
Rows O O O O O O O O O O
O O O O O O O O O O
X-axis
O O O O O O O O O O
Figure 4 The position and orientation of the pallet is specified by defining a work object.
Syntax
Offs ’(’
[Point ’:=’] <expression (IN) of robtarget> ’,’
[XOffset ’:=’] <expression (IN) of num> ’,’
[YOffset ’:=’] <expression (IN) of num> ’,’
[ZOffset ’:=’] <expression (IN) of num> ’)’
Related information
Described in:
Position data Data Types - robtarget
Example
TEST OpMode()
CASE OP_AUTO:
...
CASE OP_MAN_PROG:
...
CASE OP_MAN_TEST:
...
DEFAULT:
...
ENDTEST
Different program sections are executed depending on the current operating mode.
Syntax
OpMode’(’ ’)’
Related information
Described in:
Different operating modes User’s Guide - Starting up
Reading running mode Functions - RunMode
Example
VAR num anglex;
VAR num angley;
VAR num anglez;
VAR pose object;
.
object.rot := OrientZYX(anglez, angley, anglex)
Arguments
OrientZYX (ZAngle YAngle XAngle)
ZAngle Data type: num
Syntax
OrientZYX’(’
[ZAngle ’:=’] <expression (IN) of num> ’,’
[YAngle ’:=’] <expression (IN) of num> ’,’
[XAngle ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR robtarget p10;
VAR robtarget p11;
p10 := CRobT();
p11 := ORobT(p10);
The current positions of the robot and the external axes are stored in p10 and p11.
The values stored in p10 are related to the ProgDisp/ExtOffs coordinate system.
The values stored in p11 are related to the object coordinate system without any
offset on the external axes.
Arguments
ORobT (OrgPoint [\InPDisp] | [\InEOffs])
OrgPoint (Original Point) Data type: robtarget
Returns the TCP position in the ProgDisp coordinate system, i.e. removes exter-
nal axes offset only.
Returns the external axes in the offset coordinate system, i.e. removes program
displacement for the robot only.
Examples
p10 := ORobT(p10 \InEOffs );
The ORobT function will remove any program displacement that is active, leav-
ing the TCP position relative to the object coordinate system. The external axes
will remain in the offset coordinate system.
The ORobT function will remove any offset of the external axes. The TCP posi-
tion will remain in the ProgDisp coordinate system.
Syntax
ORobT ’(’
[ OrgPoint ’:=’ ] < expression (IN) of robtarget>
[’\’InPDisp] | [’\’InEOffs]’)’
Related information
Described in:
Definition of program displacement for Instructions - PDispOn, PDispSet the
robot
Definition of offset for external axes Instructions - EOffsOn, EOffsSet
Coordinate systems Motion and I/O Principles - Coordinate
Systems
Example
z1
Pose1
z0 Frame1
y1
x1
Frame0
y0 Pose2
x0
Arguments
PoseInv (Pose)
Pose Data type: pose
Syntax
PoseInv’(’
[Pose ’:=’] <expression (IN) of pose>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
z1
pose1 y1 z2
z0 pose2
Frame1
x1 Frame2
Frame0
y0 y2
pose3 x2
x0
Arguments
PoseMult (Pose1 Pose2)
Pose1 Data type: pose
Syntax
PoseMult’(’
[Pose1 ’:=’] <expression (IN) of pose> ’,’
[Pose2 ’:=’] <expression (IN) of pose>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
pos1
pos2 z1
z0
pose1 y1
Frame1
Frame0
y0 x1
x0
Arguments
PoseVect (Pose Pos)
Pose Data type: pose
Syntax
PoseVect’(’
[Pose ’:=’] <expression (IN) of pose> ’,’
[Pos ’:=’] <expression (IN) of pos>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num x;
VAR num y
VAR num reg1;
.
reg1:= Pow(x, y);
Arguments
Pow (Base Exponent)
Base Data type: num
Limitations
The execution of the function xy will give an error if:
Syntax
Pow’(’
[Base ’:=’] <expression (IN) of num> ’,’
[Exponent ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
An optional parameter may not be used if it was not specified when calling the routine.
This function can be used to test if a parameter has been specified, in order to prevent
errors from occurring.
Example
PROC feeder (\switch on | \switch off)
ENDPROC
The output do1, which controls a feeder, is set or reset depending on the argu-
ment used when calling the routine.
Arguments
Present (OptPar)
OptPar (Optional Parameter) Data type: Any type
Example
PROC glue (\switch on, num glueflow, robtarget topoint, speeddata speed,
zonedata zone, PERS tooldata tool, \PERS wobjdata wobj)
ENDPROC
A glue routine is made. If the argument \on is specified when calling the routine,
a pulse is generated on the signal glue_on. The robot then sets an analog output
gluesignal, which controls the glue gun, and moves to the end position. As the
wobj parameter is optional, different MoveL instructions are used depending on
whether this argument is used or not.
Syntax
Present ’(’
[OptPar’:=’] <reference (REF) of any type> ’)’
Related information
Described in:
Routine parameters Basic Characteristics - Routines
This function works on both binary and character-based files or serial channels.
Example
VAR num character;
VAR iodev inchannel;
...
Open "com2:", inchannel\Bin;
character := ReadBin(inchannel);
Arguments
ReadBin (IODevice [\Time])
IODevice Data type: iodev
The max. time for the reading operation (timeout) in seconds. If this argument is
not specified, the max. time is set to 60 seconds.
If this time runs out before the reading operation is finished, the error handler
will be called with the error code ERR_DEV_MAXTIME. If there is no error
handler, the execution will be stopped.
The timeout function is in use also during program stop and will be noticed in
the RAPID program at program start.
Program execution
Program execution waits until a byte (8 bits) can be read from the file or serial channel.
Example
VAR num bindata;
VAR iodev file;
Read the contents of a binary file myfile.bin from the beginning to the end and
displays the received binary data converted to chars on the teach pendant (one
char on each line).
Limitations
The function can only be used for files and serial channels that have been opened with
read access (\Read for character based files, \Bin or \Append \Bin for binary files).
Error handling
If an error occurs during reading, the system variable ERRNO is set to
ERR_FILEACC.
If time out before the read operation is finished, the system variable ERRNO is set to
ERR_DEV_MAXTIME.
Predefined data
The constant EOF_BIN can be used to stop reading at the end of the file.
Syntax
ReadBin’(’
[IODevice ’:=’] <variable (VAR) of iodev>
[’\’Time’:=’ <expression (IN) of num>]’)’
Related information
Described in:
Opening (etc.) files or serial channels RAPID Summary - Communication
Convert a byte to a string data Functions - ByteToStr
Example
VAR num motor_angle2;
motor_angle2 := ReadMotor(2);
The current motor angle of the second axis of the robot is stored in
motor_angle2.
Arguments
ReadMotor [\MecUnit ] Axis
The name of the mechanical unit for which an axis is to be read. If this argument
is omitted, the axis for the robot is read. (Note, in this release only robot is per-
mitted for this argument).
Program execution
The motor angle returned represents the current position in radians for the motor and
independently of any calibration offset. The value is not related to a fix position of the
robot, only to the resolver internal zero position, i.e. normally the resolver zero posi-
tion closest to the calibration position (the difference between the resolver zero posi-
tion and the calibration position is the calibration offset value). The value represents
the full movement of each axis, although this may be several turns.
Example
VAR num motor_angle3;
The current motor angle of the third axis of the robot is stored in motor_angle3.
Syntax
ReadMotor’(’
[’\’MecUnit ’:=’ < variable (VAR) of mecunit>’,’]
[Axis ’:=’ ] < expression (IN) of num>
’)’
Related information
Described in:
Reading the current joint angle Functions - CJointT
Example
VAR iodev infile;
...
Open "HOME:/file.doc", infile\Read;
reg1 := ReadNum(infile);
Arguments
ReadNum (IODevice [\Delim] [\Time])
IODevice Data type: iodev
A string containing the delimiters to use when parsing a line in the file or serial
channel. By default (without \Delim), the file is read line by line and the line-feed
character (\0A) is the only delimiter considered by the parsing. When the \Delim
argument is used, any character in the specified string argument will be consid-
ered to determine the significant part of the line.
When using the argument \Delim, the control system always adds the characters
carriage return (\0D) and line-feed (\0A) to the delimiters specified by the user.
The max. time for the reading operation (timeout) in seconds. If this argument is
not specified, the max. time is set to 60 seconds.
If this time runs out before the read operation is finished, the error handler will
be called with the error code ERR_DEV_MAXTIME. If there is no error handler,
the execution will be stopped.
The timeout function is also in use during program stop and will be noticed in the
RAPID program at program start.
Program execution
Starting at the current file position, the function reads and discards any heading delim-
iters. A heading delimiter without the argument \Delim is a line-feed character. Head-
ing delimiters with the argument \Delim are any characters specified in the \Delim
argument plus carriage return and line-feed characters. It then reads everything up to
and including the next delimiter character (will be discarded), but not more than 80
characters. If the significant part exceeds 80 characters, the remainder of the characters
will be read on the next reading.
The string that is read is then converted to a numeric value; e.g. “234.4” is converted
to the numeric value 234.4.
Example
reg1 := ReadNum(infile\Delim:="\09 ");
IF reg1 > EOF_NUM THEN
TPWrite "The file is empty";
...
Limitations
The function can only be used for character based files that have been opened for read-
ing.
Error handling
If an access error occurs during reading, the system variable ERRNO is set to
ERR_FILEACC.
If there is an attempt to read non-numeric data, the system variable ERRNO is set to
ERR_RCVDATA.
If time out before the read operation is finished, the system variable ERRNO is set to
ERR_DEV_MAXTIME.
Predefined data
The constant EOF_NUM can be used to stop reading, at the end of the file.
Syntax
ReadNum ’(’
[IODevice ’:=’]<variable (VAR) of iodev>
[‘\’Delim’:=’<expression (IN) of string>]
[’\’Time’:=’<expression (IN) of num>]’)’
Related information
Described in:
Opening (etc.) files or serial channels RAPID Summary - Communication
Example
VAR string text;
VAR iodev infile;
...
Open "HOME:/file.doc", infile\Read;
text := ReadStr(infile);
Arguments
ReadStr (IODevice [\Delim] [\RemoveCR] [\DiscardHeaders]
[\Time])
IODevice Data type: iodev
A string containing the delimiters to use when parsing a line in the file or serial
channel. By default the file is read line by line and the line-feed character (\0A)
is the only delimiter considered by the parsing. When the \Delim argument is
used, any character in the specified string argument plus by default line-feed
character will be considered to determine the significant part of the line.
A switch used to remove the trailing carriage return character when reading PC
files. In PC files, a new line is specified by carriage return and line feed (CRLF).
When reading a line in such files, the carriage return character is by default read
into the return string. When using this argument, the carriage return character will
be read from the file but not included in the return string.
This argument specifies whether the heading delimiters (specified in \Delim plus
default line-feed) are skipped or not before transferring data to the return string.
By default, if the first character at the current file position is a delimiter, it is read
but not transferred to the return string, the line parsing is stopped and the return
will be an empty string. If this argument is used, all delimiters included in the line
will be read from the file but discarded, and the return string will contain the data
starting at the first non-delimiter character in the line.
The max. time for the reading operation (timeout) in seconds. If this argument is
not specified, the max. time is set to 60 seconds.
If this time runs out before the read operation is finished, the error handler will
be called with the error code ERR_DEV_MAXTIME. If there is no error handler,
the execution will be stopped.
The timeout function is in use also during program stop and will be noticed in the
RAPID program at program start.
Program execution
Starting at the current file position, if the \DiscardHeaders argument is used, the func-
tion reads and discards any heading delimiters (line-feed characters and any character
specified in the \Delim argument). In all cases, it then reads everything up to the next
delimiter character, but not more than 80 characters. If the significant part exceeds 80
characters, the remainder of the characters will be read on the next reading. The delim-
iter that caused the parsing to stop is read from the file but not transferred to the return
string. If the last character in the string is a carriage return character and the \RemoveCR
argument is used, this character will be removed from the string.
Example 1
text := ReadStr(infile);
IF text = EOF THEN
TPWrite "The file is empty";
...
Before using the string read from the file, a check is performed to make sure that
the file is not empty.
Example 2
Consider a file containing:
<LF><SPACE><TAB>Hello<SPACE><SPACE>World<CR><LF>
text := ReadStr(infile);
text will be an empty string: the first character in the file is the default <LF>
delimiter.
text := ReadStr(infile\DiscardHeaders);
text := ReadStr(infile\RemoveCR\DiscardHeaders);
text will contain “Hello”: the first characters in the file that match either the
default <LF> delimiter or the character set defined by \Delim (space and tab) are
discarded. Data is then transferred up to the first delimiter that is read from the
file but not transferred into the string. A new invocation of the same statement
will return “World”.
Example 3
Consider a file containing:
<CR><LF>Hello<CR><LF>
text := ReadStr(infile);
text will contain the <CR> (\0d) character: <CR> and <LF> characters are read
from the file, but only <CR> is transferred to the string. A new invocation of the
same statement will return “Hello\0d”.
text := ReadStr(infile\RemoveCR);
text will contain an empty string: <CR> and <LF> characters are read from the
file; <CR> is transferred but removed from the string. A new invocation of the
same statement will return “Hello”.
text := ReadStr(infile\Delim:=”\0d”);
text will contain an empty string: <CR> is read from the file but not transferred
to the return string. A new invocation of the same instruction will return an empty
string again: <LF> is read from the file but not transferred to the return string.
text := ReadStr(infile\Delim:=”\0d”\DiscardHeaders);
text will contain “Hello”. A new invocation of the same instruction will return
“EOF” (end of file).
Limitations
The function can only be used for files or serial channels that have been opened for
reading in a character-based mode.
Error handling
If an error occurs during reading, the system variable ERRNO is set to
ERR_FILEACC.
If timeout before the read operation is finished, the system variable ERRNO is set to
ERR_DEV_MAXTIME.
Predefined data
The constant EOF can be used to check if the file was empty when trying to read from
the file or to stop reading at the end of the file.
Syntax
ReadStr ’(’
[IODevice ’:=’] <variable (VAR) of iodev>
[‘\’Delim’:=’<expression (IN) of string>]
[‘\’RemoveCR]
[‘\’DiscardHeaders]
[’\’Time’:=’ <expression (IN) of num>]’)’
Related information
Described in:
Opening (etc.) files or serial channels RAPID Summary - Communication
Example
VAR iodev channel2;
VAR string text;
...
Open “com2:”, channel2 \Bin;
text := ReadStrBin (channel2, 10);
Text is assigned a 10 characters text string read from the serial channel referred
to by channel2.
Arguments
ReadStrBin (IODevice NoOfChars [\Time])
IODevice Data type: iodev
The number of characters to be read from the binary serial channel or file.
The max. time for the reading operation (timeout) in seconds. If this argument is
not specified, the max. time is set to 60 seconds.
If this time runs out before the read operation is finished, the error handler will
be called with the error code ERR_DEV_MAXTIME. If there is no error han-
dler, the execution will be stopped.
The timeout function is in use also during program stop and will be noticed in
the RAPID program at program start.
Program execution
The function reads the specified number of characters from the binary serial channel or
file.
Example
text := ReadStrBin(infile,20);
IF text = EOF THEN
TPWrite "The file is empty";
Before using the string read from the file, a check is performed to make sure that
the file is not empty.
Limitations
The function can only be used for serial channels or files that have been opened for
reading in a binary mode.
Error handling
If an error occurs during reading, the system variable ERRNO is set to
ERR_FILEACC.
If timeout before the read operation is finished, the system variable ERRNO is set to
ERR_DEV_MAXTIME.
Predefined data
The constant EOF can be used to check if the file was empty, when trying to read from
the file or to stop reading at the end of the file.
Syntax
ReadStrBin ’(’
[IODevice ’:=’] <variable (VAR) of iodev>’,’
[NoOfChars ’:=’] <expression (IN) of num>
[’\’Time’:=’ <expression (IN) of num>]’)’
Related information
Described in:
Opening (etc.) serial channels RAPID Summary - Communication
or files
Write binary string Instructions - WriteStrBin
Example
MoveL RelTool (p1, 0, 0, 100), v100, fine, tool1;
The robot is moved to a position that is 100 mm from p1 in the direction of the
tool.
Arguments
RelTool (Point Dx Dy Dz [\Rx] [\Ry] [\Rz])
Point Data type: robtarget
The input robot position. The orientation part of this position defines the current
orientation of the tool coordinate system.
The rotation in degrees around the x axis of the tool coordinate system.
The rotation in degrees around the y axis of the tool coordinate system.
The rotation in degrees around the z axis of the tool coordinate system.
In the event that two or three rotations are specified at the same time, these will
be performed first around the x-axis, then around the new y-axis, and then around
the new z-axis.
Syntax
RelTool’(’
[ Point ’:=’ ] < expression (IN) of robtarget>’,’
[Dx ’:=’] <expression (IN) of num> ’,’
[Dy ’:=’] <expression (IN) of num> ’,’
[Dz ’:=’] <expression (IN) of num>
[’\’Rx ’:=’ <expression (IN) of num> ]
[’\’Ry ’:=’ <expression (IN) of num> ]
[’\’Rz ’:=’ <expression (IN) of num> ]’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Positioning instructions RAPID Summary - Motion
Example
IF RobOS() THEN
! Execution statements in RC
ELSE
! Execution statements in VC
ENDIF
Syntax
RobOS ’(’’)’
Example
VAR num val;
val := Round(0.38521\Dec:=3);
val := Round(0.38521\Dec:=1);
val := Round(0.38521);
Arguments
Round ( Val [\Dec])
Val (Value) Data type: num
Number of decimals.
The number of decimals must not be negative or greater than the available pre-
cision for numeric values.
Syntax
Round’(’
[ Val ’:=’ ] <expression (IN) of num>
[ \Dec ’:=’ <expression (IN) of num> ]
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Truncating a value Functions - Trunc
Example
IF RunMode() = RUN_CONT_CYCLE THEN
..
ENDIF
Arguments
RunMode ( [ \Main] )
[ \Main ] Data type: switch
If this argument is omitted, the return value always mirrors the current running
mode for the program task which executes the function RunMode.
Syntax
RunMode ’(’ [’\’Main] ’)’
Related information
Described in:
Reading operating mode Functions - OpMode
Example
VAR num angle;
VAR num value;
.
.
value := Sin(angle);
Arguments
Sin (Angle)
Angle Data type: num
Syntax
Sin’(’
[Angle’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num x_value;
VAR num y_value;
.
.
y_value := Sqrt( x_value);
Arguments
Sqrt (Value)
Value Data type: num
Syntax
Sqrt’(’
[Value’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Example
VAR num found;
found := StrFind("Robotics",1,"aeiou");
found := StrFind("Robotics",1,"aeiou"\NotInSet);
Arguments
StrFind (Str ChPos Set [\NotInSet])
Str (String) Data type: string
Start character position. A runtime error is generated if the position is outside the
string.
Syntax
StrFind’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ ChPos ’:=’ ] <expression (IN) of num> ’,’
[ Set’:=’ ] <expression (IN) of string>
[’\’NotInSet ]
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR num len;
len := StrLen("Robotics");
Arguments
StrLen (Str)
Str (String) Data type: string
Syntax
StrLen’(’
[ Str ’:=’ ] <expression (IN) of string>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR string str;
str := StrMap("Robotics","aeiou","AEIOU");
Arguments
StrMap ( Str FromMap ToMap)
Str (String) Data type: string
Syntax
StrMap’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ FromMap’:=’ ] <expression (IN) of string> ’,’
[ ToMap’:=’ ] <expression (IN) of string>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR num found;
found := StrMatch("Robotics",1,"bo");
Arguments
StrMatch (Str ChPos Pattern)
Str (String) Data type: string
Start character position. A runtime error is generated if the position is outside the
string.
Syntax
StrMatch’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ ChPos ’:=’ ] <expression (IN) of num> ’,’
[ Pattern’:=’ ] <expression (IN) of string>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR bool memb;
memb := StrMemb("Robotics",2,"aeiou");
The variable memb is given the value TRUE, as o is a member of the set "aeiou".
memb := StrMemb("Robotics",3,"aeiou");
The variable memb is given the value FALSE, as b is not a member of the set
"aeiou".
Arguments
StrMemb (Str ChPos Set)
Str (String) Data type: string
Syntax
StrMemb’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ ChPos ’:=’ ] <expression (IN) of num> ’,’
[ Set’:=’ ] <expression (IN) of string>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR bool le;
le := StrOrder("FIRST","SECOND",STR_UPPER);
The variable le is given the value TRUE, because "FIRST" comes before
"SECOND" in the character ordering sequence STR_UPPER.
Characters that are not included in the defined ordering are all assumed to follow the
present ones.
Arguments
StrOrder ( Str1 Str2 Order)
Str1 (String 1) Data type: string
Syntax
StrOrder’(’
[ Str1 ’:=’ ] <expression (IN) of string> ’,’
[ Str2 ’:=’ ] <expression (IN) of string> ’,’
[ Order ’:=’ ] <expression (IN) of string>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR string part;
part := StrPart("Robotics",1,5);
Arguments
StrPart (Str ChPos Len)
Str (String) Data type: string
Start character position. A runtime error is generated if the position is outside the
string.
Syntax
StrPart’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ ChPos ’:=’ ] <expression (IN) of num> ’,’
[ Len’:=’ ] <expression (IN) of num>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR string con_data_buffer{5} := ["10", "AE", "176", "00001010", "A"];
VAR byte data_buffer{5};
data_buffer{1} := StrToByte(con_data_buffer{1});
The content of the array component data_buffer{1} will be 10 decimal after the
StrToByte ... function.
data_buffer{2} := StrToByte(con_data_buffer{2}\Hex);
The content of the array component data_buffer{2} will be 174 decimal after the
StrToByte ... function.
data_buffer{3} := StrToByte(con_data_buffer{3}\Okt);
The content of the array component data_buffer{3} will be 126 decimal after the
StrToByte ... function.
data_buffer{4} := StrToByte(con_data_buffer{4}\Bin);
The content of the array component data_buffer{4} will be 10 decimal after the
StrToByte ... function.
data_buffer{5} := StrToByte(con_data_buffer{5}\Char);
The content of the array component data_buffer{5} will be 65 decimal after the
StrToByte ... function.
Arguments
StrToByte (ConStr [\Hex] | [\Okt] | [\Bin] | [\Char])
ConStr (Convert String) Data type: string
If the optional switch argument is omitted, the string to be converted has decimal (Dec)
format.
Limitations
Depending on the format of the string to be converted, the following string data
is valid:
RAPID character codes (e.g. “\07” for BEL control character) can be used as
arguments in ConStr.
Syntax
StrToByte’(’
[ConStr ’:=’] <expression (IN) of string>
[’\’ Hex ] | [’\’ Okt] | [’\’ Bin] | [’\’ Char]
’)’ ’;’
Related information
Described in:
Convert a byte to a string data Instructions - ByteToStr
Other bit (byte) functions RAPID Summary - Bit Functions
Other string functions RAPID Summary - String Functions
Example
VAR bool ok;
VAR num nval;
ok := StrToVal("3.85",nval);
The variable ok is given the value TRUE and nval is given the value 3.85.
Arguments
StrToVal ( Str Val )
Str (String) Data type: string
A string value containing literal data with format corresponding to the data type
used in argument Val. Valid format as for RAPID literal aggregates.
Name of the variable or persistent of any data type for storage of the result from
the conversion. The data is unchanged if the requested conversion failed.
Example
VAR string 15 := “[600, 500, 225.3]”;
VAR bool ok;
VAR pos pos15;
ok := StrToVal(str15,pos15);
The variable ok is given the value TRUE and the variable p15 is given the value
that are specified in the string str15.
Syntax
StrToVal’(’
[ Str ’:=’ ] <expression (IN) of string> ’,’
[ Val ’:=’ ] <var or pers (INOUT) of ANYTYPE>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
VAR num angle;
VAR num value;
.
.
value := Tan(angle);
Arguments
Tan (Angle)
Angle Data type: num
Syntax
Tan’(’
[Angle ’:=’] <expression (IN) of num>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Arc tangent with return value in the
range [-180, 180] Functions - ATan2
Example of resources that can need protection from access at the same time:
- Use of some RAPID routines with function problems when executed in paral-
lel.
- Use of the Teach Pendant - Operator Output & Input
Example
MAIN program task:
PERS bool tproutine_inuse := FALSE;
....
WaitUntil TestAndSet(tproutine_inuse);
TPWrite “First line from MAIN”;
TPWrite “Second line from MAIN”;
TPWrite “Third line from MAIN”;
tproutine_inuse := FALSE;
To avoid mixing up the lines, one from MAIN and one from BACK1, the use of the
TestAndSet function guarantees that all three lines from each task are not separated.
Arguments
TestAndSet Object
Object Data type: bool
User defined data object to be used as semaphore. The data object could be a
VAR or a PERS. If TestAndSet are used between different program tasks, the
object must be a PERS or an installed VAR (intertask objects).
Program execution
This function will in one indivisible step check the user defined variable and, if it is
unset, will set it and return TRUE, otherwise it will return FALSE.
Example
LOCAL VAR bool doit_inuse := FALSE;
...
PROC doit(...)
WaitUntil TestAndSet (doit_inuse);
....
doit_inuse := FALSE;
ENDPROC
Note in this case: If program execution is stopped in the routine doit and the pro-
gram pointer is moved to main, the variable doit_inuse will not be reset. To avoid
this, reset the variable doit_inuse to FALSE in the START event routine.
Syntax
TestAndSet ’(’
[ Object ’:=’ ] < variable or persistent (INOUT) of bool> ’)’
Related information
Described in:
Built-in and shared module User’s Guide - System parameters
Intertask objects RAPID Developer’s Manual -
RAPID Kernel Reference Manual -
Intertask objects
Examples
Program execution continues only after both the di1 input and the di2 input have
been set.
Arguments
TestDI (Signal)
Signal Data type: signaldi
Syntax
TestDI ’(’
[ Signal ’:=’ ] < variable (VAR) of signaldi > ’)’
Related information
Described in:
Reading the value of a digital input signal Functions - DInput
Input/Output instructions RAPID Summary -
Input and Output Signals
This function returns the momentary value or the mean value of the latest samples,
depending on channel specification in instruction TestSignDefine.
Example
CONST num speed_channel;
VAR num speed_value;
...
TestSignDefine speed_channel, speed, orbit, 1, 0;
...
! During some movements with orbit’s axis 1
speed_value := TestSignRead(speed_channel);
...
TestSignReset;
speed_value is assigned the mean value of the latest 8 samples generated each
0.5ms of the test signal speed on channel speed_channel.
The channel speed_channel measures the speed of axis 1 on the mechanical unit
orbit.
Arguments
TestSignRead (Channel)
Channel Data type: num
Program execution
Returns the momentary value or the mean value of the latest samples, depending on the
channel specification in the instruction TestSignDefine.
For predefined test signals with valid SI units for external manipulator axes, see data
type testsignal.
Example
CONST num torque_channel;
VAR num torque_value;
VAR intnum timer_int;
CONST jointtarget psync := [...];
...
CONNECT timer_int WITH TorqueTrap;
ITimer \Single, 0.05, timer_int;
TestSignDefine torque_channel, torque_ref, IRBP_K, 2, 0.001;
...
MoveAbsJ psync \NoEOffs, v5, fine, tool0;
...
IDelete timer_int;
TestSignReset;
TRAP TorqueTrap
IF (TestSignRead(torque_channel) > 6) THEN
TPWrite “Torque pos = “ + ValToStr(CJointT());
Stop;
EXIT;
ELSE
IDelete timer_int;
CONNECT timer_int WITH TorqueTrap;
ITimer \Single, 0.05, timer_int;
ENDIF
ENDTRAP
The joint position, when the torque reference for manipulator IRBP_K axis 2 is
for the first time greater than 6 Nm on the motor side during the slow movement
to position psync, is displayed on the Operators Window on the TP.
Syntax
TestSignRead’(’
[ Channel ’:=’] <expression (IN) of num>’)’
Related information
Described in:
Define test signal Instructions - TestSignDefine
Reset test signals Instructions - TestSignReset
Example
VAR num val;
val := Trunc(0.38521\Dec:=3);
reg1 := 0.38521
val := Trunc(reg1\Dec:=1);
val := Trunc(0.38521);
Arguments
Trunc ( Val [\Dec] )
Val (Value) Data type: num
Number of decimals.
The number of decimals must not be negative or greater than the available pre-
cision for numeric values.
Syntax
Trunc’(’
[ Val ’:=’ ] <expression (IN) of num>
[ \Dec ’:=’ <expression (IN) of num> ]
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Rounding a value Functions - Round
Example
VAR string str;
VAR pos p := [100,200,300];
str := ValToStr(1.234567);
str := ValToStr(TRUE);
str := ValToStr(p);
Arguments
ValToStr ( Val )
Val (Value) Data type: ANYTYPE
Syntax
ValToStr’(’
[ Val ’:=’ ] <expression (IN) of ANYTYPE>
’)’
Related information
Described in:
String functions RAPID Summary - String Functions
Definition of string Data Types - string
String values Basic Characteristics -
Basic Elements
Example
z A
Az
y
Ay
x
Ax
A vector A can be written as the sum of its components in the three orthogonal direc-
tions:
A = Ax x + Ay y + Az z
The vector is described by the data type pos and the magnitude by the data type num:
Arguments
VectMagn (Vector)
Vector Data type: pos
Syntax
VectMagn’(’
[Vector ’:=’] <expression (IN) of pos>
’)’
Related information
Described in:
Mathematical instructions and functions RAPID Summary - Mathematics
Description
Data of the type aiotrigg defines the way a low and a high threshold will be used to
determine whether the logical value of an analog signal satisfies a condition to generate
an interrupt.
Example
VAR intnum sig1int;
CONNECT sig1int WITH iroutine1;
ISignalAI \Single, ai1, AIO_BETWEEN, 1.5, 0.5, 0, sig1int;
Orders an interrupt which is to occur the first time the logical value of the analog
input signal ai1 is between 0.5 and 1.5. A call is then made to the iroutine1 trap
routine.
Predefined data
The following symbolic constants of the data type aiotrigg are predefined and can be
used when specifying a condition for the instructions ISignalAI and ISignalAO.
Characteristics
aiotrigg is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Interrupt from analog input signal Instructions - ISignalAI
Interrupt from analog output signal Instructions - ISignalAO
Data types in general, alias data types Basic Characteristics - Data Types
Description
The value of data of the type bool can be either TRUE or FALSE.
Examples
flag1 := TRUE;
highvalue is assigned the value TRUE if reg1 is greater than 100; otherwise,
FALSE is assigned.
Related information
Described in:
Logical expressions Basic Characteristics - Expressions
Operations using logical values Basic Characteristics - Expressions
This data type is used in conjunction with instructions and functions that handle the bit
manipulations and convert features.
Description
Data of the type byte represents a decimal byte value.
Examples
CONST num parity_bit := 8;
Bit number 8 (parity_bit) in the variable data1 will be set to 0, e.g. the content
of the variable data1 will be changed from 130 to 2 (decimal representation).
Error handling
If an argument of the type byte has a value that is not in the range between 0 and 255,
an error is returned on program execution.
Characteristics
Byte is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Alias data types Basic Characteristics- Data Types
Bit functions RAPID Summary - Bit Functions
Description
Data of the type clock stores a time measurement in seconds and has a resolution of
0.01 seconds.
Example
VAR clock clock1;
ClkReset clock1;
The clock, clock1, is declared and reset. Before using ClkReset, ClkStart, ClkStop and
ClkRead, you must declare a variable of data type clock in your program.
Limitations
The maximum time that can be stored in a clock variable is approximately 49 days
(4,294,967 seconds). The instructions ClkStart, ClkStop and ClkRead report clock
overflows in the very unlikely event that one occurs.
A clock must be declared as a VAR variable type, not as a persistent variable type.
Characteristics
Clock is a non-value data type and cannot be used in value-oriented operations.
Related information
Described in:
Summary of Time and Date Instructions RAPID Summary - System & Time
Non-value data type characteristics Basic Characteristics - Data Types
Description
All positions of the robot are defined and stored using rectangular coordinates. When
calculating the corresponding axis positions, there will often be two or more possible
solutions. This means that the robot is able to achieve the same position, i.e. the tool is
in the same position and with the same orientation, with several different positions or
configurations of the robots axes.
Some robot types use iterative numerical methods to determine the robot axes posi-
tions. In these cases the configuration parameters may be used to define good starting
values for the joints to be used by the iterative procedure.
-4 3
-1 0
-3 -2 1 2
For a linear axis, the value defines a meter interval for the robot axis. For each axis,
value 0 means a position between 0 and 1 meters, 1 means a position between 1 and 2
meters. For negative values, -1 means a position between -1 and 0 meters, etc. (see Fig-
ure 6).
-3 -2 -1 0 1 2 Configuration value
cfx is used to select one of eight possible robot configurations numbered from 0
through 7. The table below describes each one of them in terms of how the robot is posi-
tioned relative to the three singularities.
The pictures below give an example of how the same tool position and orientation is
attained by using the eight different configurations:
ABB
ABB
beta -beta
cfx = 0 cfx = 1
Figure 7 Example of robot configuration 0 and 1. Note the different signs of the axis 5
angle.
Axis 1 Axis 1
beta -beta
ABB
ABB
Wrist center
Wrist center
cfx = 2 cfx = 3
Figure 8 Example of robot configuration 2 and 3. Note the different signs of the axis 5
angle.
cfx = 4 cfx = 5
Figure 9 Example of robot configuration 4 and 5. Note the different signs of the axis 5
angle.
ABB
beta ABB -beta
cfx = 6 cfx = 7
Figure 10 Example of robot configuration 6 and 7. Note the different signs of the axis 5
angle.
Because of the robot’s mainly linear structure, the correct setting of the configuration
parameters c1, cx is of less importance.
Components
cf1 Data type: num
Rotating axis:
Linear axis:
Rotating axis:
Linear axis:
Rotating axis:
Linear axis:
Rotating axis:
For the IRB140, the current robot configuration, expressed as an integer in the
range from 0 to 7.
For the IRB5400, the current quadrant of axis 5, expressed as a positive or nega-
tive integer.
For other robots, using the current quadrant of axis 2, expressed as a positive or
negative integer.
Linear axis:
Example
VAR confdata conf15 := [1, -1, 0, 0]
Structure
< dataobject of confdata >
< cf1 of num >
< cf4 of num >
< cf6 of num >
< cfx of num >
Related information
Described in:
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Handling configuration data Motion and I/O Principles - Robot
Configuration
This data type is used in conjunction with instructions and functions that handle digital
input or output signals.
Description
Data of the type dionum represents a digital value 0 or 1.
Examples
CONST dionum close := 1;
Predefined data
The constants high, low and edge are predefined in the system module user.sys:
Edge can be used together with the interrupt instructions ISignalDI and ISignalDO.
Characteristics
Dionum is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Summary input/output instructions RAPID Summary -
Input and Output Signals
Configuration of I/O User’s Guide - System Parameters
Alias data types Basic Characteristics- Data Types
Description
Data of the type errdomain represents the domain where the error, warning or state
changed is logged.
Refer to User Guide - Error Management, System and Error Messages
for more information.
Example
VAR errdomain err_domain;
VAR num err_number;
VAR errtype err_type;
VAR trapdata err_data;
...
TRAP trap_err
GetTrapData err_data;
ReadErrData err_data, err_domain, err_number, err_type;
ENDTRAP
When an error is trapped to the trap routine trap_err, the error domain, the error
number and the error type are saved into appropriate variables.
Predefined data
The following predefined constants can be used to specify an error domain.
Tabell 1 Predefined error domains
Characteristics
errdomain is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Ordering an interrupt on errors Instructions - IError
Error numbers User’s Guide - System and error messages
Alias data types Basic Characteristics - Data Types
Description
If the robot detects an error during program execution, this can be dealt with in the
error handler of the routine. Examples of such errors are values that are too high and
division by zero. The system variable ERRNO, of type errnum, is thus assigned
different values depending on the nature of an error. The error handler may be able to
correct an error by reading this variable and then program execution can continue in
the correct way.
An error can also be created from within the program using the RAISE instruction.
This particular type of error can be detected in the error handler by specifying an error
number (within the range 1-90 or booked with instruction BookErrNo) as an argument
to RAISE.
Examples
reg1 := reg2 / reg3;
.
ERROR
IF ERRNO = ERR_DIVZERO THEN
reg3 := 1;
RETRY;
ENDIF
If reg3 = 0, the robot detects an error when division is taking place. This error,
however, can be detected and corrected by assigning reg3 the value 1. Following
this, the division can be performed again and program execution can continue.
An error occurs in a machine (detected by means of the input signal di1). A jump
is made to the error handler in the routine which, in turn, calls the error handler
of the calling routine where the error may possibly be corrected. The constant,
machine_error, is used to let the error handler know exactly what type of error
has occurred.
Predefined data
The system variable ERRNO can be used to read the latest error that occurred. A num-
ber of predefined constants can be used to determine the type of error that has occurred.
Characteristics
Errnum is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Error recovery RAPID Summary - Error Recovery-
Basic Characteristics - Error Recovery
Data types in general, alias data types Basic Characteristics - Data Types
Description
Data of the type errtype represents the type (state change, warning, error) of an error
message.
Refer to User Guide - Error Management, System and Error Messages
for more information.
Example
VAR errdomain err_domain;
VAR num err_number;
VAR errtype err_type;
VAR trapdata err_data;
...
TRAP trap_err
GetTrapData err_data;
ReadErrData err_data, err_domain, err_number, err_type;
ENDTRAP
When an error is trapped to the trap routine trap_err, the error domain, the error
number and the error type are saved into appropriate variables.
Predefined data
The following predefined constants can be used to specify an error type.
TYPE_ERR Error 3
Characteristics
errtype is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Ordering an interrupt on errors Instructions - IError
Error numbers User’s Guide - System and error messages
Alias data types Basic Characteristics - Data Types
Description
The robot can control up to six external axes in addition to its six internal axes, i.e. a
total of twelve axes. The six external axes are logically denoted: a, b, c, d, e, f. Each
such logical axis can be connected to a physical axis and, in this case, the connection
is defined in the system parameters.
Data of the type extjoint is used to hold position values for each of the logical axes a - f.
For each logical axis connected to a physical axis, the position is defined as follows:
- For rotating axes – the position is defined as the rotation in degrees from the
calibration position.
- For linear axes – the position is defined as the distance in mm from the calibra-
tion position.
If a logical axis is not connected to a physical one, the value 9E9 is used as a position
value, indicating that the axis is not connected. At the time of execution, the position
data of each axis is checked and it is checked whether or not the corresponding axis is
connected. If the stored position value does not comply with the actual axis connection,
the following applies:
- If the position is not defined in the position data (value is 9E9), the value will
be ignored if the axis is connected and not activated. But if the axis is activated,
it will result in an error.
- If the position is defined in the position data, although the axis is not connected,
the value will be ignored.
If an external axis offset is used (instruction EOffsOn or EOffsSet), the positions are
specified in the ExtOffs coordinate system.
Components
eax_a (external axis a) Data type: num
...
The position of the external logical axis “f”, expressed in degrees or mm (depend-
ing on the type of axis).
Example
VAR extjoint axpos10 := [ 11, 12.3, 9E9, 9E9, 9E9, 9E9] ;
- The position of the external logical axis “a” is set to 11, expressed in degrees or
mm (depending on the type of axis).
- The position of the external logical axis “b” is set to 12.3, expressed in degrees
or mm (depending on the type of axis).
- Axes c to f are undefined.
Structure
< dataobject of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Position data Data Types - robtarget
ExtOffs coordinate system Instructions - EOffsOn
Description
When a variable of type intnum is connected to a trap routine, it is given a specific
value identifying the interrupt. This variable is then used in all dealings with the inter-
rupt, such as when ordering or disabling an interrupt.
More than one interrupt identity can be connected to the same trap routine. The system
variable INTNO can thus be used in a trap routine to determine the type of interrupt that
occurs.
Examples
VAR intnum feeder_error;
.
CONNECT feeder_error WITH correct_feeder;
ISignalDI di1, 1, feeder_error;
An interrupt is generated when the input di1 is set to 1. When this happens, a call
is made to the correct_feeder trap routine.
An interrupt is generated when either of the inputs di1 or di2 is set to 1. A call is
then made to the correct_feeder trap routine. The system variable INTNO is used
in the trap routine to find out which type of interrupt has occurred.
Limitations
The maximum number of active variables of type intnum at any one time (between
CONNECT and IDelete) is limited to 40.The maximum number of interrupts, in the
queue for execution of TRAP routine at any one time, is limited to 30.
Characteristics
Intnum is an alias data type for num and thus inherits its properties.
Related information
Described in:
Summary of interrupts RAPID Summary - Interrupts
Alias data types Basic Characteristics-
Data Types
Description
Data of the type iodev contains a reference to a file or serial channel. It can be linked
to the physical unit by means of the instruction Open and then used for reading and
writing.
Example
VAR iodev file;
.
Open “HOME:/LOGDIR/INFILE.DOC”, file\Read;
input := ReadNum(file);
The file INFILE.DOC is opened for reading. When reading from the file, file is
used as a reference instead of the file name.
Characteristics
Iodev is a non-value data type.
Related information
Described in:
Communication via serial channels RAPID Summary - Communication
Configuration of serial channels User’s Guide - System Parameters
Characteristics of non-value data types Basic Characteristics - Data Types
Description
Jointtarget defines each individual axis position, for both the robot and the external
axes.
Components
robax (robot axes) Data type: robjoint
Axis position is defined as the rotation in degrees for the respective axis (arm) in
a positive or negative direction from the axis calibration position.
The position is defined as follows for each individual axis (eax_a, eax_b ...
eax_f):
- For rotating axes, the position is defined as the rotation in degrees from the cal-
ibration position.
- For linear axes, the position is defined as the distance in mm from the calibra-
tion position.
External axes eax_a ... are logical axes. How the logical axis number and the
physical axis number are related to each other is defined in the system parame-
ters.
The value 9E9 is defined for axes which are not connected. If the axes defined in
the position data differ from the axes that are actually connected on program exe-
cution, the following applies:
- If the position is not defined in the position data (value 9E9) the value will be
ignored, if the axis is connected and not activated. But if the axis is activated it
will result in error.
- If the position is defined in the position data yet the axis is not connected, the
value is ignored.
Examples
CONST jointtarget calib_pos := [ [ 0, 0, 0, 0, 0, 0], [ 0, 9E9, 9E9, 9E9, 9E9, 9E9] ];
The normal calibration position for IRB2400 is defined in calib_pos by the data
type jointtarget. The normal calibration position 0 (degrees or mm) is also
defined for the external logical axis a. The external axes b to f are undefined.
Structure
< dataobject of jointtarget >
< robax of robjoint >
< rax_1 of num >
< rax_2 of num >
< rax_3 of num >
< rax_4 of num >
< rax_5 of num >
< rax_6 of num >
< extax of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Move to joint position Instructions - MoveAbsJ
Positioning instructions RAPID Summary - Motion
Configuration of external axes User’s Guide - System Parameters
Load data usually defines the payload (grip load is defined by the instruction Grip-
Load) of the robot, i.e. the load held in the robot gripper. The tool load is specified in
the tool data (tooldata) which includes load data.
Description
Specified loads are used to set up a model of the dynamics of the robot so that the robot
movements can be controlled in the best possible way.
It is important to always define the actual tool load and when used, the payload of the
robot too. Incorrect definitions of load data can result in overloading of the robot
mechanical structure.
When incorrect load data is specified, it can often lead to the following consequences:
- If the value in the specified load data is greater than that of the value of the true
load;
-> The robot will not be used to its maximum capacity
-> Impaired path accuracy including a risk of overshooting
-> Risk of overloading the mechanical structure
- If the value in the specified load data is less than the value of the true load;
-> Impaired path accuracy including a risk of overshooting
-> Risk of overloading the mechanical structure
Components
mass Data type: num
The centre of gravity of a tool load expressed in the wrist coordinate system.
If a stationary tool is used, it means the centre of gravity for the tool holding the
work object.
The centre of gravity of a payload expressed in the tool coordinate system. The
object coordinate system when a stationary tool is used.
The orientation of the coordinate system defined by the inertial axes of the tool
load. Expressed in the wrist coordinate system as a quaternion (q1, q2, q3, q4). If
a stationary tool is used, it means the inertial axes for the tool holding the work
object.
The orientation of the tool load coordinate system must coincide with the orien-
tation of the wrist coordinate system. It must always be set to 1, 0, 0, 0.
The orientation of the coordinate system defined by the inertial axes of the pay-
load. Expressed in the tool coordinate system as a quaternion (q1, q2, q3, q4). The
object coordinate system if a stationary tool is used.
The orientation of the payload coordinate system must coincide with the orienta-
tion of the wrist coordinate system. It must always be set to 1, 0, 0, 0.
Because of this limitation, the best way is to define the orientation of the tool
coordinate system (tool frame) to coincide with the orientation of the wrist coor-
dinate system.
IY’
IZ’
Payload coordinate system -
Inertial axes of payload
IX’
Figure 11 Restriction on the orientation of tool load and payload coordinate system.
Z Gripper
Y
Tool coordinate system
Z
Y’
Payload coordinate
X
Z’ system -
Inertial axes of payload
X
Payload
The moment of inertia of the load around the x-axis of the tool load or payload
coordinate system in kgm2.
Correct definition of the inertial moments will allow optimal utilisation of the
path planner and axes control. This may be of special importance when handling
large sheets of metal, etc. All inertial moments of inertia ix, iy and iz equal to
0 kgm2 imply a point mass.
Normally, the inertial moments must only be defined when the distance from the
mounting flange to the centre of gravity is less than the dimension of the load
(see Figure 13).
payload
distance
x
dimension
Figure 13 The moment of inertia must normally be defined when the distance
is less than the load dimension.
The inertial moment of the load around the y-axis, expressed in kgm2.
The inertial moment of the load around the z-axis, expressed in kgm2.
Examples
PERS loaddata piece1 := [ 5, [50, 0, 50], [1, 0, 0, 0], 0, 0, 0];
- Weight 5 kg.
- The centre of gravity is x = 50, y = 0 and z = 50 mm in the tool coordinate sys-
tem.
- The payload is a point mass.
Set gripper;
WaitTime 0.3;
GripLoad piece1;
Connection of the payload, piece1, specified at the same time as the robot grips
the load piece1.
Reset gripper;
WaitTime 0.3;
GripLoad load0;
Disconnection of a payload, specified at the same time as the robot releases a pay-
load.
Limitations
The payload should only be defined as a persistent variable (PERS) and not within a
routine. Current values are then saved when storing the program on diskette and are
retrieved on loading.
Arguments of the type load data in the GripLoad instruction should only be an entire
persistent (not array element or record component).
Predefined data
The load load0 defines a payload, the weight of which is equal to 0 kg, i.e. no load at
all. This load is used as the argument in the instruction GripLoad to disconnect a pay-
load.
The load load0 can always be accessed from the program, but cannot be changed (it is
stored in the system module BASE).
Structure
< dataobject of loaddata >
< mass of num >
< cog of pos >
< x of num >
< y of num >
< z of num >
< aom of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< ix of num >
< iy of num >
< iz of num >
Related information
Described in:
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Definition of tool loads Data Types - tooldata
Activation of payload Instructions - GripLoad
Description
Data of the type loadsession is used in the instructions StartLoad and WaitLoad, to
identify the load session. Loadsession only contains a reference to the load session.
Characteristics
Loadsession is a non-value data type and cannot be used in value-oriented operations.
Related information
Described in:
Loading program modules during execution Instructions - StartLoad, WaitLoad
Characteristics of non-value data types Basic Characteristics - Data Types
The names of the mechanical units are defined in the system parameters and, conse-
quently, must not be defined in the program.
Description
Data of the type mecunit only contains a reference to the mechanical unit.
Limitations
Data of the type mecunit must not be defined in the program. The data type can, on the
other hand, be used as a parameter when declaring a routine.
Predefined data
The mechanical units defined in the system parameters can always be accessed from
the program (installed data).
Characteristics
Mecunit is a non-value data type. This means that data of this type does not permit
value-oriented operations.
Related information
Described in:
Activating/Deactivating mechanical units Instructions - ActUnit, DeactUnit
Configuration of mechanical units User’s Guide - System Parameters
Characteristics of non-value data types Basic Characteristics - Data Types
This data type does not normally have to be used since these settings can only be set
using the instructions VelSet, AccSet, SingArea, ConfJ, ConfL, PathResol, MotionSup,
PathAccLim, CirPathMode and WorldAccLim.
The current values of these motion settings can be accessed using the system variable
C_MOTSET.
Description
The current motion settings (stored in the system variable C_MOTSET) affect all
movements.
Components
vel.oride Data type: veldata/num
The orientation of the tool is allowed to deviate somewhat in order to prevent arm
singularity (not implemented).
Maximum permitted deviation in degrees for axis 1 (not used in this version).
Maximum permitted deviation in degrees for axis 4 (not used in this version).
Maximum permitted deviation in degrees for axis 6 (not used in this version).
Limitation of tool acceleration along the path. (TRUE = limitation and FALSE =
no limitation).
Limitation of tool deceleration along the path. TRUE = limitation and FALSE =
no limitation).
Limitations
One and only one of the components sing.wrist, sing.arm or sing.base may have a
value equal to TRUE.
Example
IF C_MOTSET.vel.oride > 50 THEN
...
ELSE
...
ENDIF
Different parts of the program are executed depending on the current velocity
override.
Predefined data
C_MOTSET describes the current motion settings of the robot and can always be
accessed from the program (installed data). C_MOTSET, on the other hand, can only
be changed using a number of instructions, not by assignment.
- at a cold start-up
- when a new program is loaded
- when starting program execution from the beginning.
Structure
<dataobject of motsetdata>
<vel of veldata > -> Affected by
instruction VelSet
< oride of num >
< max of num >
<acc of accdata > -> Affected by
instruction AccSet
< acc of num >
< ramp of num >
<sing of singdata > -> Affected by
instruction SingArea
< wrist of bool >
< arm of bool >
< base of bool >
<conf of confsupdata > -> Affected by
instructions ConfJ and ConfL
< jsup of bool >
<lsup of bool >
< ax1 of num >
< ax4 of num >
< ax6 of num >
<pathresol of num> -> Affected by
instruction PathResol
<motionsup of bool> -> Affected by
instruction MotionSup
<tunevalue of num> -> Affected by
instruction MotionSup
<acclim of bool> -> Affected by
instruction PathAccLim
<accmax of num> -> Affected by
instruction PathAccLim
<decellim of bool> -> Affected by
instruction PathAccLim
<decelmax of num> -> Affected by
instruction PathAccLim
<cirpathreori of num> -> Affected by
instruction CirPathMode
<worldacclim of bool> -> Affected by
instruction WorldAccLim
<worldaccmax of num> -> Affected by
instruction WorldAccLim
Related information
Described in:
Description
The value of the num data type may be
Integers between -8388607 and +8388608 are always stored as exact integers.
Decimal numbers are only approximate numbers and should not, therefore, be used in
is equal to or is not equal to comparisons. In the case of divisions, and operations using
decimal numbers, the result will also be a decimal number; i.e. not an exact integer.
E.g. a := 10;
b := 5;
IF a/b=2 THEN As the result of a/b is not an integer,
this condition is not necessarily
... satisfied.
Example
VAR num reg1;
.
reg1 := 3;
a := 10 DIV 3;
b := 10 MOD 3;
Predefined data
The constant pi (π) is already defined in the system module BASE.
The constants EOF_BIN and EOF_NUM are already defined in the system.
Related information
Described in:
Numeric expressions Basic Characteristics - Expressions
Operations using numeric values Basic Characteristics - Expressions
Description
If the function Absolute Limit Modpos is activated and a named position in a movement
instruction is modified with the function Modpos, then the original programmed posi-
tion is saved.
The same program after ModPos in which the point jpos40 is corrected to 2 degrees for
robot axis 1:
The original programmed point has now been saved in o_jpos40 (by the data type
o_jointtarget) and the modified point saved in jpos40 (by the data type jointtarget).
By saving the original programmed point, the robot can monitor that further Modpos
of the point in question are within the acceptable limits from the original programmed
point.
The fixed name convention means that an original programmed point with the name
xxxxx is saved with the name o_xxxxx by using Absolute Limit Modpos.
Components
robax (robot axes) Data type: robjoint
Structure
< dataobject of o_jointtarget >
< robax of robjoint>
< rax_1 of num >
< rax_2 of num >
< rax_3 of num >
< rax_4 of num >
< rax_5 of num >
< rax_6 of num >
< extax of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Position data Data Types - Jointtarget
Configuration of Limit Modpos User’s Guide - System Parameters
Description
If the function Absolute Limit Modpos is activated and a named position in a movement
instruction is modified with the function Modpos, then the original programmed posi-
tion is saved.
CONST robtarget p50 := [[500, 500, 500], [1, 0, 0, 0], [1, 1, 0, 0],
[500, 9E9, 9E9, 9E9, 9E9, 9E9] ];
...
MoveL p50, v1000, z50, tool1;
The same program after ModPos in which the point p50 is corrected to 502 in the x-
direction:
CONST robtarget p50 := [[502, 500, 500], [1, 0, 0, 0], [1, 1, 0, 0],
[500, 9E9, 9E9, 9E9, 9E9, 9E9] ];
CONST o_robtarget o_p50 := [[500, 500, 500], [1, 0, 0, 0], [1, 1, 0, 0],
[ 500, 9E9, 9E9, 9E9, 9E9, 9E9] ];
...
MoveL p50, v1000, z50, tool1;
The original programmed point has now been saved in o_p50 (by the data type
o_robtarget) and the modified point saved in p50 (by the data type robtarget).
By saving the original programmed point, the robot can monitor that further Modpos
of the point in question are within the acceptable limits from the original programmed
point.
The fixed name convention means that an original programmed point with the name
xxxxx is saved with the name o_xxxxx by using Absolute Limit Modpos.
Components
trans (translation) Data type: pos
The position (x, y and z) of the tool centre point expressed in mm.
The orientation of the tool, expressed in the form of a quaternion (q1, q2, q3 and
q4).
The axis configuration of the robot (cf1, cf4, cf6 and cfx).
Structure
< dataobject of o_robtarget >
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< robconf of confdata >
< cf1 of num >
< cf4 of num >
< cf6 of num >
< cfx of num >
< extax of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Position data Data Types - Robtarget
Configuration of Limit Modpos User’s Guide - System Parameters
Description
An opnum constant is intended to be used to define the type of comparison, when
checking values in generic instructions.
Example
TriggCheckIO checkgrip, 100, airok, EQ, 1, intno1;
Predefined data
The following symbolic constants of the data type opnum are predefined and can be
used to define the type of comparison used for instance in instruction TriggCheckIO.
1 LT Less than
2 LTEQ Less than or equal to
3 EQ Equal to
4 NOTEQ Not equal to
5 GTEQ Greater than or equal to
6 GT Greather than
Characteristics
opnum is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Data types in general, alias data types Basic Characteristics - Data Types
orient - Orientation
Orient is used for orientations (such as the orientation of a tool) and rotations (such as
the rotation of a coordinate system).
Description
The orientation is described in the form of a quaternion which consists of four ele-
ments: q1, q2, q3 and q4. For more information on how to calculate these, see below.
Components
q1 Data type: num
Quaternion 1.
Quaternion 2.
Quaternion 3.
Quaternion 4.
Example
VAR orient orient1;
.
orient1 := [1, 0, 0, 0];
The orient1 orientation is assigned the value q1=1, q2-q4=0; this corresponds to
no rotation.
Limitations
The orientation must be normalised; i.e. the sum of the squares must equal 1:
q 12 + q 22 + q 32 + q 42 = 1
What is a Quaternion?
The orientation of a coordinate system (such as that of a tool) can be described by a
rotational matrix that describes the direction of the axes of the coordinate system in
relation to a reference system (see Figure 14).
z
z
x
y Rotated
Reference
coordinate
coordinate
system
x system
y
Figure 14 The rotation of a coordinate system is described by a quaternion.
The rotated coordinate systems axes (x, y, z) are vectors which can be expressed in the
reference coordinate system as follows:
This means that the x-component of the x-vector in the reference coordinate system
will be x1, the y-component will be x2, etc.
These three vectors can be put together in a matrix, a rotational matrix, where each of
the vectors form one of the columns:
x1 y1 z1
x2 y2 z2
x3 y3 z3
A quaternion is just a more concise way to describe this rotational matrix; the quater-
nions are calculated based on the elements of the rotational matrix:
x1 + y2 + z3 + 1
q1 = -----------------------------------------
2
x1 – y2 – z3 + 1
q2 = ----------------------------------------
2
sign q2 = sign (y3-z2)
y2 – x1 – z3 + 1
q3 = ----------------------------------------
2
sign q3 = sign (z1-x3)
z3 – x1 – y2 + 1
q4 = ----------------------------------------
2
sign q4 = sign (x2-y1)
Example 1
A tool is orientated so that its Z’-axis points straight ahead (in the same direction as the
X-axis of the base coordinate system). The Y’-axis of the tool corresponds to the Y-
axis of the base coordinate system (see Figure 15). How is the orientation of the tool
defined in the position data (robtarget)?
The orientation of the tool in a programmed position is normally related to the coordi-
nate system of the work object used. In this example, no work object is used and the
base coordinate system is equal to the world coordinate system. Thus, the orientation
is related to the base coordinate system.
Z´
X´
X
Figure 15 The direction of a tool in accordance with example 1.
- x’ = -z = (0, 0, -1)
- y’ = y = (0, 1, 0)
- z’ = x = (1, 0, 0) 0 0 1
0 1 0
Which corresponds to the following rotational matrix:
–1 0 0
0+1+0+1 2
q1 = ----------------------------------- = ------- = 0.707
2 2
0–1–0+1
q2 = ---------------------------------- = 0
2
1–0–0+1 2
q3 = ---------------------------------- = ------- = 0.707
2 2
sign q3 = sign (1+1) = +
0–0–1+1
q4 = ---------------------------------- = 0
2
Example 2
The direction of the tool is rotated 30o about the X’- and Z’-axes in relation to the wrist
coordinate system (see Figure 15). How is the orientation of the tool defined in the tool
data?
X Z´
X´
- x’ = (cos30o, 0, -sin30o)
- x’ = (0, 1, 0)
- x’ = (sin30o, 0, cos30o)
cos 30 ° 0 sin 30 °
Which corresponds to the following rotational matrix: 0 1 0
– sin 30 ° 0 cos 30 °
Structure
<dataobject of orient>
<q1 of num>
<q2 of num>
<q3 of num>
<q4 of num>
Related information
Described in:
Operations on orientations Basic Characteristics - Expressions
The robtarget data type is used for the robot’s position including the orientation of the
tool and the configuration of the axes.
Description
Data of the type pos describes the coordinates of a position: X, Y and Z.
Components
x Data type: num
Examples
VAR pos pos1;
.
pos1 := [500, 0, 940];
The pos1 position is assigned the value: X=500 mm, Y=0 mm, Z=940 mm.
Structure
<dataobject of pos>
<x of num>
<y of num>
<z of num>
Related information
Described in:
Operations on positions Basic Characteristics - Expressions
Robot position including orientation Data Types- robtarget
Description
Data of the type pose describes how a coordinate system is displaced and rotated
around another coordinate system. The data can, for example, describe how the tool
coordinate system is located and oriented in relation to the wrist coordinate system.
Components
trans (translation) Data type: pos
Example
VAR pose frame1;
.
frame1.trans := [50, 0, 40];
frame1.rot := [1, 0, 0, 0];
Structure
<dataobject of pose>
<trans of pos>
<rot of orient>
Related information
Described in:
What is a Quaternion? Data Types - orient
This data type does not normally have to be used since the data is set using the instruc-
tions PDispSet, PDispOn, PDispOff, EOffsSet, EOffsOn and EOffsOff. It is only used
to temporarily store the current value for later use.
Description
The current values for program displacement can be accessed using the system variable
C_PROGDISP.
For more information, see the instructions PDispSet, PDispOn, EOffsSet and EOffsOn.
Components
pdisp (program displacement) Data type: pose
The program displacement for the robot, expressed using a translation and an ori-
entation. The translation is expressed in mm.
The offset for each of the external axes. If the axis is linear, the value is expressed
in mm; if it is rotating, the value is expressed in degrees.
Example
VAR progdisp progdisp1;
.
SearchL sen1, psearch, p10, v100, tool1;
PDispOn \ExeP:=psearch, *, tool1;
EOffsOn \ExeP:=psearch, *;
.
progdisp1:=C_PROGDISP;
PDispOff;
EOffsOff;
.
PDispSet progdisp1.pdisp;
EOffsSet progdisp1.eoffs;
Predefined data
The system variable C_PROGDISP describes the current program displacement of the
robot and external axes, and can always be accessed from the program (installed data).
C_PROGDISP, on the other hand, can only be changed using a number of instructions,
not by assignment.
Structure
< dataobject of progdisp >
<pdisp of pose>
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< eoffs of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Description
Data of the type robjoint is used to store axis positions in degrees of the robot axes 1
to 6. Axis position is defined as the rotation in degrees for the respective axis (arm) in
a positive or negative direction from the axis calibration position.
Components
rax_1 (robot axis 1) Data type: num
...
Structure
< dataobject of robjoint >
< rax_1 of num >
< rax_2 of num >
< rax_3 of num >
< rax_4 of num >
< rax_5 of num >
< rax_6 of num >
Related information
Described in:
Joint position data Data Types - jointtarget
Move to joint position Instructions - MoveAbsJ
Description
Position data is used to define the position in the positioning instructions to which the
robot and external axes are to move.
As the robot is able to achieve the same position in several different ways, the axis con-
figuration is also specified. This defines the axis values if these are in any way ambig-
uous, for example:
The position is defined based on the coordinate system of the work object, includ-
ing any program displacement. If the position is programmed with some other
work object than the one used in the instruction, the robot will not move in the
expected way. Make sure that you use the same work object as the one used when
programming positioning instructions. Incorrect use can injure someone or dam-
age the robot or other equipment.
Components
trans (translation) Data type: pos
The position (x, y and z) of the tool centre point expressed in mm.
The orientation of the tool, expressed in the form of a quaternion (q1, q2, q3 and
q4).
The axis configuration of the robot (cf1, cf4, cf6 and cfx). This is defined in the
form of the current quarter revolution of axis 1, axis 4 and axis 6. The first posi-
tive quarter revolution 0 to 90 o is defined as 0. The component cfx is only used
for the robot model IRB5400.
The position is defined as follows for each individual axis (eax_a, eax_b ...
eax_f):
- For rotating axes, the position is defined as the rotation in degrees from the cal-
ibration position.
- For linear axes, the position is defined as the distance in mm from the calibra-
tion position.
External axes eax_a ... are logical axes. How the logical axis number and the
physical axis number are related to each other is defined in the system parame-
ters.
The value 9E9 is defined for axes which are not connected. If the axes defined in
the position data differ from the axes that are actually connected on program exe-
cution, the following applies:
- If the position is not defined in the position data (value 9E9), the value will be
ignored, if the axis is connected and not activated. But if the axis is activated, it
will result in an error.
- If the position is defined in the position data although the axis is not connected,
the value is ignored.
Examples
CONST robtarget p15 := [ [600, 500, 225.3], [1, 0, 0, 0], [1, 1, 0, 0],
[ 11, 12.3, 9E9, 9E9, 9E9, 9E9] ];
- The position of the robot: x = 600, y = 500 and z = 225.3 mm in the object coor-
dinate system.
- The orientation of the tool in the same direction as the object coordinate system.
- The axis configuration of the robot: axes 1 and 4 in position 90-180o, axis 6 in
position 0-90o.
- The position of the external logical axes, a and b, expressed in degrees or mm
(depending on the type of axis). Axes c to f are undefined.
The position p20 is set to the same position as the current position of the robot by call-
ing the function CRobT. The position is then moved 10 mm in the x-direction.
Limitations
When using the configurable edit function Absolute Limit Modpos, the number of char-
acters in the name of the data of the type robtarget, is limited to 14 (in other cases 16).
Structure
< dataobject of robtarget >
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< robconf of confdata >
< cf1 of num >
< cf4 of num >
< cf6 of num >
< cfx of num >
< extax of extjoint >
< eax_a of num >
< eax_b of num >
< eax_c of num >
< eax_d of num >
< eax_e of num >
< eax_f of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Handling configuration data Motion and I/O Principles - Robot
Configuration
Configuration of external axes User’s Guide - System Parameters
What is a quaternion? Data Types - Orient
Description
World zones can be defined in 4different geometrical shapes:
- a straight box, with all sides parallel to the world coordinate system and defined
by a WZBoxDef instruction
- a sphere, defined by a WZSphDef instruction
- a cylinder, parallel to the z axis of the world coordinate system and defined by
a WZCylDef instruction
- a joint space area for robot and/or external axes, defined by the instruction
WZHomeJointDef or WZLimJointDef
The geometry of a world zone is defined by one of the previous instructions and the
action of a world zone is defined by the instruction WZLimSup or WZDOSet.
Example
VAR wzstationary pole;
VAR wzstationary conveyor;
...
PROC ...
VAR shapedata volume;
...
WZBoxDef \Inside, volume, p_corner1, p_corner2;
WZLimSup \Stat, conveyor, volume;
WZCylDef \Inside, volume, p_center, 200, 2500;
WZLimSup \Stat, pole, volume;
ENDPROC
A conveyor is defined as a box and the supervision for this area is activated. A
pole is defined as a cylinder and the supervision of this zone is also activated. If
the robot reaches one of these areas, the motion is stopped.
Characteristics
shapedata is a non-value data type.
Related information
Described in:
World Zones Motion and I/O Principles -
World Zones
World zone shape Data Types - shapedata
Define box-shaped world zone Instructions - WZBoxDef
Define sphere-shaped world zone Instructions - WZSphDef
Define cylinder-shaped world zone Instructions - WZCylDef
Define a world zone for home joints Instruction - WZHomeJointDef
Define a world zone for limit joints Instruction - WZLimJointDef
Activate world zone limit supervision Instructions - WZLimSup
Activate world zone digital output set Instructions - WZDOSet
The names of the signals are defined in the system parameters and are consequently
not to be defined in the program.
Description
Data type Used for
signalai analog input signals
signalao analog output signals
signaldi digital input signals
signaldo digital output signals
signalgi groups of digital input signals
signalgo groups of digital output signals
Variables of the type signalxo only contain a reference to the signal. The value is set
using an instruction, e.g. DOutput.
Variables of the type signalxi contain a reference to a signal as well as the possibility
to retrieve the value directly in the program, if used in value context.
The value of an input signal can be read directly in the program, e.g. :
! Digital input
IF di1 = 1 THEN ...
! Analog input
IF ai1 > 5.2 THEN ...
Limitations
Data of the data type signalxx must not be defined in the program. However, if this is
in fact done, an error message will be displayed as soon as an instruction or function
that refers to this signal is executed. The data type can, on the other hand, be used as a
parameter when declaring a routine.
Predefined data
The signals defined in the system parameters can always be accessed from the program
by using the predefined signal variables (installed data). It should however be noted
that if other data with the same name is defined, these signals cannot be used.
Characteristics
Signalxo is a non-value data type. Thus, data of this type does not permit value-
oriented operations.
Related information
Described in:
Summary input/output instructions RAPID Summary -
Input and Output Signals
Input/Output functionality in general Motion and I/O Principles -
I/O Principles
Configuration of I/O User’s Guide - System Parameters
Characteristics of non-value data types Basic Characteristics - Data Types
Description
Speed data defines the velocity:
When several different types of movement are combined, one of the velocities often
limits all movements. The velocity of the other movements will be reduced in such a
way that all movements will finish executing at the same time.
The velocity is also restricted by the performance of the robot. This differs, depending
on the type of robot and the path of movement.
Components
v_tcp (velocity tcp) Data type: num
If a stationary tool or coordinated external axes are used, the velocity is specified
relative to the work object.
If a stationary tool or coordinated external axes are used, the velocity is specified
relative to the work object.
Example
VAR speeddata vmedium := [ 1000, 30, 200, 15 ];
vmedium.v_tcp := 900;
Predefined data
A number of speed data are already defined in the system module BASE.
Name TCP speed Orientation Linear ext. axis Rotating ext. axis
v5 5 mm/s 500o/s 5000 mm/s 1000o/s
v10 10 mm/s 500o/s 5000 mm/s 1000o/s
v20 20 mm/s 500o/s 5000 mm/s 1000o/s
v30 30 mm/s 500o/s 5000 mm/s 1000o/s
v40 40 mm/s 500o/s 5000 mm/s 1000o/s
v50 50 mm/s 500o/s 5000 mm/s 1000o/s
v60 60 mm/s 500o/s 5000 mm/s 1000o/s
v80 80 mm/s 500o/s 5000 mm/s 1000o/s
v100 100 mm/s 500o/s 5000 mm/s 1000o/s
v150 150 mm/s 500o/s 5000 mm/s 1000o/s
v200 200 mm/s 500o/s 5000 mm/s 1000o/s
v300 300 mm/s 500o/s 5000 mm/s 1000o/s
v400 400 mm/s 500o/s 5000 mm/s 1000o/s
v500 500 mm/s 500o/s 5000 mm/s 1000o/s
v600 600 mm/s 500o/s 5000 mm/s 1000o/s
v800 800 mm/s 500o/s 5000 mm/s 1000o/s
v1000 1000 mm/s 500o/s 5000 mm/s 1000o/s
v1500 1500 mm/s 500o/s 5000 mm/s 1000o/s
v2000 2000 mm/s 500o/s 5000 mm/s 1000o/s
v2500 2500 mm/s 500o/s 5000 mm/s 1000o/s
v3000 3000 mm/s 500o/s 5000 mm/s 1000o/s
v4000 4000 mm/s 500o/s 5000 mm/s 1000o/s
v5000 5000 mm/s 500o/s 5000 mm/s 1000o/s
v6000 6000 mm/s 500o/s 5000 mm/s 1000o/s
v7000 7000 mm/s 500o/s 5000 mm/s 1000o/s
vmax *) 500o/s 5000 mm/s 1000o/s
*) Max. TCP speed for the used robot type and normal pratical TCP values.
The RAPID function MaxRobSpeed returns the same value.
If use of extreme big TCP values in tool frame, create own speeddata with
bigger TCP speed than returned by MaxRobSpeed.
Structure
< dataobject of speeddata >
< v_tcp of num >
< v_ori of num >
< v_leax of num >
< v_reax of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Motion/Speed in general Motion and I/O Principles - Position-
ing during Program Execution
Defining maximum velocity Instructions - VelSet
Max. TCP speed for this robot Function - MaxRobSpeed
Configuration of external axes User’s Guide - System Parameters
Motion performance Product Specification
Description
A position can be terminated either in the form of a fly-by point or a stop point.
A fly-by point means that the programmed position is never reached. A zone is speci-
fied in the instruction for the movement, defining a corner path. Instead of heading for
the programmed position, the direction of the motion is formed into the corner path
before the position is reached. See data type zonedata.
A stop point means that the robot and external axes must reach the specified position
before the robot/external axes continues with the next movement. The robot is consid-
ered to have reached a stop point when the convergence criteria of the point are satis-
fied. The convergence criteria are speed and position. It is also possible to specify
timing criteria. For stop point fine, see also data type zonedata.
The stoppointdata also determines how the movement shall be synchronized with the
RAPID execution. If the movement is synchronized, the RAPID execution waits for a
“in pos” event when the robot is in position. If the movement is not synchronized, the
RAPID execution gets a “prefetch” event almost a half second before the physical
robot reach the programmed position. When the program executer gets an “in pos” or
a “prefetch” event it continues with the next instruction. When the “prefetch” event
arrives, the robot still have a long way to move. When the “in pos” event arrives the
robot is close to the programmed position. Note that for the type stop time and follow
time, the next instruction starts its execution at the same time as the stop time and fol-
low time, respectively, start to count down. But for the type in position, the next
instruction is started when the convergence criteria is fulfilled.
In pos
Reference speed
Time
Constant lag
Min/max time
Stop time
Follow time
In the figure above, the termination of the stop points is described. The robots speed
does not decrease linear. The robot servo is always ahead the physical robot. It is shown
as the constant lag in the figure above. The constant lag is about 0.1 seconds. The tim-
ing elements of stoppointdata use the reference speed as trigger. When the reference
speed is zero the time measurement starts. Therefore the time in the timing elements
always include the constant lag. Consequently there is no sense in using values less
than the constant lag.
Components
type (type of stop point) Data type: stoppoint
Data type stoppoint is an alias data type for num. It is used to choose the type of stop
point and which data elements to use in the stoppointdata. Predefined constants are:
The position condition (the radius) for the TCP in percent of a normal fine stop
point.
The speed condition for the TCP in percent of a normal fine stop point.
The minimum wait time in seconds before in position. Used to make the robot
wait at least the specified time in the point. Maximum value is 20.0 seconds.
The maximum wait time in seconds for convergence criteria to be satisfied. Used
to assure that the robot does not get stuck in the point, if the speed and position
conditions are set too tight. Maximum value is 20.0 seconds.
The time in seconds, the TCP stands still in position before starting the next
movement. Maximum value is 20.0 seconds.
Examples
Inpos
VAR stoppointdata my_inpos := [ inpos, TRUE, [ 25, 40, 0.1, 5], 0, 0, ““, 0, 0];
MoveL *, v1000, z0 \Inpos:=my_inpos, grip4;
The stop point data my_inpos is defined by means of the following characteris-
tics:
The robot move towards the programmed position until one of the criteria posi-
tion or speed is satisfied.
my_inpos.inpos.position := 40;
MoveL *, v1000, z0 \Inpos:=my_inpos, grip4;
Stoptime
The stop point data my_stoptime is defined by means of the following charac-
teristics:
The robot moves towards the programmed position until the prefetch event
arrives. The next RAPID instruction executes. If it is a move-instruction, the
robot stops for 1.45 seconds before the next movement starts.
my_stoptime.stoptime := 6.66;
MoveL *, v1000, z0 \Inpos:=my_stoptime, grip4;
The stop point stop time is adjusted to 6.66 seconds If the next RAPID instruc-
tion is a move-instruction, the robot stops for 6.66 s.
Followtime
The stop point data my_followtime is defined by means of the following char-
acteristics:
The robot will follow the conveyor for 0.5 s before leaving it with the zone 10
mm, z10.
my_followtime.followtime := 0.4;
Predefined data
A number of stop point data are already defined in the system module BASE.
Structure
< data object of stoppointdata >
< type of stoppoint>
< progsynch of bool >
< inpos of inposdata >
< position of num >
< speed of num >
< mintime of num >
< maxtime of num >
< stoptime of num >
< followtime of num >
< signal of string >
< relation of opnum >
< checkvalue of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Movements/Paths in general Motion and I/O Principles - Position-
ing during Program Execution
Configuration of external axes User’s Guide - System Parameters
Fly-by points Data Types - zonedata
string - Strings
String is used for character strings.
Description
A character string consists of a number of characters (a maximum of 80) enclosed by
quotation marks (“”),
If the quotation marks are to be included in the string, they must be written twice,
If the back slash are to be included in the string, it must be written twice,
Example
VAR string text;
.
text := “start welding pipe 1”;
TPWrite text;
Limitations
A string may have from 0 to 80 characters; inclusive of extra quotation marks or back
slash.
A string may contain any of the characters specified by ISO 8859-1 as well as control
characters (non-ISO 8859-1 characters with a numeric code between 0-255).
Predefined data
A number of predefined string constants are available in the system and can be used
together with string functions.
The following constants are already defined in the system module BASE:
Related information
Described in:
Operations using strings Basic Characteristics - Expressions
String values Basic Characteristics - Basic Elements
Description
A symnum constant is intended to be used when checking the return value from the
functions OpMode and RunMode. See example below.
Example
IF RunMode() = RUN_CONT_CYCLE THEN
.
.
ELSE
.
.
ENDIF
Predefined data
The following symbolic constants of the data type symnum are predefined and can be
used when checking return values from the functions OpMode and RunMode
Characteristics
Symnum is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Data types in general, alias data types Basic Characteristics - Data Types
System Data
System data is the internal data of the robot that can be accessed and read by the pro-
gram. It can be used to read the current status, e.g. the current maximum velocity.
C_MOTSET Current motion settings, i.e.: motsetdata Instructions Data Types - motsetdata
- max. velocity and velocity over- - VelSet Instructions - VelSet
ride - AccSet Instructions - AccSet
- max. acceleration - SingArea Instructions - SingArea
- movement about singular points - ConfL,ConfJ Instructions - ConfL, ConfJ
- monitoring the axis configuration - PathResol Instructions - PathResol
- path resolution - MotionSup Instructions - MotionSup
- motion supervision with tunevalue - PathAccLim Instructions - PathAccLim
-reduction of TCP acceleration/ - CirPathReori Instructions - CirPathReori
deceleration along the movement
path
-modification of the tool orienta-
tion during circle interpolation
C_PROGDISP Current program displacement for progdisp Instructions Data Types - progdisp
robot and external axes. - PDispSet Instructions - PDispSet
- PDispOn Instructions - PDispOn
- PDispOff Instructions - PDispOff
- EOffsSet Instructions - EOffsSet
- EOffsOn Instructions - EOffsOn
- EOffsOff Instructions - EOffsOff
ERRNO The latest error that occurred errnum The robot Data Types - errnum
RAPID Summary -
Error Recovery
INTNO The latest interrupt that occurred intnum The robot Data Types - intnum
RAPID Summary -Inter-
rupts
The names of the program tasks are defined in the system parameters and, conse-
quently, must not be defined in the program.
Description
Data of the type taskid only contains a reference to the program task.
Limitations
Data of the type taskid must not be defined in the program. The data type can, on the
other hand, be used as a parameter when declaring a routine.
Predefined data
The program tasks defined in the system parameters can always be accessed from the
program (installed data).
For all program tasks in the system, predefined variables of the data type taskid will be
available. The variable identity will be "taskname"+"Id", e.g. for MAIN task the vari-
able identity will be MAINId, TSK1 - TSK1Id etc.
Characteristics
Taskid is a non-value data type. This means that data of this type does not permit value-
oriented operations.
Related information
Described in:
Saving program modules Instruction - Save
Configuration of program tasks User’s Guide - System Parameters
Characteristics of non-value data types Basic Characteristics - Data Types
Description
A number of predefined test signals are available in the robot system. The testsignal
data type is available in order to simplify programming of instruction TestSignDefine.
Examples
TestSignDefine 2, speed, Orbit, 2, 0;
Predefined data
The following test signals for external manipulator axes are predefined in the system.
All data is in SI units and measured on the motor side of the axis.
Characteristics
Testsignal is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Define test signal Instructions - TestSignDefine
Read test signal Functions - TestSignRead
Reset test signals Instructions - TestSignReset
If the tool is fixed in space (a stationary tool), common tool data is defined for this tool
and the gripper holding the work object.
Description
Tool data affects robot movements in the following ways:
- The tool centre point (TCP) refers to a point that will satisfy the specified path
and velocity performance. If the tool is reorientated or if coordinated external
axes are used, only this point will follow the desired path at the programmed
velocity.
- If a stationary tool is used, the programmed speed and path will relate to the
work object.
- Programmed positions refer to the position of the current TCP and the orienta-
tion in relation to the tool coordinate system. This means that if, for example,
a tool is replaced because it is damaged, the old program can still be used if the
tool coordinate system is redefined.
- Define the TCP that is not to move when the tool is reorientated.
- Define the tool coordinate system in order to facilitate moving in or rotating
about the tool directions.
It is important to always define the actual tool load and when used, the payload of the
robot too.
Incorrect definitions of load data can result in overloading of the robot mechani-
cal structure.
When incorrect tool load data is specified, it can often lead to the following conse-
quences:
- If the value in the specified load is greater than that of the value of the true load;
-> The robot will not be used to its maximum capacity
-> Impaired path accuracy including a risk of overshooting
- If the value in the specified load is less than the value of the true load;
-> Impaired path accuracy including a risk of overshooting
-> Risk of overloading the mechanical structure
Components
robhold (robot hold) Data type: bool
- The position of the TCP (x, y and z) in mm, expressed in the wrist coordinate
system (See figure 1).
- The orientation of the tool coordinate system, expressed in the wrist coordinate
system as a quaternion (q1, q2, q3 and q4) (See figure 1).
If a stationary tool is used, the definition is defined in relation to the world coor-
dinate system.
If the direction of the tool is not specified, the tool coordinate system and the
wrist coordinate system will coincide.
TCP
Y’
X
X’
Z’
Figure 18 Definition of the tool coordinate system.
TCP
IX Y’
X Tool coordinate system
X’
Z’
For more information (such as coordinate system for stationary tool or restric-
tions), see the data type loaddata.
If a stationary tool is used, the load of the gripper holding the work object must
be defined.
Note that only the load of the tool is to be specified. The payload handled by a
gripper is connected and disconnected by means of the instruction GripLoad.
Examples
PERS tooldata gripper := [ TRUE, [[97.4, 0, 223.1], [0.924, 0, 0.383 ,0]],
[5, [23, 0, 75], [1, 0, 0, 0], 0, 0, 0]];
gripper.tframe.trans.z := 225.2;
Limitations
The tool data should be defined as a persistent variable (PERS) and should not be
defined within a routine. The current values are then saved when the program is stored
on diskette and are retrieved on loading.
Arguments of the type tool data in any motion instruction should only be an entire per-
sistent (not array element or record component).
Predefined data
The tool tool0 defines the wrist coordinate system, with the origin being the centre of
the mounting flange. Tool0 can always be accessed from the program, but can never be
changed (it is stored in system module BASE).
Structure
< dataobject of tooldata >
< robhold of bool >
< tframe of pose >
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< tload of loaddata >
< mass of num >
< cog of pos >
< x of num >
< y of num >
< z of num >
< aom of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< ix of num >
< iy of num >
< iz of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Definition of payload Instructions - Gripload
Definition of load Data types - Load data
Description
A tpnum constant is intended to be used in instruction TPShow. See example below.
Example
TPShow TP_PROGRAM;
The Production Window will be active if the system is in AUTO mode and the
Program Window will be active if the system is in MAN mode, after execution
of this instruction.
Predefined data
The following symbolic constants of the data type tpnum are predefined and can be
used in instruction TPShow:
Characteristics
tpnum is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Data types in general, alias data types Basic Characteristics - Data Types
Communicating using the teach pendant RAPID Summary - Communication
Switch window on the teach pendant Instructions - TPShow
A positioning event can take the form of setting an output signal or running an interrupt
routine at a specific position along the movement path of the robot.
Description
To define the conditions for the respective measures at a positioning event, variables
of the type triggdata are used. The data contents of the variable are formed in the pro-
gram using one of the instructions TriggIO or TriggInt, and are used by one of the
instructions TriggL, TriggC or TriggJ.
Example
VAR triggdata gunoff;
The digital output signal gun is set to the value off when the TCP is at a position
5 mm before the point p1.
Characteristics
Triggdata is a non-value data type.
Related information
Described in:
Definition of triggs Instructions - TriggIO, TriggInt
Use of triggs Instructions - TriggL, TriggC,
TriggJ
Characteristics of non-value data types Basic Characteristics- Data Types
To be used in TRAP routines generated by instruction IError, before use of the instruc-
tion ReadErrData.
Description
Data of the type trapdata represents internal information related to the interrupt that
caused the current trap routine to be executed.
Its content depends on the type of interrupt.
Example
VAR errdomain err_domain;
VAR num err_number;
VAR errtype err_type;
VAR trapdata err_data;
.
TRAP trap_err
GetTrapData err_data;
ReadErrData err_data, err_domain, err_number, err_type;
ENDTRAP
When an error is trapped to the trap routine trap_err, the error domain, the error
number, and the error type are saved into appropriate non-value variables of type
trapdata.
Characteristics
trapdata is a non-value data type.
Related information
Described in:
Summary of interrupts RAPID Summary - Interrupts
More information on interrupt management Basic Characteristics - Interrupts
Non value data types Basic Characteristics - Data Types
Orders an interrupt on errors Instructions - IError
Get interrupt data for current TRAP Instructions- GetTrapData
Gets information about an error Instructions - ReadErrData
Description
A tunetype constant is intended to be used as an argument to the instruction TuneServo.
See example below.
Example
TuneServo MHA160R1, 1, 110 \Type:= TUNE_KP;
Predefined data
The following symbolic constants of the data type tunetype are predefined and can be
used as argument for the instruction TuneServo.
Characteristics
Tunetype is an alias data type for num and consequently inherits its characteristics.
Related information
Described in:
Data types in general, alias data types Basic Characteristics - Data Types
Use of data type tunetype Instructions - TuneServo
Description
If work objects are defined in a positioning instruction, the position will be based on
the coordinates of the work object. The advantages of this are as follows:
If a stationary tool or coordinated external axes are used the work object must be
defined, since the path and velocity would then be related to the work object instead of
the TCP.
Components
robhold (robot hold) Data type: bool
- TRUE-> The robot is holding the work object, i.e. using a stationary tool.
- FALSE -> The robot is not holding the work object, i.e. the robot is holding the
tool.
The mechanical unit with which the robot movements are coordinated. Only
specified in the case of movable user coordinate systems (ufprog is FALSE).
Specified with the name that is defined in the system parameters, e.g. "orbit_a".
The user coordinate system, i.e. the position of the current work surface or fixture
(see Figure 20):
- The position of the origin of the coordinate system (x, y and z) in mm.
- The rotation of the coordinate system, expressed as a quaternion (q1, q2, q3,
q4).
If the robot is holding the tool, the user coordinate system is defined in the world
coordinate system (in the wrist coordinate system if a stationary tool is used).
When coordinated external axes are used (ufprog is FALSE), the user coordinate
system is defined in the system parameters.
The object coordinate system, i.e. the position of the current work object (see Fig-
ure 20):
- The position of the origin of the coordinate system (x, y and z) in mm.
- The rotation of the coordinate system, expressed as a quaternion (q1, q2, q3,
q4).
Tool coordinates
Y
TCP
X
Z Z
Z User coordinates
Y Z Object coordinates
Z X Y
Base coordinates Y X
Y X
X
World coordinates
Figure 20 The various coordinate systems of the robot (when the robot is holding the tool).
Example
PERS wobjdata wobj2 :=[ FALSE, TRUE, "", [ [300, 600, 200], [1, 0, 0 ,0] ],
[ [0, 200, 30], [1, 0, 0 ,0] ] ];
wobj2.oframe.trans.z := 38.3;
- The position of the work object wobj2 is adjusted to 38.3 mm in the z-direction.
Limitations
The work object data should be defined as a persistent variable (PERS) and should not
be defined within a routine. The current values are then saved when the program is
stored on diskette and are retrieved on loading.
Arguments of the type work object data in any motion instruction should only be an
entire persistent (not array element or record component).
Predefined data
The work object data wobj0 is defined in such a way that the object coordinate system
coincides with the world coordinate system. The robot does not hold the work object.
Wobj0 can always be accessed from the program, but can never be changed (it is stored
in system module BASE).
PERS wobjdata wobj0 := [ FALSE, TRUE, "", [ [0, 0, 0], [1, 0, 0 ,0] ],
[ [0, 0, 0], [1, 0, 0 ,0] ] ];
Structure
< dataobject of wobjdata >
< robhold of bool >
< ufprog of bool>
< ufmec of string >
< uframe of pose >
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
< oframe of pose >
< trans of pos >
< x of num >
< y of num >
< z of num >
< rot of orient >
< q1 of num >
< q2 of num >
< q3 of num >
< q4 of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Coordinate systems Motion and I/O Principles - Coordi-
nate Systems
Coordinated external axes Motion and I/O Principles - Coordi-
nate Systems
Calibration of coordinated external axes User’s Guide - System Parameters
A world zone is supervised during robot movements both during program execution
and jogging. If the robot’s TCP reaches the world zone or if the robot/external axes
reaches the world zone in joints , the movement is stopped or a digital output signal is
set or reset.
Description
A wzstationary world zone is defined and activated by a WZLimSup or a WZDOSet
instruction.
WZLimSup or WZDOSet gives the variable or the persistent of data type stationary a
numeric value. The value identifies the world zone.
A stationary world zone is always active and is only erased by a warm start (switch
power off then on, or change system parameters). It is not possible to deactivate, acti-
vate or erase a stationary world zone via RAPID instructions.
Stationary world zones should be active from power on and should be defined in a
POWER ON event routine or a semistatic task.
Example
VAR wzstationary conveyor;
...
PROC ...
VAR shapedata volume;
...
WZBoxDef \Inside, volume, p_corner1, p_corner2;
WZLimSup \Stat, conveyor, volume;
ENDPROC
A conveyor is defined as a straight box (the volume below the belt). If the robot
reaches this volume, the movement is stopped.
Limitations
A wzstationary data can be defined as a variable (VAR) or as a persistent (PERS).
It can be global in task or local within module, but not local within a routine.
Arguments of the type wzstationary should only be entire data (not array element or
record component).
An init value for data of the type wzstationary is not used by the control system. When
there is a need to use a persistent variable in a multi-tasking system, set the init value
to 0 in both tasks,
e.g. PERS wzstationary share_workarea := [0];
Example
For a complete example see instruction WZLimSup.
Characteristics
wzstationary is an alias data type of wztemporary and inherits its characteristics.
Related information
Described in:
World Zones Motion and I/O Principles -
World Zones
World zone shape Data Types - shapedata
Temporary world zone Data Types - wztemporary
Activate world zone limit supervision Instructions - WZLimSup
Activate world zone digital output set Instructions - WZDOSet
A world zone is supervised during robot movements both during program execution
and jogging. If the robot’s TCP reaches the world zone or if the robot/external axes
reaches the world zone in joints, the movement is stopped or a digital output signal is
set or reset.
Description
A wztemporary world zone is defined and activated by a WZLimSup or a WZDOSet
instruction.
WZLimSup or WZDOSet gives the variable or the persistent of data type wztemporary
a numeric value. The value identifies the world zone.
All temporary world zones in the MAIN task are automatically erased and all data
objects of type wztemporary in the MAIN task are set to 0:
Example
VAR wztemporary roll;
...
PROC ...
VAR shapedata volume;
CONST pos t_center := [1000, 1000, 1000];
...
WZCylDef \Inside, volume, t_center, 400, 1000;
WZLimSup \Temp, roll, volume;
ENDPROC
Limitations
A wztemporary data can be defined as a variable (VAR) or as a persistent (PERS).
It can be global in a task or local within a module, but not local within a routine.
Arguments of the type wztemporary must only be entire data, not an array element or
record component.
A temporary world zone must only be defined (WZLimSup or WZDOSet) and free
(WZFree) in the MAIN task. Definitions of temporary world zones in the background
would affect the program execution in the MAIN task The instructions WZDisable and
WZEnable can be used in the background task. When there is a need to use a persistent
variable in a multi-tasking system, set the init value to 0 in both tasks,
e.g. PERS wztemporary share_workarea := [0];
Example
For a complete example see instruction WZDOSet.
Structure
<dataobject of wztemporary>
<wz of num>
Related information
Described in:
World Zones Motion and I/O Principles -
World Zones
World zone shape Data Types - shapedata
Stationary world zone Data Types - wzstationary
Activate world zone limit supervision Instructions - WZLimSup
Activate world zone digital output set Instructions - WZDOSet
Deactivate world zone Instructions - WZDisable
Activate world zone Instructions - WZEnable
Erase world zone Instructions - WZFree
Description
A position can be terminated either in the form of a stop point or a fly-by point.
A stop point means that the robot and external axes must reach the specified position
(stand still) before program execution continues with the next instruction. It is also pos-
sible to define stop points other than the predefined fine. The stop criteria, that tells if
the robot is considered to have reached the point, can be manipulated using the stop-
pointdata.
Start of reorientation
towards next position
Zones function in the same way during joint movement, but the zone size may differ
somewhat from the one programmed.
The zone size cannot be larger than half the distance to the closest position (forwards
or backwards). If a larger zone is specified, the robot automatically reduces it.
A corner path (parabola) is generated as soon as the edge of the zone is reached
(see Figure 21).
Reorientation starts as soon as the TCP reaches the extended zone. The tool is
reoriented in such a way that the orientation is the same leaving the zone as it
would have been in the same position if stop points had been programmed. Reori-
entation will be smoother if the zone size is increased, and there is less of a risk
of having to reduce the velocity to carry out the reorientation.
Figure 22 Three positions are programmed, the last with different tool orientation.
Figure 23 If all positions were stop points, program execution would look like this.
Zone size
Figure 24 If the middle position was a fly-by point, program execution would look like this
External axes start to move towards the next position as soon as the TCP reaches
the extended zone. In this way, a slow axis can start accelerating at an earlier
stage and thus execute more evenly.
Reduced zone
With large reorientations of the tool or with large movements of the external
axes, the extended zone and even the TCP zone can be reduced by the robot. The
zone will be defined as the smallest relative size of the zone based upon the zone
components (see next page) and the programmed motion.
90 mm 60 mm
MoveL with 200 mm movements pzone_ori
of the tool, 25o reorientation of pzone_tcp
P1 the tool and with zone z60 P2
The relative sizes of the zone are
pzone_tcp
________________________ = 60/200 = 30%
length of movement P1 - P2 9o
pzone_ori zone_ori
________________________ = 90/200 = 45%
length of movement P1 - P2
zone_ori
________________________ = 9o/25o = 36%
angle of reorientation P1 - P2
Figure 25 Example of reduced zone for reorientation of the tool to 36% of the motion due
to zone_ori.
P1 P2
Figure 26 Example of reduced zone for reorientation of the tool and TCP path to 15% of
the motion due to zone_ori.
When external axes are active they affect the relative sizes of the zone according to
these formulas:
pzone_eax
________________________
length of movement P1 - P2
zone_leax
________________________
length of max linear ext. axis movement P1 - P2
zone_reax
________________________
angle of max reorientation of rotating ext. axis P1 - P2
NOTE: If the TCP zone is reduced because of zone_ori, zone_leax or zone_reax the
path planner enters a mode that can handle the case of no TCP movement. If there is a
TCP movement when in this mode the speed is not compensated for the curvature of
the path in a corner zone. For instance, this will cause a 30% speed reduction in a 90
degree corner. If this is a problem, increase the limiting zone component.
Components
finep (fine point) Data type: bool
The extended zone will be defined as the smallest relative size of the zone based upon
the following components and the programmed motion.
The zone size (the radius) for the tool reorientation. The size is defined as the dis-
tance of the TCP from the programmed point in mm.
The size must be larger than the corresponding value for pzone_tcp.
If a lower value is specified, the size is automatically increased to make it the
same as pzone_tcp.
The zone size (the radius) for external axes. The size is defined as the distance of
the TCP from the programmed point in mm.
The size must be larger than the corresponding value for pzone_tcp.
If a lower value is specified, the size is automatically increased to make it the
same as pzone_tcp.
The zone size for the tool reorientation in degrees. If the robot is holding the work
object, this means an angle of rotation for the work object.
Examples
VAR zonedata path := [ FALSE, 25, 40, 40, 10, 35, 5 ];
path.pzone_tcp := 40;
Predefined data
A number of zone data are already defined in the system module BASE.
Stop points
Name
fine 0 mm
Fly-by points
Structure
< data object of zonedata >
< finep of bool >
< pzone_tcp of num >
< pzone_ori of num >
< pzone_eax of num >
< zone_ori of num >
< zone_leax of num >
< zone_reax of num >
Related information
Described in:
Positioning instructions RAPID Summary - Motion
Movements/Paths in general Motion and I/O Principles - Position-
ing during Program Execution
Configuration of external axes User’s Guide - System Parameters
Other Stop points Data Types stoppointdata
Tan 177
TestDI 183
text string 291
TextTabFreeToUse 83
time 45, 85
tooldata 301
tpnum 307
trapdata 311
triggdata 309
Trunc 189
tunetype 313
UnLoad 65
user coordinate system 315
ValToStr 191
velocity 279
wobjdata 315
work object 315
wzstationary 319
wztemporary 321