Scaling 4-20Ma rslogix5000

I would add the blue parens as above, in case the ordering of equal-precedence operations (multiplication and division) is done right to left.

PEMDAS
Mnemonic:
Please Excuse My Dear Aunt Sally
Math operation hierarchy:
Parentheses
Exponents
Multiplication
Division
Addition
Subtraction

I did a lot of scaling on some air handlers I wrote programs for in rs5K v. 20.04. I used a FBD routine and SCL instruction with input and output references. I just looked at this program again and there's 49 scaling instances. You can enter values in run mode and it's all neat and in one place. Yes, not all folks have this upgraded version of logix when they purchase a license.
I used CPT and SQRT instructions for inches Water Column for duct static pressure.
 
I am pretty sure that is not quite correct e.g. say

  • InputMin,InputMax = 4,20
  • ScaledMin,ScaledMax = 4,20
  • i.e. OutputValue should always equal InputRaw
  • So for InputRaw = 12 (half-scale):
    • (12 - 4) * (20 - 4) / ((20 - 4) + 4) = OutputValue
    • (8) * (16) / ((16) + 4) = OutputValue
    • (8 * 16) / (20) = OutputValue
    • (128) / (20) = OutputValue
    • (6.4) = OutputValue, which is not equal to the InputRaw (12)

That said, it will give correct results if [Scaled Min] is zero, and believable results of [Scaled Min] is a small fraction (1% or so) of [Scaled Max].

The correct formula is
(Input Raw - Input Min) * (Scaled Max - Scaled Min) / (Input Max - Input Min) + Scaled Min = Output
with "conventional" precedence rules (mult and div before adding; left-to-right or right-to-left for equal operator precedence), or
((Input Raw - Input Min) * (Scaled Max - Scaled Min) / (Input Max - Input Min)) + Scaled Min = Output
to eliminate more operator precedence rules as a possible issue other than parenthetical statements evaluated first and inside to outside.


I used to be amazed at the frequency at which scaling questions comes up on this forum. But then I watched a quiz competition on a twitch channel where one adult thought named "Van Golf" painted the Mona Lisa, another said the product of 19 and 11 was 201, and a third said 209 but needed the entire thirty seconds to get there.

I have used

(InputRaw - InputMin) * ((ScaledMax - ScaledMin) / (InputMax - InputMin)) + ScaledMin

Which I thought to be correct, but now you have me second guessing myself.
 
I have used

(InputRaw - InputMin) * ((ScaledMax - ScaledMin) / (InputMax - InputMin)) + ScaledMin

Which I thought to be correct, but now you have me second guessing myself.


Sorry about that, but what you are using there is also correct as long as parentheses have a higher priority than multiplication, and multiplication has a higher precedence than addition; it even has the added benefit of not requiring left-to-right among equal-precedence operations.
 

Similar Topics

5069 IF8 with a 4-20ma 0-100psi, sealed fixed, no calibration, transducer attached. IF8 is scaled 4ma= 0 psi, 20ma=100psi. If over time the...
Replies
12
Views
2,568
Hello, I have looked through the archives and haven't had any luck on the basics of scaling. I'm trying to refresh myself and what formulas I can...
Replies
10
Views
2,692
Hi, im using a wago 750-455 connected to s7-300 cpu I use fc105 but the scaling is not right, the value is 20% off. Almost like the fc thinks im...
Replies
15
Views
4,308
Hello, I am seeing an issue with inaccurate tank level. It is an elliptical bottom tank with an Anderson Level sensor mounted on the bottom of...
Replies
20
Views
7,441
Hey guys, I have been having a bit of trouble with analog output scaling. I’m programming out of a compactlogix, I’m trying to output 4-20mA to a...
Replies
13
Views
3,125
Back
Top Bottom