# Combining Modbus Registers Indirectly

**URL:** <https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105>\
**Category:** Ignition\
**Tags:** modbus\
**Created:** [May 29, 2024, 8:21pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105 "2024-05-29T20:21:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julian\_Islic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/julian_islic/32/57055_2.png) [@Julian\_Islic](https://forum.inductiveautomation.com/u/Julian_Islic)\
**Post date:** [May 29, 2024, 8:21pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105/1 "2024-05-29T20:21:40Z")

</div>

I have a plc that is mirroring values from a Modbus device (Not connected directly) and it is giving me Hi and Lo values to combine into 1 tag.

What is the appropriate math to do in an expression tag? I have 2 values, 1 is an integer combine, the other is a float.

See screenshots below:  
Integers

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/2/e2d218dba4f35b46960aa035cb6819fa370b2d8b.png)

Float

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/877b1f667d75ca42f927a7544fff42128ec81808.png)

Online, I keep people saying that I need to do (hi \<\< 16) + (Lo 0xFFFF) but this doesn't really work for me using the expression language.

For the integer one, I have been using this int(hi \* 10000) + int(Lo). It gets me the correct value that matches the one on the device.

I don't believe either of these are correct, but I am not really sure if this is bullet proof or not. Ignition doesn't really have tools to see what is happening on the bit level in the opc browser, so I can't easily diagnose what the math needs to be.

Also, for the float one, I am simply getting wild numbers.

---

<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:** [May 29, 2024, 8:51pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105/2 "2024-05-29T20:51:16Z")

</div>

What is the exact expression you were using? Do you have the high and low words brought in as OPC tags already, and you're now just creating a 3rd expression tag to combine them?

P.S. the float case is tricky and can't be done with the expression language alone: [64-Bit Double Little Endian Input Register - #25 by Kevin.Herron](https://forum.inductiveautomation.com/t/64-bit-double-little-endian-input-register/73987/25) (there's also a corresponding `Float.intBitsToFloat` in the Java standard library)

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [May 29, 2024, 10:24pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105/3 "2024-05-29T22:24:27Z")

</div>

Personally, I would combine these in the PLC and then pass them onto the HMI as the proper DINT/Integer or REAL/Float. For the float you're going to have to do some BITD commands to put the bits in the proper order into a DINT, then do a COP of that DINT to a REAL.

---

<div class="post-metadata">

**Author:** ![Julian\_Islic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/julian_islic/32/57055_2.png) [@Julian\_Islic](https://forum.inductiveautomation.com/u/Julian_Islic)\
**Post date:** [May 30, 2024, 5:12pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105/4 "2024-05-30T17:12:02Z")

</div>

So yes, they are already in as OPC points. Unfortunately I have no control over the PLC.

So here is the expression that cave me the correct value. IMO weird way to store a number as you are separating out digits at this point. However, I cannot figure out how the float one works.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b93d88ffccd0c651870776c3f56fbb949cdd003b.png)

I will try the library you suggested.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [May 30, 2024, 7:08pm UTC](https://forum.inductiveautomation.com/t/combining-modbus-registers-indirectly/91105/5 "2024-05-30T19:08:41Z")

</div>

As @Kevin.Herron pointed out, floating point values are represented completely different. Try whatever he's suggested, but here's the basics of how it works.

[https://en.wikibooks.org/wiki/A-level\_Computing/AQA/Paper\_2/Fundamentals\_of\_data\_representation/Floating\_point\_numbers](https://en.wikibooks.org/wiki/A-level_Computing/AQA/Paper_2/Fundamentals_of_data_representation/Floating_point_numbers)
