Universal Robots Forum

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

The descriptive text in the beginning of the Modbus Server article “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.

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: 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.

2 Likes

Indeed make my program work
thank