RobotComms Fanuc v1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 19

Tech Note: Robot Communications - FANUC

1 OVERVIEW....................................................................................................................2
1.1 Scope..........................................................................................................................2
2 SERIAL COMMUNICATIONS....................................................................................2
2.1 Needed Hardware.......................................................................................................2
2.2 Needed Software.........................................................................................................2
2.3 In-Sight Setup.............................................................................................................2
2.4 Robot Controller KAREL code..................................................................................2
2.5 In-Sight Serial Port Setup...........................................................................................4
2.5.1 Input Settings......................................................................................................4
2.5.2 Serial Settings.....................................................................................................5
2.6 In-Sight Job Setup......................................................................................................5
3 ETHERNET COMMUNICATIONS............................................................................6
3.1 Needed Hardware.......................................................................................................6
3.2 Needed Software.........................................................................................................6
3.3 In-Sight Setup.............................................................................................................6
3.4 Robot Controller Setup...............................................................................................6
3.4.1 Configuring the Socket Messaging Option.........................................................6
3.4.1.1 Setup the Client Tag.....................................................................................6
3.4.1.2 Set the System Variable (Client Tag)..........................................................7
3.4.2 Robot Controller KAREL code..........................................................................8
3.5 In-Sight Job Setup....................................................................................................10
4 SENSOR INTERFACE COMMUNICATIONS........................................................12
4.1 Needed Hardware.....................................................................................................12
4.2 Needed Software.......................................................................................................12
4.3 In-Sight Setup...........................................................................................................12
4.4 Robot Controller Teach-Pendant code.....................................................................12
4.5 In-Sight Serial Port Setup.........................................................................................13
4.5.1 Serial Settings...................................................................................................13
4.6 In-Sight Job Setup....................................................................................................14
5 TROUBLE SHOOTING..............................................................................................14
5.1 Serial with HyperTerminal.......................................................................................14
5.1.1 In-Sight Serial Port Setup.................................................................................14
5.1.2 Input Settings....................................................................................................14
5.1.3 Serial Settings...................................................................................................15
5.1.4 Setup a Test Job................................................................................................15
5.1.5 Connect to In-Sight..........................................................................................17
5.2 Verify Ethernet connection with Telnet...................................................................17
5.2.1 Setup a Test Job................................................................................................17
5.2.2 Connect to In-Sight...........................................................................................18

Page 1 of 17
Version 1.0 8/16/06
1 Overview
1.1 Scope
The purpose of this document is to outline the steps needed to connect and
transfer data from a Cognex In-Sight Sensor to a FANUC Robot Controller. In all
setups outlined the robot controller will be the device controlling the acquisition
and transfer of data. In general the robot controller, with the use of In-Sight
Native Mode commands, will trigger the sensor to acquire and process an image
and then the robot controller will request specific data from the sensor.

For a full list of Native Mode commands from In-Sight Explorer Select Help | In-
Sight Explorer Help; from the Contents tab expand Communications Reference |
Native Mode Communications and here you'll find the full list of all Basic and
Extended Native Mode commands.

2 Serial communications
2.1 Needed Hardware
In-Sight Sensor (models 3400 or 5x00)
In-Sight I/O module (model 1450 or 1460)
DB9 Serial Cable (300-0281)
Computer
FANUC Robot Controller (RJ2 or RJ3)
K-Floppy Cable (DB25 to DB9)
Null Modem Adapter (DB9 to DB9)

2.2 Needed Software


Cognex In-Sight Explorer version 3.3 or higher
Cognex In-Sight Explorer firmware version 3.3 or higher
FANUC KAREL programming language

2.3 In-Sight Setup


• Make sure In-Sight Explorer version 3.3 or higher is installed
• Make sure In-Sight firmware is version 3.3 of higher

2.4 Robot Controller KAREL code

VAR
file_var :FILE
Status :STRING[4]
xs :STRING[9]
ys :STRING[9]
angles :STRING[9]

Page 2 of 17
Version 1.0 8/16/06
x :REAL
y :REAL
angle :REAL

BEGIN
-- Connect to In-Sight
OPEN FILE file_var ('RW', 'P2:')

-- Instruction In-Sight to Acquire an Image


-- (wait for a response)
WRITE file_var ('sw8',CHR(13))

-- Read status
READ file_var (status::1::0)
IF status <> '1' THEN
WRITE TPDISPLAY('sw8 Failed',CR)
RETURN
ENDIF

CLR_IO_STAT(file_var)

-- Get the value in cell C7


WRITE file_var ('gvc007',CHR(13))

