FanucPlugin 1
FanucPlugin 1
9. Move the cursor to the Protocol Name item, and press F4, [CHOICE].
10. Select SM.
11. Move the cursor to the Startup State item, press F4, [CHOICE], and choose DEFINE.
12. Move the cursor to the Server IP/Hostname item, and press ENTER.
13. Type in hostname or IP address the of the remote host server you want to use for
socket messaging.
Note If you are not using DNS, you must add the remote host and its IP address into the
host entry table.
14. Press F2, [ACTION], and select DEFINE.
15. Set the system variable:
a. Press MENUS.
b. Select NEXT.
c. Select SYSTEM, and press F1, [TYPE].
d. Select Variables.
e. Move the cursor to $HOSTC_CFG, and press ENTER.
f. Move the cursor to the structure corresponding to the tag selected in Step 8 . For
example, if you are setting up tag C3, move the cursor structure element [3], as shown
in the following screen.
h. Move the cursor to $SERVER_PORT. Type in the name of the TCP/IP server port you
want to use for socket messaging. The client tag is now ready to use from a KAREL
program.
Karel
FANUC
The following will indicate how to set the Client and the Karel code to communicate with the
FlexiBowl. This script can be called to move the FlexiBowl or to put it in a parallel task, and to
regulate the execution through a traffic light.
The code will receive a command to execute, and return a string with the response from the
FlexiBowl.
STEP 2: Host Client C7 configuration to communicate with the FlexiBowl address: 192.168.1.10
Karel
FANUC
Karel
FANUC
STEP 3:
Karel
FANUC
Karel
FANUC
Karel
FANUC
Karel
FANUC
PROGRAM Flb_Plugin
STEP 6: VAR
Karel PingAddress:BOOLEAN
return_string : STRING[128]
status : INTEGER
moving:INTEGER
cmd_type: INTEGER
cmd_int_val:INTEGER
cmd_real_val:REAL
cmd_str_val:STRING[128]
command_Str:STRING[128]
file_var : FILE
tmp_str : STRING[128]
tmp_str1:STRING[128]
tmp_str2:STRING[128]
entry : INTEGER
ROUTINE Ping
BEGIN
PingAddress=FALSE
MSG_DISCO('C7:',status)
MSG_CONNECT('C7:',status)
IF(status=0) THEN
PingAddress=TRUE
else
PingAddress=FALSE
ENDIF
MSG_DISCO('C7:',status)
END Ping
----///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
---////////////////////////////////////////////////SENDCOMMAND////////////////////////////////////////////
--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ROUTINE SendCommand(CommandExecute:STRING):STRING
BEGIN
return_string='FAIL';
command_Str=CommandExecute
Karel
FANUC
CLR_IO_STAT(file_var)
status = IO_STATUS(file_var)
IF status = 0 THEN
--Write
tmp_str=CHR(0)+CHR(7)+ command_Str + CHR(13)
WRITE file_var (tmp_str)
IF( IO_STATUS(file_var)<>0) THEN
return_string='FAIL'
WRITE ('Status var OUT fail',CR)
go to end_it
ENDIF
--READ
entry=0
WHILE entry <1 DO
BYTES_AHEAD(file_var, entry, status)
ENDWHILE
STATUS = IO_STATUS(file_var)
IF(STATUS<>0)THEN
return_string='FAIL'
WRITE ('Status var IN fail',CR)
go to end_it
ENDIF
IF (entry>0) THEN
READ file_var (tmp_str1::entry)
tmp_str2=SUB_STR(tmp_str1,2,entry-1)
return_string=tmp_str2
ELSE
return_string='FAIL'
go to end_it
ENDIF
ELSE
WRITE ('Status var fail',CR)
return_string='FAIL'
go to end_it
ENDIF
end_it::
RETURN(return_string)
END SendCommand
----///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BEGIN
GET_TPE_PRM(1,cmd_type,cmd_int_val,cmd_real_val,cmd_str_val,S
TATUS)
IF(STR_LEN(cmd_str_val)>0) THEN
command_Str=cmd_str_val
else
return_string='FAIL'
go to end_it2
ENDIF
--setto i parametri di connessione
SET_FILE_ATR(file_var, ATR_IA)
MSG_DISCO('C7:', status)
MSG_CONNECT('C7:',status)
IF(status <> 0) THEN
return_string='FAIL'
go to end_it2
ENDIF
OPEN FILE file_var ('RW','C7:')
return_string=SendCommand(command_Str)
IF((INDEX(return_string,'%')<>0)
AND (INDEX(command_Str,'Q')<>0)) THEN
-----wait move
moving=1
WHILE (moving = 1) DO
command_Str='RS'
return_string=SendCommand(command_Str)
IF(INDEX(return_string,'F')>0) THEN
moving = 1
else
moving = 0
ENDIF
DELAY(50)
ENDWHILE
return_string='Done'
else
return_string=return_string
ENDIF
end_it2::
CLOSE FILE file_var
MSG_DISCO('C7:',status)
Action Description
MOVE Moves the feeder the current
parameters.
MOVE-FLIP Moves the feeder and activates Flip
simultaneously
MOVE-BLOW- Moves the feeder and activates Flip
FLIP and blow simultaneously
MOVE-BLOW Moves the feeder and activates Flip
simultaneously
SHAKE Shakes the feeder with the current
parameters
LIGHT ON Light on
LIGHT OFF Light off
FLIP Flip
BLOW Blow
QUICK_EMPTING Quick Emptying Option
RESET_ALARM Reset Alarm and enable the motor
Command Description
QX2 Move
QX3 Move - Flip
QX4 Move - Blow - Flip
QX5 Move - Blow
QX5 Shake
QX7 Light on
QX8 Light off
QX9 Flip
QX10 Blow
QX11 Quick Emptying Option
QX12 Reset Alarm
AL Status Allarm