Allen Nelson
Member
Floats are not Real
There's one more thing to consider - how floating points are stored in the PLC.
The following is from Rockwell Knowledgebase article A8262:
Keep in mind that this error can also occur when doing a calculation, depending on the numbers used. Thus, the calculation of an internal 7.52 (which is actually 7.5199997) times 2 should come up with 14.04, it could conceivably come up with 14.03999997. But if you were to type 14.04, that might be stored as 14.04, and thus your GEQ (particularly the EQ part) will determine that the typed number is 'good', but that the calculation is 'bad'.
I don't know that this is what's happening, but it's a straw to grasp at. I do remember in my early years being bitten when trying to compare a float using an EQU, and discovering that it was quite exactly equal - just really, really close.
There's one more thing to consider - how floating points are stored in the PLC.
The following is from Rockwell Knowledgebase article A8262:
[There is a] limitation of the IEEE floating point format used by Logix, PLC-5 and SLC-500 processors. The data are stored as a single precision floating point number consisting of 32 bits: 23 bits for the fraction, 8 bits for the exponent and 1 bit for the sign.
The fractional number displayed is the sum of (1/2)**N, where N is the 23 bit fraction part. If the number can be EXACTLY represented as a sum of fractions such as ½, ¼, 1/8, 1/16, etc., then it will display "correctly". Otherwise, the inaccuracy is about 1x10e-007.
RSLogix 5000 displays the exact value contained in the processor, rather than rounding the data, thus, for 7.52, you might see 7.5199997, as an example.
Keep in mind that this error can also occur when doing a calculation, depending on the numbers used. Thus, the calculation of an internal 7.52 (which is actually 7.5199997) times 2 should come up with 14.04, it could conceivably come up with 14.03999997. But if you were to type 14.04, that might be stored as 14.04, and thus your GEQ (particularly the EQ part) will determine that the typed number is 'good', but that the calculation is 'bad'.
I don't know that this is what's happening, but it's a straw to grasp at. I do remember in my early years being bitten when trying to compare a float using an EQU, and discovering that it was quite exactly equal - just really, really close.