number-formattingdata-conversionplc

Converting a 10-digit numerical to a decimal °C value


I am reading temperature values from a PLC. The values are stored in Double_Word (4 bytes) in the form of "1102393648". Always 10 digits, and always starting with 110. They should be around room-temp like 20,00-23,00°C, but I don't understand how to convert it.

I tried different ways of converting and interpreting the values, but can't make sense of it. The technician who provided me with the connection couldn't tell me either, only that in his software, it shows up as actual °C, so they are correct values.

EDIT: I hear the comments, sorry it's not phrased better.

I guess I was hoping that this is a known way of reading values/temperatures, and that there is a formula to convert it.

I tried finding meaning in the 10 digits; in the hex conversion of it, the individual bytes, and of course tried googling possible ways to interpret it.


Solution

  • 1102393648 is 0x41B53130 (litte endian 0x30 0x31 0xB5 0x41 as bytes). These bytes convert to 22,6490... when interpreted as a float 32 bit value.

    But note that some sensors deliver really quirky values and the PLC just forwards them. You should really consult the datasheet of your sensor and/or the PLC, also regarding endianness.

    Another interpretation of the same value could be 1102393648 / 100000000 * 2 = 22,04°.

    Therefore, don't rely on a single input and output value as a reference. Always test multiple values, ideally over the whole range of the temperature sensor. Up to 100°C is usually simple. Just put the sensor into hot water.