Have you ever purchased a simple 4..20 mA or 0..10 VDC analog sensor and wondered how to get them more accurate as read by the PLC? It is not uncommon for someone to assume a thermocouple, RTD, pH or other analog sensor comes “out of the box” set up and ready for exact measurement. In fact, sometimes they are advertised that way. But let us not be fooled, we have all at some point looked at the readings and said “this can be much more accurate”.
This is a quick how-to guide to help you quickly and efficiently calibrate and scale those analog sensors for the accuracy you desire. We will skip the theory as much as possible and only brush on the necessary technical topics. This guide is intended for anybody with access to a PLC, an analog sensor, and a desire to get a more accurate sensor reading.
What you need:
|1. A general understanding on what you are trying to measure with your analog sensor (Temperature, pressure, level, etc.)|
|2. Access and general knowledge of basic Ladder logic or similar style programming|
|3. A “high” and “low” test sample or way to define two end points of what you are trying to measure. For example, a cup of ice water for a low temperature reading and a cup of boiling water for a high reading|
|4. Something to measure your test samples (thermometer, ruler, etc.)|
|5. Knowledge of Calculus 1 or 2 (Just kidding, but we will be using the equation of a line, “y = mx + b”)|
|1. You know your way around the PLC you are utilizing|
|2. The sensor is hooked up to an analog input and confirmed working. For example, holding the thermocouple in your hand nets an increasing register value as seen by the PLC. Removing your hand you can observe the raw analog value decrease back to a steady state.|
Step by Step Guide:
Time needed: 20 minutes
How to calibrate and scale a analog sensor
- Create two samples of “high” and “low” points for a control
In this example we will be calibrating and scaling a thermocouple. We have chosen a cup of ice water for our “low” point, and a cup of hot water for our “high” point.
- Locate the sensor input in the PLC and prepare to record values
Make sure you have located the correct register in the PLC that contains the sensor information. We are going to be taking a few measurements to assist in our scaling and calibration.
- Place the sensor in the “low” state/condition
For example, we will place the thermocouple in our cold water with a actual thermometer so we can measure the exact temperature we should be reading.
- Record the sensor register value and actual value
Look at the register in the PLC and record the number as X1. Record the actual temperature as seen on the thermometer as Y1. We measured a water temperature of 35 degrees F with a PLC register value of 3000.
- Repeat this process for the “high” state/condition
In this example, we will repeat the above step replacing the cold water with our cup of hot water and record those values as X2 and Y2 respectively. We measured a water temperature of 200 degrees F with a PLC register value of 23000.
- Prepare for Simple Calculus
We are now going to create our equation of a line with the numbers we just measured.
- Calculate the Slope or m
From the equation we are going to calculate m from “y = mx + b”; to do this, simply calculate the following equation ((Y2-Y1)/(X2-X1)); no this is not a Facebook math trick problem.
From our above example with X1 = 3000, Y1 = 35 (degrees F) and X2 = 23000 and Y2 = 200 (degrees F)
m = (Y2-Y1) / (X2-X1) = (200 – 35) / (23000 – 3000) = 0.00825
m = 0.00825
- Calculate the offset of b
This is generally the trickiest part of the problem. When calculating the offset, or b, you will need to pick one of the two above measurements (high or low) and plug them back into the equation of a line and calculate for b. We will choose to use the low point for this example.
From the above example, choosing the “low” point as our test:
y = m x + b
35 = 0.00825 * 3000 + b
b = 35 – 24.75
b = 10.25
- Combine the slope and offset to create the equation of the line
Combine all of the above information and you will form the equation:
y = 0.00825 * x + 10.25
This is the new scaled and calibrated equation based off the real world samples you took. Now, for every PLC register value X, you will have a corresponding temperature in Fahrenheit Y. This is typically entered in the PLC as a CMP (compute) block where y would be called your “Temperature_Scaled” and the value would calculate from the equation 0.00825 * raw_analog_input + 10.25
That is it guys. Easy as cake. In the above examples you an try substituting pH samples in for a pH sensor or any other measurable combination of analog values and desired outputs (like a level transmitter and a actual product level). As long as you can physically measure it in real life you can scale the PLC accordingly.
BONUS TIP: Assuming scaling is linear (and generally this is true for most sensors) the equation you created can expand far above and below your high and low measurements. For example, say the temperature sensor you scaled really operates in the ranges of 400-600 degrees F; assuming the sensor you calibrated is meant for the total range we have observed ( in our example 35 F to now 600 F) our simple bench top equation should expand into the 400 – 600 degrees F range without any work required on your part*. The beauty about the linear equation is that it is defined for all points in space. You are only limited by the PLC register that is sending you data.
*In our above example we had a high value of 2300; in general, most analog inputs (raw) will range up to 32000 or 64000 depending on the register type (we are not intending on this to be a technical discussion) so take our example with a grain of salt knowing that you would have much different values if the sensor was in fact rated for 35 F to 600 F. Please contact us if you want more personalized help on this topic!