# RsLogix 500 - Analog Scaling using y=mx+b

## Analog inputs and outputs in a PLC can be used to make decisions and control outputs precisely, but we need to convert them from their raw format to units that can be understood, usually called engineering units.

This can be done with the SCP Scale with Parameters instruction that you will learn about in the next lesson.   But first we will use the equation y=mx+b so that you will know how to do it if there is no SCP instruction plus you are going to need to do some manual calculations using this to setup your SCP instruction.

What is y=mx=b

y=mx+b can be used to scale your raw data of an analog input to the engineering units of the analog sensor that is connected to it or your engineering units of an analog output to the raw data that an analog output module requires.

y - This will be the scaled result.

m - This is the multiplier to convert your data to the scaled value.  It will be y's full range divided by x's full range.

x - This is the analog data you are converting.

b - This is the offset or difference between the starting points of x and y.

Example - We are going to scale input 0, configured for voltage, of a 1762-IF2OF2, from it's raw data to volts.

y=0.003205*I:1.0+0

y - This will be the analog input in volts.

m - In our last lesson, RsLogix 500 - Analog Bit Resolution and Precision, we learned that the raw analog range of the 1762-IF2OF2 is 0-32760. Since our analog input is configured for 0-10VDC, you'll be tempted to use 10 as the full range of y however if you look at page 21 of the 1762-IF2OF2 Installation Instructions, you see that the "Full Scale Analog Range"  in voltage mode is 0-10.5.  This makes m = (10.5-0)/(32760-0) = 0.00032051

x - This will be input 0's value which is data address I:1.0

b - Since the starting point of both our x and y scales is 0, our offset is 0

Important uses for this that will be needed for the SCP Scale with Parameters instruction

The full scale analog range of the 1762-IF2OF2 is 0-10.5 for voltage and 0-21mA for current but most analog instrument's engineering ranges will be specified from 0-10 for voltage or 4-20 for current.  So you will need to know the raw values for the minimum and maximum values of both the voltage and current scale.

Min and max raw values for 0-10VDC - 0 minimum and 31200 maximum

Bot the raw scale of 0-32,760 and voltage scale of 0-10 start at 0 so the scaled minimum will be 0

We have the multiplier from our example above that we can plug in 10/((10.5-0)/(32760-0)) giving us a 10VDC raw value of 31,200