June 19, 2019, 03:05:53 AM
Robotforum | Industrial Robots Community

 Communication kuka/Cognex using EthernetKRL (TCP/IP protocol)

veryhot_post Author Topic:  Communication kuka/Cognex using EthernetKRL (TCP/IP protocol)  (Read 935 times)

0 Members and 1 Guest are viewing this topic.

May 18, 2019, 12:01:52 PM
Read 935 times
Offline

Dante


Hello all
I have a KR C4 that I would like to couple with a cognex using EthernetKRL.
1. I installed the package (EthernetKRL) and tested all the samples provided with using the server.exe program and the example server "XmlServer" with a Hyperterminal as it was mentioned in the manual.
2. On cognex (In-Sight Explorer) I have a program that extracts Blods and transmits the data to an external system via TCP / IP. I tested it with hypeterminal using the cognex as server to transmit the data at first, and transmit data from hyperterminal in a second time.
Both are working perfectly.
3. But I can not communicate the kuka to the cognex, I used kuka as server and cognex as client and inverted but it does not work. The flag tells me that there was no connection.
Can you help me to solve this problem?

Today at 03:05:53 AM
Reply #1

Advertisement

Guest

May 18, 2019, 04:39:52 PM
Reply #1
Offline

panic mode

Global Moderator
you just stated that you tested stock samples but provided no program example or description of what you are actually doing. obviously some adaptations are needed.


so, read READ FIRST and try again
1) http://www.robot-forum.com/robotforum/kuka-robot-forum/read-first/
2) if you want reply about robot, post it in forum
3) read 1 and 2

May 19, 2019, 11:32:59 AM
Reply #2
Offline

Dante


I tried to make a communication between a cognex (In-Sight 5100) and a kuka model KR 6 R700 sixx, type of controller KR C4 compact version KSS 8.3
1.I have the EthernetKRL package installed, but I can not get a connection between cognex / kuka. Nothing happens when I launch my connection program (below)
2.Is there a specific library that allows communication between kuka / cognex?

Code: [Select]
DEF XmlServer( )

