# MODBUS stops the Robot Program

**URL:** <https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689>\
**Category:** Robot Communication\
**Tags:** modbus\
**Created:** [December 10, 2020, 8:14am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689 "2020-12-10T08:14:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [December 10, 2020, 8:14am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/1 "2020-12-10T08:14:43Z")

</div>

Hello,

I am communicating the cb5 UR Robot with a PLC.

There is no issue in the communication.

But when I send _modbus\_set\_output\_signal()_ or _modbus\_set\_output\_register()_, the robot program stops.

I am using ScriptSender and ScriptCommand from Jacob’s repository. I checked the _Sequential Mode_ in the installation.

I tried the same thing with ursim and the server in my PC, the same thing happened.

What could be the issue?

Thank you,

MB

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 15, 2020, 4:15am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/2 "2020-12-15T04:15:26Z")

</div>

The scriptsender does say in the code:

| | /\*\* |
| --- | --- |
| | \* Method used to send a ScriptCommand as a primary program to the Secondary Client Interface. |
| | \* If called while a program is already running, the existing program will halt. |
| | \* @param command the ScriptCommand object to send. |
| | \*/ |

So this is expected. If you explain a little more about how you’re trying to sequence your modbus communications with the main program, perhaps we can suggest a different approach.

---

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [December 15, 2020, 5:49am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/3 "2020-12-15T05:49:42Z")

</div>

> [@ajp](#):
>
> So this is expected. If you explain a little more about how you’re trying to sequence your modbus communications with the main program, perhaps we can suggest a different approach.

I have a PLC as a Modbus Server that is constantly updating 2 registers with servo position data.

I am trying to plan a trajectory according to the servo position data that is coming from the PLC.

Therefore I need to read the values of the modbus registers while the program is running and send them to Java.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 15, 2020, 7:09am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/4 "2020-12-15T07:09:11Z")

</div>

Ok, is there no way that you can plan the trajectory in the program running in Polyscope/URScript? The Java side of things is generally intended for handling GUI related tasks, not robot motions.

---

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [December 15, 2020, 7:25am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/5 "2020-12-15T07:25:59Z")

</div>

I think I can plan the trajectory in URScript.

But I have already written the trajectory program in Java and it is working fine.

So is there any way to send variables from URScript to Java while the program is running?

---

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [December 17, 2020, 2:04pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/6 "2020-12-17T14:04:36Z")

</div>

I tried to implement the trajectory planning in URScript/Polyscope as you have instructed.

But I am having hard time doing that because the arrays in URScript are not resizable.

In my application, I get 2 points from the user and plan the trajectory accordingly.

Then, I move the robot in generateScript using _writer.appendline()_.

But I need to read the values of _get\_actual\_tcp\_pose()_ and _modbus\_get\_signal\_status()_ without halting the robot program.

---

<div class="post-metadata">

**Author:** ![anon60474395](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon60474395](https://forum.universal-robots.com/u/anon60474395)\
**Post date:** [December 19, 2020, 9:42pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/7 "2020-12-19T21:42:10Z")

</div>

Maybe it would be good idea to use URCap with daemon written in C++ or Python. You can get values of actual TCP pose and modbus signal status in URScript and send it to daemon. Daemon can do calculations and send it back to URScipt (for example to feed servoj() function with trajectory).

Here is URCap with daemon example: [GitHub - UniversalRobots/MyDaemonSwing: URCap sample that mainly demonstrates the principle of DaemonContribution and DaemonService](https://github.com/UniversalRobots/MyDaemonSwing)

For communication between URCap and daemon you can use [RTDE](https://www.universal-robots.com/articles/ur/real-time-data-exchange-rtde-guide/). Maybe this will be useful for you: [Universal Robots RTDE C++ Interface](https://sdurobotics.gitlab.io/ur_rtde/index.html)

---

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [December 29, 2020, 6:36am UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/8 "2020-12-29T06:36:41Z")

</div>

Please correct me if I am wrong but we can’t get _modbus\_get\_signal\_status()_ from RTDE, right?

---

<div class="post-metadata">

**Author:** ![anon60474395](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon60474395](https://forum.universal-robots.com/u/anon60474395)\
**Post date:** [January 2, 2021, 12:09pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/9 "2021-01-02T12:09:21Z")

</div>

I’m not sure, but I suppose the answer is: yes.

Using RTDE you can exchange data between URScript and daemon (C++/Python), so you can get value using modbus\_get\_signal\_status() in URScript, put this value in some INT register and read it from this register in daemon.

---

<div class="post-metadata">

**Author:** ![anon5706138](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon5706138](https://forum.universal-robots.com/u/anon5706138)\
**Post date:** [January 7, 2021, 1:44pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/10 "2021-01-07T13:44:20Z")

</div>

Do I have to assign a register inside a Thread in InstallationContributionNode like:

_a = modbus\_get\_signal\_status(“servo1”, False)_  
_write\_output\_integer\_register(24, a)_

Then call the register from Python/ C++ via RTDE?

---

<div class="post-metadata">

**Author:** ![anon60474395](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon60474395](https://forum.universal-robots.com/u/anon60474395)\
**Post date:** [January 8, 2021, 12:36pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/11 "2021-01-08T12:36:25Z")

</div>

Yes, something like this 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/system/32/1_2.png) [@system](https://forum.universal-robots.com/u/system)\
**Post date:** [January 10, 2021, 12:36pm UTC](https://forum.universal-robots.com/t/modbus-stops-the-robot-program/10689/12 "2021-01-10T12:36:38Z")

</div>

Closed on January 10, 2021, 12:36pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
