FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual - page 21

 

  Index      Manuals     FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual (MARRC75KR07091E Rev D)

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     19      20      21      22     ..

 

 

 

FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual - page 21

 

 

MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[in] jpos : JOINTPOS
[out] status :INTEGER
[in] group_no :INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the position register in which to store the position, jpos .
The position data is set in JOINTPOS representation with no conversion.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
If group_no is omitted, the default group for the program is assumed. Data for other groups
is not changed.
If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
See Also: GET_JPOS_REG, GET_POS_REG, SET_POS_REG, POS_REG_TYPE Built-in
Procedures
Example: Refer to Section B.5 ,"Using Register Built-ins" (REG_EX.KL), for a detailed program
example.
A.20.17
SET_JPOS_TPE Built-In Procedure
Purpose: Stores a JOINTPOS value in the specified position in the specified teach pendant program
Syntax : SET_JPOS_TPE(open_id, position_no, posn, status<, group_no>)
Input/Output Parameters :
[in] open_id : INTEGER
[in] position_no : INTEGER
[in] posn : JOINTPOS
[out] status : INTEGER
[in] group_no :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
A-305
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
open_id specifies the opened teach pendant program. Before calling this built-in, a program must
be opened using the OPEN_TPE Built-In, and have read/write access.
position_no specifies the position in the program in which to store the value.
The position data is set in JOINTPOS representation with no conversion.
status explains the status of the attempted operation. If not equal to 0, then an error has occurred.
If group_no is omitted, the default group for the program is assumed. Data for other groups
is not changed.
If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
See Also: GET_JPOS_TPE, GET_POS_TPE, SET_POS_TPE, GET_POS_TYP Built-in Procedures
Example: Refer to Section B.14 , "Applying Offsets to a Copied Teach Pendant Program"
(CPY.TP.KL), for a detailed program example.
A.20.18
SET_LANG Built-In Procedure
Purpose: Changes the current language
Syntax : SET_LANG(lang_name, status)
Input/Output Parameters :
[in] lang_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
lang_name specifies which language from which the dictionaries should be read/written. Use
one of the following pre-defined constants:
dp_default
dp_english
dp_japanese
dp_french
dp_german
A-306
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
dp_spanish
The read-only system variable $LANGUAGE indicates which language is currently in use.
status explains the status of the attempted operation. If not equal to 0, then an error occurred
setting the language.
The error, 33003, "No dict found for language," will be returned if no dictionaries are loaded
into the specified language. The KCL command "SHOW LANGS" can be used to view which
languages are created in the system.
See Also: Chapter 10 DICTIONARIES AND FORMS
Example: Refer to Section B.13 , "Using the DISCTRL_ALPHA Built-in" (DCALP_EX.KL), for a
detailed program example.
A.20.19
SET_PERCH Built-In Procedure
Purpose: Sets the perch position and tolerance for a group of axes
Syntax : SET_PERCH(jpos, tolerance, indx)
Input/Output Parameters :
[in] jpos : JOINTPOS
[in] tolerance : ARRAY[6] of REAL
[in] indx : INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
The values of jpos are converted to radians and stored in the system variable $REFPOS1[ indx
].$perch_pos.
The tolerance array is converted to degrees and stored in the system variable $REFPOS1[ indx
].$perchtol. If the tolerance array is uninitialized, an error is generated.
indx specifies the element number to be set in the $REFPOS1 array.
The group of axes is implied from the specified position, jpos . If JOINTPOS is not in group 1,
then the system variable $REFPOSn is used where n corresponds to the group number of jpos
and indx must beset to 1.
See Also: The appropriate application-specific FANUC Robotics Setup and Operations Manual
to setup Reference Positions
A-307
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Example: In the following example, $REFPOS1[2].$perchpos and $REFPOS1[2].$perchtol are
set according to perch_pos and tolerance[i].
SET_PERCH Built-In Procedure
VAR
perch_pos: JOINTPOS IN GROUP[1]
BEGIN
FOR i = 1 to 6 DO
tolerance[i] = 0.01
ENDFOR
SET_PERCH (perch_pos, tolerance, 2)
END
A.20.20
SET_PORT_ASG Built-In Procedure
Purpose: Allows a KAREL program to assign one or more logical ports to specified physical port(s)
Syntax : SET_PORT_ASG(log_port_type, log_port_no, rack_no, slot_no, phy_port_type,
phy_port_no, n_ports, status)
Input/Output Parameters :
[in] log_port_type : INTEGER
[in] log_port_no : INTEGER
[in] rack_no : INTEGER
[in] slot_no : INTEGER
[in] phy_port_type : INTEGER
[in] phy_port_no : INTEGER
[in] n_ports : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :IOSETUP
Details:
log_port_type specifies the code for the type of port to be assigned. Codes are defined in
KLIOTYPS.KL.
A-308
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
log_port_no specifies the number of the port to be assigned.
rack_no is the rack containing the port module. For process I/O boards, memory-image, and
dummy ports, this is zero; for Allen-Bradley and Genius ports, this is 16.
slot_no is the slot containing the port module. For process I/O boards, this is the sequence in
the SLC-2 chain. For memory-image and dummy ports, this is zero; for Allen-Bradley and
Genius ports, this is 1.
phy_port_type is the type of port to be assigned to. Often this will be the same as log_port_type .
Exceptions are if log_port_type is a group type ( io_gpin or io_gpout ) or a port is assigned
to memory-image or dummy ports.
phy_port_no is the number of the port to be assigned to. If log_port_type is a group, this is the
port number for the least-significant bit of the group.
n_ports is the number of physical ports to be assigned to the logical port. If log_port_type is a
group type, n_ports indicates the number of bits in the group. When setting digital I/O, n_ports is
the number of points you are configuring. In most cases this will be 8, but may be 1 through 8.
status is returned with zero if the parameters are valid. Otherwise, it is returned with an error
code. The assignment is invalid if the specified port(s) do not exist or if the assignment of
log_port_type to phy_port_type is not permitted.
For example, GINs cannot be assigned to DOUTs. Neither log_port_type nor phy_port_type can
be a system port type (SOPIN, for example).
Note The assignment does not take effect until the next power-up.
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.21
SET_PORT_ATR Built-In Function
Purpose: Sets the attributes of a port
Syntax : SET_PORT_ATR(port_id, atr_type, atr_value)
Function Return Type :INTEGER
Input/Output Parameters :
[in] port_id : INTEGER
[in] atr_type : INTEGER
[in] atr_value : INTEGER
%ENVIRONMENT Group :FLBT
A-309
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Details:
port_id is one of the predefined constants as follows:
port_1
port_2
port_3
port_4
atr_type specifies the attribute type to set. One of the following predefined constants should be
used:
atr_readahd :Read ahead buffer
atr_baud :Baud rate
atr_parity :Parity
atr_sbits :Stop bits
atr_dbits :Data length
atr_xonoff :XON/XOFF
atr_eol :End of line
atr_modem :Modem line
atr_value specifies the value for the attribute type. See Table A-20 on the following page which
contains acceptable pre-defined attribute types with corresponding values.
Table
A-20.
Attribute Values
ATR_TYPE
ATR_VALUE
atr_readahd
any integer, represents multiples of 128 bytes (for example: atr_value=1 means
the buffer length is 128 bytes.
atr_baud
baud_9600
baud_4800
baud_2400
baud_1200
atr_parity
parity_none
parity_even
parity_odd
A-310
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Table
A-20.
Attribute Values (Cont’d)
ATR_TYPE
ATR_VALUE
atr_sbits
sbits_1
sbits_15
sbits_2
atr_dbits
dbits_5
dbits_6
dbits_7
dbits_8
atr_xonoff
xf_not_used
xf_used
atr_eol
an ASCII code value, Refer to Appendix D , "Character Codes"
atr_modem
md_not_used
md_use_dsr
md_nouse_dsr
md_use_dtr
md_nouse_dtr
md_use_rts
md_nouse_rts
A returned integer is the status of this action to port.
See Also: SET_FILE_ATR Built-In Procedure, Section 7.3.1 , ‘‘Setting File and Port Attributes,’’
for more information
Example: Refer to the example for the GET_PORT_ATR Built_In Function.
A.20.22
SET_PORT_CMT Built-In Procedure
Purpose: Allows a KAREL program to set the comment displayed on the teach pendant, for a
specified logical port
Syntax : SET_PORT_CMT(port_type, port_no, comment_str, status)
Input/Output Parameters :
[in] port_type : INTEGER
[in] port_no : INTEGER
[in] comment_str : STRING
A-311
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[out] status : INTEGER
%ENVIRONMENT Group :IOSETUP
Details:
port_type specifies the code for the type of port whose mode is being set. Codes are defined
in KLIOTYPS.KL.
port_no specifies the port number whose mode is being set.
comment_str is a string whose value is the comment for the specified port. This must not be over
16 characters long.
status is returned with zero if the parameters are valid and the specified mode can be set for the
specified port.
See Also: SET_PORT_VALUE, SET_PORT_MOD, GET_PORT_CMT, GET_PORT_VALUE,
GET_PORT_MOD Built-in Procedures
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.23
SET_PORT_MOD Built-In Procedure
Purpose: Allows a KAREL program to set (or reset) special port modes for a specified logical port
Syntax : SET_PORT_MOD(port_type, port_no, mode_mask, status)
Input/Output Parameters :
[in] port_type : INTEGER
[in] port_no : INTEGER
[in] mode_mask : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :IOSETUP
Details:
port_type specifies the code for the type of port whose mode is being set. Codes are defined
in KLIOTYPS.KL.
port_no specifies the port number whose mode is being set.
mode_mask is a mask specifying which modes are turned on. The following modes are defined:
A-312
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
1 :reverse mode - sense of the port is reversed; if the port is set to TRUE, the physical output
is set toFALSE. If the port is set to FALSE, the physical output is set to TRUE. If a physical
input is TRUE when the port is read, FALSE is returned. If a physical input is FALSE when the
port is read, TRUE is returned.ports.
2 :complementary mode - the logical port is assigned to two physical ports whose values are
complementary. In this case, port_no must be an odd number. If port n is set to TRUE, port n is
set to TRUE, and port n + 1 is set to FALSE. If port n is set to FALSE, port n is set to FALSE
and port n + 1 is set to TRUE. This is effective only for output
Note The mode setting does not take effect until the next power-up.
status is returned with zero if the parameters are valid and the specified mode can be set for the
specified port.
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.24
SET_PORT_SIM Built-In Procedure
Purpose: Sets port simulated
Syntax : SET_PORT_SIM(port_type, port_no, value, status)
Input/Output Parameters :
[in] port_type : INTEGER
[in] port_no : INTEGER
[in] value : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :IOSETUP
Details:
port_type specifies the code for the type of port to simulate. Codes are defined in KLIOTYPS.KL.
port_no specifies the number of the port to simulate.
value specifies the initial value to set.
status is returned with zero if the port is simulated.
See Also: SET_PORT_ASG, GET_PORT_ASG, GET_PORT_SIM Built-in Procedures
A-313
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.25
SET_PORT_VAL Built-In Procedure
Purpose: Allows a KAREL program to set a specified output (or simulated input) for a specified
logical port
Syntax : SET_PORT_VAL(port_type, port_no, value, status)
Input/Output Parameters :
[in] port_type : INTEGER
[in] port_no : INTEGER
[in] value : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :IOSETUP
Details:
port_type specifies the code for the type of port whose mode is being set. Codes are defined
in KLIOTYPS.KL.
port_no specifies the port number whose mode is being set.
value indicates the value to be assigned to a specified port. If the port_type is BOOLEAN
(i.e. DOUT), this should be 0 = OFF, or 1 = ON. This field can be used to set input ports if
the port is simulated.
status is returned with zero if the parameters are valid and the specified mode can be set for the
specified port.
See Also: SET_PORT_VALUE, SET_PORT_MOD, GET_PORT_CMT, GET_PORT_VALUE,
GET_PORT_MOD Built-in Procedures
Example: The following example sets the value for a specified port.
SET_PORT_VAL Built-In Procedure
PROGRAM setvalprog
%ENVIRONMENT IOSETUP
%INCLUDE FR:\kliotyps
ROUTINE set_value(port_type: INTEGER;
port_no: INTEGER;
A-314
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
g_value: BOOLEAN): INTEGER
VAR
value: INTEGER
status: INTEGER
BEGIN
IF g_value THEN
value = 1
ELSE
value = 0;
ENDIF
SET_PORT_VAL (port_type, port_no, value, status)
RETURN (status)
END set_value
BEGIN
END setvalprog
A.20.26
SET_POS_REG Built-In Procedure
Purpose: Stores an XYZWPR value in the specified position register
Syntax : SET_POS_REG(register_no, posn, status<, group_no>)
Input/Output Parameters :
[in] register_no : INTEGER
[in] posn : XYZWPR
[out] status : INTEGER
[in] group_no : INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the position register in which to store the value.
The position data is set in XYZWPR representation with no conversion.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
If group_no is omitted, the default group for the program is assumed. Data for other groups
is not changed.
If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
A-315
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Example: Refer to Section B.5 ,"Using Register Built-ins" (REG_EX.KL), for a detailed program
example.
A.20.27
SET_POS_TPE Built-In Procedure
Purpose: Stores an XYZWPR value in the specified position in the specified teach pendant program
Syntax : SET_POS_TPE(open_id, position_no, posn, status<, group_no>)
Input/Output Parameters :
[in] open_id : INTEGER
[in] position_no : INTEGER
[in] posn : XYZWPR
[out] status : INTEGER
[in] group_no : INTEGER
%ENVIRONMENT Group :PBCORE
Details:
open_id specifies the opened teach pendant program. Before calling this built-in, a program must
be opened using the OPEN_TPE Built-In, and have read/write access.
position_no specifies the position in the program in which to store the value.
A motion instruction must already exist that uses the position_no or the position will not be
used by the teach pendant program.
The position data is set in XYZWPR representation with no conversion.
status explains the status of the attempted operation. If not equal to 0, then an error has occurred.
If group_no is omitted, the default group for the program is assumed. Data for other groups
is not changed.
If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
Example: Refer to Section B.14 , "Applying Offsets to a Copied Teach Pendant Program"
(CPY_TP.KL), for a detailed program example.
A-316
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.20.28
SET_PREG_CMT Built-In-Procedure
Purpose: To set the comment information of a KAREL position register based on a given register
number and a given comment.
Syntax: SET_PREG_CMT (register_no, comment_string, status)
Input/Output Parameters:
[in] register_no: INTEGER
[in] comment_string: STRING
[out] status: INTEGER
%ENVIRONMENT group: REGOPE
A.20.29
SET_REAL_REG Built-In Procedure
Purpose: Stores a REAL value in the specified register
Syntax : SET_REAL_REG(register_no, real_value, status)
Input/Output Parameters :
[in] register_no : INTEGER
[in] real_value : REAL
[out] status : INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the register into which real_value will be stored.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: SET_INT_REG, GET_REAL_REG, GET_INT_REG Built-in Procedures
A.20.30
SET_REG_CMT Built-In-Procedure
Purpose: To set the comment information of a KAREL register based on a given register number
and a given comment.
A-317
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Syntax: SET_REG_CMT (register_no, comment_string, status
Input/Output Parameters:
[in] register_no: INTEGER
[in] comment_string: STRING
[out] status: INTEGER
%ENVIRONMENT group REGOPE
Details:
Register_no specifies which register to retrieve the comments from. The comment_string
represents the data which is to be used to set the comment of the given register. If the
comment_string exceeds more than 16 characters, the built-in will truncate the string.
A.20.31 SET_SREG_CMT Built-in Procedure
Purpose: Sets the comment for the specified string register.
Syntax : SET_SREG_CMT(register_no, comment, status)
Input/Output Parameters:
[in] register_no :INTEGER
[in] comment :STRING[254]
[out] status :INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the string register to get.
comment contains the comment to set to the specified string register.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: GET_STR_REG, GET_SREG_CMT, SET_STR_REG Built-in Procedures.
A-318
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.20.32 SET_STR_REG Built-in Procedure
Purpose: Sets the value for the specified string register.
Syntax : SET_STR_REG(register_no, value, status)
Input/Output Parameters:
[in] register_no :INTEGER
[in] value :STRING[254]
[out] status :INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the string register to get.
value contains the value to set to the specified string register.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: GET_STR_REG, GET_SREG_CMT, SET_SREG_CMT Built-in Procedures.
A.20.33
SET_TIME Built-In Procedure
Purpose: Set the current time within the KAREL system
Syntax : SET_TIME(i)
Input/Output Parameters :
[in] i : INTEGER
%ENVIRONMENT Group :TIM
Details:
i holds the INTEGER representation of time within the KAREL system. This value is represented
in 32-bit INTEGER format as follows:
A-319
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Table
A-21.
32-Bit INTEGER Format of Time
31-25
24-21
20-16
year
month
day
15-11
10-5
4-0
hour
minute
second
The contents of the individual fields are as follows:
— DATE:
Bits 15-9 — Year since 1980
Bits 8-5 — Month (1-12)
Bits 4-0 — Day of the month
— TIME:
Bits 31-25 — Number of hours (0-23)
Bits 24-21 — Number of minutes (0-59)
Bits 20-16 — Number of 2-second increments (0-29)
This value can be determined using the GET_TIME and CNV_STR_TIME Built-In procedures.
If i is 0, the time on the system will not be changed.
INTEGER values can be compared to determine if one time is more recent than another.
See Also: CNV_STR_TIME, GET_TIME Built-In Procedures
Example: The following example converts the STRING variable str_time , input by the user in
‘‘DD-MMM-YYY HH:MM:SS’’ format, to the INTEGER representation of time int_time using the
CNV_STR_TIME Built-In procedure. SET_TIME is then used to set the time within the KAREL
system to the time specified by int_time .
SET_TIME Built-In Procedure
WRITE(’Enter the new time : ’)
READ(str_time)
CNV_STR_TIME(str_time,int_time)
SET_TIME(int_time)
A-320
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.20.34
SET_TPE_CMT Built-In Procedure
Purpose: Provides the ability for a KAREL program to set the comment associated with a specified
position in a teach pendant program.
Syntax : SET_TPE_CMT(open_id, pos_no, comment, status)
Input/Output Parameters :
[in] open_id :INTEGER
[in] pos_no :INTEGER
[in] comment :STRING
[out] status :INTEGER
%ENVIRONMENT Group :TPE
Details:
open_id specifies the open_id returned from a previous call to OPEN_TPE. An open mode of
TPE_RWACC must be used in the OPEN_TPE call.
pos_id specifies the number of the position in the teach pendant program to get a comment from.
The specified position must have been recorded.
comment is the comment to be associated with the specified position. A zero length string can be
used to ensure that a position has no comment. If the string is over 16 characters, it is truncated
and used and a warning error is returned.
status indicates zero if the operation was successful, otherwise an error code will be displayed.
See Also: GET_TPE_CMT and OPEN_TPE for more Built-in Procedures.
A.20.35
SET_TRNS_TPE Built-In Procedure
Purpose: Stores a POSITION value within the specified position in the specified teach pendant
program
Syntax : SET_TRNS_TPE(open_id, position_no, posn, status)
Input/Output Parameters :
[in] open_id : INTEGER
A-321
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[in] position_no : INTEGER
[in] posn : POSITION
[out] status : INTEGER
%ENVIRONMENT Group :PBCORE
Details:
open_id specifies the opened teach pendant program. A program must be opened before calling
this built-in.
position_no specifies the position in the program in which to store the value specified by posn .
Data for other groups is not changed.
The position data is set in POSITION representation with no conversion.
posn is the group number of position_no .
status explains the status of the attempted operation. If not equal to 0, then an error has occurred.
A.20.36
SET_TSK_ATTR Built-In Procedure
Purpose: Set the value of the specified running task attribute
Syntax : SET_TSK_ATTR(task_name, attribute, value, status)
Input/Output Parameters :
[in] task_name : STRING
[in] attribute : INTEGER
[in] value : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :PBCORE
Details:
task_name is the name of the specified running task. A blank task_name will indicate the calling
task.
attribute is the task attribute whose value is to be set. The following attributes are valid:
A-322
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
TSK_PRIORITY :Priority, see %PRIORITY for value information
TSK_TIMESLIC :Time slice duration, see %TIMESLICE for value information
TSK_NOBUSY :Busy lamp off, see %NOBUSYLAMP
TSK_NOABORT :Ignore abort request
Pg_np_error :no abort on error
Pg_np_cmd :no abort on command
TSK_NOPAUSE :Ignore pause request
pg_np_error :no pause on error
pg_np_end :no pause on command when TP is enabled
pg_np_tpenb :no pause
TSK_TRACE :Trace enable
TSK_TRACELEN :Maximum number of lines to store when tracing
TSK_TPMOTION :TP motion enable, see %TPMOTION for value information
TSK_PAUSESFT :Pause on shift, reverse of %NOPAUSESHFT
value depends on the task attribute being set.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: GET_TSK_INFO Built-in Procedure
Example: See examples in Chapter 15 MULTI-TASKING
A.20.37
SET_TSK_NAME Built-In Procedure
Purpose: Set the name of the specified task
Syntax : SET_TSK_NAME(old_name, new_name, status)
Input/Output Parameters :
[in] old_name : STRING
A-323
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[in] new_name : STRING
[out] status : INTEGER
%ENVIRONMENT Group :MULTI
Details:
task_name is the name of the task of interest. A blank task_name will indicate the calling task.
new_name will become the new task name.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: GET_ATTR_PRG Built-in Procedure
Example: See examples in Chapter 15 MULTI-TASKING
A.20.38
SET_VAR Built-In Procedure
Purpose: Allows a KAREL program to set the value of a specified variable
Syntax : SET_VAR(entry, prog_name, var_name, value, status)
Input/Output Parameters :
[in,out] entry : INTEGER
[in] prog_name : STRING
[in] var_name : STRING
[in] value : Any valid KAREL data type except PATH
[out] status : INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
entry returns the entry number in the variable data table of var_name in the device directory
where var_name is located. This variable should not be modified.
prog_name specifies the name of the program that contains the specified variable. If prog_name
A-324
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
is ’’, then it defaults to the current task name being executed. prog_name can also access a
system variable on a robot in a ring.
Use prog_name of ’*SYSTEM*’ to set a system variable.
var_name must refer to a static variable.
var_name can contain node numbers, field names, and/or subscripts.
If both var_name and value are ARRAYs, the number of elements copied will equal the size of
the smaller of the two arrays.
If both var_name and value are STRINGs, the number of characters copied will equal the size of
the smaller of the two strings.
If both var_name and value are STRUCTUREs of the same type, value will be an exact copy
of var_name .
var_name will be set to value .
If value is uninitialized, the value of var_name will be set to uninitialized and status will be set to
12311. value must be a static variable within the calling program.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
Caution
Using SET_VAR to modify system variables could cause unexpected results.
The designated names of all the robots can be found in the system variable $PH_MEMBERS[].
This also include information about the state of the robot. The ring index is the array index for
this system variable. KAREL users can write general purpose programs by referring to the names
and other information in this system variable rather than explicit names.
See Also: CREATE_VAR, RENAME_VAR Built-In Procedures, Internet Options Manual for
information on accessing system variables on a robot in a ring.
Example 1:To access $TP_DEFPROG on the MHROB03 robot in a ring, see Accessing
$TP_DEFPROG on MHROB03 .
Accessing $TP_DEFPROG on MHROB03
SET_VAR(entry, ’\\MHROB03\*system*’, ’$TP_DEFPROG’, strvar, status)
Example 2: In GET_VAR SET_VAR Example , an array [ipgetset]set_data[x,y] is set on all robots in
the ring from all robots in the ring. In this array x is the source robot index and y is the destination
robot index:
GET_VAR SET_VAR Example
A-325
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
FOR idx = 1 TO $PH_ROSIP.$NUM_MEMBERS DO
IF idx = $PH_ROSIP.$MY_INDEX THEN
-- This will work but it this robot so is inefficient
ELSE
SELECT $PH_MEMBERS[idx].$STATE OF
CASE (0) : -- Offline
sstate = ’ Offline’
CASE (1) : -- Online
sstate = ’ Online ’
CASE (2) : -- Synchronized
sstate = ’ Synch
CNV_INT_STR(idx, 1, 10, sidx)
prog_name = ’\\’ + $PH_MEMBERS[idx].$NAME + ’\ipgetset’
var_name = ’set_data[’+ smy_index + ’,’ + sidx + ’]’
GET_VAR(entry, prog_name, var_name, set_data[$PH_ROSIP.$MY_INDEX,
idx], status[idx])
IF status[idx] = 0 THEN
IF uninit(set_data[$PH_ROSIP.$MY_INDEX, idx]) THEN
set_data[$PH_ROSIP.$MY_INDEX, idx] = 0
ELSE
set_data[$PH_ROSIP.$MY_INDEX, idx] = set_data[$PH_ROSIP.$MY_INDEX,
idx] + 1
ENDIF
SET_VAR(entry, prog_name, var_name, set_data[$PH_ROSIP.$MY_INDEX, idx],
status[idx])
ENDIF
ENDSELECT
ENDIF
ENDFOR
Example 3: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example.
Example 4 GET_VAR and SET_VAR can also be used to set register values.
This will work for the local robot with the program names *posreg* and *numreg*. For the local robot
this has similar functionality to the GET_POS_REG, GET_REG and SET_REG, SET_POS_REG
built-ins. The built-ins only work for the local robot. You can access robots in the ring via GET_VAR
and SET_VAR by using the robot name as part of the program name.
For the case of SET_VAR on numeric registers the register type will be set to the type of the KAREL
variable. In the example below after executing this code numeric register 20 will be an integer and
numeric register 21 will be a real.
If a position register is locked and you attempt to set it the error position register locked is returned.
See Using GET_VAR and SET_VAR To Set Register Values .
A-326
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Using GET_VAR and SET_VAR To Set Register Values
program GETREG
%nolockgroup
VAR
entry: integer
status: integer
int_data: integer
real_data: real
posext_data: xyzwprext
BEGIN
GET_VAR(entry, ’\\mhrob01\*numreg*’, ’$NUMREG[10]’, int_data, status)
IF status <> 0 THEN
GET_VAR(entry, ’\\mhrob01\*numreg*’, ’$NUMREG[10]’, real_data, status)
ENDIF
GET_VAR(entry, ’\\mhrob01\*posreg*’, ’$POSREG[1, 10]’, posext_data, status)
SET_VAR(entry, ’\\mhrob01\*numreg*’, ’$NUMREG[20]’, int_data, status)
SET_VAR(entry, ’\\mhrob01\*numreg*’, ’$NUMREG[21]’, real_data, status)
SET_VAR(entry, ’\\mhrob01\*posreg*’, ’$POSREG[1, 20]’, posext_data, status)
end GETREG
A.20.39
%SHADOWVARS Translator Directive
Purpose: This directive specifies that all variables by default are created in SHADOW.
Syntax : %SHADOWVARS
A.20.40
SHORT Data Type
Purpose: Defines a variable as a SHORT data type
Syntax : SHORT
Details:
SHORT, is defined as 2 bytes with the range of (-32768 <= n >= 32766). A SHORT variable
assigned to (32767) is considered uninitialized.
SHORTs are allowed only within an array or within a structure.
A-327
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
SHORTs can be assigned to BYTEs and INTEGERs, and BYTEs and INTEGERs can be assigned
to SHORTs. An assigned value outside the SHORT range is detected during execution and
causes the program to be aborted.
A.20.41
SIGNAL EVENT Action
Purpose: Signals an event that might satisfy a condition handler or release a waiting program
Syntax : SIGNAL EVENT[event_no]
where:
event_no : an INTEGER expression
Details:
You can use the SIGNAL EVENT action to indicate a user-defined event has occurred.
event_no occurs when signaled and is not remembered. Thus, if a WHEN clause has the event as
its only condition, the associated actions will occur.
If other conditions are specified that are not met at the time the event is signaled, the actions are
not taken, even if the other conditions are met at another time.
event_no must be in the range of -32768 to 32767. Otherwise, the program is aborted with an error.
See Also: EVENT Condition
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.42
SIGNAL EVENT Statement
Purpose: Signals an event that might satisfy a condition handler or release a waiting program
Syntax : SIGNAL EVENT [event_no]
where:
event_no : an INTEGER
Details:
You can use the SIGNAL EVENT statement to indicate a user-defined event has occurred.
event_no occurs when signaled and is not remembered. Thus, if a WHEN clause has the event as
its only condition, the associated actions will occur.
A-328
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
If other conditions are specified that are not met at the time the event is signaled, the actions are
not taken, even if the other conditions are met at another time.
event_no must be in the range of -32768 to 32767. Otherwise, the program is aborted with an error.
See Also: Appendix E , ‘‘Syntax Diagrams’’ for more syntax information, EVENT Condition
Example: Refer to the DISABLE CONDITION Statement example program.
A.20.43
SIGNAL SEMAPHORE Action
Purpose: Adds one to the value of the indicated semaphore
Syntax : SIGNAL SEMAPHORE[semaphore_no]
where:
semaphore_no : an INTEGER expression
Details:
The semaphore indicated by semaphore_no is incremented by one.
semaphore_no must be in the range of 1 to the number of semaphores defined on the controller.
See Also: Section 15.8 , "Task Communication" for more information and examples.
A.20.44
SIN Built-In Function
Purpose: Returns a REAL value that is the sine of the specified angle argument
Syntax : SIN(angle)
Function Return Type :REAL
Input/Output Parameters :
[in] angle : REAL
%ENVIRONMENT Group :SYSTEM
Details:
angle specifies an angle in degrees.
A-329
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
angle must be in the range of ± 18000 degrees. Otherwise, the program will be aborted with an
error.
Example: Refer to Section B.8 , "Generating and Moving Along a Hexagon Path" (GEN_HEX.KL),
for a detailed program example.
A.20.45
SQRT Built-In Function
Purpose: Returns a REAL value that is the positive square root of the specified REAL argument
Syntax : SQRT(x)
Function Return Type :REAL
Input/Output Parameters :
[in] x : REAL
%ENVIRONMENT Group :SYSTEM
Details:
x must not be negative. Otherwise, the program will be aborted with an error.
Example: The following example calculates the square root of the expression (a*a+b*b) and indicates
that this is the hypotenuse of a triangle.
SQRT Built-In Function
c = SQRT(a*a+b*b)
WRITE (’The hypotenuse of the triangle is ’,c::6::2)
A.20.46
%STACKSIZE Translator Directive
Purpose: Specifies stack size in long words.
Syntax : %STACKSIZE = n
Details:
n is the stack size.
The default value of n is 300 (1200 bytes).
A-330
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
See Also: Section 5.1.6 , ‘‘Stack Usage,’’ for information on computing stack size
A.20.47
STD_PTH_NODE Data Type
Purpose: Defines a data type for use in PATHs.
Syntax : STD_PTH_NODE = STRUCTURE
node_pos : POSITION in GROUP[1]
group_data : GROUP_ASSOC in GROUP[1] (no longer used)
common_data : COMMON_ASSOC (no longer used)
ENDSTRUCTURE
Details:
If the NODEDATA clause is omitted from the PATH declaration, then STD_PTH_NODE will
be the default.
Each node in the PATH will be of this type.
A.20.48
STOP Action
Purpose: Stops any motion in progress, leaving it in a resumable state
Syntax : STOP <GROUP[n{,n}]>
Details:
Any motion in progress is decelerated to a stop. The unfinished motion as well as any pending
motions are grouped together in a motion set and placed on a stack.
More than one motion might be stacked by a single STOP action.
If the KAREL program was waiting for the completion of the motion in progress, it will continue
to wait.
The stacked motion set can be removed from the stack and restarted with either a RESUME
statement or action or by issuing RESUME from the operator interface (CRT/KB).
If the group clause is not present, all groups for which the task has control (when the condition is
defined) will be stopped.
If the motion that is stopped, resumed, canceled, or held is part of a SIMULTANEOUS or
COORDINATED motion with other groups, the motions for all groups are stopped, resumed,
canceled, or held.
A-331
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Motion cannot be stopped for a different task.
See Also: RESUME Statement
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.20.49
STOP Statement
Purpose: Stops any motion in progress, leaving it in a resumable state
Syntax : STOP <GROUP[n{,n}]>
Details:
Any motion in progress is decelerated to a stop. The unfinished motion as well as any pending
motions are grouped together in a motion set and placed on a stack.
More than one motion might be stacked by a single STOP statement.
If the KAREL program was waiting for the completion of the motion in progress, it will continue
to wait.
The stacked motion set can be removed from the stack and restarted with either a RESUME
statement or action, or by issuing RESUME from the CRT/KB.
If the group clause is not present, all groups for which the task has control will be stopped.
If the motion that is stopped, resumed, canceled, or held is part of a SIMULTANEOUS or
COORDINATED motion with other groups, the motions for all groups are stopped, resumed,
canceled, or held.
Motion cannot be stopped for a different task.
See Also: RESUME Action, RESUME Statement, Appendix E , ‘‘Syntax Diagrams,’’ for more
syntax information
Example: The following example stops motion if the digital input is ON.
STOP Statement
IF DIN[2] THEN
STOP
ENDIF
A-332
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.20.50
STRING Data Type
Purpose: Defines a variable or routine parameter as STRING data type
Syntax : STRING[length]
where:
length : an INTEGER constant or literal
Details:
length , the physical length of the string, indicates the maximum number of characters for which
space is allocated for a STRING variable.
length must be in the range 1 through 254 and must be specified in a STRING variable declaration.
A length value is not used when declaring STRING routine parameters; a STRING of any length
can be passed to a STRING parameter.
Attempting to assign a STRING to a STRING variable that is longer than the physical length
of the variable results in the STRING value being truncated on the right to the physical length
of the STRING variable.
Only STRING expressions can be assigned to STRING variables or passed as arguments to
STRING parameters.
STRING values cannot be returned by functions.
Valid STRING operators are:
— Relational operators (>, >=, =, <>, <, and <=)
— Concatenation operator (+)
STRING literals consist of a series of ASCII characters enclosed in single quotes (apostrophes).
Examples are given in the following table.
Table
A-22.
Example STRING Literals
VALID
INVALID
REASON
‘123456’
123456
Without quotes 123456 is an INTEGER literal
Example: Refer to the following sections for detailed program examples:
Section B.2 , "Copying Path Variables" (CPY_PTH.KL)
Section B.3 , "Saving Data to the Default Device" (SAVE_VR.KL)
Section B.7 , "Listing Files and Programs and Manipulating Strings" (LIST_EX.KL)
A-333
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Section B.9 , "Using the File and Device Built-ins" (FILE_EX.KL)
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL)
Section B.13 , "Using the DISCTRL_ALPHA Built-in" (DCALP_EX.KL)
Section B.14 , "Applying Offsets to a Copied Teach Pendant Program" (CPY_TP.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.20.51
STR_LEN Built-In Function
Purpose: Returns the current length of the specified STRING argument
Syntax : STR_LEN(str)
Function Return Type :INTEGER
Input/Output Parameters :
[in] str : STRING
%ENVIRONMENT Group :SYSTEM
Details:
The returned value is the length of the STRING currently stored in the str argument, not the
maximum length of the STRING specified in its declaration.
Example: Refer to Section B.12 , "Displaying a List from a Dictionary File" (DCLST_EX.KL) for a
detailed program example.
A.20.52
STRUCTURE Data Type
Purpose: Defines a data type as a user-defined structure
Syntax : new_type_name = STRUCTURE
field_name_1: type_name_1
field_name_2: type_name_2
A-334
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
ENDSTRUCTURE
Details:
A user-defined structure is a data type consisting of a list of component fields, each of which can
be a standard data type or another, previously defined, user data type.
When a program containing variables of user-defined types is loaded, the definitions of these
types is checked against a previously created definition. If this does not exist, it is created.
The following data types are not permitted as part of a data structure:
— STRUCTURE definitions (types that are declared structures are permitted)
— PATH types
— FILE types
— Vision types
— Variable length arrays
— The data structure itself, or any type that includes it, either directly or indirectly
A variable may not be defined as a structure, but as a data type previously defined as a structure
See Also: Section 2.4.2 , ‘‘User-Defined Data Structures’’
Example: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example.
A.20.53
SUB_STR Built-In Function
Purpose: Returns a copy of part of a specified STRING argument
Syntax : SUB_STR(src, strt, len)
Function Return Type :STRING
Input/Output Parameters :
[in] src : STRING
[in] strt : INTEGER
[in] len : INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
A-335

 

 

 

 

 

 

 

Content      ..     19      20      21      22     ..