How to tie an "event" to the stop button


How does one tie an “Event” or “If” statement that is continually checked to the stop button? At the bottom of the UR user interface?

I have 2 robots: under MODBUS they communicate with one another. So I have

If Master Robot = 1
(Slave Robot waits)
If Slave Robot = 1
(Master Robot waits)

When either robot reaches a waypoint that is clear of the pickup point, the other may enter. But I need to be able to return the Robots to a value of “0” when I press the stop button, or some other easy way to for sale of convenience.

Any simple ideas would be appreciated, thanks.

1 Like

Are these variables you are trying to reset, modbus signals, or some IO? There are runstate options in the URScript manual for Modbus signals and IO to go to a specific state when the program stops.

The variable I would like to reset is a simple assignment such as a UR_State. When in a certain loop of the program, it enters [i.e.] “UR_State_1”. If I “stop” because something is wrong, I would like it to be able to return to UR_State_0 if possible. The other robot will not go until the Master Robot returns to a “UR_State_0”

I have tried sifting through the UR Script Manual, but I’m relatively new to this.

As far as I am aware, it is not possible to run any sequence after the robot has been stopped (intentionally or due to safety or other reasons) from the robot interface itself.

If you enter your installation and I/O Setup, you will have the option to set a MODBUS signal low (false), when the program is not running. This could solve your issue, but UR_State will always be 0 when the robot is not running then.

Another way to solve this could be to make a watchdog of a sort. I like to do this better, since it gives you more options to work with.
Make a thread in each robot which awaits a signal from the other robot to become 1, then it sets a signal to 1 itself to the other robot, then 0 and so forth. Then, if the signal stops coming for a couple of seconds, the robot will know that the other robot has stopped and you can make a sequence to reset this robot, too.

I made a quick example. I hope it makes sense. It basically sends a signal to R2 (robot 2) and then waits 3 seconds to get a response. If no response for 3 seconds, it will set NoReplyR2 to True, and then it will exit the If-statement and enter the next one.
Make sure to make all three If-statements continuously checked.

1 Like

I believe if you put an assignment in the “Before Start Sequence”, whenever you start a program the variable will start at that default value. So if you were to start, after stopping the program, it should assign to this initial value whenever you start it again. You can also do this by creating the variable in the Installation variables under Installation → General → Variables and creating it there.

1 Like

check out the script function

modbus_set_runstate_dependent_choice(signal_name, runstate_choice) in section 17.1.1 of the script manual.

see here: Modbus Server - 16377 | Universal Robots Support
and be sure to check out the attached files.

for example: you could setup a thread in each that monitors the state of the modbus address 258 for the ‘other’ robot to monitor the status of the controller’s program.:

if modbus 258 == 7:
    then the other robot is running
    then the other robot is not running

(see ModBus_server_data.pdf attached in the above link)
[note: the above is just pseudo code, let me know if you need more precise help]

EDIT: NVM. I guess ‘running’/modbus address 258 = 7 is the robot is running, brakes released, not program running. sorry.

1 Like

Thank you all very much. I will consider the following options going forward.