DECL EKI_STATUS RET
BAS (#INITMOV,0 )

RET=EKI_Init("XmlServer")
RET=EKI_Open("XmlServer")

; wait until server is conntected
wait for $FLAG[1]

; wait until server is deconnected
wait for $FLAG[1]==FALSE

RET=EKI_Clear("XmlServer")
END

May 19, 2019, 06:08:50 PM
Reply #3
Offline

panic mode

Global Moderator

No... Ethernet communication is using Client-Server model.
There is no Server-Server model.


You already mentioned that IS5100 is working as a Server, and i doubt you can change that behavior.

KRC can be either Client or Server but ... since IS5100 is acting as a Server, KRC must be acting as a Client...

« Last Edit: May 19, 2019, 06:14:39 PM by panic mode »

May 19, 2019, 09:25:35 PM
Reply #4
Offline

Dante


Yes I know for the ethernet communication model (server / client), IS5100 can work as a server or as a client too.
I tried communication using KRC as server and IS5100 as client it does not work. After I invert the model using this time KRC as client and IS5100 as the server and this the same result (still nothing, no connection).
Before trying the communication between KRC and cognex, I performed a series of tests with hyperterminal:
--with KRC
--and with cognex too
the communication worked for both.

May 19, 2019, 09:36:13 PM
Reply #5
Offline

panic mode

Global Moderator
what are the settings? network, XML config?
you can use EireShark to monitor communication and see what the difference is between samples (working) and your code (not working)

May 19, 2019, 10:00:25 PM
Reply #6
Offline

Dante


In KRC I have an XML file (image attached) in which I made my configuration and I use the same configuration data on the side of IS5100 (port, IP address).
 I have a flag that tells me if the connection is established or not.

Code: [Select]
<CONFIGURATION>
<EXTERNAL>
<TYPE>Client</TYPE>
</EXTERNAL>
<INTERNAL>
<ENVIRONMENT>Program</ENVIRONMENT>
<BUFFERING Mode="FIFO" Limit="10"/>
<BUFFSIZE Limit="16384"/>
<TIMEOUT Connect="60000"/>
<ALIVE Set_Out="666" Ping="200"/>
<IP>192.1.10.20</IP>
<PORT>54600</PORT>
<PROTOCOL>TCP</PROTOCOL>
<MESSAGES Logging="error" Display="disabled"/>
</INTERNAL>
</CONFIGURATION>

Today at 03:05:53 AM
Reply #7

Advertisement

Guest

May 20, 2019, 12:52:03 PM
Reply #7
Offline

SkyeFire

Global Moderator
As Panic said, are you using WireShark to capture the network traffic and compare the working and non-working packets?

Your XML config file is set to use port 54600 -- did you configure the Cognex to use Telnet on that same port?

How is the camera being triggered?  Unless you're sending 'SE8' or something similar to the camera, it can only be triggered by the hardware input.

Your KRL code has no EKI_GET commands.

Your KRL code is using $FLAG[1] to detect the connection, but you do not have that flag configured in your XML.  You also have no flag configured for Data Received.

Why are you trying to configure the robot as the server?  It should be far simpler to let the camera act as the server, send trigger commands via raw ASCII, and parse the returned string.





May 20, 2019, 04:48:28 PM
Reply #8
Offline

Dante


Thanks
the connection is established in server / client mode (KRC is the server) as I wanted but I can not read and write data on the camera software.
The instructions for the transmission and reception of EthernetKRL data are not recogiled by IS5100.
Is there a specific library to allow the exchange of data between KRC / IS5100 without ambiguity ???

May 20, 2019, 05:36:18 PM
Reply #9
Offline

panic mode

Global Moderator
There was a KUKA.VisionCom but not sure if it is still available. Talk to your KUKA rep

May 21, 2019, 05:05:39 PM
Reply #10
Offline

SkyeFire

Global Moderator
If you're trying to connect to the Cognex Telnet interface, you have to use RAW mode in EKI and build your strings correctly for the Cognex Native Mode commands (and append the ASCII codes for CR and LF to the end).  And build a Telnet-send element into the Cognex program, and then pull the returned string from the EKI buffer and parse it into its components in KRL.

And if you want help, try answering the questions.  "Cannot read/write data on the camera software" tells us NOTHING about the DETAILS we need to know in order to have any chance of offering you any practical assistance.

May 23, 2019, 07:12:53 PM
Reply #11
Offline

Dante


Thanks,
I contacted kuka to ask them for the library kuka.VisionCom but they told me to use EthernetKRL to do frame exchanges with the camera (they did not mention kuka.VisioCom).

1. SkyeFire@ I did not quite understand what you mean by "create your channels correctly for the native cognex mode control", I used RAW mode in EKI for data reception and in my program KRL I uses the CAST_TO() and CAST_FROM() instructions for sending and receiving data (see attached code).
2. In my cognex program I created a TCPDevice("IP robot","Port","Packet type","Timeout") and with a WriteDevice("Evenement","Device","Data",[Data1,Data2...]") I send the data, does this correspond to the cognex telnet sending element that you are talking about?
can you enlighten me a little, in advance thank you.


Code: [Select]
Fichier Configuration<CONFIGURATION>
      <EXTERNAL>
           <IP>192.168.1.99</IP>
           <PORT>59152</PORT>
           <TYPE>Server</TYPE>
      </EXTERNAL>
         <RECEIVE>
            <RAW>
                   <ELEMENT Size="10" Set_Flag="1" Type="BYTE" Tag="Buffer"/>
            </RAW>
         </RECEIVE>
         <SEND/>
     </ETHERNETKRL>
</CONFIGURATION>

Code: [Select]
Programme KRLDEF BinaryFixed( )
;FOLD Declaration
          DECL EKI_STATUS RET
          CHAR Bytes[10]
          INT i
          INT OFFSET
          REAL valueReal          INT    valueInt;ENDFOLD (Declaration)

  BAS (#INITMOV,0 )

;FOLD Initialize sample data
  FOR i=(1) TO (10) 
    Bytes[i]=0
  ENDFOR 
  OFFSET=0
  valueReal=0  valueInt=0;ENDFOLD (Initialize sample data)

RET=EKI_Init("BinaryFixed")
RET=EKI_Open("BinaryFixed")

OFFSET=0
CAST_TO(Bytes[],OFFSET,34.425,6743)

RET = EKI_Send("BinaryFixed",Bytes[])
WAIT FOR $FLAG[1]

RET=EKI_GetString("BinaryFixed","Buffer",Bytes[])
$FLAG[1]=FALSE

OFFSET=0
CAST_FROM(Bytes[],OFFSET,valueReal,valueInt)

RET=EKI_Close("BinaryFixed")
RET=EKI_Clear("BinaryFixed")
END

May 24, 2019, 06:37:32 PM
Reply #12
Offline

SkyeFire

Global Moderator
You have both the KRC and the Cognex set up as Clients.  One has to be a server, the other has to be a client.

Look up "Native Mode Commands" in the Cognex documentation.  That can be carried out using simply ASCII strings, sent Raw via EKI, with no CAST instructions.

May 25, 2019, 12:42:24 AM
Reply #13
Offline

Dante


Thank you for your answer

KRC is the client and cognex the server. I read the native command doc of cognex but I can not use them in/with EthernetKRL.
But I can send as you said a character for the moment since EKI using the Raw format and I recover it on cognex in ASCII format (for example Eki_Send ("BinaryFixed", Bytes []).

1. If I want to send real values, should I code in ASCII characters?

2. If I send more data from EKI how to sort the cognex side to the recovery (because in cognex I use a TCTDivice to read the data send by EKI)

Today at 03:05:53 AM
Reply #14

Advertisement

Guest

May 28, 2019, 03:07:19 PM
Reply #14
Offline

SkyeFire

Global Moderator
If you're using Native Mode Commands, stick with ASCII, don't mess with bytes.  XML config must be Raw.

Build your command string using SWRITE functions in KRL.  Then you will have to directly append the CR&LF characters via direct ASCII value manipulation, like this:
Code: [Select]
DEF SendCommandToCognex (FI_chCommandString[])
DECL STATE_T _State
DECL INT _nOffset
DECL CHAR FI_chCommandString[]
DECL CHAR _chCommandString[100]
_nOffset = 0
SWRITE(_chCommandString[], _State, _nOffset, "%s,", "SE8")
_chCommandString[STRLEN(_chCommandString[]) + 1] = 'H0D' ; append CR
_chCommandString[STRLEN(_chCommandString[]) + 2] = 'H0A' ; append LF
; put EKI_SEND commands here
END

The Cognex depends on seeing the CR&LF characters when using Telnet-style commands, but they can't be added into a string normally, hence the workaround.

The return data from the Cognex should be, IIRC, comma-separated.  Once you use the EKI_GET commands to pull the string from the EKI buffer, you can use CREAD to parse it into usable variables.

June 02, 2019, 07:24:15 PM
Reply #15
Offline

Dante


Thank you for the feedback

it works with the SWRITE function I can send any kind of data to the cognex.

But I don't understand what is the FI_chCommandString [] variable that you used in the program above?

June 03, 2019, 12:10:16 AM
Reply #16
Offline

SkyeFire

Global Moderator
Whoops.  I got my samples mixed together.

Basically, FI_chCommandString would be a string received as an argument by the SendCommandToCognex().

Replace "SE8" in the SWRITE with FI_chCommandString[], and SendCommandToCognex() would act as a simple "formatter" -- whatever string argument was sent to the subroutine as FI_chCommandString[] would have CR&LF appended, then the result (_chCommandString[]) would be passed to the EKI_SEND function.

June 03, 2019, 09:26:03 AM
Reply #17
Offline

Dante


SE8 is a native telnet command from cognex, does cognex identify it as a command or as a simple datum?

For example with the attached code I can send data that is read by the device on cognex (image attache capture0) and I send a data to KRC at the same time.

Code: [Select]
RET=EKI_Init("BinaryFixed")
RET=EKI_Open("BinaryFixed")

SWRITE(_chCommandString[],_STATE,_OFFSET,"%r,","7Ak3")
_chCommandString[STRLEN(_chCommandString[])+1]='H0D'
_chCommandString[STRLEN(_chCommandString[])+2]='H0A'

RET =EKI_Send("BinaryFixed",_chCommandString[])

WAIT FOR $FLAG[1]
wait sec 2

RET=EKI_GetString("BinaryFixed","Buffer",_chCommandString[])
$FLAG[1]=FALSE
WAIT SEC 2

RET=EKI_Close("BinaryFixed")
RET=EKI_Clear("BinaryFixed")

Now I would like to use the native commands (image attache capture2) to trigger events on cognex, but each time when I use a command (SE0 for example) it displays it on the device and does not execute the command .
Do you have an idea?

June 03, 2019, 07:58:48 PM
Reply #18
Offline

SkyeFire

Global Moderator
"SE8" is, IIRC, the basic Trigger command for the Image object located in cell A0.  It does not connect to a TCPDevice object.  There are several similar commands, all detailed in the Native Command sections of the InSight documentation.

June 03, 2019, 09:29:53 PM
Reply #19
Offline

Dante


yes I read the documentation on Native commands of InSight but it does not work when I send it, nothing happens.

I already realized an application with a Robot Staubli RX60 couple with cognex (pick and place with vision) but I had a library that allowed me to run Native commands from InSight since RX60.
But with kuka I can not send Native commands via EthernetKRL.

June 04, 2019, 01:26:31 AM
Reply #20
Offline

panic mode

Global Moderator
why not... Ethernet message is just a sequence of bytes. that is where WireShark comes in

Today at 03:05:53 AM
Reply #21

Advertisement

Guest

June 04, 2019, 10:40:00 PM
Reply #21
Offline

SkyeFire

Global Moderator
  Have you set up the A0 image object properly?  The Trigger condition has to be set to match the communication method being used
Yes, you can.  I've done it.

June 05, 2019, 02:57:37 PM
Reply #22
Offline

Dante


 
I check each time with WireShark to see if the transmission of data has occurred, and I see each time it happened.


Quote
Have you set up the A0 image object properly?  The Trigger condition has to be set to match the communication method being used
I did not touch the configuration not default of A0 it's just the trigger mode that I chose "extern"
 
Quote
Yes, you can.  I've done it.
Oh good, I've been trying since, but I'm having some difficulty:

1. with Hyperterminal and cognex when I launch the communication I get on hyperterminal a message (see image1 attached) I put the Usernam "admin" and the Password "" and I receive another logged User message.

2. with KRC and cognex I receive the welcome message in the buffer memory of the KRC (see image2 attached) but this time I have trouble putting the User name and the Password because I do not have a screen on which I display, and when I send him a string "admin" and " " as Password he sends me a message << User: Password: Invalid Password >>

June 05, 2019, 03:33:12 PM
Reply #23
Offline

SkyeFire

Global Moderator
...what?  No, you have to emulate the HyperTerminal interaction.  You don't send "User: blah", you have to open the connection, send just the Username (with CR&LF appended), then receive the password prompt, then send just the password (with CR&LF appended).

June 05, 2019, 04:05:52 PM
Reply #24
Offline

Dante


same now it's blocking at the flag (line 57 image attached)  :wallbash:


Share via facebook Share via linkedin Share via pinterest Share via reddit Share via twitter

question
KUKA communication with Cognex In sight

Started by Robin de Bree on KUKA Robot Forum

16 Replies
2033 Views
Last post June 12, 2018, 12:21:38 PM
by panic mode
clip
Kuka communication failure with Cognex In-Sight smart camera over Profinet

Started by YangTao on KUKA Robot Forum

13 Replies
7620 Views
Last post December 13, 2016, 03:09:58 PM
by SkyeFire
xx
Delayed response in over communication on EthernetKRL

Started by piyushjadhav on KUKA Robot Forum

2 Replies
1175 Views
Last post May 12, 2017, 04:10:48 PM
by piyushjadhav
xx
Fanuc / Cognex EIP communication

Started by worseltes on Fanuc Robot Forum

5 Replies
6163 Views
Last post December 16, 2015, 09:39:40 PM
by ESIELI