This is how to connect Cognex camera to a Doosan Robot
Configure these parameters
port = 10000
ip = "192.168.137.10"
then open a TCP connection to the camera
socket = client_socket_open(ip, port)
After connecting, the camera sends a welcome message and asks for a username and password.
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "admin\r\n".encode()) # username + carage return, new line character
### Asked for a password ###
receive = client_socket_read(socket, -1, -1)[1].decode()
client_socket_write(socket, "\r\n".encode()) # password(empty) + carriage return, newline character
If successful, then you will get a logged-in message.
receive = client_socket_read(socket, -1, -1)[1].decode()
After the login procedure, trigger the camera. This function only works if the Cognex camera is on Online Mode
client_socket_write(socket, "SE8\r\n".encode())
wait(3)
triggerstatus = client_socket_read(socket, -1, -1)[1].decode()[:-2]
if triggerstatus != "1":
tp_log("Trigger failed: " + str(triggerstatus))
return 0
After triggering the camera, We can get the cell value from the Cognex table cell.
cel_data = "GVC019"
client_socket_write(socket, (cel_data + "\r\n").encode()) # GVC013
getvaluestatus, rec, _empty = str(client_socket_read(socket, -1, -1)[1].decode()).split("\r\n")
if getvaluestatus == "1":
# tp_log("GetValue successful: " + str(getvaluestatus))
rec = str(rec).split(",")
else:
tp_log("GetValue failed: " + str(getvaluestatus))
After get the cell value, we need to close the connection
client_socket_close(socket)
This was the end of this tutorial, I hope it helped you. Good luck with your project!
If you want to discuss this topic or if you have questions, reply in the comments.