# Modbus RTU: method to get float value from main and least significant bytes in Ignition

**URL:** <https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [March 8, 2024, 1:18pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029 "2024-03-08T13:18:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernst\_DA](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Ernst\_DA](https://forum.inductiveautomation.com/u/Ernst_DA)\
**Post date:** [March 8, 2024, 1:18pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/1 "2024-03-08T13:18:34Z")

</div>

Hello everyone,

I am using a probe for which I want to get a floating value that is stored as 4 bytes separated in two Modbus RTU registers with the main and least significant byte. Each register correspond to a tag in my Kepware server.

For now, I have written a short jython script that reads the two separate tags and do the conversion to a float value. Then the value is written into a memory tag.

I was wondering if there is a more elegant way to do it? Is that something achievable using an expression tag to avoid any script?

Thank you for your insights

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 8, 2024, 1:28pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/2 "2024-03-08T13:28:56Z")

</div>

Can Kepware not combine the registers for you? If you were using Ignition's native driver, there would be many built-in options for these kinds of multi-register conversions.

---

<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:** [March 8, 2024, 2:14pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/3 "2024-03-08T14:14:48Z")

</div>

> [@pturmel](#):
>
> Can Kepware not combine the registers for you?

It can. This would be the elegant solution.

---

<div class="post-metadata">

**Author:** ![Ernst\_DA](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Ernst\_DA](https://forum.inductiveautomation.com/u/Ernst_DA)\
**Post date:** [March 8, 2024, 2:18pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/4 "2024-03-08T14:18:55Z")

</div>

Ah well that's great, I am not familliar with kepware (my company use it that's the reason I am using it) and I haven't seen any obvious solution to do that, would you have a ressource on the internet which explain how to do that?

---

<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:** [March 8, 2024, 2:21pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/5 "2024-03-08T14:21:04Z")

</div>

> [@Ernst\_DA](#):
>
> would you have a ressource on the internet which explain how to do that?

[https://www.ptc.com/~/media/kepware-store/en/manuals/modbus-ethernet-manual](https://www.ptc.com/~/media/kepware-store/en/manuals/modbus-ethernet-manual)

---

<div class="post-metadata">

**Author:** ![Ernst\_DA](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Ernst\_DA](https://forum.inductiveautomation.com/u/Ernst_DA)\
**Post date:** [March 11, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/6 "2024-03-11T14:29:11Z")

</div>

@pturmel @Kevin.Herron  
Thank you both for your help. I finally found out. I initially got confused and used the script cause I wasn't getting the expected values: It appears kepware is weirdly made, and I had to decrement by one the Modbus register adress for floating values only.

---

<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:** [March 11, 2024, 3:11pm UTC](https://forum.inductiveautomation.com/t/modbus-rtu-method-to-get-float-value-from-main-and-least-significant-bytes-in-ignition/87029/7 "2024-03-11T15:11:49Z")

</div>

> [@Ernst\_DA](#):
>
> and I had to decrement by one the Modbus register adress for floating values only.

Are you sure you're not just reading half the intended register now? If non-float values don't need the register address decremented it's more likely that you are combining the registers using the wrong byte or word order. This should be configurable in Kepware.
