# Modbus communication CMMO

**URL:** <https://forum.universal-robots.com/t/modbus-communication-cmmo/2039>\
**Category:** URScript\
**Created:** [May 29, 2018, 10:41am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039 "2018-05-29T10:41:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon89006500](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon89006500](https://forum.universal-robots.com/u/anon89006500)\
**Post date:** [May 29, 2018, 10:41am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/1 "2018-05-29T10:41:51Z")

</div>

Hi,

I have a problem. I’m trying to comunicate via modbus the UR to a CMMO festo motor controller (slave).  
I have to send this:

0010000000044301006400000000

Slave number: 00  
Function code: 10  
Memo Dir: 0000  
Number of words: 0004  
Data: 4301006400000000

I’ve try using the URScript function modbus\_send\_custom\_command() like this:  
modbus\_send\_custom\_command(“192.168.1.2”,0,16,[0,0,0,4,67,1,0,100,0,0,0,0])

But nothing happends.

Thanks

---

<div class="post-metadata">

**Author:** ![anon28553715](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon28553715](https://forum.universal-robots.com/u/anon28553715)\
**Post date:** [May 30, 2018, 10:09am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/2 "2018-05-30T10:09:12Z")

</div>

I would verify the sent modbus packet with a Socket Test server ([http://sockettest.sourceforge.net/](http://sockettest.sourceforge.net/)) to see if the packet is correct.

Please beware of endianness.  
[https://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/](https://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/)

---

<div class="post-metadata">

**Author:** ![anon47597633](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon47597633](https://forum.universal-robots.com/u/anon47597633)\
**Post date:** [June 5, 2018, 8:46am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/3 "2018-06-05T08:46:11Z")

</div>

The easiest way to test if your Modbus code is formally done right, is to use the general purpose registers, e.g. 128-131 on the UR robot. Just go to the Modbus tab, set the IP to localhost and add the signals. Then change the IP in your Modbus to localhost and try it out. However, the Modbus code seems all right - as I see it - so you should check how you have configured Modbus in Festo Configuration Tool - for instance that you send the right number of words.

---

<div class="post-metadata">

**Author:** ![anon89006500](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@anon89006500](https://forum.universal-robots.com/u/anon89006500)\
**Post date:** [June 6, 2018, 7:55am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/4 "2018-06-06T07:55:42Z")

</div>

I’ve noticed that the problem is that the function creates a buffer and introduces each function to the buffer. Then it does not stop sending the functions in a loop, although from the program it indicated that it only runs once, even if i stop the program, i continue receiving the packets.

How can i specify to send the instrucction one time?

---

<div class="post-metadata">

**Author:** ![mmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/mmi/32/691_2.png) [@mmi](https://forum.universal-robots.com/u/mmi)\
**Post date:** [June 8, 2018, 10:07am UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/5 "2018-06-08T10:07:25Z")

</div>

Currently there is no way to send one off modbus commands in the application, but I think it’s great [feature request](https://forum.universal-robots.com/c/feature-requests) for modbus client.

---

<div class="post-metadata">

**Author:** ![anon47597633](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@anon47597633](https://forum.universal-robots.com/u/anon47597633)\
**Post date:** [June 8, 2018, 12:31pm UTC](https://forum.universal-robots.com/t/modbus-communication-cmmo/2039/6 "2018-06-08T12:31:15Z")

</div>

Oh, I see! As a matter of fact, I have unfortunately also faced the very same problem. From my experience, I have learned that there is a solution but it is not straight-forward. However, if your UR robot supports URCaps, and you are up for the challenge, here is what you can do:

1. Create your own application in C++ or Python containing the Modbus functions that you need.
2. Add a XML-RPC server to your code which can share your functions to a XML-RPC client.
3. Implement your application as a daemon in a URCap.
4. Add a XML-RPC-client in the URCap which connects to the deamon server.
5. Install the URCap.

Hereby you should be able to call your Modbus functions in the daemon via XML-RPC commucation. If your UR robot supports Python 2.7 (CB3.1), I can recommend using the pymodbus 1.4.0 library which is released under the BSD License: [http://pymodbus.readthedocs.io](http://pymodbus.readthedocs.io)  
I hope that this is useful on some level until UR improves the Modbus client ability on the robot.
