Robot Communications - Kawasaki Robot Controller

Overview

The purpose of this topic is to outline the steps to connect and transfer data from an In-Sight vision system to a Kawasaki Robot Controller. For this topic, 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 (via either Telnet or serial RS-232), will trigger the sensor to acquire and process an image and then the robot controller will request specific data from the sensor.  Data can be transferred using serial or Ethernet communications; however, Kawasaki recommends using Ethernet TCP/IP communications.For more information on Native Mode Commands, see Native Mode Commands.

Required Hardware

  • In-Sight vision system (In-Sight Micro 1000 series, In-Sight 5000 series, In-Sight 7000 series or the In-Sight 8000 series vision system)
  • For serial communications, an I/O module, Breakout cable (In-Sight 5000 series or In-Sight 7000 series only).

    Note:
    • While serial-based robot communications are supported with the Breakout cable (In-Sight 5000 series or In-Sight 7000 series only), an I/O module is recommended for ease of setup.
    • In-Sight Micro 1000 series vision systems only support serial communication when connected to the CIO-MICRO or CIO-MICRO-CC I/O module.
    • There are two options for enabling serial communication for the In-Sight 70xx - 74xx series vision system: using the Breakout cable or using the CIO-MICRO or CIO-MICRO-CC I/O module. When connected to the Breakout cable (and there is no connection to an I/O module), the vision system allows one discrete input line and one discrete output line to be configured as Serial Receive and Serial Transmit, respectively.
    • In-Sight 8000 series vision systems only support serial communication when connected to the CIO-MICRO I/O module.
    • The CIO-WENET Ethernet I/O module does not support serial communication.
  • PC
  • D-Controller 1QN (with Ethernet option) or C-Controller 1HA (with Ethernet Option)
  • Ethernet connection capable cables (100Base-T)
  • Sensor Interface (for Serial communications)

Required Software

  • Cognex In-Sight Explorer version 3.3.1 or higher
  • Cognex In-Sight firmware version 3.3.1 or higher
  • Kawasaki AS Language Programming

In-Sight Configuration

Configuring the In-Sight vision system to connect and transfer data to a Kawasaki robot controller involves configuring the vision system's Network Settings to communicate with the robot controller, and building a job that extracts position data.When an In-Sight vision system is configured to communicate with a Kawasaki robot controller, the vision system acts as a server.The robot controller will send a request for a value (GetValue - TCP_SEND), the vision system will process the request and respond with the cell value. The robot controller will receive the data (TCP_RECEIVE) and decode the data into a useable format.

In-Sight Network Settings

  1. From the Sensor menu, select Network Settings.
  2. In the Network Settings dialog, uncheck the Use DHCP Server checkbox.
  3. In the IP Address parameter, enter the vision system's IP address (192.168.0.12, in this example).
  4. Set the Telnet Port parameter to 10,000.
  5. Press OK to close the Network Settings dialog.

In-Sight Job Setup

  1. From the File menu, create a New Job.
  2. In the AcquireImage property sheet (double-click on cell A0), set the following parameters:
    • Trigger = External
    • Manual = Checked
  3. Select cell A2 and type ExtractBlobs and press Enter (at this point the ExtractBlobs property sheet will be displayed).
  4. Click OK (leaving all parameters at their default settings).
  5. Select cell A4 and, from the Palette's Snippets tab, insert the Communication > Robots > General.cxd Snippet into the spreadsheet.
  6. Define the coordinate cell references:
    • X: Double-click C6, double-click C2,
    • Y: Double-click D6, double-click D2
    • Angle: Double-click E6, double-click E2
  7. Press the Manual Trigger icon a few times to confirm that data from the ExtractBlobs function is changing.
  8. Save the job.
  9. Put the sensor Online.

Robot Controller Setup

The code example shows the controller connecting to an In-Sight vision system with the IP address 192.168.0.12.To find the IP address of your vision system from In-Sight Explorer, right-click the vision system's name in the In-Sight Network tree and select Properties.

.PROGRAM cognex()

;POINT FRAME1 is the part frame, where frame1 is calculated using

;the FRAME command: POINT FRAME1=FRAME(f.origin,f.x1,f.xy,f.origin)

;The coordinates are assumed to be received from the vision system in the part frame

$termchk=$CHR(13)+$CHR(10)

