# Convert unsigned value of modbus address 270 to 275 to signed value

**URL:** <https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641>\
**Category:** Robot Communication\
**Created:** [March 23, 2017, 2:09am UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641 "2017-03-23T02:09:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon52467762](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@anon52467762](https://forum.universal-robots.com/u/anon52467762)\
**Post date:** [March 23, 2017, 2:09am UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641/1 "2017-03-23T02:09:21Z")

</div>

The descriptive text in the beginning of the [Modbus Server article](https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/modbus-server-16377/) “if (val \> 32768): val = val - 65535” is incorrect for modbus address between 270 to 275.

modbus address between 270 to 275 is UR joint position in mili radian. As max degree allow to turn would be ±360 or ±6.283 rad or ±6283 m rad.  
So unsigned value between modbus address 270 to 275 would never more than 32768.

I try derive formula and observe that in the case of  
joint pose in -ve,than it should  
val=(val-6283)/1000 radian  
however in the case of joint pose in +ve,then  
val=(val/1000) radian

I would like to get exactly same value get\_actual\_joint\_position()

if joint in +ve  
base=modbus[260]/1000  
shoulder=modbus[261]/1000  
elbow=modbus[262]/1000  
w1=modbus[263]/1000  
w2=modbus[264]/1000  
w3=modbus[265]/1000

if joint in -ve  
base=(modbus[260]-6283)/1000  
shoulder=(modbus[261]-6283)/1000  
elbow=(modbus[262]-6283)/1000  
w1=(modbus[263]-6283)/1000  
w2=(modbus[264]-6283)/1000  
w3=(modbus[265]-6283)/1000

p[base,shoulder,elbow,w1,w2,w3]

however in run time,doesnt know either the joint in +ve or -ve.please advice.

---

<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:** [March 23, 2017, 10:00am UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641/2 "2017-03-23T10:00:12Z")

</div>

Hi Willie,

Modbus registers 320 - 325 contain revolution counters for each joint.

“Base joint revolution count (number of full turns, typically 0 or 1) - See more at: [Modbus Server - 16377 | Universal Robots Support](https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/modbus-server-16377/#sthash.7XvpFLWH.dpuf)”

As you’ve observed there are no negative numbers represented, the angle is counted up from zero for each cycle. For -360 to 0 (negative angles) rev counter register will be high (65535), 0 to +360 rev counter register will be low (0).

This should give you all you need to make it work.

---

<div class="post-metadata">

**Author:** ![anon52467762](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@anon52467762](https://forum.universal-robots.com/u/anon52467762)\
**Post date:** [March 24, 2017, 2:08am UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641/3 "2017-03-24T02:08:55Z")

</div>

Indeed make my program work  
thank

---

<div class="post-metadata">

**Author:** ![john.gramlich](https://avatars.discourse-cdn.com/v4/letter/j/ce7236/32.png) [@john.gramlich](https://forum.universal-robots.com/u/john.gramlich)\
**Post date:** [October 3, 2023, 12:42pm UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641/4 "2023-10-03T12:42:00Z")

</div>

Hey Guys,

Has this changed since?

currently my registers 270-275 don’t seem to be counting down when the angle goes negative.

---

<div class="post-metadata">

**Author:** ![anon24273550](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@anon24273550](https://forum.universal-robots.com/u/anon24273550)\
**Post date:** [May 31, 2024, 2:52pm UTC](https://forum.universal-robots.com/t/convert-unsigned-value-of-modbus-address-270-to-275-to-signed-value/641/5 "2024-05-31T14:52:33Z")

</div>

I think its reversed u should get a higher word value if its negative and vice versa