-- Read status
READ file_var (status::1::0)
IF status <> '1' THEN
WRITE TPDISPLAY('gvc007 Failed',CR)
RETURN
ENDIF

CLR_IO_STAT(file_var)

-- Read the data


-- This will split the information at the quotations "'".
-- Example String '10.5''9.8''15.9'
READ file_var (xs::0::2, ys::0::2, angles::0::2)

-- Convert the data


CNV_STR_REAL(xs, x)
CNV_STR_REAL(ys, y)
CNV_STR_REAL(angles, angle)

-- Remove comment for testing


-- WRITE TPDISPLAY('X:',x,CR,'Y:',y,CR,'R',Angle,CR)

--
-- Use Vision Data
--

-- Close the connection


CLOSE FILE file_var

Page 3 of 17
Version 1.0 8/16/06
2.5 In-Sight Serial Port Setup
While connected to the sensor and Offline:
2.5.1 Input Settings
• Select Sensor | Discrete I/O Settings | Input Settings…
• For Input Module, select I/O Expansion Module

• Click OK

Page 4 of 17
Version 1.0 8/16/06
2.5.2 Serial Settings
• Select Sensor | Serial Port Settings…
• Set the following properties:

o Baud Rate: 19200


o Data Bits: 8
o Stop Bits: 1
o Parity: None
o Handshake: None
o Mode: Native
o Fixed Input Length: Unchecked
o Input Terminator: 13
o Output Terminator: 0
o Verify that the dialog reports that the “I/O Expansion Module is
attached”
• Click OK

2.6 In-Sight Job Setup


