Example: Comparing Real Values Using Subtraction (-) Abs, And Less Than (<) - Allen-Bradley Micro800 General Instructions Manual

Programmable controllers
Hide thumbs Also See for Micro800:
Table of Contents

Advertisement

Chapter 3
Ladder Diagram (LD) elements
Example: Comparing Real Values using Subtraction (-) ABS, and Less
than (<)
The Real data type is not recommended when comparing values for equality
because of differences in the way numbers are rounded. Two output values may
appear equal in a Connected Components Workbench display, but will evaluate as
false.
For example, 23.500001 compared to 23.499999 will both display as 23.5 in the
variable input display, but will not be equal in the controller.
To test whether two Real data type values are equal, you can use a Subtraction
instruction to get the difference between the values and then determine if the
difference is Less Than an established precision value. See the following LD
program example for comparing two Real data type values.
Rockwell Automation Publication 2080-RM001D-EN-E - February 2015
53

Advertisement

Table of Contents
loading

Table of Contents