Formatting Cognex Camera For UR Script

Hello everyone,

I am using a UR10e with a Cognex 8402C. The firmware on the UR10e is 5.5.

I am unsure on how to format my camera to receive and send data base off the UR Script code I have pasted below. I am very new to using these two systems so any help will be very much appreciated.

Credit to this link for the code: Communication between UR and Cognex - #4 by Sibel

Code:
port = 23586
ip = “192.168.0.10”
socket_name = “Cognex”

Connect to camera and return status

socket = socket_open(ip, port, socket_name)
textmsg("Connection successful?: ", socket)

After connecting the camera first sends a welcome message and asks for username and password

receive = socket_read_string(socket_name)
textmsg(receive)

Send username

socket_send_string(“admin” , socket_name)
socket_send_byte([13,10], socket_name)

Receive request for password

receive = socket_read_string(socket_name)
textmsg(receive)

Send password

socket_send_string(“”, socket_name)
socket_send_byte(13, socket_name) # Empty string and list of bytes gave some problems in the past, sending them seperate
socket_send_byte(10, socket_name)

receive = socket_read_string(socket_name)
textmsg(receive)

socket_close(socket_name)

socket_send_string(“GVA009”, socket_name)
socket_send_byte([13,10], socket_name)

# Expected format of data string: “(x, y, z)” where x, y, and z are floats or integers
value_count = 4
timeout = 5
receive_list = socket_read_ascii_float(value_count , socket_name, timeout)

### There is still some data remaining in the camera buffer, we should empty it.
buf = socket_read_string(socket_name)

### Show the resulting list
textmsg("Received list:", receive_list)

Hello Sanjevan,

I am currently working on a similar project with a ur10 but my camera is a Cognex IS2800. In my case, I only needed to turn on the telnet server in the camera software (the port also changes, normally to port 23, it is the telnet default port). After that I was able to communicate between the robot and the camera.
Just be aware that you always need to send bytes 10 and 13 after sending a string otherwise it will not work.

Hope it helps!

Best regards,
Vasco Dias

Hello Vasco,

I attempted the same with telnet server in the camera software. However, I’m not too sure if I am connecting properly since when I send SW0 for trigger, the camera will not trigger. I believe it is when I send over the password since I get the return message through my script to send a password. After sending password I do not get any return message saying that I am connected to the server/camera.

Did you have a similar problem?

If you don’t receive a message after sending the password, there must be a problem there.
You should receive something like “User logged In…”.
Maybe your camera has a password, or the problem come from the previous code.