Version 26.1 by Mengting Qiu on 2024/09/02 17:19

Hide last authors
Mengting Qiu 4.1 1 **~ Table of Contents:**
2
3 {{toc/}}
4
5
6
7 = 1. Instroduction =
8
9
10 This chapter shows how to perform linear calibration.
11
12
13 = 2. Linear calibration =
14
15
16 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.
17
Mengting Qiu 8.1 18
19 == 2.1 Solve the linear relationship manually ==
20
21
Mengting Qiu 7.1 22 (% style="color:blue" %)**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.
Mengting Qiu 4.1 23
Mengting Qiu 6.1 24 We can make a coordinate axis as below:
Mengting Qiu 4.1 25
Mengting Qiu 7.1 26 1. (% style="color:#4f81bd" %)**Y**(%%) axis is the real value, from 0~~10 meters
27 1. (% style="color:#4f81bd" %)**X**(%%) axis is the probe output , from 4~~20mA
Mengting Qiu 4.1 28
Mengting Qiu 6.1 29 We use two points to make the linear line: Point1(x1,y1) = (4,0), Point2(x2,y2)= (20,10).
Mengting Qiu 4.1 30
Mengting Qiu 7.1 31 Since the reading is linear, all (% style="color:#4f81bd" %)**probe output**(%%) and (% style="color:#4f81bd" %)**real value**(%%) is on this line, so we can calculate the real value by probe output in two steps:
Mengting Qiu 4.1 32
Mengting Qiu 7.1 33 * **Step1:** Get (% style="color:#4f81bd" %)**realk(Slope)**(%%) for the line:
Mengting Qiu 6.1 34
35 k=(y2-y1)/(x2-x1) = (10-0)/(20-4) =10/16= 0.625
36
Mengting Qiu 7.1 37 * **Step2:** Get (% style="color:#4f81bd" %)**real value( y )**(%%):
Mengting Qiu 6.1 38
Mengting Qiu 7.1 39 k =(y-y1)/(x-x1)  
Mengting Qiu 4.1 40
Mengting Qiu 7.1 41 ~-~-> y = k*(x-x1)+y1 = 0.625 * (x-4) + 0.
Mengting Qiu 4.1 42
Mengting Qiu 7.1 43 ~= 0.625 * (x-4)
Mengting Qiu 4.1 44
Mengting Qiu 7.1 45 Thus, we can introduce x-values to the already obtained equations to derive the corresponding y-values:
Mengting Qiu 4.1 46
Mengting Qiu 7.1 47 When x=12 mA , y=5 meters
Mengting Qiu 4.1 48
Mengting Qiu 7.1 49 When x=8 mA, y=2.5 meters
Mengting Qiu 4.1 50
Mengting Qiu 7.1 51
Mengting Qiu 4.1 52 A more general formular:
53
Mengting Qiu 22.1 54 (% style="color:blue" %)**Y=(y2-y1)/(x2-x1)* (x-x1) + y1**
Mengting Qiu 4.1 55
56
Mengting Qiu 7.1 57 Calibration Curve Schematic:
Mengting Qiu 4.1 58
Mengting Qiu 14.1 59 [[image:image-20240902114541-1.png||height="336" width="596"]]
Mengting Qiu 4.1 60
61
Mengting Qiu 8.1 62 == 2.2 Performing linear calibration curves in Excel ==
Mengting Qiu 7.1 63
Mengting Qiu 8.1 64
65 In addition, we can also perform calibration curves in Excel and directly obtain linear equations by statistics of X and Y values.
66
Mengting Qiu 14.1 67 Citing the same example above, (% style="color:#4f81bd" %)**X**(%%) and (% style="color:#4f81bd" %)**Y**(%%).
Mengting Qiu 8.1 68
69
Mengting Qiu 14.1 70 === Step 1: Create chart ===
Mengting Qiu 8.1 71
72
Mengting Qiu 14.1 73 A simple spreadsheet with two columns: X values and Y values.
Mengting Qiu 8.1 74
Mengting Qiu 14.1 75 [[image:image-20240902160516-1.png||height="404" width="561"]]
Mengting Qiu 8.1 76
Mengting Qiu 14.1 77 * Start by selecting the data you want to plot in the chart.
78 * First, select the X-Value column cell, then press the Ctrl key, and finally click the Y-value column cell.
Mengting Qiu 8.1 79
Mengting Qiu 14.1 80 [[image:image-20240902160755-2.png||height="394" width="562"]]
81
Mengting Qiu 22.1 82 * Go to the "(% style="color:#4f81bd" %)**Insert**(%%)" TAB, navigate to the "(% style="color:#4f81bd" %)**Chart**(%%)" menu, and then select the first option in the "(% style="color:#4f81bd" %)**Scatter**(%%)" drop-down list.
Mengting Qiu 14.1 83 * A chart will appear with the data points in the two columns.
84
85 [[image:image-20240902161202-3.png||height="453" width="824"]]
86
Mengting Qiu 22.1 87 * Right-click on one of the blue dots and select the (% style="color:#4f81bd" %)**"Add Trendline" **(%%)option.
Mengting Qiu 14.1 88
89 [[image:image-20240902161711-4.png||height="490" width="681"]]
90
91 * A straight line will appear on the chart.
92
Mengting Qiu 22.1 93 On the right side of the screen, the Format Trendline menu will appear. Check the boxes next to (% style="color:#4f81bd" %)**"Show formulas on chart" **(%%)and (% style="color:#4f81bd" %)**"Show R-squared values on chart"**(%%).
Mengting Qiu 14.1 94
Mengting Qiu 22.1 95 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.
Mengting Qiu 14.1 96
Mengting Qiu 22.1 97 Because the ideal data example is used, the R-squared value in this case is 1.
Mengting Qiu 14.1 98
Mengting Qiu 22.1 99 As the difference between the data points and the line increases, the R-squared value decreases, with **0.000** being the lowest possible value.
Mengting Qiu 14.1 100
Mengting Qiu 22.1 101 The equation is of the form (% style="color:blue" %)**"y = kx + b"**(%%),(% style="color:blue" %)** **(%%)where (% style="color:blue" %)**k**(%%) is the slope and (% style="color:blue" %)**b**(%%) is the y-intercept of the line.
Mengting Qiu 14.1 102
Mengting Qiu 22.1 103 [[image:image-20240902161857-5.png||height="559" width="1103"]]
104
105 * Calibration is complete. The user can customize the chart by editing the title and adding the axis title.
106
107 [[image:image-20240902163527-7.png||height="349" width="656"]]
108
109
110 === Step 2: Calculate the line equation and R-squared statistic ===
111
112 * Write the Slope formula in the formula bar according to the original x and y values statistics table.
113
114 [[image:image-20240902164104-8.png||height="503" width="492"]]
115
116
117 * Write Intercept formula in the formula bar according to the original x and y value statistics table.
118
119 [[image:image-20240902164156-9.png||height="525" width="488"]]
120
121
122 * Write Correl's squared formula in the formula bar based on the original x and y statistics table.
123
124 The CORREL function returns "R", so we have to square it to compute "R squared".
125
126 [[image:image-20240902164503-11.png||height="523" width="743"]]
127
128
129 * These values match those shown in the chart.
130
131 [[image:image-20240902164910-12.png||height="420" width="897"]]
132
133
134 === Step 3: Set up formulas to quickly calculate X and Y values. ===
135
136
137
138
139
140
141
142
Mengting Qiu 4.1 143 = 3. Case examples =
144
145
146 Some case for example which we can use Linear Calibration:
147
148
Mengting Qiu 7.1 149 (% style="color:blue" %)**Case 1: Calibrate Microwave Radar Readling.**
Mengting Qiu 4.1 150
151 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.
152
153
Mengting Qiu 7.1 154 (% style="color:blue" %)**Case 2: Calibrate the Soil EC base on SE01 soil sensor raw EC reading.**
Mengting Qiu 4.1 155
156 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
157
158
Mengting Qiu 7.1 159 (% style="color:blue" %)**Case 3: use water level probe to calibrate for oil.**
Mengting Qiu 4.1 160
161 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
162
163
Mengting Qiu 7.1 164 (% style="color:red" %)**Notice for Linear Calibrate:**
Mengting Qiu 4.1 165
166 1. k(Slope) is very important, We can measure more points to calculate the most accuracy k.
Mengting Qiu 7.1 167 1. Make sure the mapping is linear, and choose two calibrate points as "far" as possible.
Mengting Qiu 4.1 168
169