Allen Bradley Simple Subtract instruction incorrect.

JeremyAdair87

Member
Join Date
Jun 2014
Location
By International Airports
Posts
64
Hi,

Can anyone else try this and tell me what revision you are using if the value is correct.

Subtract
SUB
Source A 1.0 (constant)
Source B .8 (tag)
Result .19999999

Controller Compact Logix 1769-L27ERM-QVFC1B
Revision 30.011

I get the same without the decimal
Subtract
SUB
Source A 1 (constant)
Source B .8 (tag)
Result .19999999

I get the same with Compute

CPT
Dest PercentPerformanceLoss
0.1999999999
Expression 1.0-Performance

I get the same with Compute without the decimal
CPT
Dest PercentPerformanceLoss
0.1999999999
Expression 1-Performance

I understand a decimal being off on multiplication and division but simple addition and subtraction?

The quality guys are going to notice this difference.
 
As floating point numbers are an approximation ( though exact if the number is a submultiple of 2 like 1/2 1/4 1/8 or made up of submultiple) the operations on them yield approximations also. Your second number, .8, or 8/10, is not a submultiple of 2. If shown on an hmi try limiting the number of decimal points shown. That may give an acceptable view of the number. Remember, integers are for counting. Floating point is for measuring.


There are 'floating point calculator's available online. See the actual binary representation of .8
 
I can't use dint. The value will be changing based on the number of parts the machine has made and the number of minutes that have passed for OEE. I was just doing some soft calculations to verify my work.

I do like the idea of having the HMI round the number for me though.

1-.8=.2

No one will probably notice. I am just amazed such a simple floating point subtraction is not correct.
 
Humans have effectively infinite resolution. Number systems do not. The result of that subtraction is correct within the ability of the number system to represent it. The "simplicity" or "complexity" of the operation has nothing to do with the ability of the number system to represent any given number.

Keith
 
REAL is 32 bit, but V32 introduced 64 Bit Floating point LREAL.
Not sure if it will help you, but may be you can check.
 
here's a little demonstration ...

in RSLogix/Studio 5000 - go to a new/unused REAL location and simply type in this pattern:

123456789

now look at what value gets stored ...

I understand a decimal being off on multiplication and division but simple addition and subtraction?

even if you don't do ANY math functions (specifically, just type the number in) you can still have fun and games ...

The quality guys are going to notice this difference.

oh yeah ... and try teaching these little quirks to nuclear engineers ...
 
Last edited:

Similar Topics

Found a couple of old unused Micro 810s with lcd displays in the miscellaneous section. Don't ever use ccw or indeed any Allen Bradley, but...
Replies
12
Views
4,106
Hi I'm used to programming Siemens stuff but haven't touched AB for a few years now. I've got some simple mods to do to a program at work and...
Replies
7
Views
2,775
I have a client who periodically experiences network communication issues. Sometimes when I VPN into the site, their SCADA systems will flash comm...
Replies
2
Views
68
Hi Having issues with a older PanelView touch not working. Screen is connected to a Desktop computer. screen used as a display with touch...
Replies
1
Views
78
Hi good day Everyone, I have a cimplicity v10 project with 7 to 8k tags communicating with AB PLC through OPC and Rslinx classic. I have this...
Replies
1
Views
82
Back
Top Bottom