The format of floats has changed with the
Siemens S7 range. This SIEMENS driver was never designed for use
with the S7 range, and this driver does not make use of the full
features provided by the S7 series. However, to use 'floats' keep
in mind the conversion as follows:
Conversion of Siemens Floats to IEEE
Short Floats
If the exponent (and sign) of the Siemens float is -128 then
convert the number to the IEEE infinity value:
(7F800000H or 0111 1111 1000 0000 0000 0000 0000 0000B).
Otherwise, add 127 to the exponent to get the IEEE biased exponent.
Move the mantissa sign bit to bit number 31, and move the biased
exponent to bits 23 to 32.
Conversion of IEEE Short Floats to Siemens
Floats
If the biased exponent is 255 (Not A Number or Indefinite), IEEE
value is negative infinity:
(0FF800000H or 1111 1111 1000 0000 0000 0000 0000 0000B),
or positive infinity:
(7F800000H or 0111 1111 1000 0000 0000 0000 0000 0000B),
then convert the number to the maximum Siemens float:
(7F7FFFFFH or 0111 1111 0111 1111 1111 1111 1111 1111B).
If the IEEE value is negative zero:
(80000000H or 1000 0000 0000 0000 0000 0000 0000 0000B),
Make the Siemens float zero (0H).
Otherwise, subtract 127 from the exponent to get the Siemens
exponent (9-bits, including the sign). Move the Mantissa sign to
bit number 23. Put the exponent sign bit in bit number 31 and the
rest of the exponent in bits 24 to 30. If the
exponent (and sign) of the Siemens float is -128 then convert the
number to the IEEE infinity value: (7F800000H or 0111 1111 1000
0000 0000 0000 0000 0000B). Otherwise, add 127 to the exponent to
get the IEEE biased exponent. Move the mantissa sign bit to bit
number 31, and move the biased exponent to bits 23 to 32. If the
biased exponent is 255 (Not A Number or Indefinite), IEEE value is
negative infinity: (0FF800000H or 1111 1111 1000 0000 0000 0000
0000 0000B), or positive infinity: (7F800000H or 0111 1111 1000
0000 0000 0000 0000 0000B), then convert the number to the maximum
Siemens float: (7F7FFFFFH or 0111 1111 0111 1111 1111 1111 1111
1111B). If the IEEE value is negative zero: (80000000H or 1000 0000
0000 0000 0000 0000 0000 0000B), Make the Siemens float zero (0H).
Otherwise, subtract 127 from the exponent to get the Siemens
exponent (9-bits, including the sign). Move the Mantissa sign to
bit number 23. Put the exponent sign bit in bit number 31 and the
rest of the exponent in bits 24 to 30.
As you can see, this can be solved in the PLC.
|