Difference between revisions of "Load Cell Calibration"

From HiveTool
Jump to: navigation, search
(Example)
(Hivetool version 0.7.2 and earlier)
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is how to scale ("calibrate") the load cells into usable units.  This same method can be used for all sensors.  
+
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.'''
 +
 
 
==Theory==
 
==Theory==
In general, we assume the output is linear and use linear scaling based on the formula for a straight line, Y=mX+b
+
We assume the output is linear and use linear scaling based on the formula for a straight line,  
 +
 
 +
'''Y=mX+b'''
 +
 
 
Where:
 
Where:
 
  Y is the desired output in engineering units (pounds, kilograms, stones, etc.)
 
  Y is the desired output in engineering units (pounds, kilograms, stones, etc.)
Line 8: Line 14:
 
  b is the intercept.
 
  b is the intercept.
  
Two known points are required and two equations are solved simultaneously Usually one of the known points is 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).
+
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).
==Proceedure==
+
 
 +
==Procedure==
 +
 
  
===Method 1 using algebra===
 
  
 
With nothing on the scale, read the output of the HX711 ADC by running hx711:
 
With nothing on the scale, read the output of the HX711 ADC by running hx711:
Line 31: 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 solve Y= mX + b for m and b.
+
Now you have two know points and can calculate the slope, m, and the intercept, b.
  
 
==Example==
 
==Example==
 +
 +
 +
 
#With nothing on the scale, read the output of the HX711 ADC by running hx711.  In this case, the average was -345252.
 
#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).
 
#Weigh yourself (235.2 lbs).
 
#Then run sudo hx711 again while standing on the scale. The average was 1160807.
 
#Then run sudo hx711 again while standing on the scale. The average was 1160807.
#Now solve the two equations simultaneously:
+
 
 +
 
 +
 
 +
===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]
 
     0 = m * -345252 + b  [1]
 
  235.2 = m * 1160807 + b  [2]
 
  235.2 = m * 1160807 + b  [2]
  
Rearrange equation 1 by subtracting b from both sides:
+
Rearrange equation 1 by adding m*345252 to both sides:
    -b = m * -345252
+
 
 +
b = m*345252
 +
 
 +
Substitute b into equation 2:
 +
 
 +
235.2 = m *1160807 + m*345252
 +
 
 +
235.2 = m * (1160807 + 345252)
  
Rearrange equation 1 by dividing both sides by -345252:
+
235.2 = m * 1,506,059
    -b / -345252 = m or
 
    m= b/345252
 
  
Now substitute m in equation 2 and solve for b:
+
235.2/1506059 = m
  
  234.2 = (b/345252) * 1160807  + b
+
  0.000156169180623 = m
 
   
 
   
  234.2/b  = (1/345252) * 1160807 + 1
+
Plug m into equation 1 and solve for b:
   
+
 
  234.2/b = 1160807/345252 + 1
+
  0 = mX + b
   
+
  0 = 0.000156169180623 * -345252 + b
  234.2/b = 34.6222157857
+
  0 = -53.9177219485 + b
   
+
  b = 53.9177219485
  b = 234.2/34.6222157857
+
 
 +
 
 +
===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)
  
b = 6.76444284934
 
  
Now solve for m by plugging b into equation 1 or 2. It doesn't matter, but the math is easier if you use equation 2:
+
==Hivetool version 0.7.2 and earlier==
  
  
    0 = m * -345252 + 6.76444284934
+
'''''*** WARNING: This method is old and should not be used any more. ***'''''
   
 
  -6.76444284934 = m * -345252
 
 
 
-6.76444284934/-345252  = m
 
 
  .0000195927694824= m
 
  
 +
sudo hx711
  
===Method 2 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
+
It will return a number that depends on the frame design, weight of the frame, whether a bottom board is attached, etc. For this exalemple we will use 244210.
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:
+
Then place a know weight on the frame, preferably something around 2/3rds of full scale.  I usually just weigh myself and stand on it. For this example, we will use 3 50 lbs bags of concrete mix that were weighed on another digital and had a total weight of 153.25 lb.
 
 
    1160807 - -345252 = 1506059
 
  
 +
Run
  
Now to calculate the slope by dividing rise by run:
+
sudo hx711 244210
  
  m = 235.2/1506059
+
It will return a number. For the purposes of this example, we will use 1491713
  m = 0.000156169180623
 
  
Hivetool version 0.7.3 and greater
+
Divide this number by the weight:
  
 +
1491713/153.25 = 9,737.03002611
  
Hivetool version 0.7.2 and less
+
In the configuration page, enter 9737.03 for the slope and 244210 as the intercept.

Latest revision as of 17:47, 4 December 2017

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.

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

  1. With nothing on the scale, read the output of the HX711 ADC by running hx711. In this case, the average was -345252.
  2. Weigh yourself (235.2 lbs).
  3. 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

  1. 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)


Hivetool version 0.7.2 and earlier

*** WARNING: This method is old and should not be used any more. ***

sudo hx711


It will return a number that depends on the frame design, weight of the frame, whether a bottom board is attached, etc. For this exalemple we will use 244210.

Then place a know weight on the frame, preferably something around 2/3rds of full scale. I usually just weigh myself and stand on it. For this example, we will use 3 50 lbs bags of concrete mix that were weighed on another digital and had a total weight of 153.25 lb.

Run

sudo hx711 244210

It will return a number. For the purposes of this example, we will use 1491713

Divide this number by the weight:

1491713/153.25 = 9,737.03002611

In the configuration page, enter 9737.03 for the slope and 244210 as the intercept.