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

 

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

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     11      12      13      14     ..

 

 

 

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

 

 

MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[in] open_id :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
open_id indicates the teach pendant program to close. All teach pendant programs that are opened
must be closed before they can be executed. Any unclosed programs remain opened until the
KAREL program which opened it is aborted or runs to completion.
status explains the status of the attempted operation. If not equal to 0, then an error has occurred.
See Also: OPEN_TPE Built-In Procedure
Example: Refer to Section B.14 , "Applying Offsets to a Copied Teach Pendant Program"
(CPY_TP.KL), for a detailed program example.
A.4.15
CLR_IO_STAT Built-In Procedure
Purpose: Clear the results of the last operation on the file argument
Syntax : CLR_IO_STAT(file_id)
Input/Output Parameters :
[in] file_id :FILE
%ENVIRONMENT Group :PBCORE
Details:
Causes the last operation result on file_id , which is returned by IO_STATUS, to be cleared to zero.
See Also: I/O-STATUS Built-In Function
Example: Refer to Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL), for a
detailed program example.
A.4.16
CLR_PORT_SIM Built-In Procedure
Purpose: Sets the specified port to be unsimulated
Syntax : CLR_PORT_SIM(port_type, port_no, status)
A-57
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Input/Output Parameters :
[in] port_type :INTEGER
[in] port_no :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :iosetup
Details:
port_type specifies the code for the type of port to unsimulate. Codes are defined in
FR:KLIOTYPS.KL.
port_no specifies the port number to unsimulate.
status is returned with zero if parameters are valid and the simulation of the specified port
is cleared.
See Also: GET_PORT_SIM, SET_PORT_SIM Built-In Procedures
A.4.17
CLR_POS_REG Built-In Procedure
Purpose: Removes all data for the specified group in the specified position register
Syntax : CLR_POS_REG(register_no, group_no, status)
Input/Output Parameters :
[in] register_no :INTEGER
[in] group_no :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :REGOPE
Details:
register_no specifies the register number whose data should be cleared.
If group_no is zero, data for all groups is cleared.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: SET_POS_REG Built-In Procedure, GET_POS_REG Built-In Function
Example: The following example clears the first 100 position registers.
A-58
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
CLR_POS_REG Built-In Procedure
FOR register_no = 1 to 100 DO
CLR_POS_REG(register_no, 0, status)
ENDFOR
A.4.18
%CMOSVARS Translator Directive
Purpose: Specifies the default storage for KAREL variables is permanent memory
Syntax : %CMOSVARS
Details:
If %CMOSVARS is specified in the program, then all static variables by default will be created in
permanent memory.
If %CMOSVARS is not specified, then all static variables by default will be created in temporary
memory.
If a program specifies %CMOSVARS, but not all static variables need to be created in permanent
memory, the IN DRAM clause can be used on selected variables.
See Also: Section A.10.2 IN DRAM Clause
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DCLST_EX.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.4.19
%CMOS2SHADOW Translator Directive
Purpose: Instructs the translator to put all CMOS variables in Shadow memory
Syntax : %CMOS2SHADOW
A.4.20
CNC_DYN_DISB Built-In Procedure
Purpose: Cancels the dynamic display based on the value of a BOOLEAN variable in a specified
window.
Syntax : CNC_DYN_DISB (b_var, window_name, status)
A-59
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Input/Output Parameters :
[in] b_var :BOOLEAN
[in] window_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
b_var is the boolean variable whose dynamic display is to be canceled.
window_name must be a previously defined window name. See Section 7.10.1 . and Section
7.10.2 for predefined window names.
If there is more than one display active for this variable in this window, all the displays are
canceled.
status returns an error if there is no dynamic display active specifying this variable and window.
If not equal to 0, then an error occurred.
See Also: INI_DYN_DISB Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A.4.21
CNC_DYN_DISE Built-In Procedure
Purpose: Cancels the dynamic display based on the value of an INTEGER variable in a specified
window.
Syntax : CNC_DYN_DISe (e_var, window_name, status)
Input/Output Parameters :
[in] e_var :INTEGER
[in] window_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
A-60
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Details:
e_var is the integer variable whose dynamic display is to be canceled.
Refer to the CNC_DYN_DISB built-in procedure for a description of the other parameters
listed above.
See Also: INI_DYN_DISE Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A.4.22
CNC_DYN_DISI Built-In Procedure
Purpose: Cancels the dynamic display of an INTEGER variable in a specified window.
Syntax : CNC_DYN_DISI(int_var, window_name, status)
Input/Output Parameters :
[in] int_var :INTEGER
[in] window_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
int_var is the integer variable whose dynamic display is to be canceled.
Refer to the CNC_DYN_DISB built-in procedure for a description of the other parameters
listed above.
See Also: INI_DYN_DISI Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A-61
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.4.23
CNC_DYN_DISP Built-In Procedure
Purpose: Cancels the dynamic display based on the value of a port in a specified window.
Syntax : CNC_DYN_DISP(port_type, port_no, window_name, status)
Input/Output Parameters :
[in] port_type :INTEGER
[in] port_no :INTEGER
[in] window_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
port_type and port_no are integer values specifying the port whose dynamic display is to be
canceled.
Refer to the CNC_DYN_DISB built-in procedure for a description of the other parameters
listed above.
See Also: INI_DYN_DISP Built-In Procedure for information on port_type codes.
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A.4.24
CNC_DYN_DISR Built-In Procedure
Purpose: Cancels the dynamic display of a REAL number variable in a specified window.
Syntax : CNC_DYN_DISR(real_var, window_name, status)
Input/Output Parameters :
[in] real_var :REAL
[in] window_name :STRING
[out] status :INTEGER
A-62
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
%ENVIRONMENT Group :UIF
Details:
real_var is the REAL variable whose dynamic display is to be canceled.
Refer to the CNC_DYN_DISB built-in procedure for a description of the other parameters
listed above.
See Also: INI_DYN_DISR Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A.4.25
CNC_DYN_DISS Built-In Procedure
Purpose: Cancels the dynamic display of a STRING variable in a specified window.
Syntax : CNC_DYN_DISS(str_var, window_name, status)
Input/Output Parameters :
[in] str_var :STRING
[in] window_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
str_var is the STRING variable whose dynamic display is to be canceled.
Refer to the CNC_DYN_DISB built-in procedure for a description of the other parameters
listed above.
See Also: INI_DYN_DISS Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.10 , "Using Dynamic Display Built-ins" (DYN_DISP.KL)
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
A-63
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.4.26
CNCL_STP_MTN Built-In Procedure
Purpose: Cancels all stopped motions
Syntax : CNCL_STP_MTN
%ENVIRONMENT Group :motn
All stopped motions will be canceled for all groups that the program controls.
The statements following the motion statements will be executed.
CNCL_STP_MTN will have no effect if no motions are currently stopped.
Motion cannot be cancelled for a different task.
Example: The following example will cancel all stopped motions for all groups that the program
controls after an emergency stop has occurred.
CNCL_STP_MTN Built-In Procedure
ROUTINE e_stop_hndlr
BEGIN
CNCL_STP_MTN
END e_stop_hndlr
CONDITION[100]:
WHEN ERROR[estop] DO
UNPAUSE
ENABLE CONDITION[100]
e_stop_hndlr
END CONDITION
ENABLE CONDITION[100]
A.4.27 CNV_CNF_STRG Built-In Procedure
Purpose: Converts the specified CONFIG into a STRING using an optional group_no
Syntax : CNV_CNF_STRG(source, target <,group_no>)
Input/Output Parameters :
[in] source :CONFIG
[out] target :STRING
[in] group_no :INTEGER
A-64
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
%ENVIRONMENT Group :STRNG
Details:
target receives the STRING form of the configuration specified by source .
target must be long enough to accept a valid configuration string for the robot arm attached to the
controller. Otherwise, the program will be aborted with an error.
Using a length of 25 is generally adequate because the longest configuration string of any robot is
25 characters long.
The config mask from group_no is used during conversion. If group_no is omitted, then default
group for the program is assumed.
If group_no is specified, it must be in the range 1 to the total number of groups defined on
the controller.
See Also: CNV_STR_CONF Built-In Procedure
Example: The following example converts the configuration from position posn into a STRING and
puts it into config_string using the configuration mask from group 2. The string is then displayed on
the screen.
CNV_CNF_STRG Built-In Procedure
CNV_CNF_STRG(posn.pos_config, config_string, 2)
WRITE(’Configuration of posn in group 2: ’, config_string, cr)
A.4.28
CNV_CONF_STR Built-In Procedure
Purpose: Converts the specified CONFIG into a STRING
Syntax : CNV_CONF_STR(source, target)
Input/Output Parameters :
[in] source :CONFIG
[out] target :STRING
%ENVIRONMENT Group :STRNG
Details:
target receives the STRING form of the configuration specified by source .
A-65
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
target must be long enough to accept a valid configuration string for the robot arm attached to the
controller. Otherwise, the program will be aborted with an error.
Using a length of 25 is generally adequate because the longest configuration string of any robot is
25 characters long.
See Also: CNV_STR_CONF Built-In Procedure
Example: The following example converts the configuration from position posn into a STRING and
puts it into config_string . The string is then displayed on the screen.
CNV_CONF_STR Built-In Procedure
CNV_CONF_STR(posn.pos_config, config_string)
WRITE(’Configuration of posn: ’, config_string, cr)
A.4.29
CNV_INT_STR Built-In Procedure
Purpose: Formats the specified INTEGER into a STRING
Syntax : CNV_INT_STR(source, length, base, target)
Input/Output Parameters :
[in] source :INTEGER expression
[in] length :INTEGER expression
[in] base :INTEGER expression
[out] target :STRING expression
%ENVIRONMENT Group :PBCORE
Details:
source is the INTEGER to be formatted into a STRING.
length specifies the minimum length of the target . The actual length of target may be greater if
required to contain the contents of source and at least one leading blank.
base indicates the number system in which the number is to be represented. base must be in
the range 2-16 or 0 (zero) indicating base 10.
If the values of length or base are invalid, target is returned uninitialized.
If target is not declared long enough to contain source and at least one leading blank, it is returned
with one blank and the rest of its declared length filled with ‘‘*".
A-66
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
See Also: CNV_STR_INT Built-In Procedure
Example: Refer to the following section for detailed program examples:
Section B.7 , "Listing Files and Programs and Manipulating Strings" (LIST_EX.KL)
A.4.30
CNV_JPOS_REL Built-In Procedure
Purpose: Allows a KAREL program to examine individual joint angles as REAL values
Syntax : CNV_JPOS_REL(jointpos, real_array, status)
Input/Output Parameters :
[in] joint_pos :JOINTPOS
[out] real_array :ARRAY [num_joints] OF REAL
[out] status :INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
joint_pos is one of the KAREL joint position data types: JOINTPOS, or JOINTPOS1 through
JOINTPOS9.
num_joints can be smaller than the number of joints in the system. A value of nine can be used if
the actual number of joints is unknown. Joint number one will be stored in real_array element
number one, etc. Excess array elements will be ignored.
The measurement of the real_array elements is in degrees.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: CNV_REL_JPOS Built-In Procedure
Example: Refer to Section B.14 , "Applying Offsets to a Copied Teach Pendant Program"
(CPY_TP.KL), for a detailed program example.
A.4.31
CNV_REAL_STR Built-In Procedure
Purpose: Formats the specified REAL value into a STRING
Syntax : CNV_REAL_STR(source, length, num_digits, target)
A-67
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Input/Output Parameters :
[in] source :REAL expression
[in] length :INTEGER expression
[in] num_digits :INTEGER expression
[out] target :STRING
%ENVIRONMENT Group :STRNG
Details:
source is the REAL value to be formatted.
length specifies the minimum length of the target . The actual length of target may be greater if
required to contain the contents of source and at least one leading blank.
num_digits specifies the number of digits displayed to the right of the decimal point. If
num_digits is a negative number, source will be formatted in scientific notation (where the ABS(
num_digits ) represents the number of digits to the right of the decimal point.) If num_digits is
0, the decimal point is suppressed.
If length or num_digits are invalid, target is returned uninitialized.
If the declared length of target is not large enough to contain source with one leading blank, target
is returned with one leading blank and the rest of its declared length filled with ‘‘*’’s (asterisks).
See Also: CNV_STR_REAL Built-In Procedure
Example: The following example converts the REAL number in cur_volts into a STRING and puts
it into volt_string . The minimum length of cur_volts is specified to be seven characters with two
characters after the decimal point. The contents of volt_string is then displayed on the screen.
CNV_REAL_STR Built-In Procedure
cur_volts = AIN[2]
CNV_REAL_STR(cur_volts, 7, 2, volt_string)
WRITE(’Voltage=’,volt_string,CR)
A.4.32
CNV_REL_JPOS Built-In Procedure
Purpose: Allows a KAREL program to manipulate individual angles of a joint position
Syntax : CNV_REL_JPOS(real_array, joint_pos, status)
Input/Output Parameters :
A-68
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[in] real_array :ARRAY [num_joints] OF REAL
[out] joint_pos :JOINTPOS
[out] status :INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
real_array must have a declared size, equal to or greater than, the number of joints in the system.
A value of nine can be used for num_joints, if the actual number of joints is unknown. Array
element number one will be stored in joint number one, and so forth. Excess array elements will
be ignored. If the array is not large enough the program will abort with an invalid argument error.
If any of the elements of real_array that correspond to a joint angle are uninitialized, the program
will be paused with an uninitialized variable error.
The measurement of the real_array elements is degrees.
joint_pos is one of the KAREL joint position types: JOINTPOS, or JOINTPOS1 through
JOINTPOS9.
joint_pos receives the joint position form of real_array.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
Example: Refer to the following sections for detailed program examples:
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
Section B.8 , "Generating and Moving Along a Hexagon Path" (GEN_HEX.KL)
Section B.14 , "Applying Offsets to a Copied Teach Pendant Program" (CPY_TP.KL)
A.4.33
CNV_STR_CONF Built-In Procedure
Purpose: Converts the specified configuration string into a CONFIG data type
Syntax : CNV_STR_CONF(source, target, status)
Input/Output Parameters :
[in] source :STRING
[out] target :CONFIG
[out] status :INTEGER
A-69
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
%ENVIRONMENT Group :STRNG
Details:
target receives the CONFIG form of the configuration string specified by source .
source must be a valid configuration string for the robot arm attached to the controller.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: CNV_CONF_STR Built-In Procedure
Example: The following example sets the configuration of position xyz_pos to the configuration
specified by config_string and then moves the TCP to that position.
CNV_STR_CONF Built-In Procedure
CNV_STR_CONF(config_string, xyz_pos.config_data, status)
SET_POS_REG(1, xyz_pos, status) —— Put xyz_pos in PR[1]
move_to_pr —— Call TP program to move to PR[1]
A.4.34
CNV_STR_INT Built-In Procedure
Purpose: Converts the specified STRING into an INTEGER
Syntax : CNV_STR_INT(source, target)
Input/Output Parameters :
[in] source :STRING
[out] target :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
source is converted into an INTEGER and stored in target .
If source does not contain a valid representation of an INTEGER, target is set uninitialized.
See Also: CNV_INT_STR Built-In Procedure
Example: Refer to the following sections for detailed program examples:
Section B.2 , "Copying Path Variables" (CPY_PTH.KL)
Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL)
A-70
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.4.35
CNV_STR_REAL Built-In Procedure
Purpose: Converts the specified STRING into a REAL
Syntax : CNV_STR_REAL(source, target)
Input/Output Parameters :
[in] source :STRING
[out] target :REAL
%ENVIRONMENT Group :PBCORE
Details:
Converts source to a REAL number and stores the result in target .
If source is not a valid decimal representation of a REAL number, target will be set uninitialized.
source may contain scientific notation of the form nn.nnEsnn where s is a + or - sign.
See Also: CNV_REAL_STR Built-In Procedure
Example: The following example converts the STRING str into a REAL and puts it into rate .
CNV_STR_REAL Built-In Procedure
REPEAT
WRITE(’Enter rate:’)
READ(str)
CNV_STR_REAL(str, rate)
UNTIL NOT UNINIT(rate)
A.4.36
CNV_STR_TIME Built-In Procedure
Purpose: Converts a string representation of time to an integer representation of time.
Syntax : CNV_STR_TIME(source, target)
Input/Output Parameters :
[in] source :STRING
[out] target :INTEGER
%ENVIRONMENT Group :TIM
A-71
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Details:
The size of the string parameter, source , is STRING[20].
source must be entered using ‘‘DD-MMM-YYY HH:MM:SS’’ format. The seconds specifier,
‘‘SS,’’ is optional. A value of zero (0) is used if seconds is not specified. If source is invalid,
target will be set to 0.
target can be used with the SET_TIME Built-In Procedure to reset the time on the system. If
target is 0, the time on the system will not be changed.
See Also: SET_TIME Built-In Procedure
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 procedure. SET_TIME is then used to set the time within the KAREL system to
the time specified by int_time .
CNV_STR_TIME Built-In Procedure
WRITE(’Enter the new time : ’)
READ(str_time)
CNV_STR_TIME(str_time,int_time)
SET_TIME(int_time)
A.4.37
CNV_TIME_STR Built-In Procedure
Purpose: Converts an INTEGER representation of time to a STRING
Syntax : CNV_TIME_STR(source, target)
Input/Output Parameters :
[in] source :INTEGER
[out] target :STRING
%ENVIRONMENT Group :TIM
Details:
The GET_TIME Built-In Procedure is used to determine the INTEGER representation of
time. CNV_TIME_STR is used to convert source to target , which will be displayed in
‘‘DD-MMM-YYY HH:MM:’’ format.
See Also: GET_TIME Built-In Procedure
A-72
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Example: Refer to Section B.9 , "Using the File and Device Built-ins" (FILE_EX.KL), for a detailed
program example.
A.4.38
%COMMENT Translator Directive
Purpose: Specifies a comment of up to 16 characters
Syntax : %COMMENT = ’ssssssssssssssss’
where ssssssssssssssss = space
Details:
The comment can be up to 16 characters long.
During load time, the comment will be stored as a program attribute and can be displayed on the
teach pendant or CRT/KB.
%COMMENT must be used after the PROGRAM statement, but before any CONST, TYPE, or
VAR sections.
See Also: SET_ATTR_PRG and GET_ATTR_PRG Built-In Procedures
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.5 ,"Using Register Built-ins" (REG_EX.KL)
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
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.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.4.39 COMPARE_FILE Built-in Procedure
Purpose: Compares the contents of one file with anotherfile
A-73
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
Syntax : COMPARE_FILE(filea, fileb, result_file, ascii_flag, diff_count, status)
Input/Output Parameters :
[in] filea :STRING
[in] fileb :STRING
[out] result_file :FILE
[in] ascii_flag:BOOLEAN
[out] diff_count :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :FDEV
Details:
filea specifies the device, name, and type of the file to compare. If no device is specified, the
default device is used. You must specify both a name and type.
fileb specifies the device, name, and type of the file to compare. If no device is specified, the
default device is used. You must specify both a name and type.
result_file this must be an open FILE variable open for write. The comparison result will be
written to this FILE.
ascii_flag specifies that the file(s) should be compared based on ASCII (text) content.
diff_count how many ASCII (text) lines differed.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: COPY_FILE, RENAME_FILE, DELETE_FILE Built-In Procedures
The following example illustrates how this built-in can be used to detect if any TP programs have
changed since a reference copy was saved to MC:\ref. To try this out copy md:*.ls to mc:\ref (or
another file storage area of your choosing) and then run this program.
Figure A-1. Example of COMPARE_FILE built-in Procedure
-----------------------------------------------------------
PROGRAM compfiles
-----------------------------------------------------------
VAR
status: integer
prog_name: string[128]
logfile: file
file_ary: array [1638] of string[MAX_PROG_NAM]
A-74
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
tempstore in CMOS: string[40]
index: integer
findex: integer
n_progs: integer
diff_count: integer
BEGIN
prog_name = ’*’
index = 0
n_progs = 1
diff_count=1
IF uninit(tempstore) THEN
tempstore = ’MC:\ref’
ENDIF
OPEN FILE logfile (’RW’, ’CMPFILES.LOG’)
PROG_LIST(prog_name, 2, 0, 1, file_ary, n_progs, index)
FOR index = 1 TO n_progs DO
-- COMPARE_FILE( filename1: string;
(IN) First file name for comparison
--
filename2: string;
(IN) Second file name for comparison
--
out_file: file;
(OUT) Open KAREL file for output
--
ascii_flag: boolean; (IN) If TRUE the comprison is ASCII
--
count: integer;
(OUT) ASCII- Number of differences/
–-
Binary first different byte
--
status: integer)
(OUT) Result such as cannot open file
COMPARE_FILE(’MD:\’ + file_ary[index]+’.LS’,
tempstore + ’\’ + file_ary[index]+’.LS’, logfile, TRUE,
diff_count, status)
write logfile (’Compared ’ + file_ary[index], ’ ’, status, ’ ’,
diff_count, ’ ’, index, CR)
ENDFOR
CLOSE FILE logfile
END compfiles
A.4.40
CONDITION...ENDCONDITION Statement
Purpose: Defines a global condition handler
Syntax : CONDITION[cond_hand_no]: [with_list]
WHEN cond_list DO action_list
A-75
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
{WHEN cond_list DO action_list}
ENDCONDITION
Details:
cond_hand_no specifies the number associated with the condition handler and must be in the
range of 1-1000. The program is aborted with an error if it is outside this range.
If a condition handler with the specified number already exists, the old one is replaced with the
new one.
The optional [with_list] can be used to specify condition handler qualifiers. See the WITH
clause for more information.
All of the conditions listed in a single WHEN clause must be satisfied simultaneously for the
condition handler to be triggered.
Multiple conditions must all be separated by the AND operator or the OR operator. Mixing of
AND and OR is not allowed.
The actions listed after DO are to be taken when the corresponding conditions of a WHEN
clause are satisfied simultaneously.
Multiple actions are separated by a comma or on a new line.
Calls to function routines are not allowed in a CONDITION statement.
The condition handler is initially disabled and is disabled again whenever it is triggered. Use the
ENABLE statement or action, specifying the condition handler number, to enable it.
Use the DISABLE statement or action to deactivate a condition handler.
The condition handler remains defined and can subsequently be reactivated by the ENABLE
statement or action.
The PURGE statement can be used to delete the definition of a condition handler.
Condition handlers are known only to the task which defines them. Two different tasks can use
the same cond_hand_no even though they specify different conditions.
See Also: Chapter 6 CONDITION HANDLERS , Appendix E , ‘‘Syntax Diagrams,’’ for additional
syntax information
Example: Refer to the following sections for detailed program examples:
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A-76
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.4.41
CONFIG Data Type
Purpose: Defines a variable or structure field as a CONFIG data type
Syntax : CONFIG
Details:
CONFIG defines a variable or structure field as a highly compact structure consisting of fields
defining a robot configuration.
CONFIG contains the following predefined fields:
— CFG_TURN_NO1 :INTEGER
— CFG_TURN_NO2 :INTEGER
— CFG_TURN_NO3 :INTEGER
— CFG_FLIP :BOOLEAN
— CFG_LEFT :BOOLEAN
— CFG_UP :BOOLEAN
— CFG_FRONT :BOOLEAN
Variables and fields of structures can be declared as CONFIG.
Subfields of CONFIG data type can be accessed and set using the usual structure field notation.
Variables and fields declared as CONFIG can be
— Assigned to one another.
— Passed as parameters.
— Written to and read from unformatted files.
Each subfield of a CONFIG variable or structure field can be passed as a parameter to a routine,
but is always passed by value.
A CONFIG field is part of every POSITION and XYZWPR variable and field.
An attempt to assign a value to a CONFIG subfield that is too large for the field results in an
abort error.
Example: The following example shows how subfields of the CONFIG structure can be accessed
and set using the usual structure.field notation.
CONFIG Data Type
VAR
config_var1, config_var2: CONFIG
pos_var: POSITION
seam_path: PATH
A-77
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
i: INTEGER
BEGIN
config_var1 = pos_var.config_data
config_var1 = config_var2
config_var1.cfg_turn_no1 = 0
IF pos_var.config_data.cfg_flip THEN...
FOR i = 1 TO PATH_LEN(seam_path) DO
seam_path[i].node_pos.config_data = config_var1
ENDFOR
A.4.42
CONNECT TIMER Statement
Purpose: Causes an INTEGER variable to start being updated as a millisecond clock
Syntax : CONNECT TIMER TO clock_var
where:
clock_var :a static, user-defined INTEGER variable
Details:
clock_var is presently incremented by the value of the system variable $SCR.$COND_TIME
every $SCR.$COND_TIME milliseconds as long as the program is running or paused
and continues until the program disconnects the timer, ends, or aborts. For example, if
$SCR.$COND_TIM E=32 then clock_var will be incremented by 32 every 32 milliseconds.
You should initialize clock_var before using the CONNECT TIMER statement to ensure a
proper starting value.
If the variable is uninitialized, it will remain so for a short period of time (up to 32 milliseconds)
and then it will be set to a very large negative value (-2.0E31 + 32 milliseconds) and incremented
from that value.
The program can reset the clock_var to any value while it is connected.
A clock_var initialized at zero wraps around from approximately two billion to approximately
minus two billion after about 23 days.
If clock_var is a system variable or a local variable in a routine, the program cannot be translated.
Note If two CONNECT TIMER statements using the same variable, are executed in two different
tasks, the timer will advance twice as fast. For example, the timer will be incremented by 2 *
$SCR.$COND_TIME every $SCR.$COND_TIME ms. However, this does not occur if two or
more CONNECT TIMER statements using the same variable, are executed in the same task.
See Also: Appendix E for additional syntax information, DISCONNECT TIMER Statement
A-78
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Example: Refer to the following sections for detailed program examples:
Section B.8 , "Generating and Moving Along a Hexagon Path" (GEN_HEX.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.4.43
CONTINUE Action
Purpose: Continues execution of a paused task
Syntax : CONTINUE <PROGRAM[n]>
Details:
The CONTINUE action will not resume stopped motions.
If program execution is paused, the CONTINUE action will continue program execution.
The CONTINUE action can be followed by the clause PROGRAM[n], where n is the task number
to be continued. Use GET_TSK_INFO to get a task number for a specified task name.
A task can be in an interrupt routine when CONTINUE is executed. However, you should be
aware of the following circumstances because CONTINUE only affects the current interrupt level,
and interrupt levels of a task might be independently paused or running.
— If the interrupt routine and the task are both paused, CONTINUE will continue the interrupt
routine but the task will remain paused.
— If the interrupt routine is running and the task is paused, CONTINUE will appear to have no
effect because it will try to continue the running interrupt routine.
— If the interrupt routine is paused and the task is running, CONTINUE will continue the
interrupt routine.
Example: Refer to Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
for a detailed program example.
A.4.44
CONTINUE Condition
Purpose: Condition that is satisfied when program execution is continued
Syntax : CONTINUE <PROGRAM[n]>
Details:
The CONTINUE condition monitors program execution.
If program execution is paused, the CONTINUE action, issuing CONTINUE from the CRT/KB
A-79
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
or a CYCLE START from the operator panel, will continue program execution and satisfy the
CONTINUE condition.
The CONTINUE condition can be followed by the clause PROGRAM[n], where n is the task
number to be continued. Use GET_TSK_INFO to get the task number of a specified task name.
Example: In the following example, program execution is being monitored. When the program is
continued, a digital output will be turned on.
CONTINUE Condition
CONDITION[1]:
WHEN CONTINUE DO DOUT[1] = ON
ENDCONDITION
A.4.45
CONT_TASK Built-In Procedure
Purpose: Continues the specified task
Syntax : CONT_TASK(task_name, status)
Input/Output Parameters :
[in] task_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :MULTI
Details:
task_name is the name of the task to be continued. If the task was not paused, an error is returned
in status.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
A task can be in an interrupt routine when CONT_TASK is executed. However, you should be
aware of the following circumstances because CONT_TASK only affects the current interrupt
level, and interrupt levels of a task might be independently paused or running.
— If the interrupt routine and the task are both paused, CONT_TASK will continue the interrupt
routine but the task will remain paused.
— If the interrupt routine is running and the task is paused, CONT_TASK will appear to have no
effect because it will try to continue the running interrupt routine.
— If the interrupt routine is paused and the task is running, CONT_TASK will continue the
interrupt routine.
A-80
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
See Also: RUN_TASK, ABORT_TASK, PAUSE_TASK Built-In Procedures, Chapter 15
MULTI-TASKING
Example: The following example prompts the user for the task name and continues the task
execution. Refer to Chapter 15 MULTI-TASKING , for more examples.
CONT_TASK Built-In Procedure
PROGRAM cont_task_ex
%ENVIRONMENT MULTI
VAR
task_str: STRING[12]
status: INTEGER
BEGIN
WRITE(’Enter task name to continue:’)
READ(task_str)
CONT_TASK(task_str, status)
END cont_task_ex
A.4.46
COPY_FILE Built-In Procedure
Purpose: Copies the contents of one file to another with the overwrite option
Syntax : COPY_FILE(from_file, to_file, overwrite_sw, nowait_sw, status)
Input/Output Parameters :
[in] from_file :STRING
[in] to_file :STRING
[in] overwrite_sw :BOOLEAN
[in] nowait_sw :BOOLEAN
[out] status :INTEGER
%ENVIRONMENT Group :FDEV
Details:
from_file specifies the device, name, and type of the file from which to copy. from_file can be
specified using the wildcard (*) character. If no device is specified, the default device is used.
You must specify both a name and type. However, these can be a wildcard (*) character.
to_file specifies the device, name, and type of the file to which to copy. to_file can be specified
using the wildcard (*) character. If no device is specified, the default device is used.
A-81
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
overwrite_sw specifies that the file(s) should be overwritten if they exist.
If nowait_sw is TRUE, execution of the program continues while the command is executing. If
it is FALSE, the program stops, including condition handlers, until the operation is complete.
If you have time critical condition handlers in the program, put them in another program that
executes as a separate task.
If the program is aborted during the copy, the copy will completed before aborting.
If the device you are copying to becomes full during the copy, an error will be returned.
Note nowait_sw is not available in this release and should be set to FALSE.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: RENAME_FILE, DELETE_FILE Built-In Procedures
Example: Refer to Section B.9 , "Using the File and Device Built-ins" (FILE_EX.KL), for a detailed
program example.
A.4.47
COPY_PATH Built-In Procedure
Purpose: Copies a complete path, part of a path, or a path in reverse node order (including associated
data), to another identical type path variable.
Syntax : COPY_PATH (source_path, start_node, end_node, dest_path, status)
Input/Output Parameters :
[in] source_path :PATH
[in] start_node :INTEGER
[in] end_node :INTEGER
[in] dest_path :PATH
[out] status :INTEGER
%ENVIRONMENT Group :pathop
Details:
source_path specifies the source path to copy from. This path can be a standard path or a user
defined path.
start_node specifies the number of the first node to copy. A value of 0 will copy the complete
path, including header information. The start_node number must be between 0 and the highest
node number in the source path. Otherwise, error status will be returned.
A-82
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
end_node specifies the number of the last node to copy. A value of 0 will copy the complete path,
including header information. The end_node number must be between 0 and the highest node
number of the source path. Otherwise, error status will be returned.
dest_path specifies the destination path to copy to. This path can be a standard path or a user
defined path. However, the dest_path type must be identical to the source_path type. If they are
not identical, an error status will be returned.
status of 0 is returned if the parameters are valid and the COPY_PATH operation was successful.
Non-zero status indicates the COPY_PATH operation was unsuccessful.
Note To copy a complete path from one path variable to another identical path variable, set the
start_node and end_node parameters to 0 (zero).
An example of a partial path copy to a destination path.
Executing the COPY_PATH(P1, 2, 5, P2) command will copy node 2 through node 5 (inclusive) of
path P1 to node 1 through 4 of Path P2, provided the path length of P1 is greater than or equal to 5. The
destination path P2 will become a 4 node path. The original destination path is completely overwritten.
An example of a source path copy in reverse order to a destination path.
Executing the COPY_PATH(P1, 5, 2, P2) command will copy node 5 through node 2 (inclusive) of
path P1 to node 1 through 4 of Path P2, provided the path length of P1 is greater than or equal to 5. The
destination path P2 will become a 4 node path. The original destination path is completely overwritten.
Specifically, the above command will copy node 5 of P1 to node 1 of P2, node 4 of P1 to node
2 of P2, and so forth.
Example: Refer to Section B.2 , "Copying Path Variables " (CPY_PTH.KL), for a detailed program
example.
A.4.48
COPY_QUEUE Built-In Procedure
Purpose: Copies one or more consecutive entries from a queue into an array of integers. The entries
are not removed but are copied, starting with the oldest and proceeding to the newest, or until the
output array, or integers, are full. A parameter specifies the number of entries at the head of the list
(oldest entries) to be skipped.
Syntax : COPY_QUEUE(queue, queue_data, sequence_no, n_skip, out_data, n_got, status)
Input/Output Parameters :
[in] queue_t :QUEUE_TYPE
[in] queue_data :ARRAY OF INTEGER
A-83
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[in] n_skip :INTEGER
[in] sequence_no :integer
[out] out_data :ARRAY OF INTEGER
[out] n_got :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBQMGR
Details:
queue_t specifies the queue variable for the queue from which the values are to be read.
queue_data specifies the array variable for the queue from which the values are to be read.
sequence_no specifies the sequence number of the oldest entry to be copied. If the sequence_no
is zero, the starting point for the copy is determined by the n_skip parameter.
n_skip specifies the number of oldest entries to be skipped. A value of zero indicates to return the
oldest entries.
out_data is an integer array into which the values are to be copied; the size of the array is the
maximum number of values returned.
n_got is returned with the number of entries returned. This will be one of the following:
— Zero if there are n_skip or fewer entries in the queue.
(queue_to n_entries_skip ) if this is less than ARRAY_LEN(out_data)
— ARRAY_LEN(out_data) if this is less than or equal to queue.n_entries - n_skip
status is returned with zero
See Also: APPEND_QUEUE, DELETE_QUEUE, INSERT_QUEUE Built-In Procedures, Section
15.8 , "Using Queues for Task Communication"
Example: The following example gets one ‘‘page’’ of a job queue and calls a routine, disp_queue, to
display this. If there are no entries for the page, the routine returns FALSE; otherwise the routine
returns TRUE.
COPY_QUEUE Built-In Procedure
PROGRAM copy_queue_x
%environment PBQMGR
VAR
job_queue FROM global_vars: QUEUE_TYPE
job_data FROM global_vars: ARRAY[100] OF INTEGER
ROUTINE disp_queue(data: ARRAY OF INTEGER;
n_disp: INTEGER) FROM disp_prog
ROUTINE disp_page(data_array: ARRAY OF INTEGER;
A-84
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
page_no: INTEGER): BOOLEAN
VAR
status: INTEGER
n_got: INTEGER
BEGIN
COPY_QUEUE(job_queue, job_data,
(page_no - 1) * ARRAY_LEN(data_array), 0,
data_array, n_got, status)
IF (n_got = 0) THEN
RETURN (FALSE)
ELSE
disp_queue(data_array, n_got)
RETURN (TRUE)
ENDIF
END disp_page
BEGIN
END copy_queue_x
A.4.49
COPY_TPE Built-In Procedure
Purpose: Copies one teach pendant program to another teach pendant program.
Syntax : COPY_TPE(from_prog, to_prog, overwrite_sw, status)
Input/Output Parameters :
[in] from_prog :STRING
[in] to_prog :STRING
[in] overwrite_sw :BOOLEAN
[out] status :INTEGER
%ENVIRONMENT Group :TPE
Details:
from_prog specifies the teach pendant program name, without the .tp extension, to be copied.
to_prog specifies the new teach pendant program name, without the .tp extension, that from_prog
will be copied to.
overwrite_sw , if set to TRUE, will automatically overwrite the to_prog if it already exists and it
is not currently selected. If set to FALSE, the to_prog will not be overwritten if it already exists.
status explains the status of the attempted operation. If not equal to 0, the copy did not occur.
A-85
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
See Also: CREATE_TPE Built-in Procedure
Example: Refer to Section B.14 , "Applying Offsets to a Copied Teach Pendant Program"
(CPY_TP.KL), for a detailed program example.
A.4.50
COS Built-In Function
Purpose: Returns the REAL cosine of the REAL angle argument, specified in degrees
Syntax : COS(angle) Function Return Type :REAL
Input/Output Parameters :
[in] angle :REAL expression
%ENVIRONMENT Group :SYSTEM
Details:
angle is an angle specified 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.4.51
CR Input/Output Item
Purpose: Can be used as a data item in a READ or WRITE statement to specify a carriage return
Syntax : CR
Details:
When CR is used as a data item in a READ statement, it specifies that any remaining data in the
current input line is to be ignored.
The next data item will be read from the start of the next input line.
When CR is used as a data item in a WRITE statement, it specifies that subsequent output to the
same file will appear on a new line.
See Also: Appendix E , ‘‘Syntax Diagrams,’’ for additional syntax information
Example: Refer to the following sections for detailed program examples:
A-86
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Section B.3 ,"Saving Data to the Default Device" (SAVE_VR.KL)
Section B.4 ,"Standard Routines" (ROUT_EX.KL)
Section B.5 ,"Using Register Built-ins" (REG_EX.KL)
Section B.6 , "Path Variables and Condition Handlers Program" (PTH_MOVE.KL)
Section B.7 , "Listing Files and Programs and Manipulating Strings" (LIST_EX.KL)
Section B.8 , "Generating and Moving Along a Hexagon Path" (GEN_HEX.KL)
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.4.52
CREATE_TPE Built-In Procedure
Purpose: Creates a teach pendant program of the specified name
Syntax : CREATE_TPE(prog_name, prog_type, status)
Input/Output Parameters :
[in] prog_name :STRING
[in] prog_type :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :TPE
Details:
prog_name specifies the name of the program to be created.
prog_type specifies the type of the program to be created. The following constants are valid for
program type: PT_MNE_UNDEF :TPE program of undefined sub type PT_MNE_JOB :TPE job
PT_MNE_PROC :TPE process PT_MNE_MACRO :TPE macro
A-87

 

 

 

 

 

 

 

Content      ..     11      12      13      14     ..