With a New Job perform the following steps:
• Set the A0 Image cell properties (double-click cell A0):
o Trigger = External
o Manual = Checked
• In cell A2 type ExtractBlobs( at this point the property sheet for
ExtractBlobs should popup, click OK
• Insert Snippet “FANUC Communications”:
o Select cell A4
o If the Tool Palette isn’t visible; select View | Tool Palette
o From the Snippets tag double-click FANUC Communications
• Define the coordinate cell references:
o X: Double-click C6, double-click C2,

Page 5 of 17
Version 1.0 8/16/06
o Y: Double-click D6, double-click D2
o Angle: Double-click E6, double-click E2
• Press the Manual Trigger icon a few times to confirm that ExtractBlobs( )
data is changing.
• Save the job
• Turn the sensor Online

3 Ethernet Communications
3.1 Needed Hardware
In-Sight Sensor (models 3400 or 5x00)
In-Sight I/O module (model 1450 or 1460)
Ethernet Cable
Computer
FANUC Robot Controller (RJ3)
NOTE: RJ2 is not compatible with Ethernet communications

3.2 Needed Software


Cognex In-Sight Explorer version 3.3 or higher
Cognex In-Sight Explorer firmware version 3.3 or higher
FANUC Socket Messaging Option
FANUC KAREL programming language
3.3 In-Sight Setup
• Make sure In-Sight Explorer version 3.3 or higher is installed
• Make sure the sensors firmware is version 3.3 of higher

3.4 Robot Controller Setup


3.4.1 Configuring the Socket Messaging Option
• The tag you want to setup cannot be configured for uses by another
device on your network
3.4.1.1 Setup the Client Tag
• Cold start the controller.
o On the teach pendant , press and hold the SHIFT and RESET
keys. Or, on the operator panel , press and hold RESET.
o While still pressing SHIFT and RESET on the teach pendant (or
RESET on the operator panel), press the ON button on the
operator.
o Release all of the keys.
• On the teach pendant, press MENUS.
• Select SETUP.
• Press F1, [TYPE].
• Select Host Comm.

Page 6 of 17
Version 1.0 8/16/06
• Press F4, [SHOW].
• Choose Clients.
• Move the cursor to the tag you want set up for Socket Messaging, and
press F3

You will see a screen similar to the following:


SETUP Tags

Tag C3:

1 Comment: ****************
2 Protocol name: SM
3 Port name: *****
4 Mode: *************************
Current
State: UNDEFINED
5 Remote: ********
6 Path: ****************************
Startup
7 State:
8 Remote: 192.168.0.1
9 Path: ****************************
Options
10 Error Reporting: OFF
11 Inactivity Timeout: 15 min

• Move the cursor to Protocol name, and press F4, [CHOICE].


• Select SM.
• Move the cursor to Startup State, and press F4, [CHOICE].
• Select Start, and press ENTER.
• Select Remote, and press ENTER.
• Type in the of the remote host server you want to use for socket
messaging, and press F2, [ACTION].
• Select DEFINE.

Note

If you are not using DNS, you must add the remote host and its IP
address into the host entry table.

3.4.1.2 Set the System Variable (Client Tag)


• Press MENUS.
• Select NEXT.
• Select SYSTEM, and press F1, [TYPE].
• Select Variables.
• Move the cursor to $HOSTC_CFG, and press ENTER.

Page 7 of 17
Version 1.0 8/16/06
• Move the cursor to the structure corresponding to the tag selected in
the previous section Setup the Tag For example, if you are setting up
tag S3, move the cursor structure element [3], as shown in the
following screen.

SYSTEM Variables
$HOSTS_CFG
1 [1] HOST_CFG_T
2 [2] HOST_CFG_T
3 [3] HOST_CFG_T
4 [4] HOST_CFG_T
5 [5] HOST_CFG_T
6 [6] HOST_CFG_T
7 [7] HOST_CFG_T
8 [8] HOST_CFG_T

• Press ENTER. You will see a screen similar to the following.


SYSTEM Variables
$HOSTS_CFG[3]
1 $COMMENT *uninit*
2 $PROTOCOL ’SM’
3 $PORT *uninit*
4 $OPER 3
5 $STATE 3
6 $MODE *uninit*
7 $REMOTE *uninit*
8 $REPERRS FALSE
9 $TIMEOUT 15
10 $PATH *uninit*
11 $STRT_PATH *uninit*
12 $STRT_REMOTE *uninit*
13 $USERNAME *uninit*
14 $PWRD_TIMOUT 0
15 $SERVER_PORT 23

• 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.

The code example shows the controller connecting to an In-Sight with IP address
192.168.0.1; To find the IP address of your sensor, from In-Sight Explorer, right-
click the sensor name under In-Sight Network and select Properties.
3.4.2 Robot Controller KAREL code
PROGRAM eComm
VAR
file_var : FILE
tmp_int : INTEGER
mp_str : STRING[128]
status : INTEGER
entry : INTEGER

Page 8 of 17
Version 1.0 8/16/06
try : INTEGER
statuss :STRING[1]
xs :STRING[9]
ys :STRING[9]
angles :STRING[9]
x :REAL
y :REAL
angle :REAL
BEGIN
WRITE TPDISPLAY(CR,CR,CR,CR,CR,CR,CR,CR,CR,CR,CR,CR,CR,CR,CR)
SET_FILE_ATR(file_var, ATR_IA)

-- Connect the tag


WRITE TPDISPLAY('Connecting…',CR)
MSG_DISCO('C3:', status)
MSG_CONNECT('C3:',status)
OPEN FILE file_var('rw','C3:')

-- Read the In-Sight Welcome message


WRITE TPDISPLAY('Logging In',CR)
mp_str =''
READ file_var(mp_str)
WRITE TPDISPLAY(mp_str,CR)

-- Read User: prompt


READ file_var(mp_str::6::0)
IF UNINIT(mp_str) THEN
mp_str = ''
ENDIF
WRITE TPDISPLAY(mp_str,CR)
IF (mp_str <>'User: ') THEN
WRITE TPDISPLAY('User Failed',CR)
--Error
RETURN
ENDIF

--Send User Name


WRITE file_var('admin',CHR(13),CHR(10))

-- Read Password prompt


mp_str =''
READ file_var(mp_str::10::0)
IF UNINIT(mp_str) THEN
mp_str = ''
ENDIF
WRITE TPDISPLAY(mp_str,CR)
IF (mp_str <>'Password: ') THEN
WRITE TPDISPLAY('Password Failed',CR)
--Error
RETURN
ENDIF

--Send Password
WRITE file_var('',CHR(13),CHR(10))

-- Read Login Response

Page 9 of 17
Version 1.0 8/16/06
mp_str =''
READ file_var(mp_str)
IF UNINIT(mp_str) THEN
mp_str = ''
ENDIF
WRITE TPDISPLAY(mp_str,CR)
IF (mp_str <> 'User Logged In') THEN
WRITE TPDISPLAY('Log In Failed',CR)
--Error
RETURN
ENDIF

-- Instruction In-Sight to Acquire an Image


-- (wait for a response)
WRITE TPDISPLAY('Trigger',CR)
WRITE file_var ('sw8',CHR(13),CHR(10))

-- Read Status
READ file_var (statuss)
IF statuss <> '1' THEN
WRITE TPDISPLAY('sw8 Failed',CR)
RETURN
ENDIF

-- Get the value in cell C7


WRITE TPDISPLAY('Get Value C7',CR)
WRITE file_var ('gvc007',CHR(13),CHR(10))

-- Read Status
READ file_var (statuss)
IF statuss <> '1' THEN
WRITE TPDISPLAY('gvc007 Failed',CR)
RETURN
ENDIF

-- Read the data


-- This will split the information at the quotations "'".
-- Example String '10.5''9.8''15.9'
READ file_var (xs::0::2, ys::0::2, angles::0::2)

--Disconnect Socket
MSG_DISCO('C3:', status)

-- Convert the data


CNV_STR_REAL(xs, x)
CNV_STR_REAL(ys, y)
CNV_STR_REAL(angles, angle)
WRITE TPDISPLAY('X:',x,CR,'Y:',y,CR,'R',Angle,CR)
END eComm

3.5 In-Sight Job Setup


With a New Job perform the following steps:
• Set the following A0 Image cell properties (double-click cell A0):
o Trigger = External

Page 10 of 17
Version 1.0 8/16/06
o Manual = Checked
• In cell A2 type ExtractBlobs( at this point the property sheet for
ExtractBlobs should popup, click OK
• Insert Snippet “FANUC Communications”:
o Select cell A4
o If the Tool Palette isn’t visible; select View | Tool Palette
o From the Snippets tag double-click FANUC Communications
• Define the coordinate cell references:
o X: Double-click C6, double-click C2,
o Y: Double-click D6, double-click D2
o Angle: Double-click E6, double-click E2
• Press the Manual Trigger icon a few times to confirm that ExtractBlobs( )
data is changing.
• Save the job
• Turn the sensor Online

Page 11 of 17
Version 1.0 8/16/06
4 Sensor Interface Communications
To use the Sensor Interface option a third-party protocol converter, from
PREMOSYS http://www.premosys.com, is required. This converter handles the
serial handshaking protocol of FANUC’s Sensor Interface.

4.1 Needed Hardware


In-Sight Sensor (models 3400 or 5x00)
In-Sight I/O module (model 1450 or 1460)
PREMOSYS Protocol converter VE0010
Computer
FANUC Robot Controller (RJ3)
Serial Cable (DB25 to DB25)
In-Sight to VE0010 cable (see VE0010 manual)

4.2 Needed Software


Cognex In-Sight Explorer version 3.3 or higher
Cognex In-Sight Explorer firmware version 3.3 or higher
FANUC Sensor Interface Option

4.3 In-Sight Setup


• Make sure In-Sight Explorer version 3.3 or higher is installed
• Make sure In-Sight firmware is version 3.3 of higher

4.4 Robot Controller Teach-Pendant code

1: R[20:MEASURE_CNTR_CAM]=0 ;
2: R[2:ALARM CODE]=0 ;
3: LBL[9] ;
4: !REGISTER CHOICE ;
5: R[51:REGISTER_CHOICE]=5 ;
6: R[6:INTERMEDIATE_CALC]=R[51:REGISTER_CHOICE]*65536 ;
7: R[1:SEND_CAM]=R[50:PRODUCT_CHOICE]+256 ;
8: R[1:SEND_CAM]=R[1:SEND_CAM]+1 ;
9: R[1:SEND_CAM]=R[1:SEND_CAM]+R[6:INTERMEDIATE_CALC] ;
10: R[5:REC_ACK]=0 ;
11: SEND R[1:SEND_CAM] ;
12: RCV R[5:REC_ACK] LBL[1] TIMEOUT,LBL[1] ;
13: R[20:MEASURE_CNTR_CAM]=R[20:MEASURE_CNTR_CAM]+1 ;
14: JMP LBL[2] ;
15: !Measurement I/O ;
16: LBL[2] ;
17: IF R[5:REC_ACK]=1,JMP LBL[3] ;
18: !Measurement Not OK ;
19: IF R[20:MEASURE_CNTR_CAM]=1,JMP LBL[9] ;
20: IF R[20:MEASURE_CNTR_CAM]=2,JMP LBL[10] ;
21: LBL[10] ;

Page 12 of 17
Version 1.0 8/16/06
22: !In-Sight TO ROBOT ;
23: IF R[5:REC_ACK]=2 OR R[5:REC_ACK]=3 OR R[5:REC_ACK]=6,JMP LBL[4]
;
24: !ROBOT TO In-Sight ;
25: IF R[5:REC_ACK]=4 OR R[5:REC_ACK]=5 OR R[5:REC_ACK]=8 OR
: R[5:REC_ACK]=9,JMP LBL[5] ;
26: !POSITION IS Not OK ;
27: IF R[5:REC_ACK]=12,JMP LBL[6] ;
28: LBL[4:Alarm Code 1] ;
29: R[2:ALARM CODE]=4 ;
30: JMP LBL[3] ;
31: LBL[5:Alarm Code 2] ;
32: R[2:ALARM CODE]=5 ;
33: JMP LBL[3] ;
34: LBL[6:Alarm Code 3] ;
35: R[2:ALARM CODE]=6 ;
36: JMP LBL[3] ;
37: LBL[3:End] ;

4.5 In-Sight Serial Port Setup


While connected to the sensor and Offline:
4.5.1 Serial Settings
• Select Sensor | Serial Port Settings…
• Set the following properties:

o Baud Rate: 4800


o Data Bits: 8
o Stop Bits: 1
o Parity: None
o Handshake: None
o Mode: Native
o Fixed Input Length: Unchecked
o Input Terminator: 13
o Output Terminator: 13

Page 13 of 17
Version 1.0 8/16/06
• Click OK

4.6 In-Sight Job Setup


Use the sample included with the VE0010 protocol converter

5 Trouble Shooting
5.1 Serial with HyperTerminal
5.1.1 In-Sight Serial Port Setup
While connected to the sensor and Offline:
5.1.2 Input Settings
• Select Sensor | Discrete I/O Settings | Input Settings…
• For Input Module, select I/O Expansion Module

• Click OK

Page 14 of 17
Version 1.0 8/16/06
5.1.3 Serial Settings
• Select Sensor | Serial Port Settings…
• Set the following properties:

o Baud Rate: 115200


o Data Bits: 8
o Stop Bits: 1
o Parity: None
o Handshake: None
o Mode: Native
o Fixed Input Length: Unchecked
o Input Terminator: 13
o Output Terminator: 13
o Verify that the dialog reports that the “I/O Expansion Module is
attached”
• Click OK
5.1.4 Setup a Test Job
• With a New Job perform the following steps:
o Confirm the following A0 Image cell properties (double-click cell
A0):
 Trigger = External
 Manual = Checked (default)
o In cell A2 type ExtractBlobs( at this point the property sheet for
ExtractBlobs should popup, click OK
o In cell A4 type FindBlobs( at this point the property sheet for
FindBlobs should popup, enter B2 for the Blobs property and then
click OK
• You can test the job by clicking the Manual Trigger button on the icon bar
or selecting Image | Manual Trigger from the menus

Page 15 of 17
Version 1.0 8/16/06
• Put the sensor Online by either clicking the Online button on the icon bar
or selecting Sensor | Online from the menus

Page 16 of 17
Version 1.0 8/16/06
5.1.5 Connect to In-Sight
• From Windows click Start | All Programs | Accessories | Communications |
HyperTerminal
• Create a New Connection
o Port: COM1
o Bits per second: 115200
o Data bits: 8
o Parity: None
o Stop bits: 1
o Flow Control: None
• File | Properties | Settings
o Emulation: ANSI
o ANSII Setup (for viewing ease) set the following
 Send line ends with line feeds
 Echo typed characters locally
 Append line feeds to incoming line ends
 Wrap lines that exceed terminal width
• Connect
• Type: sw8 (this will cause a manual acquire and the image should
change)
• Type: gvC004 (this will get the value of cell C4)

5.2 Verify Ethernet connection with Telnet


5.2.1 Setup a Test Job
• Check and record the IP address of your sensor by selecting Help | About
In-Sight Explorer... from the menus
• With a New Job perform the following steps:
o Confirm the following A0 Image cell properties (double-click cell
A0):
 Trigger = External
 Manual = Checked (default)
o In cell A2 type ExtractBlobs( at this point the property sheet for
ExtractBlobs should popup, click OK
o In cell A4 type FindBlobs( at this point the property sheet for
FindBlobs should popup, enter B2 for the Blobs property and then
click OK
• You can test the job by clicking the Manual Trigger button on the icon bar
or selecting Image | Manual Trigger from the menus
• Put the sensor Online by either clicking the Online button on the icon bar
or selecting Sensor | Online from the menus

Page 17 of 17
Version 1.0 8/16/06
5.2.2 Connect to In-Sight
• From Windows click Start | Run...
• In the Run window type: telnet <the sensors IP Address> example: telnet
10.27.80.66
• Click OK
• You should be prompted for a user name, type admin
• Press Enter
• The password by default is blank, so just press Enter
• You should now see User Logged In
• Type: sw8 (this will cause a manual acquire and the image should
change)
• Type: gvC004 (this will get the value of cell C4)
• To disconnect your telnet session type CTRL + ]
• type: quit to close the window

Page 18 of 17
Version 1.0 8/16/06

You might also like