[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)
else:
textmsg("Trigger failed: ", triggerstatus)
end

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)
else:
textmsg("GetValue failed: ", getvaluestatus)
end

sleep(1)
rec = socket_read_ascii_float(3, socket_name)

returns the value i have put in cell C20.

What am i missing/how do fix?

@Mathijs
@Roel

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:

Hi,

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:
socket_send_string(“admin”,“socket0”)
socket_send_byte([13,10],“socket0”)
wait: 0.01
ustat2=socket_read_line(“socket0”)
socket_send_string("",“socket0”)
socket_send_byte([13,10],“socket0”)
wait: 0.2
pstat=socket_read_line(“socket0”)