.ret1=-1

.ret1a=-1

.ret1a1=-1

.ret1b=-1

.ret1b1=-1

.ret1bc=-1

.ret2=-1

CALL tcp_open(10000); sock_id1 = CAMERA

IF sock_id1<0 THEN

RETURN

END

$receive=""

CALL tcp_recv(.ret1a,$receive)

IF .ret1a<0 GOTO quit

.$str = "admin"+$CHR(13)+$CHR(10)

CALL tcp_send(.ret1a1,.$str)

IF .ret1a1<0 GOTO quit

$receive = ""

CALL tcp_recv(.ret1b,$receive)

IF .ret1b<0 GOTO quit

$receive = ""

CALL tcp_recv(.ret1c,$receive)

IF .ret1c<0 GOTO quit

.$str = "GVA002"+$CHR(13)+$CHR(10)

CALL tcp_send(.ret1,.$str)

IF .ret1<0 GOTO quit

$receive = ""

CALL tcp_recv(.ret2,$receive)

IF .ret2<0 GOTO quit

$response = $receive

$ok = $DECODE($response,$termchk,0)

ok = VAL($ok)

IF ok <>1 GOTO quit

$response = $RIGHT($response,LEN($response)-4)

$response = $LEFT($response,LEN($response)-5)

$x = $DECODE($response,",",0)

x = VAL($x)

$temp = $DECODE($response,",",1)

$y = $DECODE($response,",",0)

y = VAL($y)

$temp = $DECODE($response,",",1)

o = VAL($response)

PRINT x,y,o

POINT pick = frame1 + TRANS(x,y,o)

HOME

LAPPRO pick, 100

LMOVE pick

CLAMP 1

LDEPART 100

HOME

quit:

CALL tcp_close

.END

.PROGAM tcp_close()

ret = 0

TCP_CLOSE ret,sock_id1

IF ret<0 THEN

PRINT "TCP_CLOSE error id = ",sock_id1

ELSE

PRINT "TCP_CLOSE OK id = ",sock_id1

END

.END

.PROGRAM tcp_open(.port)

tout_open = 60

ip[1] = 192

ip[2] = 168

ip[3] = 0

ip[4] = 12

port = .port

.er_count = 0

connect:

TIMER (2) = 0

TCP_CONNECT sock_id1,port,ip[1],tout_open

IF sock_id1<0 THEN

IF .er_count>=5 THEN

PRINT "Client Communication with Cognex has failed"

GOTO forgetit

ELSE

.er_count = .er_count+1

PRINT "TCP_CONNECT error id = ",sock_id1," error count = ",.er_count

GOTO connect

END

ELSE

PRINT "TCP_CONNECT OK id = ",sock_id1," with timep = ",TIMER(2)

END

forgetit:

RETURN

.END

.PROGRAM tcp_recv(.ret,$receive)

.ret = 0

.eret = -99

tout_rec = 60

max_length = 255

.$receive = ""

.num = 0

TCP_RECV .eret,sock_id1,.#recv_buff[1],.num,tout_rec,max_length

TIMER(3) = 0

IF .eret<0 THEN

PRINT "TCP_RECV error in RECV",.eret

PRINT ".num = ",.num

.ret = -1

ELSE

IF .num>0 THEN

IF .num*max_length<=255 THEN

PRINT "TCP_RECV OK in RECV",.eret

PRINT "Number of array elements = ",.num

FOR .j = 1 TO .num

.$receive = .$receive + .#recv_buf[.j]

PRINT "len(.$recv_buf[",.j,"] = ",LEN(.$recv_buf[.j])

PRINT ".$receive = ",.$receive

END

ELSE

.ret = -1

PRINT "String too long"

PRINT .$recv_buf[1]

END

ELSE

PRINT "Invalid response"

.ret = -1

END

.END

.PROGRAM tcp_send(.ret,.$data)

.$send_buf[1] = .$data

.buf_n = 1

.ret = 1

tout = 60

TCP_SEND .sret,sock_id1,.$send_buf[1],.buf_n,tout

IF .sret<0 THEN

.ret = -1

PRINT "TCP SEND error in SEND",.sret

ELSE

PRINT "TCP_SEND OK in SEND",.sret

PRINT "Sent string = ",$send_buf[1]

END

.END