Scaling Data in Ladder Logic


Introduction to Scaling Data in Ladder Logic with ControlLogix

In this section, we’ll be Scaling Data in Ladder Logic. Scaling simply means that we convert a raw value into engineering units. For example, 4-10mA of input will give us a raw value of 3277 to 16383. This number does not mean a lot to us. However, this value is linear. A value of 3277 represents 4mA. Likewise, 16383 represents 20mA. We must perform some math on this value to get it back into engineering units. That way, it’s more meaningful to us in the logic. For this example, let’s say we have a pressure transducer. The transducer itself will output 4mA at 0 PSI. When it reads a pressure of 200 PSI, it will output 20 mA

It’s important to realize that some modules support scaling directly. In other words, we can go to the properties of the module. In the properties screen, you can configure the scaling. Simply specify what value we want at 4mA. At the same time, specify what value you need at 20mA. You configure each module individually.

When using Function Blocks, you have an SCL command available. Check out that post here.

When you connect to other remote chassis, we may need to scale the data in logic.

Step 1: Find the Offset

Consider the following chart:

Raw ValueScaled Value
3277 (RAW DATA)0 (PSI — Scaled Value)
16384 (RAW DATA)200 (PSI — Scaled Value)

As you can see, we need to subtract 3277 from our raw value. This gives us the same starting point. When we subtract 3277 from the raw value, it’s range becomes 0 – 13106.

Step 2: Find the Multiplier

At this point, we need to find our multiplier. We know that when we have the value of 13106, we really want a value of 200. This will be our scaled value.

As your self, “What value do we multiply 13106 by to get 200?”

The answer, of course will be 200 / 13106, which is 0.015260186. On the other hand, we could just do a divide. If we do a divide, then we need to divide the raw value by 65.53. This might be a little easier to understand. The DIV is simply the reciprical of the multiplier.

Let’s add the DIV statement, and see what our scaled value is.

As you expect, we get the value of 200. Our scaling is complete.

Using the CPT Statement

Another way to do scaling is all at once with the CPT Statement In this case, we simply enter an expression that performs the math on the raw value:

Another way to do this is to spell out our work:

It’s important to realize that one of the numbers in the second compute statement also contained a decimal point. By including a decimal point in the expression, we force the CPT to do it’s math in floating point. Without this decimal point, the CPT would do it’s math all in integers. The result would be a scaled value of either 0 or 1.

Summary

To summarize, there are many different methods to perform scaling. If you need to do the math in ladder logic, then this method might work for you. Understand that we don’t always have to do the math in logic. Some modules support scaling on-board the module.

You can also use tags instead of constants. By using tags, you can change the scaling on the fly. This could be from the HMI. Also, by using tags, it’s easier to change the scaling. You do not need to perform online edits to change the value of tags.

For other posts, please visit the ControlLogix Category Page.

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *