Difference between revisions of "Load Cell Calibration"
(→Procedure) |
|||
Line 38: | Line 38: | ||
The numbers may be negative, it doesn't matter. Now put a know weight on the scale and run hx711 again. The numbers should be significantly different (much bigger). | The numbers may be negative, it doesn't matter. Now put a know weight on the scale and run hx711 again. The numbers should be significantly different (much bigger). | ||
− | Now you have two know points and can calculate m and b. | + | Now you have two know points and can calculate the slope, m, and the intercept, b. |
==Example== | ==Example== | ||
Line 107: | Line 107: | ||
===Method 3 Linear Regression=== | ===Method 3 Linear Regression=== | ||
+ | Using your favorite spread sheet program (this is an open source project, so this example uses LibreOffice Calc), enter the data points in two columns: | ||
+ | |||
+ | Two methods can be used: | ||
+ | |||
+ | SLOPE Returns the slope of of the linear regression line | ||
+ | INTERCEPT Returns the intercept of the linear regression line. | ||
+ | |||
+ | or | ||
+ | |||
+ | LINEST Calculates the parameters of a linear regression as an array | ||
+ | |||
+ | |||
+ | |||
+ | =SLOPE(A4:A5,B4:B5) | ||
+ | =INTERCEPT(A4:A5,B4:B5) | ||
==Hivetool version 0.7.2 and earlier== | ==Hivetool version 0.7.2 and earlier== |
Revision as of 04:37, 12 April 2016
This is how to scale ("calibrate") the load cells into usable units. This same method can be used for other sensors.
Note: this is the method used in HiveTool version 0.7.3 and greater. A different method was used in HiveTool version 0.7.2 and earlier.
Contents
Theory
We assume the output is linear and use linear scaling based on the formula for a straight line,
Y=mX+b
Where:
Y is the desired output in engineering units (pounds, kilograms, stones, etc.) m is the slope X is the output from the Analog to Digital Converter (ADC) in counts b is the intercept.
Two points determine a line, so two known points are required. One of the known points may be zero, and the other is a known weight. Zero is used as it is convenient and it simplifies the math. The other point is arbitrary but ideally is near the other end, near full scale (200 KG or 440 lbs if four 50KG load cells are used. (I usually just use my weight, 150 lbs).
Procedure
With nothing on the scale, read the output of the HX711 ADC by running hx711:
sudo hx711
It will read the HX711 chip 64 times, and display the output of the ADC in binary and decimal with one reading per line and the average of the 64 readings at the end:
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 0 1 1 n: 1546646 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 n: 1546794 - . . . . . . . . . . . . . . . 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 0 0 0 n: 1547088 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 1 1 1 0 0 n: 1546168 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 n: 1546118 - 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 n: 1546014 - 1546640
The numbers may be negative, it doesn't matter. Now put a know weight on the scale and run hx711 again. The numbers should be significantly different (much bigger).
Now you have two know points and can calculate the slope, m, and the intercept, b.
Example
- With nothing on the scale, read the output of the HX711 ADC by running hx711. In this case, the average was -345252.
- Weigh yourself (235.2 lbs).
- Then run sudo hx711 again while standing on the scale. The average was 1160807.
Method 1 using graphical methods
The slope (m) is defined as rise over run (rise/run or rise divided by run). Using the numbers from the above example, the rise is the difference in the engineering units (the vertical or Y axis).
235.2 - 0 = 235.2
The run is the difference in the counts (horizontal or X axis:
1160807 - -345252 = 1506059
Calculate the slope by dividing rise by run:
m = 235.2/1506059 m = 0.000156169180623
Calculate the intercept by solving for b
Y = m * X + b 0 = 0.000156169180623 * -345252 +b 0 = -53.9177219485 + b 53.9177219485 = b
Method 2 using algebra
- Solve the two equations simultaneously:
0 = m * -345252 + b [1] 235.2 = m * 1160807 + b [2]
Rearrange equation 1 by adding m*345252 to both sides:
b = m*345252
Substitute b into equation 2:
235.2 = m *1160807 + m*345252
235.2 = m * (1160807 + 345252)
235.2 = m * 1,506,059
235.2/1506059 = m
0.000156169180623 = m
Plug m into equation 1 and solve for b:
0 = mX + b 0 = 0.000156169180623 * -345252 + b 0 = -53.9177219485 + b b = 53.9177219485
Method 3 Linear Regression
Using your favorite spread sheet program (this is an open source project, so this example uses LibreOffice Calc), enter the data points in two columns:
Two methods can be used:
SLOPE Returns the slope of of the linear regression line INTERCEPT Returns the intercept of the linear regression line.
or
LINEST Calculates the parameters of a linear regression as an array
=SLOPE(A4:A5,B4:B5) =INTERCEPT(A4:A5,B4:B5)