[SOLVED] Cognex Trigger not working

Sending a trigger:
socket_send_string(“SW8”, socket_name)
socket_send_byte([13,10], socket_name)
triggerstatus = socket_read_line(socket_name)

if triggerstatus == “1”:
textmsg("Trigger successful: ", triggerstatus)
textmsg("Trigger failed: ", triggerstatus)

returns a trigger failed with a trigger status of -2

Insight help just gives “Command Cannot Be Executed” as the explanation for error code -2.

I have copy pasted the code from the integration practicum, and manually set a string in cell C20. Communication between the robot and cognex works, a few lines in the copy pasted code:
socket_send_string(“GVC020”, socket_name)
socket_send_byte([13,10], socket_name)

getvaluestatus = socket_read_line(socket_name)

if getvaluestatus == “1” :
textmsg("GetValue successful: ", getvaluestatus)
textmsg("GetValue failed: ", getvaluestatus)

rec = socket_read_ascii_float(3, socket_name)

returns the value i have put in cell C20.

What am i missing/how do fix?


There is some exotic setting to make the trigger status work properly. You can just comment it out.

Exotic setting in the UR code or in the Cognex?

I think on the cognex. The trigger status integer will only be 1 if the trigger mode is set correctly (in the Image settings in cell A0) and if the camera is in “Online mode”.

Maybe putting it in online mode makes it work already.

It is in online mode, otherwise we wouldn’t be able to connect at all.

The trigger mode should probably be set to external or manual. I can test it alter today and post the results.

Yeah, that was the problem, thanks :smiley:


I’m having similar issue. It looks like communication is established. But it’s giving password is invalid message. Do you have any idea?

Please see attached picture.

The comments:
wait: 0.01
wait: 0.2