Negative values in Modbus Master

Joshua37

Member
Join Date
Aug 2014
Location
Dallas
Posts
47
Hi All,
I am using Modbus Master program to get data from DEIF controllers for 4 DG's to a CompactLogix L32E on the serial port.

While everything else is working perfect I am getting incorrect negative values of KWH except for one DG.

Function code:4 (Input Register 537)
Actual Data VS Modbus Data
DG1 =51287 / -13921
DG2 =9789 / 9789 (Correct data)
DG3 =46783 / -23993
DG4 =41324 / -24957

While using Modscan I am getting the correct values via Modbus.

Could somebody help ??

Thanks :)
 
It looks like your DG uses a 16 bit unsigned word, while on the Logix side you are using a signed 16 bit word. What are your data types?
 
Int[600]

It looks like your DG uses a 16 bit unsigned word, while on the Logix side you are using a signed 16 bit word. What are your data types?

Its the default data type from the Modbus Master program from 5000 sample programs.

Mod_Data_InpReg3[xyz]
The data type is INT[600]

Do I need to change the data type?
 
Hi All,
I am using Modbus Master program to get data from DEIF controllers for 4 DG's to a CompactLogix L32E on the serial port.

While everything else is working perfect I am getting incorrect negative values of KWH except for one DG.

Function code:4 (Input Register 537)
Actual Data VS Modbus Data
DG1 =51287 / -13921
DG2 =9789 / 9789 (Correct data)
DG3 =46783 / -23993
DG4 =41324 / -24957

While using Modscan I am getting the correct values via Modbus.

Could somebody help ??

Thanks :)

You'll get negative values returned if they're over 32767 because you are probably using signed integer type. MSB typically equals sign. If it's 1, number will be displayed as negative
 
You'll get negative values returned if they're over 32767 because you are probably using signed integer type. MSB typically equals sign. If it's 1, number will be displayed as negative

That's what I thought except that the negative values shown don't represent the large positive number interpreted as signed.

Please post a link to the sample program or its documentation.

Can you post a link to the DEIG manual which describes the Modbus registers? Exactly which Modbus registers are these reading?
 
Last edited:
That's what I thought except that the negative values shown don't represent the large positive number interpreted as signed.

You're right! Even if you invert the bits for the most significant register, the numbers just don't compute.

I'm stumped, but I would sure like to see the solution to this one.
 
These are long shots, but are you sure you're not populating the values of the registers in the L32E within the program? Maybe you're writing values from another device? Maybe you're MSGs are overlapping?
 
Yeah, I saw that too (that the unsigned values don't match up to the converted signed values). But it sure looks like the problem is originating with the sign bit.

So, try loading these values in different data types (Unsigned, Real), to see what happens.

And it should be possible to tap into the Modbus network and do a capture of the traffic and post it here. We can then convert these messages by hand to see what the DG's are sending out.
 
I must say I have had some funny results from DEIF controllers in the past but I heard they had fixed the problem. Hopefully they have - good luck. Always use Woodward these days then no issues.
 

Similar Topics

I have 3 koyo PLC's in series. The 1st and 3rd are reporting values correctly but the 2nd is reporting negative values. The values in the PLC and...
Replies
3
Views
1,414
I am new to PLC programming, so maybe this is a no brainer: I am using a DINT array with a negative value of -34000 as one of the elements in an...
Replies
5
Views
2,217
I have 24 E5CN controllers hooked up RS485 to a Omron CJ. They communicate using the Compoway/F protocol, and a routine written with the PCMR...
Replies
3
Views
2,631
Up to date, I've only had to deal with Positive PV values with my PID controls where Zero was the absolute Minimum value in to the PID PV...
Replies
3
Views
4,246
Hi everyone, I am working with micro850, a proximity sensor (FOTEK, PL-05P) and a 3DOF serial arm robot. I use MC_MoveRelative to control the...
Replies
1
Views
57
Back
Top Bottom