In the FANUC Robotics SYSTEM R-30iA and R-30iB Controller KAREL Reference Manual, Table A-7. KAREL Built-In Routine Summary lists ADD_BYNAMEPC
, ADD_INTPC
, ADD_REALPC
, ADD_STRINGPC
, SEND_DATAPC
and SEND_EVENTPC
in a Category named "Personal Computer Communications".
I am interested in SEND_DATAPC
, but I am having a difficult time finding additional information about setting it up. Do you have any experience using this KAREL built-in procedure? I guess my confusion is about %ENVIRONMENT Group :PC
. What is being sent to "the PC" and how do you properly define "the PC"?
I looked at information about the "%ENVIRONMENT Translator Directive". I gather that I probably need to define a "PC.ev" environment file, but I am not sure what that should look like regarding syntax and what all it should contain for SEND_DATAPC
to function properly.
Quote[%ENVIRONMENT Translator Directive] is used by the off-line translator to specify that the binary file, path_name.ev, should be loaded. Environment files contain definitions for predefined constants, ports, types, system variables, and built-ins.
The previously mentioned reference manual explains the purpose, syntax, details and has a small example that sends event 12 to the PC with a data buffer:
PROGRAM TESTDATA
%ENVIRONMENT PC
CONST
er_about = 2
VAR
dat_buffer: ARRAY[100] OF BYTE
index: INTEGER
status: INTEGER
BEGIN
index = 1
ADD_INTPC(dat_buffer, index, 55, status)
ADD_REALPC(dat_buffer, index, 123.5, status)
ADD_STRINGPC(dat_buffer, index, 'YES', status)
-- send event 12 and data buffer to PC
SEND_DATAPC(12, dat_buffer, status)
IF status<>0 THEN
POST_ERR(status, '', 0, er_abort)
ENDIF
END TESTDATA
Display More
Does anyone know about SEND_DATAPC or if using SEND_DATAPC
in a condition handler will work?
I am new to FANUC and KAREL so I do not know if the following KAREL code snippet will work or not. Essentially, I want to have this running to capture and send any errors that occur while running a TP program. Any help or advice is very appreciated. Thank you.
PROGRAM SEND_ERR
%NOLOCKGROUP
%NOPAUSE = COMMAND + TPENABLE + ERROR
%NOBUSYLAMP
%NOABORT = ERROR + COMMAND
%COMMENT = 'SEND ERROR'
%ENVIRONMENT PC
VAR
dat_buffer: ARRAY[244] OF BYTE
index: INTEGER
status: INTEGER
error_code: INTEGER
error_string: STRING[40]
cause_code: INTEGER
cause_string: STRING[40]
time_int: INTEGER
severity: INTEGER
prog_nam: STRING[40]
ecst,esst,ccst,csst,tist,sst,pnst: INTEGER -- status variables
BEGIN
index = 1
CONDITION[1]:
WHEN ERROR[*] DO
-- seq_num should be set to MAXINT if the most recent error is desired.
ERR_DATA(MAXINT, error_code, error_string, cause_code, cause_string, time_int, severity, prog_nam)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'ERROR_CODE', ecst)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'ERROR_STRING', esst)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'CAUSE_CODE', ccst)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'CAUSE_STRING', csst)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'TIME_INT', tist)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'SEVERITY', sst)
ADD_BYNAMEPC(dat_buffer, index, 'SEND_ERR', 'PROG_NAM', pnst)
IF (ecst=0) AND (esst=0) AND (ccst=0) AND (csst=0) AND (tist=0) AND (sst=0) AND (pnst=0) THEN
SEND_DATAPC(0, dat_buffer, status)
ENDIF
index = 1
ENDCONDITION
ENABLE CONDITION[1]
END SEND_ERR
Display More