Table of Contents:

1. Instroduction

This chapter shows how to perform linear calibration.

2. Linear calibration

In some case, the measurement and real value are in different range, but they are both linear, we have to calculate the real value with the measurement we can use a simple Linear Calibration.

2.1 Solve the linear relationship manually

Example: we have a water level probe, the measurement range is 0 ~ 10 meters, and the output is 4~20mA, this means the when the water level is 0 meter, the output is 4mA, when the water level is 10 meters, the output is 20mA.

We can make a coordinate axis as below:

  1. Y axis is the real value, from 0~10 meters
  2. X axis is the probe output , from 4~20mA

We use two points to make the linear line: Point1(x1,y1) = (4,0), Point2(x2,y2)= (20,10).

Since the reading is linear, all probe output and real value is on this line, so we can calculate the real value by probe output in two steps:

  • Step1: Get realk(Slope) for the line:

          k=(y2-y1)/(x2-x1) = (10-0)/(20-4) =10/16= 0.625

  • Step2: Get real value( y ):

          k =(y-y1)/(x-x1)   

    --> y = k*(x-x1)+y1 = 0.625 * (x-4) + 0.

             = 0.625 * (x-4)

Thus, we can introduce x-values to the already obtained equations to derive the corresponding y-values:

When x=12 mA , y=5 meters 

When x=8 mA, y=2.5 meters

A more general formular:

Y=(y2-y1)/(x2-x1)* (x-x1) + y1

Calibration Curve Schematic:

image-20240902114541-1.png

2.2 Performing linear calibration curves in Excel

In addition, we can also perform calibration curves in Excel and directly obtain linear equations by statistics of X and Y values.

Citing the same example above, X and Y.

Step 1: Create chart

A simple spreadsheet with two columns: X values and Y values.

image-20240902160516-1.png

  • Start by selecting the data you want to plot in the chart.
  • First, select the X-Value column cell, then press the Ctrl key, and finally click the Y-value column cell.

image-20240902160755-2.png

  • Go to the "Insert" TAB, navigate to the "Chart" menu, and then select the first option in the "Scatter" drop-down list.
  • A chart will appear with the data points in the two columns.

image-20240902161202-3.png

  • Right-click on one of the blue dots and select the "Add Trendline" option.

image-20240902161711-4.png

  • A straight line will appear on the chart.

On the right side of the screen, the Format Trendline menu will appear. Check the boxes next to "Show formulas on chart" and "Show R-squared values on chart".

The R-squared value is a statistic that tells you how well the line fits the data. The best R-squared value is 1.000, which means that every data point touches the line.

Because the ideal data example is used, the R-squared value in this case is 1.

As the difference between the data points and the line increases, the R-squared value decreases, with 0.000 being the lowest possible value.

The equation is of the form "y = kx + b", where k is the slope and b is the y-intercept of the line.

image-20240902161857-5.png

  • Calibration is complete. The user can customize the chart by editing the title and adding the axis title.

image-20240902163527-7.png

Step 2: Calculate the line equation and R-squared statistic

  • Write the Slope formula in the formula bar according to the original x and y values statistics table.

image-20240902164104-8.png

  • Write Intercept formula in the formula bar according to the original x and y value statistics table.

image-20240902164156-9.png

  • Write CORREL's squared formula in the formula bar based on the original x and y statistics table.

The CORREL function returns "R", so we have to square it to compute "R squared".

image-20240902164503-11.png

  • These values match those shown in the chart.

image-20240902164910-12.png

Step 3: Set up formulas to quickly calculate X and Y values.

  • The equation of the best fitting line is "Y-value = SLOPE * x-value + INTERCEPT", so the solution of "y-value" is obtained by multiplying X value and SLOPE, and then INTERCEPT is added.

A simple formula table for calculating Y value automatically with input X value is obtained.

image-20240902171627-15.png

  • The X value based on the Y value is solved by subtracting INTERCEPT from the Y value and dividing the result by SLOPE: "x-value = (y-value-intercept)/SLOPE".

A simple formula table for automatically calculating X value based on the input Y value is obtained.

image-20240902171909-16.png

3. Case examples

Some case for example which we can use Linear Calibration:

Case 1: Calibrate Microwave Radar Readling.

The microwave radar reading might effect by the OUM(Object Under Measured), but the reading still linear. In this case, we can measure the closest(x1,y1) and the farthest point(x2,y2). Where the x is reading in platform, y is the real value. And use above method to calibrate.

Case 2: Calibrate the Soil EC base on SE01 soil sensor raw EC reading.

The SE01 probe is calibrated via mineral soil. The reading for other soil will be different by still in linear, In this case, we can measure two points (x1,y1) and (x2,y2). Where the x is reading of Raw EC, y is the real EC for the soil. And use above method to calibrate

Case 3: use water level probe to calibrate for oil.

Oil has different density vs water, but we can still use the immersion type water level pressure sensor to get the oil level. In this case, we can measure two points (x1,y1) and (x2,y2). Where the x is reading of water level, y is the oil level. And use above method to calibrate

Notice for Linear Calibrate:

1. k(Slope) is very important, We can measure more points to calculate the most accuracy k. 

2. Make sure the mapping is linear, and choose two calibrate points as "far" as possible.

 

Tags:
    
Copyright ©2010-2024 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0