# Problem Reading Modbus TCP-Register

**URL:** <https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580>\
**Category:** Ignition\
**Created:** [June 17, 2014, 8:49am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580 "2014-06-17T08:49:22Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [June 17, 2014, 8:49am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/1 "2014-06-17T08:49:22Z")

</div>

Hi!

I’m having a strange problem with Modbus TCP.  
I have connected our Ignition server to a Saia PCD through Modbus TCP.  
I’m reading energy consumption information from the PCD.  
It worked correctly up till last Saturday. Around six a clock when the register reached value of 65436 (raw value) it suddenly set the value to 0.  
Now its counting upwards correctly. (When i add the 65436 to the current value i get the correct value)

When i connect to the PCD straight and look at the register, it is showing the correct value.  
Also when i added a new SQL-Tag that was connected to the same register, it still shows the incorrect value (Value that was zeroed on Saturday).

What could be causing this?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [June 17, 2014, 12:46pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/2 "2014-06-17T12:46:35Z")

</div>

Maybe you’re supposed to be reading 2 registers as a 32-bit value instead of 1 as a 16-bit value… does this sound possible? Do you have documentation for the unit?

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [June 18, 2014, 11:09am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/3 "2014-06-18T11:09:08Z")

</div>

Hi!

I was thinking that too, but when i read the registers as 32-bit its shows a value 2 314 456 413, or something on that line.  
I also tried the Step-Function and it didn’t help.  
The PCD is connected to a Energy meter through Modbus RTU and is reading a 32-bit register.

Do you mean the PCDs documentation?  
Here is a link to a manual:  
[saia-support.com/en/product- … -pcd1room/](http://www.saia-support.com/en/product-index/pcd1/m2xxx-cpu-units/m2110r1-pcd1room/)

---

<div class="post-metadata">

**Author:** ![james.hunt](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james.hunt](https://forum.inductiveautomation.com/u/james.hunt)\
**Post date:** [July 15, 2014, 2:19pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/4 "2014-07-15T14:19:48Z")

</div>

Have you tired setting the reverse word order property to true in the device settings for this device?Sounds like you might be reading the value backward since you are getting such a large number when trying to read a 32 bit register.

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [August 19, 2014, 12:13pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/5 "2014-08-19T12:13:45Z")

</div>

Hi!

Yes that solved the problem with the big number.  
But it didn’t solve the initial problem. We are reading the value as a 32bit, but after it reaches 65535 it resets to 0. ![:scratch:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/76d1620bec252bfac07050c889ff5a91dc8a9c25.gif ":scratch:")

PS. Sorry about the slow answer. 😊

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [August 19, 2014, 1:45pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/6 "2014-08-19T13:45:18Z")

</div>

whats the datatype of your sqltag?

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [August 21, 2014, 9:05am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/7 "2014-08-21T09:05:10Z")

</div>

Its Float 8

---

<div class="post-metadata">

**Author:** ![james.hunt](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james.hunt](https://forum.inductiveautomation.com/u/james.hunt)\
**Post date:** [August 22, 2014, 7:47pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/8 "2014-08-22T19:47:22Z")

</div>

Can I see the OPC Item path for the tag in question ?

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [August 28, 2014, 9:04am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/9 "2014-08-28T09:04:23Z")

</div>

OPC Item Path: [DEVICE\_NAME]1.HRI340

---

<div class="post-metadata">

**Author:** ![james.hunt](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james.hunt](https://forum.inductiveautomation.com/u/james.hunt)\
**Post date:** [September 2, 2014, 9:29pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/10 "2014-09-02T21:29:17Z")

</div>

Have you tried reading the second bit first like [DEVICE\_NAME]1.HRI341 ? It could be that you are reading the registers in the wrong order. And you need to start from the second register first.

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [September 8, 2014, 7:16am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/11 "2014-09-08T07:16:52Z")

</div>

Okay.  
How do i combine the registers if i read them in “wrong order”?  
Meaning that i read the the second address first and then the first. How do i make them a one 32-bit register?

---

<div class="post-metadata">

**Author:** ![james.hunt](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james.hunt](https://forum.inductiveautomation.com/u/james.hunt)\
**Post date:** [September 8, 2014, 9:42pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/12 "2014-09-08T21:42:36Z")

</div>

Using the HRI prefix is what is telling the modbus device to read the two 16-bit registers as a single 32-bit register. So if you were trying to read [deviceName]1.HRI340 you will need to change this to [deviceName]1.HRI341 so that you are reading 340 and 341 as a group that are treated as a single 32-bit register.

---

<div class="post-metadata">

**Author:** ![Tumeksi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tumeksi/32/4697_2.png) [@Tumeksi](https://forum.inductiveautomation.com/u/Tumeksi)\
**Post date:** [September 9, 2014, 11:05am UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/13 "2014-09-09T11:05:12Z")

</div>

Hi!

Okay I tried that.  
First when i put the second address first it gives me a value of 32 794 214,4.  
So that means the registers are in wrong order.

I Took the Reverse Word-order off. Now it shows 4995 which is not correct either. (Also all the other values show up incorrectly)

We have made a script that gets around this problem:  
We are counting the value from 0 to 65535 (which is being counted correctly) Then we count the times which the register has been set to 0 and we multiply the 65535 by that number and add that to the current counted value of the register. This shows the correct value.

I also have another problem with Modbus RTU / over TCP Should i add that one here or make new thred for it here?

---

<div class="post-metadata">

**Author:** ![james.hunt](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@james.hunt](https://forum.inductiveautomation.com/u/james.hunt)\
**Post date:** [September 9, 2014, 9:40pm UTC](https://forum.inductiveautomation.com/t/problem-reading-modbus-tcp-register/8580/14 "2014-09-09T21:40:57Z")

</div>

Post it on a new thread if it is for a different problem.
