# Read Bit from 16 Bit Modbus Register mapped to General purpose 16 bit registers \[Doc 16377\]

**URL:** https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540
**Category:** Technical Questions
**Created:** [February 24, 2021, 10:08am UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540 "2021-02-24T10:08:25Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 24, 2021, 10:08am UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/1 "2021-02-24T10:08:25Z")

</div>

Hi,

according to [Modbus Server Article](https://www.universal-robots.cn/articles/ur/modbus-server/) the UR has 128 GP Modbus Registers which can be used for communication.

Currently, we have a application using Profinet (on PLC Master Side and other Slaves) and Modbus (for UR Slave only, because there is still no option to access Fieldbus GPIO Registers with the Java API).

My Aim is to Access Single Bits with the script function read\_port\_bit and write\_port\_bit. The Doc says it is possible to use the Coil Nr - which in the case of the first General Purpose Register is Adress 2048. When i use this Adress like below:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/3/36c533263299c97d1dd21561431f61aee2d63988.png)

the bit cannot be changed (Value Mark) - ofc on the real robot (Sim is just for example)

Is it even possible to access Single Bits from the Registers with the Coil Adress and add them with the Adress Name (to Access that one with the API)?

Or do i have to convert every 16 Bit Modbus Register to Access a Coil?

Thank You! 🙂

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 24, 2021, 10:49am UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/2 "2021-02-24T10:49:08Z")

</div>

in other words: read\_port\_bit or write\_port\_bit does not work with bit (coil) adresses higher than 255 (Getting Modbus Error with Status Message “2”) - although there are more than 1024x16 Bits to read…

Is this a bug?

---

<div class="post-metadata">

### Author: ![andreas.enhuber](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@andreas.enhuber](https://forum.universal-robots.com/u/andreas.enhuber)
#### Post date: [February 24, 2021, 12:06pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/3 "2021-02-24T12:06:05Z")

</div>

Hello everyone,

> [@m.birkholz](#):
>
> Currently, we have a application using Profinet (on PLC Master Side and other Slaves) and Modbus (for UR Slave only, because there is still no option to access Fieldbus GPIO Registers with the Java API).

we had this problem with the Fieldbus GPIOs here as well for a couple of times. Things could be much easier if the Java API has direct access to the Fieldbus GPIOs.

Is there a feature request about this topic?

Regards,  
Andreas

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 24, 2021, 12:25pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/4 "2021-02-24T12:25:19Z")

</div>

well, that was your topic once 😃

> [@Direct addressing Fieldbus Registers with URCap](https://forum.universal-robots.com/t/direct-addressing-fieldbus-registers-with-urcap/5150):
>
> Hello all, I need to address some fieldbus boolean registers. They were on a modbus module before and they were pretty easy accessable, but we changed the system and now the robot has to communicate over fieldbus. As far as i understand there are no getValue() and setValue() Methods available for the boolean, integer and float registers. Through UR Script these values can also be written and read directly. Did i miss something? Is there a special reason for them beeing not available by Java? …

---

<div class="post-metadata">

### Author: ![andreas.enhuber](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@andreas.enhuber](https://forum.universal-robots.com/u/andreas.enhuber)
#### Post date: [February 24, 2021, 1:30pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/5 "2021-02-24T13:30:22Z")

</div>

@jbm Any news regarding this?

---

<div class="post-metadata">

### Author: ![fujikit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/fujikit/32/6042_2.png) [@fujikit](https://forum.universal-robots.com/u/fujikit)
#### Post date: [February 25, 2021, 2:01pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/6 "2021-02-25T14:01:20Z")

</div>

I think it as something unavoidable that the value of GPIOs cannot be obtained by java api.  
So I had created the urcap for reading and writing GPIOs and published on github repository.

> [@URCap Sample : Ethernet/IP I/O Monitor URCap (included the feature of RTDE and XML-RPC Server by JAVA)](https://forum.universal-robots.com/t/urcap-sample-ethernet-ip-i-o-monitor-urcap-included-the-feature-of-rtde-and-xml-rpc-server-by-java/8724):
>
> To all developer. I have developped the urcap for monitoring I/O of Ehternet/IP. I use the features of RTDE, XML-RPC and so on to developping this. I want to make it better in operation. So would you try to use this and send me your message or reply if you have the suggetions and improvements? Regards. GitHub

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 25, 2021, 2:19pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/7 "2021-02-25T14:19:22Z")

</div>

Hey Takaaki,

i like your solution but having to send robot programs over the real time interface is not a solution for real real-time applications. Its latency is just too high! 😉

Also, RTDE has less priority than polyscope (messages will not be sent when polyscope has a high performance load).

Therefore a native GPIO Java Interface should be best

---

<div class="post-metadata">

### Author: ![fujikit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/fujikit/32/6042_2.png) [@fujikit](https://forum.universal-robots.com/u/fujikit)
#### Post date: [February 25, 2021, 2:27pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/8 "2021-02-25T14:27:02Z")

</div>

How long is your expected latency?

---

<div class="post-metadata">

### Author: ![anon8732348](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@anon8732348](https://forum.universal-robots.com/u/anon8732348)
#### Post date: [February 25, 2021, 9:08pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/9 "2021-02-25T21:08:45Z")

</div>

I recently got Modbus I/O working myself so let me see if my issues help you.

I am doing Modbus UR \<=\> Mits PLC

The Modbus Server link you posted is exactly that, It is only vaild for the UR to be the Server (master) and was not accessible to write to from my PLC Master.

In my application, I was able to setup the UR as both a Slave and Server. I use my PLC to read status data from the locations listed on that Server Article (above) and setup the UR as a slave with individual Inputs/ Outputs / Registers

 ![PLCModbus](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/b/b420953cbc37287b869a501eb11f1ce3c428ca5d.png) ![URModbus1](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/d/db7a3eb53c11851dec18dfd2b0450ffedd51d45a.jpeg) ![URModbus2](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/9/9fa1dd189307bcd5cb0d23589187ca088cb60c09.jpeg)

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 25, 2021, 9:31pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/10 "2021-02-25T21:31:56Z")

</div>

Hi,

what also confuses me is the naming of slave = server and client = master according to the UR doc, which differs from your explaination.

What i want to do is read the UR‘s input registers from the URCap API (localhost adress) which are changed by the plc. That means i have to read Registers 128 - 255. but how do i access Single Coils with a Name if i can‘t setup a Adress higher than 255 for both registers and bits? When i use a higher adress it says my modbus device is disconnected

---

<div class="post-metadata">

### Author: ![m.birkholz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/m.birkholz/32/7084_2.png) [@m.birkholz](https://forum.universal-robots.com/u/m.birkholz)
#### Post date: [February 25, 2021, 9:34pm UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/11 "2021-02-25T21:34:36Z")

</div>

Hi Takaaki,

It should be less than 50 ms. So using robot background programs just to set gpios is no option.

---

<div class="post-metadata">

### Author: ![anon8732348](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@anon8732348](https://forum.universal-robots.com/u/anon8732348)
#### Post date: [February 26, 2021, 2:42am UTC](https://forum.universal-robots.com/t/read-bit-from-16-bit-modbus-register-mapped-to-general-purpose-16-bit-registers-doc-16377/12540/12 "2021-02-26T02:42:08Z")

</div>

Yeah the Server/Master/Slave… confused me too. After about 5 days of messing with it this is what worked. Both my PLC & UR see all the inputs & outputs as single bits, and registers work too

The way i set it up, the inputs are all accessible directly in jobs and should show up to the URCap just like a standard Input signal does.
