# Convert to float (32 bits) IEEE754

**URL:** <https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [August 25, 2025, 5:27pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153 "2025-08-25T17:27:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wvillegas](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wvillegas](https://forum.inductiveautomation.com/u/wvillegas)\
**Post date:** [August 25, 2025, 5:27pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/1 "2025-08-25T17:27:21Z")

</div>

Hello community,  
I'm having some trouble reading Modbus TCP addresses from an oxygen and methane sensor on an MSA device. The MSA device manual contains Modbus addresses in a specific format that I need to convert to see the actual value. Details of the format can be found here:

 ![Captura de pantalla 2025-08-25 121225](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/897efca2bb9d95a8b3d49b4a4ce4ea4d6bb42866.png)

I'm using ModbusTester as a quick tool to visualize data. In ModbusTester, I have the option to change the format, which does give me the measured value (which appears on the device 20.8). So, how would I do it in Ignition?

 ![Captura de pantalla 2025-08-25 121114](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a9b0ed72b897c35d26907c2161e6fdbf6f2cf4ba.png)

I'm trying this code, but it doesn't update the value when the Modbus tags change. It's as if it only performs the calculation once and doesn't refresh when the Modbus tag values ​​change.

 ![Captura de pantalla 2025-08-25 122522](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/04167a1d835a08d32afead3a2447c8651b36baab.png)

```python
def transform(self, value, quality, timestamp):
	
	try:
        
        	high = self.custom.key1 & 0xFFFF # Tag 107
        	low = self.custom.key2 & 0xFFFF # Tag 106

        
        # Change 32 bits
        	combined = (high << 16) | low

        # read IEEE754 float (32 bits)
        	sign = -1 if (combined & 0x80000000) else 1
        	exponent = ((combined >> 23) & 0xFF) - 127
        	mantissa = combined & 0x7FFFFF

        
        	if exponent == -127:
            		result = sign * (mantissa / float(1 << 23)) * (2 ** (-126))
        	else:
            		result = sign * (1 + mantissa / float(1 << 23)) * (2 ** exponent)

        	return round(result, 3)

    	except:
        
        	return None

```

---

<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:** [August 25, 2025, 5:29pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/2 "2025-08-25T17:29:37Z")

</div>

You don't need to do this combination yourself, just create a tag with an address (OPC Item Path) like `[Device]HRF107` or and the driver will read 2 registers and combine them into a floating point.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 25, 2025, 5:37pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/3 "2025-08-25T17:37:04Z")

</div>

For future referencing:

> **[Modbus Addressing | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/opc-ua/opc-ua-drivers/modbus/modbus-addressing#modbus-specific-addressing)**
>
> Manually Addressing a Modbus Device

---

<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:** [August 25, 2025, 6:43pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/4 "2025-08-25T18:43:31Z")

</div>

Also note that the left column in ModbusTester is **zero-based** , where IA's driver defaults to **one-based**. (Change in the device advanced settings.) When documentation shows addresses in hexadecimal, that is almost always zero-based.

---

<div class="post-metadata">

**Author:** ![wvillegas](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wvillegas](https://forum.inductiveautomation.com/u/wvillegas)\
**Post date:** [August 25, 2025, 7:02pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/5 "2025-08-25T19:02:18Z")

</div>

Thanks for the clarification of the prefixes that should be added. But is there a problem with RS323 to TCP?  
In OPC Item Path, it is displayed like this. (Analog8 = 106)

 ![Captura de pantalla 2025-08-25 130621](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/da3b2570e8cb37614cf8a65ad0138cacd1d04bbe.png)

RS232 to TCP

 ![Image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/1/91e716a44c69fd55d041792a54806e8bdd6f75ab.jpeg)

Thank you and please excuse my lack of knowledge on this part of the topic.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 25, 2025, 7:06pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/6 "2025-08-25T19:06:08Z")

</div>

You appear to be using the modbus address mapping configuration. Don't do that, just enter the address directly. e.g `ns=1;s=[FieldServerMD_TCP]1.HRF106`.

Note that you do not have the ability to browse registers on modbus devices using Ignition's driver. Anything you are seeing currently is driven by the address mapping config.

> **[Modbus Address Mapping | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/opc-ua/opc-ua-drivers/modbus/modbus-address-mapping)**
>
> Because it can be tedious to manually enter OPC Tag information one-by-one, the driver offers an address mapping feature. This feature allows entering blocks of common addresses and the driver will create the individual addresses and display them in...

Edit: for pturmel.

---

<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:** [August 25, 2025, 7:12pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/7 "2025-08-25T19:12:49Z")

</div>

> [@ryan.white](#):
>
> ability to browse registers on modbus devices

- _Cough_ \*

_Unless you use an alternate driver...._

/shameless plug

---

<div class="post-metadata">

**Author:** ![wvillegas](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@wvillegas](https://forum.inductiveautomation.com/u/wvillegas)\
**Post date:** [August 25, 2025, 9:04pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/8 "2025-08-25T21:04:05Z")

</div>

I thank everyone for their cooperation. The problem is resolved by following their instructions.

 ![Captura de pantalla 2025-08-25 160309](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/2/a2d4c4ab1d4e09736a8f3903d17da26482b0f7d1.png)

---

<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:** [August 25, 2025, 9:30pm UTC](https://forum.inductiveautomation.com/t/convert-to-float-32-bits-ieee754/110153/9 "2025-08-25T21:30:34Z")

</div>

You should not use an address mapping prefix that matches a manual addressing prefix, as that will prevent any manual addressing with that prefix.

It is best to not use the address mapping feature _ **at all** _.
