Signed & Unsigned Modbus Registers

Ones_Zeros

Member
Join Date
Feb 2014
Location
at work
Posts
367
Hello,
I'm reading a modbus register 40125
I'm using a modbus poll program to read this register. If i read the
register as a "signed" value it displays correctly with value of -2. If
I read the register as a "unsigned" value it displays the value of 65534.

The issue that I'm having is with Wonderware.
Its reading the register 40125 value as 65534 (the unsigned value) and I can't seem to get the scaling correct.

I have tried Raw scaling of 0-65535 and 0-32767 but no luck

any ideas what i could try?

Also this register seems to be the only register that is reading this way for some reason. what causes some registers to read as "signed and some as "unsigned"


thanks,
 
Hello,
I'm reading a modbus register 40125
I'm using a modbus poll program to read this register. If i read the
register as a "signed" value it displays correctly with value of -2. If
I read the register as a "unsigned" value it displays the value of 65534.

The issue that I'm having is with Wonderware.
Its reading the register 40125 value as 65534 (the unsigned value) and I can't seem to get the scaling correct.

I have tried Raw scaling of 0-65535 and 0-32767 but no luck

any ideas what i could try?

Also this register seems to be the only register that is reading this way for some reason. what causes some registers to read as "signed and some as "unsigned"


thanks,

A data word contains 16 bits. If the data word is a signed integer one of those 16 bits will determine weather or not the value is positive or negative, this is called the sign bit. That only leaves 15 bits for the actual integer value, so the range of a 16 bit signed integer is -32767 to +32767 decimal. Signed integers are used when the value can be expected to be positive or negative, like a temperature reading. Unsigned integers can only be positive or 0. 0 -65535 decimal because all 16 bits are used for the integer value. unsigned would be used for something like a valve position feedback (0-100%) or something where no negative value is expected.

So, depending on the device you are talking to you could have a blend of signed and unsigned data types.
 
I don't see where is the problem:

The 16 bit register in the PLC has an hex value = FFFE

FFFE as two complement signed is -2 in decimal representation, or 65534 as unsigned ... all seems correct.
 
lfe,
We’re I’m having an issue is getting
This raw value in Wonderware scale
To read -2.
If I set the raw scaling 0-65535
Engineering scale = -14.7 to 30

I don’t get the -2 value I should be getting?
Any ideas?
 
I'm probably off base here, but how are you reading this modbus register? What's the data path?

Whatever driver you are using have to know what the 16 bit register represent.
 
As sapper mentioned this is a difference only in the interpretation of the data type not the data flow. You should set your value scale to -32768 to +32767. Alternatively you can’t change the data type to a signed int (SINT) you can also write a bit masking script to strip out bit 15
 
beware of some modbus device drivers. some drivers reverse the upper and lower Byte values.



so the following word

0000 1111 0101 1010

can become

0101 1010 0000 1111

i have had this before, there is usually a setting to reverse the byte order (big endian/little endian sometimes refered to)


there is some freeware called "CAS Modbus Scanner" that may help here to diagnose the issue.
http://store.chipkin.com/products/tools/cas-modbus-scanner
 
Last edited:
Australian is on the money; you need to change your tag address definition to use the type modifiers. S for signed, F for float etc.

Thats assuming you're using MBTCP or the OI driver for modbus
 
Thanks for the help everyone
I will try putting an “S” at the end of the register.

I haven’t tried that, I will let you know
If this fixed it.


Thanks again
 

Similar Topics

Hello, I'm using the MSG command with RSLogix 500. The values are being read in as signed integers. Is there a way I can read them in as an...
Replies
10
Views
6,472
Hello, I am working on a HMI/Motion controller system, that utilises Modbus. HMI is Master, Motion Controller Slave. When a value of 32767 is...
Replies
5
Views
6,237
I'm having to make an AOI to use with a generic ethernet device because the manufacturer does not provide an AOP. I just want to do a sanity check...
Replies
13
Views
1,152
Is there a way in CX-Programmer to ad UINTs together with an instruction without a compiler warning. Ladder Rung: Warning: Instructions...
Replies
2
Views
1,223
I'm trying to read a u32 register from a fuel meter over modbus rtu. There isn't a unsigned integer option under the "treat as" field. I select...
Replies
15
Views
3,823
Back
Top Bottom