Index Manuals FANUC Robotics SYSTEM R-30iA and R-30iB Controller. KAREL Reference Manual (MARRC75KR07091E Rev D)
|
|
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
• status explains the status of the attempted operation. If it is not equal to 0, then an error occurred.
Some of the possible errors are as follows:
7015 Specified program exist
9030 Program name is NULL
9031 Remove num from top of Program name
9032 Remove space from Program name
9036 Memory is not enough
9038 Invalid character in program name
• The program is created to reference all motion groups on the system. The program is
created without any comment or any other program attributes. Once the program is created,
SET_ATTR_PRG can be used to specify program attributes.
See Also: SET_ATTR_PRG Built-In Procedure
A.4.53
CREATE_VAR Built-In Procedure
Purpose: Creates the specified KAREL variable
Syntax : CREATE_VAR(var_prog_nam, var_nam, typ_prog_nam, type_nam, group_num,
inner_dim, mid_dim, outer_dim, status, <mem_pool>)
Input/Output Parameters :
[in] var_prog_nam :STRING
[in] var_nam :STRING
[in] typ_prog_nam :STRING
[in] type_nam :STRING
[in] group_num :INTEGER
[in] inner_dim :INTEGER
[in] mid_dim :INTEGER
[in] outer_dim :INTEGER
[out] status :INTEGER
A-88
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[in] mem_pool :INTEGER
%ENVIRONMENT Group :MEMO
Details:
•
var_prog_nam specifies the program name that the variable should be created in. If var_prog_nam
is ’ ’, the default, which is the name of the program currently executing, is used.
•
var_nam specifies the variable name that will be created.
•
If a variable is to be created as a user-defined type, the user-defined type must already be
created in the system. typ_prog_nam specifies the program name of the user-defined type. If
typ_prog_nam is ’ ’, the default, which is the name of the program currently executing, is used.
•
type_nam specifies the type name of the variable to be created. The following type names are
valid:
’ARRAY OF BYTE’
’ARRAY OF SHORT’
’BOOLEAN’
’CAM_SETUP’
’CONFIG’
’FILE’
’INTEGER’
’JOINTPOS’
’JOINTPOS1’
’JOINTPOS2’
’JOINTPOS3’
’JOINTPOS4’
’JOINTPOS5’
’JOINTPOS6’
’JOINTPOS7’
’JOINTPOS8’
A-89
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
’JOINTPOS9’
’MODEL’
’POSITION’
’REAL’
’STRING[n]’, where n is the string length; the default is 12 if not specified.
’VECTOR’
’VIS_PROCESS’
’XYZWPR’
’XYZWPREXT’
Any other type names are considered user-defined types.
•
group_num specifies the group number to be used for positional data types.
•
inner_dim specifies the dimensions of the innermost array. For example, inner_dim = 30 for
ARRAY[10,20,30] OF INTEGER. inner_dim should be set to 0 if the variable is not an array.
•
mid_dim specifies the dimensions of the middle array. For example, mid_dim = 20 for
ARRAY[10,20,30] OF INTEGER. mid_dim should be set to 0 if the variable is not a 2-D array.
•
outer_dim specifies the dimensions of the outermost array. For example, outer_dim = 10 for
ARRAY[10,20,30] OF INTEGER. outer_dim should be set to 0 if the variable is not a 3-D array.
•
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
•
mem_pool is an optional parameter that specifies the memory pool from which the variable is
created. If not specified, then the variable is created in DRAM which is temporary memory. The
DRAM variable must be recreated at every power up and the value is always reset to uninitialized.
•
If mem_pool = -1, then the variable is created in CMOS RAM which is permanent memory.
See Also: CLEAR, RENAME_VAR Built-In Procedures
Example: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example.
A.4.54
%CRTDEVICE
Purpose: Specifies that the CRT/KB device is the default device
Syntax : %CRTDEVICE
A-90
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Details:
• Specifies that the INPUT/OUTPUT window will be the default in the READ and WRITE
statements instead of the TPDISPLAY window.
Example: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example showing how to use this device.
A.4.55
CURJPOS Built-In Function
Purpose: Returns the current joint position of the tool center point (TCP) for the specified group of
axes, even if one of the axes is in an overtravel
Syntax : CURJPOS(axs_lim_mask, ovr_trv_mask <,group_no>)
Function Return Type :JOINTPOS
Input/Output Parameters :
[out] axs_lim_mask :INTEGER
[out] ovr_trv_mask :INTEGER
[in] group_no :INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
• If group_no is omitted, the default group for the program is assumed.
• If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
• axs_lim_mask specifies which axes are outside the axis limits.
• ovr_trv_mask specifies which axes are in overtravel.
Note axis_limit_mask and ovr_trv_mask are not available in this release and can be set to 0.
See Also: CURPOS Built-In Function, Chapter 8 POSITION DATA
Example: The following example gets the current joint position of the robot.
CURJPOS Built-In Function
PROGRAM getpos
VAR
jnt: JOINTPOS
A-91
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
BEGIN
jnt=CURJPOS(0,0)
END getpos
A.4.56
CURPOS Built-In Function
Purpose: Returns the current Cartesian position of the tool center point (TCP) for the specified group
of axes even if one of the axes is in an overtravel
Syntax : CURPOS(axis_limit_mask, ovr_trv_mask <,group_no>)
Function Return Type :XYZWPREXT
Input/Output Parameters :
[out] axis_limit_mask :INTEGER
[out] ovr_trv_mask :INTEGER
[in] group_no :INTEGER
%ENVIRONMENT Group :SYSTEM
Details:
• If group_no is omitted, the default group for the program is assumed.
• If group_no is specified, it must be in the range of 1 to the total number of groups defined on
the controller.
• The group must be kinematic.
• Returns the current position of the tool center point (TCP) relative to the current value of the
system variable $UFRAME for the specified group.
• axis_limit_mask specifies which axes are outside the axis limits.
• ovr_trv_mask specifies which axes are in overtravel.
Note axis_limit_mask and ovr_trv_mask are not available in this release and will be ignored if set.
See Also: Chapter 8 POSITION DATA
Example: Refer to Section B.5 ,"Using Register Built-ins," for a detailed program example.
Section B.5 ,"Using Register Built-ins" (REG_EX.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A-92
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.4.57
CURR_PROG Built-In Function
Purpose: Returns the name of the program currently being executed
Syntax : CURR_PROG
Function Return Type :STRING[12]
%ENVIRONMENT Group :BYNAM
Details:
• The variable assigned to CURR_PROG must be declared with a string variable length 12
Example: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example.
A.5
- D - KAREL LANGUAGE DESCRIPTION
A.5.1
DAQ_CHECKP Built-In Procedure
Purpose: To check the status of a pipe and the number of bytes available to be read from the pipe.
Syntax : DAQ_CHECKP(pipe_num, pipe_stat, bytes_avail)
Input/Output Parameters :
[in] pipe_num :INTEGER
[out] pipe_stat :INTEGER
[out] bytes_avail :INTEGER
Details:
• pipe_num is the number of the pipe (1 - 5) to check.
• pipe_stat is the status of the pipe returned. The status is a combination of the following flags:
— DAQ_PIPREG is when the pipe is registered (value = 1).
— DAQ_ACTIVE is when the pipe is active, i.e., has been started (value = 2).
— DAQ_CREATD is when the pipe is created (value = 4).
— DAQ_SNAPSH is when the pipe is in snapshot mode (value = 8).
— DAQ_1STRD is when the pipe has been read for the first time (value = 16).
A-93
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
— DAQ_OVFLOW is when the pipe is overflowed (value = 32).
— DAQ_FLUSH is when the pipe is being flushed (value = 64).
• bytes_avail is the number of bytes that are available to be read from the pipe.
DAQ_CHECKP Built-In Procedure
The pipe_stat returned parameter can be AND’ed with the
above flag constants to determine whether the pipe is
registered, is active, and so forth. For example, you must check
to see if the pipe is active before writing to it.
DAQ_CHECKP Built-In Procedure
The DAQ_OVFLOW flag will never be set for the task that
writes to the pipe when it calls DAQ_CHECKP. This
flag applies only to tasks that read from the pipe.
See Also: DAQ_WRITE Built-In.
Example: Refer to the DAQWRITE example in the built-in function DAQ_WRITE.
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.2
DAQ_REGPIPE Built-In Procedure
Purpose: To register a pipe for use in KAREL.
Syntax : DAQ_REGPIPE(pipe_num, mem_type, pipe_size, prog_name, var_name, pipe_name,
stream_size, and status)
Input/Output Parameters :
[in] pipe_num :INTEGER
[in] mem_type :INTEGER
[in] pipe_size :INTEGER
[in] prog_name :STRING
[in] var_name :STRING
A-94
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[in] pipe_name :STRING
[in] stream_size :INTEGER
[out] status :INTEGER
Details:
•
pipe_num is the number of the pipe (1-5) to be registered.
•
mem_type allows you to allocate the memory to be used for the pipe. The following constants
can be used:
— DAQ_DRAM allows you to allocate DRAM memory.
— DAQ_CMOS allows you to allocate CMOS memory.
•
pipe_size is the size of the pipe, is expressed as the number of data records that it can hold. The
data record size itself is determined by the data type of var_name.
•
prog_name is the name of the program containing the variable to be used for writing to the pipe.
If passed as an empty string, the name of the current program is used.
•
var_name is the name of the variable that defines the data type to be used for writing to the pipe.
Once registered, you can write any variable of this data type to the pipe.
•
pipe_name is the name of the pipe file. For example, if the pipe name is passed as ’foo.dat’, the
pipe will be accessible using the file string ’PIP:FOO.DAT’. A unique file name with an extension
is required even if the pipe is being used only for sending to the PC.
•
stream_size is the number of records to automatically stream to an output file, if the pipe is
started as a streamed pipe. A single write of the specified variable constitutes a single record in
the pipe. If stream size is set to zero, the pipe will not automatically stream records to a file
device; all data will be kept in the pipe until the pipe is read. Use stream_size to help optimize
network loading when the pipe is used to send data to the PC. If it is zero or one, the monitoring
task will send each data record as soon as it is seen in the pipe. If the number is two or more, the
monitor will wait until there are that many data records in the pipe before sending them all to
the PC. In this manner, the overhead of sending network packets can be minimized. Data will
not stay in the pipe longer than the time specified by the FlushTime argument supplied with
the FRCPipe.StartMonitor Method.
•
status is the status of the attempted operation. If not 0, then an error occurred and the pipe
was not registered.
See Also: DAQ_UNREG Built-In.
DAQ_REGPIPE Built-In Procedure
Pipes must be registered before they can be started and to which data
is written. The registration operation tells
the system how to configure the pipe when it is to be used. After
it is registered, a pipe is configured to accept the
writing of a certain amount of data per record, as governed by the
A-95
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
size of the specified variable. In order to
change the configuration of a pipe, the pipe must first be unregistered
using DAQ_UNREG, and then
re-registered.
Example: The following example registers KAREL pipe 1 to write a variable in the program.
DAQ_REGPIPE Built-In Procedure
PROGRAM DAQREG
%ENVIRONMENT DAQ
CONST
er_abort = 2
VAR
status: INTEGER
datavar: INTEGER
BEGIN
-- Register pipe 1 DRAM as kldaq.dat
-- It can hold 100 copies of the datavar variable
-- before the pipe overflows
DAQ_REGPIPE(1, DAQ_DRAM, 100, ’’, ’datavar’, &
’kldaq.dat’, 0, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ENDIF
END DAQREG
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.3
DAQ_START Built-In Procedure
Purpose: To activate a KAREL pipe for writing.
Syntax : DAQ_START(pipe_num, pipe_mode, stream_dev, status)
Input/Output Parameters :
[in] pipe_num :INTEGER
[in] pipe_mode :INTEGER
[in] stream_dev :STRING
[out] status :INTEGER
A-96
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Details:
• pipe_num is the number of the pipe (1 - 5) to be started. The pipe must have been previously
registered
• pipe_mode is the output mode to be used for the pipe. The following constants are used:
— DAQ_SNAPSHT is the snapshot mode (each read of the pipe will result in all of the pipe’s
contents).
— DAQ_STREAM is the stream mode (each read from the same pipe file will result in data
written since the previous read).
• stream_dev is the device to which records will be automatically streamed. This parameter is
ignored if the stream size was set to 0 during registration.
• status is the status of the attempted operation. If not 0, then an error occurred and the pipe
was not unregistered.
See Also: DAQ_REGPIPE Built-In and DAQ_STOP Built-In,
DAQ_START Built-In Procedure
This built-in call can be made either from the same task/program as
the writing task, or from a separate
activate/deactivate task. The writing task can lie dormant until
the pipe is started, at which point it begins to write
data.
DAQ_START Built-In Procedure
A pipe is automatically started when a PC application issues the FRCPipe.
StartMonitor method. In this case,
there is no need for the KAREL application to call DAQ_START to activate
the pipe..
DAQ_START Built-In Procedure
Starting and stopping a pipe is tracked using a reference counting
scheme. That is, any combination of two
DAQ_START and FRCPipe.StartMonitor calls requires any comb
Example: The following example starts KAREL pipe 1 in streaming mode.
DAQ_START Built-In Procedure
PROGRAM PIPONOFF
%ENVIRONMENT DAQ
CONST
er_abort = 2
VAR
A-97
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
status: INTEGER
tpinput: STRING[1]
BEGIN
-- prompt to turn on pipe
WRITE(’Press 1 to start pipe’)
READ (tpinput)
IF tpinput = ’1’ THEN
-- start pipe 1
DAQ_START(1, DAQ_STREAM, ’RD:’, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ELSE
-- prompt to turn off pipe
WRITE(’Press any key to stop pipe’)
READ (tpinput)
-- stop pipe 1
DAQ_STOP(1, FALSE, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ENDIF
ENDIF
ENDIF
END PIPONOFF
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.4
DAQ_STOP Built-In Procedure
Purpose: To stop a KAREL pipe for writing.
Syntax : DAQ_STOP(pipe_num, force_off, status)
Input/Output Parameters :
[in] pipe_num :INTEGER
[in] force_off :BOOLEAN
[out] status :INTEGER
Details:
• pipe_num is the number of the pipe (1 - 5) to be stopped.
A-98
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
• force_off occurs if TRUE force the pipe to be turned off, even if another application made a
start request on the pipe. If set FALSE, if all start requests have been accounted for with stop
requests, the pipe is turned off, else it remains on.
• status is the status of the attempted operation. If not 0, then an error occurred and the pipe
was not stopped.
See Also: DAQ_START Built-In.
DAQ_STOP Built-In Procedure
The start/stop mechanism on each pipe works on a reference count.
The pipe is started on the first start request,
and each subsequent start request is counted. If a stop request is
received for the pipe, the count is decremented.
DAQ_STOP Built-In Procedure
If the pipe is not forced off, and the count is not zero, the pipe
stays on. By setting the force_off flag to TRUE,
the pipe is turned off regardless of the count. The count is reset.
DAQ_STOP Built-In Procedure
FRCPipe.StopMonitor method issued by a PC application is equivalent
to a call to DAQ_STOP.
Example: Refer to the PIPONOFF example in the built-in function DAQ_START.
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.5
DAQ_UNREG Built-In Procedure
Purpose: To unregister a previously-registered KAREL pipe, so that it may be used for other data.
Syntax : DAQ_UNREG(pipe_num, status)
Input/Output Parameters :
[in] pipe_num :INTEGER
[out] status :INTEGER
Details:
• pipe_num is the number of the pipe (1 - 5) to be unregistered.
A-99
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
• status is the status of the attempted operation. If not 0, then an error occurred and the pipe
was not unregistered.
See Also: DAQ_REGPIPE Built-In.
DAQ_UNREG Built-In Procedure
Unregistering a pipe allows the pipe to be re-configured for a different
data size, pipe size, pipe name, and so
forth. You must un-register the pipe before re-registering using
DAQ_REGPIPE.
Example: The following example unregisters KAREL pipe 1.
DAQ_UNREG Built-In Procedure
PROGRAM DAQUNREG
%ENVIRONMENT DAQ
CONST
er_abort = 2
VAR
status: INTEGER
BEGIN
-- unregister pipe 1
DAQ_UNREG(1, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ENDIF
END DAQUNREG
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.6
DAQ_WRITE Built-In Procedure
Purpose: To write data to a KAREL pipe.
Syntax : DAQ_WRITE(pipe_num, prog_name, var_name, status)
Input/Output Parameters :
[in] pipe_num :INTEGER
[in] prog_name :STRING
[in] var_name :STRING
A-100
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
[out] status :INTEGER
Details:
• pipe_num is the number of the pipe (1 - 5) to which data is written.
• prog_name is the name of the program containing the variable to be written. If passed as an
empty string, the name of the current program is used.
• var_name is the name of the variable to be written.
• status is the status of the attempted operation. If not 0, then an error occurred and the data
was not written.
See Also: DAQ_REGPIPE and DAQ_CHECKP.
DAQ_WRITE Built-In Procedure
You do not have to use the same variable for writing data to the pipe
that was used to register the pipe. The only
requirement is that the data type of the variable written matches
the type of the variable used to register the pipe.
DAQ_WRITE Built-In Procedure
If a PC application is monitoring the pipe, each call to DAQ_WRITE
will result in an FRCPipe_Receive Event.
Example: The following example registers KAREL pipe 2 and writes to it when the pipe is active.
DAQ_WRITE Built-In Procedure
PROGRAM DAQWRITE
%ENVIRONMENT DAQ
%ENVIRONMENT SYSDEF
CONST
er_abort = 2
TYPE
daq_data_t = STRUCTURE
count: INTEGER
dataval: INTEGER
ENDSTRUCTURE
VAR
status: INTEGER
pipestat: INTEGER
numbytes: INTEGER
datavar: daq_data_t
BEGIN
-- register 10KB pipe 2 in DRAM as kldaq.dat
DAQ_REGPIPE(2, DAQ_DRAM, 100, ’’, ’datavar’, &
A-101
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
’kldaq.dat’, 1, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ENDIF
-- use DAQ_CHECKP to monitor status of pipe
DAQ_CHECKP(2, pipestat, numbytes)
datavar.count = 0
WHILE (pipestat AND DAQ_PIPREG) > 0 DO
-- do
while
registered
-- update data variable
datavar.count = datavar.count + 1
datavar.dataval = $FAST_CLOCK
-- check if pipe is active
IF (pipestat AND DAQ_ACTIVE) > 0 THEN
-- write to pipe
DAQ_WRITE(2, ’’, datavar, status)
IF status<>0 THEN
POST_ERR(status,’ ’,0,er_abort)
ENDIF
ENDIF
-- put in delay to reduce loading
DELAY(200)
DAQ_CHECKP(2, pipestat, numbytes)
ENDWHILE
END DAQWRITE
Note This built-in is only available when DAQ or data monitor options are loaded.
A.5.7
%DEFGROUP Translator Directive
Purpose: Specifies the default motion group to be used by the translator
Syntax : %DEFGROUP = n
Details:
• n is the number of the motion group.
• The range is 1 to the number of groups on the controller.
• If %DEFGROUP is not specified, group 1 is used.
A.5.8
DEF_SCREEN Built-In Procedure
Purpose: Defines a screen
A-102
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Syntax : DEF_SCREEN(screen_name, disp_dev_name, status)
Input/Output Parameters :
[in] screen_name :STRING
[in] disp_dev_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :UIF
Details:
• Define a screen, associated with a specified display device, to which windows could be attached
and be activated (displayed).
• screen_name must be a unique, valid name (string), one to four characters long.
• disp_dev_name must be one of the display devices already defined, otherwise an error is returned.
The following are the predefined display devices:
’TP’ Teach Pendant Device’CRT’ CRT/KB Device
• status explains the status of the attempted operation. (If not equal to 0, then an error occurred.)
See Also: ACT_SCREEN Built-In Procedure
Example: Refer to Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL), for a
detailed program example.
A.5.9
DEF_WINDOW Built-In Procedure
Purpose: Define a window
Syntax : DEF_WINDOW(window_name, n_rows, n_cols, options, status)
Input/Output Parameters :
[in] window_name :STRING
[in] n_rows :INTEGER
[in] n_cols :INTEGER
[in] options :INTEGER
[out] status :INTEGER
A-103
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
%ENVIRONMENT Group :PBCORE
Details:
•
Define a window that can be attached subsequently to a screen, have files opened to it, be written
or have input echoed to it, and have information dynamically displayed in it.
•
window_name must be a valid name string, one to four characters long, and must not duplicate a
window with the same name.
•
n_rows and n_cols specify the size of the window in standard-sized characters. Any line
containing double-wide or double-wide-double-high characters will contain only half this many
characters. The first row and column begin at 1.
•
options must be one of the following:
0 :No option
wd_com_cursr :Common cursor
wd_scrolled :Vertical scrolling
wd_com_cursr + wd_scrolled :Common cursor + Vertical scrolling
•
If common cursor is specified, wherever a write leaves the cursor is where the next write will
go, regardless of the file variable used. Also, any display attributes set for any file variable
associated with this window will apply to all file variables associated with the window. If this is
not specified, the cursor position and display attributes (except character size attributes, which
always apply to the current line of a window) are maintained separately for each file variable open
to the window. The common-cursor attribute is useful for windows that can be written to by more
than one task and where these writes are to appear end-to-end. An example might be a log display.
•
If vertical scrolling is specified and a line-feed, new-line, or index-down character is received
and the cursor is in the bottom line of the window, all lines except the top line are moved up and
the bottom line is cleared. If an index-up character is written, all lines except the bottom line
are moved down and the top line is cleared. If this is not specified, the bottom or top line is
cleared, but the rest of the window is unaffected.
•
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: ATT _WINDOW_D, ATT_WINDOW_S Built-In Procedures
A.5.10
%DELAY Translator Directive
Purpose: Sets the amount of time program execution will be delayed every 250 milliseconds. Each
program is delayed 8ms every 250ms by default. This allows the CPU to perform other functions such
as servicing the CRT/KB and Teach Pendant user interfaces. %DELAY provides a way to change
from the default and allow more CPU for system tasks such as user interface.
A-104
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Syntax : %DELAY = n
Details:
• n is the delay time in milliseconds.
• The default delay time is 8 ms, if no DELAY is specified
• If n is set to 0, the program will attempt to use 100% of the available CPU time. This could result
in the teach pendant and CRT/KB becoming inoperative since their priority is lower. A delay of 0
is acceptable if the program will be waiting for motion or I/O.
• While one program is being displayed, other programs are prohibited from executing. Interrupt
routines (routines called from condition handlers) will also be delayed.
• Very large delay values will severely inhibit the running of all programs.
• To delay one program in favor of another, use the DELAY Statement instead of %DELAY.
A.5.11
DELAY Statement
Purpose: Causes execution of the program to be suspended for a specified number of milliseconds
Syntax : DELAY time_in_ms
where:
time_in_ms :an INTEGER expression
Details:
• If motion is active at the time of the delay, the motion continues.
• time_in_ms is the time in milliseconds. The actual delay will be from zero to $SCR.$cond_time
milliseconds less than the rounded time.
• A time specification of zero has no effect.
• If a program is paused while a delay is in progress, the delay will continue to be timed.
• If the delay time in a paused program expires while the program is still paused, the program, upon
resuming and with no further delay, will continue execution with the statement following the delay.
Otherwise, upon resumption, the program will finish the delay time before continuing execution.
• Aborting a program, or issuing RUN from the CRT/KB when a program is paused, terminates
any delays in progress.
• While a program is awaiting expiration of a delay, the KCL> SHOW TASK command will
show a hold of DELAY.
• A time value greater than one day or less than zero will cause the program to be aborted with an
error.
A-105
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
See Also: Appendix E , ‘‘Syntax Diagrams,’’ for additional syntax information
Example: Refer to the following sections for detailed program examples:
Section B.11 , "Manipulating Values of Dynamically Displayed Variables" (CHG_DATA.KL)
Section B.1 , "Setting Up Digital Output Ports for Monitoring" (DOUT_EX.KL)
A.5.12
DELETE_FILE Built-In Procedure
Purpose: Deletes the specified file
Syntax : DELETE_FILE(file_spec, nowait_sw, status)
Input/Output Parameters :
[in] file_spec :STRING
[in] nowait_sw :BOOLEAN
[out] status :INTEGER
%ENVIRONMENT Group :FDEV
Details:
• file_spec specifies the device, name, and type of the file to delete. file_spec can be specified using
the wildcard (*) character. If no device name is specified, the default device is used.
• 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.
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: COPY_FILE, RENAME_FILE Built-In Procedures
Example: Refer to Section B.3 ,"Saving Data to the Default Device" (SAVE_VRS.KL), for a
detailed program example.
A-106
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.5.13
DELETE_NODE Built-In Procedure
Purpose: Deletes a path node from a PATH
Syntax : DELETE_NODE(path_var, node_num, status)
Input/Output Parameters :
[in] path_var :PATH
[in] node_num :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PATHOP
Details:
• node_num specifies the node to be deleted from the PATH specified by path_var .
• All nodes past the deleted node will be renumbered.
• node_num must be in the range from one to PATH_LEN(path_var). If it is outside this range,
the status is returned with an error.
• status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: APPEND_NODE, INSERT_NODE Built-In Procedures
Example: Refer to Section B.2 , "Copying Path Variables" (CPY_PTH.KL), for a detailed program
example.
A.5.14
DELETE_QUEUE Built-In Procedure
Purpose: Deletes an entry from a queue
Syntax : DELETE_QUEUE(sequence_no, queue, queue_data, status)
Input/Output Parameters :
[in] sequence_no :INTEGER
[in,out] queue_t :QUEUE_TYPE
[in,out] queue_data :ARRAY OF INTEGER
[out] status :INTEGER
A-107
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
%ENVIRONMENT Group :PBQMGR
Details:
• Use COPY_QUEUE to get a list of the sequence numbers.
• sequence_no specifies the sequence number of the entry to be deleted. Use COPY_QUEUE to
get a list of the sequence numbers.
• queue_t specifies the queue variable for the queue.
• queue_data specifies the array used to hold the data in the queue. The length of this array
determines the maximum number of entries in the queue.
• status returns 61003, ‘‘Bad sequence no,’’ if the specified sequence number is not in the queue.
See Also: APPEND_QUEUE, COPY_QUEUE, INSERT_QUEUE Built-In Procedures, Section
15.8 , "Using Queues for Task Communication"
A.5.15
DEL_INST_TPE Built-In Procedure
Purpose: Deletes the specified instruction in the specified teach pendant program
Syntax : DEL_INST_TPE(open_id, lin_num, status)
Input/Output Parameters :
[in] open_id :INTEGER
[in] lin_num :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :TPE
Details:
• open_id specifies the opened teach pendant program. A program must be opened with read/write
access, using the OPEN_TPE built-in, before calling the DEL_INST_TPE built-in.
• lin_num specifies the line number of the instruction to be deleted.
• status explains the status of the attempted operation. If not equal to 0, then an error has occurred.
See Also: CREATE_TPE, CLOSE_TPE, COPY_TPE, OPEN_TPE, SELECT_TPE Built-In
Procedures
A-108
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
A.5.16
DET_WINDOW Built-In Procedure
Purpose: Detach a window from a screen
Syntax : DET_WINDOW(window_name, screen_name, status)
Input/Output Parameters :
[in] window_name :STRING
[in] screen_name :STRING
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
• Removes the specified window from the specified screen.
• window_name and screen_name must be valid and already defined.
• The areas of other window(s) hidden by this window are redisplayed. Any area occupied by this
window and not by any other window is cleared.
• An error occurs if the window is not attached to the screen.
• status explains the status of the attempted operation. If not equal to 0, then an error occurred.
See Also: DEF_WINDOW, ATT_WINDOW_S, ATT_WINDOW_D Built-In Procedures
Example: Refer to Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL), for a
detailed program example.
A.5.17
DISABLE CONDITION Action
Purpose: Used within a condition handler to disable the specified condition handler
Syntax : DISABLE CONDITION [cond_hand_no]
where:
cond_hand_no :an INTEGER expression
Details:
• If the condition handler is not defined, DISABLE CONDITION has no effect.
A-109
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
• If the condition handler is defined but not currently enabled, DISABLE CONDITION has no
effect.
• When a condition handler is disabled, its conditions are not tested. Thus, if it is activated again,
the conditions must be satisfied after the activation.
• Use the ENABLE CONDITION statement or action to reactivate a condition handler that has
been disabled.
• cond_hand_no must be in the range of 1-1000. Otherwise, the program will be aborted with an
error.
See Also: Chapter 6, ‘‘Condition Handlers,’’ for more information on using DISABLE CONDITION
in condition handlers
Example: The following example disables condition handler number 2 when condition number 1 is
triggered.
DISABLE CONDITION Action
CONDITION[1]:
WHEN EVENT[1] DO
DISABLE CONDITION[2]
ENDCONDITION
A.5.18
DISABLE CONDITION Statement
Purpose: Disables the specified condition handler
Syntax : DISABLE CONDITION [cond_hand_no]
where:
cond_hand_no :an INTEGER expression
Details:
• If the condition handler is not defined, DISABLE CONDITION has no effect.
• If the condition handler is defined but not currently enabled, DISABLE CONDITION has no
effect.
• When a condition handler is disabled, its conditions are not tested. Thus, if it is activated again,
the conditions must be satisfied after the activation.
• Use the ENABLE CONDITION statement or action to reactivate a condition handler that has
been disabled.
• cond_hand_no must be in the range of 1-1000. Otherwise, the program will be aborted with an
error.
A-110
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
See Also: Chapter 6 CONDITION HANDLERS , for more information on using DISABLE
CONDITION in condition handlers, Appendix E , ‘‘Syntax Diagrams,’’ for additional syntax
information
Example: The following example allows the operator to choose whether or not to see count .
DISABLE CONDITION Statement
PROGRAM p_disable
VAR
count
: INTEGER
answer
: STRING[1]
ROUTINE showcount
BEGIN
WRITE (’count = ’,count::10,CR)
END showcount
BEGIN
CONDITION[1]:
WHEN EVENT[1] DO
-- Condition[1] shows count
showcount
ENABLE CONDITION[1]
ENDCONDITION
ENABLE CONDITION[1]
count = 0
WRITE (’do you want to see count?’)
READ (answer,CR)
IF answer = ’n’
THEN DISABLE CONDITION[1]
-- Disables condition[1]
ENDIF
-- Count will not be shown
FOR count = 1 TO 13 DO
SIGNAL EVENT[1]
ENDFOR
END p_disable
A.5.19
DISCONNECT TIMER Statement
Purpose: Stops updating a clock variable previously connected as a timer
Syntax : DISCONNECT TIMER timer_var
where:
timer_var :a static, user-defined INTEGER variable
Details:
A-111
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
• If timer_var is not currently connected as a timer, the DISCONNECT TIMER statement has
no effect.
• If timer_var is a system or local variable, the program will not be translated.
See Also: Appendix E , ‘‘Syntax Diagrams,’’ for additional syntax information, CONNECT TIMER
Statement
Example: The following example moves the TCP to the initial position in PR[1], sets the INTEGER
variable timevar to 0 and connects the timer. After moving to the destination position in PR[2], the
timer is disconnected.
DISCONNECT TIMER Statement
move_to_pr1 - Call TP program to move to PR[1]
timevar = 0
CONNECT TIMER TO timevar
move_to_pr2 - Call TP program to move to PR[2]
DISCONNECT TIMER timevar
A.5.20
DISCTRL_ALPH Built_In Procedure
Purpose: Displays and controls alphanumeric string entry in a specified window.
Syntax : DISCTRL_ALPH(window_name, row, col, str, dict_name, dict_ele, term_char, status)
Input/Output Parameters :
[in] window_name :STRING
[in] row :INTEGER
[in] col :INTEGER
[in,out] str :STRING
[in] dict_name :STRING
[in] dict_ele :INTEGER
[out] term_char :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :UIF
A-112
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
Details:
•
window_name identifies the window where the str is currently displayed. See also Section 7.10.1
or Section 7.10.2 for a listing of windows that may be used for window_name.
•
row specifies the row number where the str is displayed.
•
col specifies the column number where the str is displayed.
•
str specifies the KAREL string to be modified, which is currently displayed on the window_name
at position row and col.
•
dict_name specifies the dictionary that contains the words that can be entered. dict_name can also
be set to one of the following predefined values.
’PROG’ :program name entry
’COMM’ :comment entry
•
dict_ele specifies the dictionary element number for the words. dict_ele can contain a maximum
of 5 lines with no "&new_line" accepted on the last line. See the example below.
•
If a predefined value for dict_name is used, then dict_ele is ignored.
•
term_char receives a code indicating the character that terminated the menu. The code for
key terminating conditions are defined in the include file FR:KLEVKEYS.KL. The following
predefined constants are keys that are normally returned:
ky_enter
ky_prev
ky_new_menu
•
DISCTRL_ALPH will display and control string entry from the teach pendant device. To display
and control string entry from the CRT/KB device, you must create an INTEGER variable,
device_stat, and set it to crt_panel. To set control to the teach pendant device, set device_stat to
tp_panel. Refer to the example below.
•
status explains the status of an attempted operation. If not equal to 0, then an error occurred.
Note DISCTRL_ALPH will only display and control string entry if the USER or USER2 menu
is the selected menu. Therefore, use FORCE_SPMENU(device_stat, SPI_TPUSER, 1) before
calling DISCTRL_ALPH to force the USER menu.
See Also: ACT_SCREEN, DISCTRL_LIST Built-In Procedures
Example: Refer to Section B.13 , "Using the DISCTRL_ALPHA Built-in" (DCLAP_EX.KL), for a
detailed program example.
A-113
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
A.5.21
DISCTRL_FORM Built_In Procedure
Purpose: Displays and controls a form on the teach pendant or CRT/KB screen
Syntax : DISCTRL_FORM(dict_name, ele_number, value_array, inact_array, change_array,
term_mask, def_item, term_char, status)
Input/Output Parameters :
[in] dict_name : STRING
[in] ele_number : INTEGER
[in] value_array : ARRAY OF STRING
[in] inactive_array : ARRAY OF BOOLEAN
[out] change_array : ARRAY OF BOOLEAN
[in] term_mask : INTEGER
[in,out] def_item : INTEGER
[out] term_char : INTEGER
[out] status : INTEGER
%ENVIRONMENT Group :PBcore
Details:
• dict_name is the four-character name of the dictionary containing the form.
• ele_number is the element number of the form.
• value_array is an array of variable names that corresponds to each edit or display only data item
in the form. Each variable name can be specified as a ’[prog_name]var_name’.
— [prog_name] is the name of the program that contains the specified variable. If [prog_name]
is not specified, the current program being executed is used. ’[*SYSTEM*]’ should be
used for system variables.
— var_name must refer to a static, global program variable.
— var_name can contain node numbers, field names, and/or subscripts.
— var_name can also specify a port variable with index. For example, ’DIN[1]’.
• inactive_array is an array of booleans that corresponds to each item in the form.
— Each boolean defaults to FALSE, indicating it is active.
— You can set any boolean to TRUE which will make that item inactive and non-selectable.
A-114
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
— The array size can be greater than or less than the number of items in the form.
— If an inactive_array is not used, then an array size of 1 can be used. The array does not
need to be initialized.
•
change_array is an array of booleans that corresponds to each edit or display only data item in
the form.
— If the corresponding value is set, then the boolean will be set to TRUE, otherwise it is set to
FALSE. You do not need to initialize the array.
— The array size can be greater than or less than the number of data items in the form.
— If change_array is not used, an array size of 1 can be used.
•
term_mask is a bit-wise mask indicating conditions that will terminate the form. This should be
an OR of the constants defined in the include file klevkmsk.kl.
kc_func_key — Function keys
kc_enter_key — Enter and Return keys
kc_prev_key — PREV key
If either a selectable item or a new menu is selected, the form will always terminate, regardless
of term_mask.
•
For version 6.20 and 6.21, def_item receives the item you want to be highlighted when the
form is entered. def_item returns the item that was currently highlighted when the termination
character was pressed.
•
For version 6.22 and later, def_item receives the item you want to be highlighted when the form is
entered. def_item is continuously updated while the form is displayed and contains the number of
the item that is currently highlighted
•
term_char receives a code indicating the character or other condition that terminated the form.
The codes for key terminating conditions are defined in the include file klevkeys.kl. Keys
normally returned are pre-defined constants as follows:
ky_undef — No termination character was pressed
ky_select — A selectable item was selected
ky_new_menu — A new menu was selected
ky_f1 — Function key 1 was selected
ky_f2 — Function key 2 was selected
ky_f3 — Function key 3 was selected
ky_f4 — Function key 4 was selected
A-115
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
ky_f5 — Function key 5 was selected
ky_f6 — Function key 6 was selected
ky_f7 — Function key 7 was selected
ky_f8 — Function key 8 was selected
ky_f9 — Function key 9 was selected
ky_f10 — Function key 10 was selected
• DISCTRL_FORM will display the form on the teach pendant device. To display the form on the
CRT/KB device, you must create an INTEGER variable, device_stat , and set it to crt_panel . To
set control to the teach pendant device, set device_stat to tp_panel.
• status explains the status of the attempted operation. If status returns a value other than 0, an
error has occurred.
Note DISCTRL_FORM will only display the form if the USER2 menu is the selected
menu. Therefore, use FORCE_SPMENU(device_stat, SPI_TPUSER2, 1) before calling
DISCTRL_FORM to force the USER2 menu.
See Also: Chapter 10 DICTIONARIES AND FORMS , for more details and examples.
A.5.22
DISCTRL_LIST Built-In Procedure
Purpose: Displays and controls cursor movement and selection in a list in a specified window
Syntax : DISCTRL_LIST(file_var, display_data, list_data, action, status)
Input/Output Parameters :
[in] file_ var :FILE
[in,out] display_data :DISP_DAT_T
[in] list_data :ARRAY OF STRING
[in] action :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group :PBCORE
Details:
• file_var must be opened to the window where the list data is to appear.
A-116
MARRC75KR07091E Rev D
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
• display_data is used to display the list. Refer to the DISP_DAT_T data type for details.
• list_data contains the list of data to display.
• action must be one of the following:
dc_disp : Positions cursor as defined in display_data
dc_up : Moves cursor up one row
dc_dn : Moves cursor down one row
dc_lf : Moves cursor left one field
dc_rt : Moves cursor right one field
• status explains the status of the attempted operation. If not equal to 0, then an error occurred.
• Using DISCTRL_FORM is the preferred method for displaying and controlling information in a
window.
See Also: DISCTRL_FORM Built-In Procedure, Section 7.10.1 , "User Menu on the Teach Pendant,"
Section 7.10.2 , "User Menu on the CRT/KB," Chapter 10 DICTIONARIES AND FORMS
Example: Refer to Section B.12 , "Displaying a List From a Dictionary File" (DCLST_EX.KL), for a
detailed program example.
Caution
The input parameters are not checked for validity. You must make sure the input
parameters are valid; otherwise, the built-in might not work properly.
A.5.23
DISCTRL_PLMN Built-In Procedure
Purpose: Creates and controls cursor movement and selection in a pull-up menu
Syntax : DISCTRL_PLMN(dict_name, element_no, ftn_key_no, def_item, term_char, status)
Input/Output Parameters :
[in] dict_name :STRING
[in] element_no :INTEGER
[in] ftn_key_num :INTEGER
[in,out] def_item :INTEGER
A-117
A. KAREL LANGUAGE ALPHABETICAL DESCRIPTION
MARRC75KR07091E Rev D
[out] term_char :INTEGER
[out] status :INTEGER
%ENVIRONMENT Group : UIF
Details:
•
The menu data in the dictionary consists of a list of enumerated values that are displayed and
selected from a pull-up menu on the teach pendant device. A maximum of 9 values should be
used. Each value is a string of up to 12 characters.
A sequence of consecutive dictionary elements, starting with element_no , define the values. Each
value must be put in a separate element, and must not end with &new_line. The characters are
assigned the numeric values 1..9 in sequence. The last dictionary element must be "".
•
dict_name specifies the name of the dictionary that contains the menu data.
•
element_no is the element number of the first menu item within the dictionary.
•
ftn_key_num is the function key where the pull-up menu should be displayed.
•
def_item is the item that should be highlighted when the menu is entered. 1 specifies the first
item. On return, def_item is the item that was currently highlighted when the termination
character was pressed.
•
term_char receives a code indicating the character that terminated the menu. The codes for key
terminating conditions are defined in the include file FROM:KLEVKEYS.KL. Keys normally
returned are pre-defined constants as follows:
ky_enter — A menu item was selected
ky_prev — A menu item was not selected
ky_new_menu — A new menu was selected
ky_f1
ky_f2
ky_f3
ky_f4
ky_f5
•
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
Example: In this example, dictionary file TPEXAMEG.TX is loaded as ’EXAM’ on the controller.
TPPLMN.KL calls DISCTRL_PLMN to display and process the pull-up menu above function key 3.
A-118
|
||
|
|
|