Hi everyone,
I’m working with a Siemens ET200SP and I’m using the Siemens S7-1500 Ignitions Driver.
While everything else is working fine, I’m experiencing some trouble reading and writing LREAL Tags.
In Ignition the tags are declared as Float8.
If i write the value 0.0 from Ignition, i can see 0.0 in the PLC via TIA PORTAL and the same i can see in Ignition.
Writing the value 1000 from Ignition will produce a number wich is around 7.6e+21 in tia portal, but, i can see the correct value in Ignition.
I would like to understand if the problem is linked to the Siemens Driver, if I’m doing something wrong, if i choose the wrong driver for the PLC.
I tried to write on a REAL using in Ignition the Float4, and everything is working correctly.
Thanks
The driver doesn’t support LREAL types 
Ok Thanks for the support Kevin,
have a nice day.
Hello,
For reading LREAL datatype from Siemens, you can read the individual words into 4 integer tags and use the script below to calculate the double value:
def words_to_double(word1, word2, word3, word4):
# Combine the 4 16-bit words into a single 64-bit integer (big endian format)
combined = (long(word1) << 48) | (long(word2) << 32) | (long(word3) << 16) | long(word4)
# Extract sign, exponent, and mantissa from the 64-bit integer
sign = (combined >> 63) & 1
exponent = (combined >> 52) & 0x7FF
mantissa = combined & ((1 << 52) - 1)
# Handle special cases (zero, infinity, NaN)
if exponent == 0:
if mantissa == 0:
return 0.0 if sign == 0 else -0.0
else:
# Denormalized number
significand = float(mantissa) / float(1 << 52)
return ((-1) ** sign) * significand * (2 ** (1 - 1023))
elif exponent == 0x7FF:
if mantissa == 0:
return float('inf') if sign == 0 else float('-inf')
else:
return float('nan')
# Calculate the double-precision floating-point number
significand = 1 + float(mantissa) / float(1 << 52)
double_val = ((-1) ** sign) * significand * (2 ** (exponent - 1023))
return double_val
You can then write this into a memory tag (double)