You are on page 1of 16

Load Cells for Weight Measurement

Aliya Kusumo, Jay Huber, Rachel Williams, Matthew Nelson


Dept. of Mechanical Engineering, University of California at Berkeley
(Date: November 1, 2020)

gauges as the amount of applied force to the free


Abstract end of the load cell fluctuates. Externally, the
This lab examined a cantilevered load cell data from those force variations is transmitted
under uniformly increasing and decreasing digitally through a breadboard-microcontroller
loads. The experiment was used to analyze the DAQ setup and into a csv file.
numerical relationship between the sensor output In the load cell cantilever configuration the
and the load applied. From the measurements of independent variable was the applied force from
3 load cells, load-output behaviors were derived each static load. The load increased
by reconstructing the data to quantify incrementally and induced an electrical response
non-linearity and hysteresis of the load cell due to tensile forces. The dependent variable, by
response and calibrating the digital outputs default then, is the electrical signal output. The
among several load cells. corresponding digital values of the applied
It was found that random error could come tension forces were expected to be proportional
from small disturbances to the hanging load, as and reactive, as they depend on the load cell’s
one test yielded an output 23 times less precise capacity as a force transducer. As the goal was
than one without disturbance. To calibrate the to quantify a relationship between sensor outputs
output of each load cell, best linear fit lines were and external inputs, all other possible factors
constructed from the output versus load plots. It affecting output values were held constant, such
was determined that the load-output relationship as the stability of the platform for the applied
could be considered linear as hysteresis and load and the mounting position of the sensor.
non-linearity of the data were less than 2% of The digital outputs were measured and
the full-scale output (FSO). After combining the compared with increasing and decreasing
3 datasets, it was found that the data points weights in order to plot the relationship between
needed to be offset to zero no load conditions to output and input. The graphs were analyzed to
avoid systematic error from varying platforms. quantify the associated errors within the
Other systematic errors (i.e. room temperature, load-sensor configuration as well as potential
location, load cell setup) could also account for nonlinearities between the varying load cells and
any variation between each load cells’ outputs. their applied loads. Analysis included
manipulation of data points between 3 load cells
to develop comprehensive linear fit curves.
1. Introduction Understanding the variations in the 3 datasets
allows us to further categorize the errors and
The purpose of the lab is to understand how evaluate the performance of our sensor
to calibrate a sensor to quantify a relationship calibration.
between the output of a sensor and the input
applied to it. In this lab, load cells are used to
evaluate weight measurements as a digital 2. Theory
output among distinctive applied forces. Each
load cell has a cantilever configuration that 2.1 Strain gauges, Load Cells
measures the bending force applied to one free A load cell is a sensor that can measure
end of the unit. Internally, the device measures force applied in an experiment. The load cell
the change in resistance among a series of strain used in this experiment is set up in a cantilever

1
configuration that measures the bending force changes and are typically noted as a combined
applied to one end of the sensor while the other error specification as displayed in Fig (1).
end is fixed. Structurally, the sensor has a metal
body made out of a material that is sturdy and
also minimally elastic. When the load cell
experiences a bending moment, change in
resistance is measured across an array of strain
gauges secured to the metal body. These
electrical variable resistance strain gauges are
constructed of fine wire configured in a grid
pattern and measure displacement with reference
to change in axial strain. More information
about these sensors can be found in the data
sheets referenced at the end of this paper.

2.2 Stress-Strain Relationships


Stress is defined by the measurement of an
Figure 1. Typical Load Cell Calibration Curve
applied force over a given cross-sectional area
while strain is the relation of deformation on a
body due to stress. In the case of this 3. Methods
experiment, axial strain is given by change in
length. As a material is strained, the resistance 3.1 Equipment
increases due to increased length, L, and 1. Digital multimeter (DMM)
decreased cross-sectional area, A, according to 2. Microcontroller (ESP32 Feather) and
Eq (1) where 𝜌 is density. corresponding USB cable
𝑅= 𝐴
ρ𝐿
(1) 3. Breadboard
4. Jumper wires (F-F, F-M, and M-M)
Therefore one can measure strain through
5. Load cell
measuring change in resistance with quation (2)
6. HX711 amplifier (24-bit ADC)
where F is the gage factor and 𝜀 is axial strain.
1 ∆𝑅 7. Rigid plate where a load cell can be
ε= 𝐹 𝑅 (2) fixed into a cantilever position
The resistance change is measured as voltage 8. Heavy objects to secure the load cell
and this change in voltage is proportional to the (toolbox, pumpkin, and dresser)
force applied. 9. U.S. quarter coins (5.670 ± 0.01g)
10. Thread or wire with a lightweight
container to load objects
2.3 Quantifying Performance 11. Computer (PC) with a free USB port
The load cell performance is quantified
through hysteresis and non-linearity analysis.
Hysteresis refers to the maximum difference 3.2 Setup
between the load cell outputs for the same
Mechanical Setup
applied load. The different readings are
The mechanical portion of the experimental
measured during one test increasing load from
setup consisted of a load cell in a cantilever
zero and another test decreasing load from the
position, fixed in place with a heavy object on
sensor's maximum rated capacity, otherwise
one end (a toolbox, pumpkin, and dresser were
known as the full scale output (FSO).
used). Lightweight plastic cups (used for holding
Non-linearity refers to the calibration curve's
weights) were suspended and tied with a thin
maximum deviation from a straight line
cord (thread, fishing line) to the overhanging
connecting the data points at zero load and at
portion of the cantilevered load cell. For all
FSO. The error caused by both hysteresis and
non-linearity diminish with small weight

2
testing, quarters were used as weights. See Fig The first testing included eight different stages
(2) for a diagram of this setup. for the loading cell to read. During the testing
cycle, four different loads are used such that the
weight increases, then decreases, in an even way.
See Table (1) for the stages of these loads. The
exact weights of each load were arbitrarily
chosen.
The second testing was done using W1 by
adding a small swing to the platform (1°-2°)
while measuring strain. This was compared to
stage 8 of the initial testing to study the impact
of a swing on reliability of the measurements.
Table 1. Loading stages during the testing cycle
Stage Load condition
1 No load
2 Static load W1
Figure 2. Suspended weight setup.
3 Static load W2 (W1 < W2)
Electrical Setup 4 Static load W3 (W2 < W3)
The electrical portion of the experimental 5 Static load W4 (W3 < W4)
setup consisted of the microcontroller (inserted 6 Static load W3 (W4 > W3)
into a breadboard), attached to the PC (with a 7 Static load W2 (W3 > W2)
USB cable) and to a 24-bit ADC (with jumper
cables). This 24-bit ADC is attached to the load 8 Static load W1 (W2 > W1)
cell (see Fig (3)). The PC communicates with
the microcontroller via the Arduino integrated Calibration Process
development environment (IDE). MATLAB is A calibration process was necessary before
also used for data processing. data analysis or plotting could be completed. In
this case, testing was performed with different,
arbitrary loads; therefore calibration was needed
using a best linear fit of the load cell output
versus weights. The slopes from these lines
could then be compared to a common reference
weight (in this case, a digital multimeter). This
was done through a two-point calibration with
no load and the DMM load points. Best fit
slopes from the load increase and decrease tests
were used for fining reference sensitivity.

Uncertainty and Propagation


Uncertainty in the data collected from these
Figure 3. Electrical setup. procedures comes from the strain gage and
weight setup uncertainty. Because the HX711
amplifier has a high bit resolution, it can be
3.3 Procedures assumed that quantization has a negligible
Mechanical Testing impact.
The testing process included multiple stages; The weights used for all testing were US
these included an 8-stage variable load test and quarters, which are 5.67 ± 0.01 grams at 99%
a test with a small disturbance to the platform confidence. The uncertainty of the weights is
(causing a 1°~2° swing). determined by multiplying ±0.01g by the

3
number of coins. The uncertainty of the load Parts (b) - (c)
cell output at 99% confidence was recorded as For calibration, the digital outputs were
±3SD from the 100+ data points for each test. plotted versus the weights to find a best fit
straight line. The slopes of the best fit lines
represent the increase in digital output steps for
4. Results and Discussion each additional gram of force. The plots for the
One load cell was faulty; it had output increasing load conditions and the decreasing
changes multiple orders of magnitude smaller load conditions for load cell 1 can be found in
than the output order for a considerable increase Fig (4) - (5). The same plots for the load cell 2
in load. Therefore, that load cell’s data has been and 3 can be found in Fig (6) - (7) in the
omitted, and measurements from 3 rather than 4 Appendix and Fig (8) - (9) in the Appendix.
load cells were used. respectively.

4.1 Question 1
Part (a)
After test #8 (W1 in the unloading condition)
for load cell 2, the digital output was measured
under the same load with a small disturbance
caused by swinging the platform about 1 to 2
degrees. The two different measurements are
recorded in Table (2).

Table 2. Load cell digital output and uncertainty at


99% confidence without and with a small disturbance
Digital output D.O. Unc
[steps] [steps]
W1 unloading 2.0004*105 ±121
Figure 4. Load cell 1 calibration for increasing load
W1 disturbance 1.9941*105 ±2804 from best fit line of output vs load

Part (b)
The output from the small disturbance
measurement has an uncertainty at 99%
confidence that is about 23 times larger than the
uncertainty without disturbance.
Part (c)
The error caused by the swing can be
classified as a random error as it is a deviation
from the experimental procedure. The
measurements should be taken when the
platform is still to avoid this random error that
reduces the precision of the measurement.

4.2 Question 2
Part (a) Figure 5. Load cell 1 calibration for decreasing load
The 8 data points of weight and digital from best fit line of output vs load
output from the load cells can be found in Tables
(3) - (5) in the Appendix. The uncertainties It appeared that the data from test #8 of load
recorded for each measurement are at 99% cell 3 was a blunder. Only 40 data points were
confidence. collected, and the outputs were lower than

4
expected (close to the no load condition). It is 4.4 Question 4
assumed there was some malfunction to cause
Part (a)
this blunder. The plot for calibration of the
Since the same load cell was used for the
decreasing load conditions was redone for load
three datasets, combining the data points could
cell 3 excluding this blunder and can be found in
provide more reliable calibration. The plot of
Fig (10) in the Appendix.
all data points with the best linear fit without the
Part (d)
blunder can be found in Fig (11), and the plot
The DMM was used as a reference weight
with the blunder can be found in Fig (13) in the
for the load cells, A calibration between the no
Appendix. Combining all the data points did not
load and DMM load measurements yields a
yield more reliable calibration because the no
reference sensitivity for the load cells. This
load output for the three load cells varied
reference sensitivity seems to match the best fit
depending on the setup. Since all data points
slopes from the load increase and decrease tests
were taken in reference to the no load condition,
as seen in Table (6).
the data points for the three load cells at each
load vary greatly from the best fit line as seen in
Table 6. Reference sensitivity from DMM and slopes
from load increase and decrease tests the plot.
Ref Sens Increase test Decrease test
Dataset
[steps/gf] [steps/gf] [steps/gf]
1 1862 1867 1864
2 1907 1892 1892
3 2004 2005 2004

4.3 Question 3
Parts (a) - (c)
From the measurements, non-linearity and
hysteresis in the digital output steps and percent
of FSO were determined and can be found in
Tables (7). The FSO was measured at 226.80 ±
.40 gf rather than the max load of the load cell(1
kg). The hysteresis measurements reported for
dataset 3, exclude the blunder mentioned earlier. Figure 11. Combined load cell calibration from best
From the non-linearity and hysteresis reported as fit line of output vs load with removed blunder
percentages of the FSO, it can be assumed that
the response of the load cell is linear as these Part (b)
percentages are all smaller than 1% with the Furthermore, the data points were offset so
exception of the non-linearity of load cell 2 that output at no load becomes 0. The new
which is 1.22%. calibration plot with a best fit line from this
Table 7. Non-linearity and hysteresis of the load cells offset without the blunder can be found in Fig
Non-linearity Hysteresis (12), and the plot with the blunder can be found
in Fig (14) in the Appendix. The data points
Dataset [steps] [% FSO] [steps] [% FSO] look more consistent than those of the
1 749 0.13% 3323 0.58% calibration plot without the offset. The load cell
2 6321 1.22% 188 0.04% error removed by offsetting the points is
3 533 0.12% 501 0.11% systematic error. Offsetting the points is a form
of calibration for the rest of the load cell outputs
as it zeros the no load condition with the varying
platforms used.

5
Table 8. Team member contributions to the lab
Name of author Contributions
Huber, Jay Methods
Kusumo, Aliya Results and Discussion
Nelson, Matthew Abstract and Introduction
Williams, Rachel Theory

References
[1] “Coin Specifications.” (2019). U.S. Mint.
[Online] Accessed Oct. 28, 2020.
Figure 12. Combined load cell calibration with offset
points with removed blunder
Available:https://www.usmint.gov/learn/coin-an
d-medal-programs/coin-specifications
Part (c) [2] “Load Cell and Amplifier.” The MicroKit
A couple additional factors that could Resource Hub, 17 Aug. 2020,
possibly differentiate each load cell’s response coemicrokit.wpengine.com/load-cell/.
from others include the temperature of the room [3] University of California, Berkeley (2020).
the tests were run in and whether or not the load Module 3 Clip 3 ‘Strain Gage’. [Online]
cell is parallel to the ground (perpendicular to Available:
gravity). A load cell reads out a digital output https://bcourses.berkeley.edu/courses/1495129/fi
based on the strain it experiences. The load cell les/folder/Course%20Videos/Module%203%20-
materials have a non-zero coefficient of thermal %20Sensors%20and%20Techniques?preview=7
expansion, therefore, varying temperatures 8371836link
would affect the strain. If the load cell is not [4] University of California, Berkeley (2020).
perpendicular to gravity, the load experienced Discussion 9 Homework3 ‘MicroKit Lab 2’.
would not equal the expected load from the [Online] Available:
weights since there is an additional angle that https://bcourses.berkeley.edu/courses/1495129/fi
affects the load. Since there was no les/folder/Course%20Videos/Discussion%20Vid
experimental design control for how level the
eos?preview=78731758
load cell was in the setup, this could cause
variation between the load cell outputs. For [5] Engineering, Omega. “Load Cells & Force
more consistent results in the future, more Sensors.” Omega Engineering Inc (2020).
experimental design controls could be used. [Online] Accessed Oct. 28, 2020. Available:
www.omega.com/en-us/resources/load-cells.
Acknowledgements [6] Load Cells | Industrial Force Transducers,
We wish to acknowledge the ME103 Fall 2020 Sensor, Load Cell Central. [Online] Accessed
teaching team for providing the sample template Oct. 28, 2020 Available:
and contents which could be reproduced with https://www.800loadcel.com/load-cells/loadcells
permission. .html
[7] Five Factors That Can Affect Your Weighing
System’s Accuracy. Hardy Process Solutions.
[Online] Accessed Oct. 28, 2020. Available:
https://www.hardysolutions.com/tenants/hardy/d
ocuments/5factorsa.pdf

6
Appendix

Appendix A: Plots, figures, and tables


Table 3. Dataset 1 weight and digital outputs from load cell with uncertainty reported at 99% confidence

Load Cell 1

Test Weight [g] Weight Unc [g] Digital Output [do steps x105] D.O. Unc [do steps]

1 0 -- 1.5295 ±107

2 56.70 ±.10 2.5959 ±173

3 113.40 ±.20 3.6441 ±248

4 170.10 ±.30 4.7014 ±324

5 226.80 ±.40 5.7686 ±602

6 170.10 ±.30 4.6681 ±108

7 113.40 ±.20 3.6634 ±140

8 56.70 ±.10 2.5755 ±105

Table 4. Dataset 2 weight and digital outputs from load cell with uncertainty reported at 99% confidence

Load Cell 2

Test Weight [g] Weight Unc [g] Digital Output [do steps x105] D.O. Unc [do steps]

1 0 -- .85916 ±103

2 56.70 ±.10 1.9998 ±119

3 113.40 ±.20 3.0534 ±146

4 170.10 ±.30 4.1101 ±105

5 226.80 ±.40 5.1689 ±114

6 170.10 ±.30 4.1111 ±93

7 113.40 ±.20 3.0553 ±125

8 56.70 ±.10 2.0004 ±121

7
Table 5. Dataset 3 weight and digital outputs from load cell with uncertainty reported at 99% confidence

Load Cell 3

Test Weight [g] Weight Unc [g] Digital Output [do steps x105] D.O. Unc [do steps]

1 0 -- .035749 ±153

2 56.70 ±.10 1.1670 ±103

3 113.40 ±.20 2.3032 ±102

4 170.10 ±.30 3.4431 ±115

5 226.80 ±.40 44.5814 ±140

6 170.10 ±.30 3.4429 ±136

7 113.40 ±.20 2.3082 ±120

8 56.70 ±.10 .034711 ±92

Figure 6. Load cell 2 calibration for increasing load from best fit line of output vs load

8
Figure 7. Load cell 2 calibration for decreasing load from best fit line of output vs load

Figure 8. Load cell 3 calibration for increasing load from best fit line of output vs load

9
Figure 9. Load cell 3 calibration for decreasing load from best fit line of output vs load

Figure 10. Load cell 3 calibration for decreasing load from best fit line of output vs load with blunder removed

10
Figure 13. Combined load cell calibration from best fit line of output vs load

Figure 14. Combined load cell calibration with offset points so no load results in output of 0

11
Appendix B: MATLAB Codes
% Reading csv files for load cell output
name = ["Matthew" "Jay" "Rachel"];
data = cell(3,9);
for i = 1:3
for j = 1:9
d = csvread(append('C:\Users\aliya\OneDrive\Documents\ME 103\MKL
2\',name(i),'\data',num2str(j),'.csv'));
data{i,j} = d(:,2);
end
end

Q1
oscil = csvread('C:\Users\aliya\OneDrive\Documents\ME 103\MKL 2\Jay\oscillating.csv');
oscil_avg = mean(oscil(:,2));
oscil_unc = 3.*std(oscil(:,2));

Q2
% Finding average and uncertainty of load cell output
output_avg = zeros(3,9);
output_unc = zeros(3,9);
for i = 1:3
for j = 1:9
output_avg(i,j) = mean(data{i,j});
output_unc(i,j) = 3.*std(data{i,j});
end
end

% Mass of single quarter in g


weight = 5.67;
% Uncertainty of mass of single quarter in g
e = .01;
% Loads applied
w = [0 10*weight 20*weight 30*weight 40*weight];
% 99 percent confidence for load error bar
w_unc = e.*[0 10 20 30 40];

% Increasing Load Calibration


p_i = zeros(3,2);
f_i = zeros(3,5);
eq_i = cell(3,1);
for i = 1:3
% best fit line for output vs weight
p_i(i,:) = polyfit(w, output_avg(i,1:5), 1);
f_i(i,:) = polyval(p_i(i,:), w);
eq_i{i} = "y = " + num2str(p_i(i,1),4) + " x + " + num2str(p_i(i,2),5);
figure(i)

12
plot(w, f_i(i,:), 'b')
hold on
% uncertainty at 99% confidence
errorbar(w, output_avg(i,1:5), output_unc(i,1:5), output_unc(i,1:5), w_unc, w_unc,
'.','MarkerEdgeColor','red')
title(append('Dataset ',num2str(i),' Increasing Weight Load Cell Calibration'))
legend({append('best fit line: ',eq_i{i}),append('raw data points at 99% CI')}, 'Location',
'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on
end

% Decreasing Load Calibration


p_d = zeros(3,2);
f_d = zeros(3,5);
eq_d = cell(3,1);
o = zeros(1,5);
o_unc = zeros(1,5);
for i = 1:3
o(1) = output_avg(i,1);
o_unc(1) = output_unc(i,1);
for m = 1:4
o(1+m) = output_avg(i,9-m);
o_unc(1+m) = output_unc(i,9-m);
end
% best fit line for output vs weight
p_d(i,:) = polyfit(w, o, 1);
f_d(i,:) = polyval(p_d(i,:), w);
eq_d{i} = "y = " + num2str(p_d(i,1),4) + " x + " + num2str(p_d(i,2),5);
figure(3+i)
plot(w, f_d(i,:), 'b')
hold on
% uncertainty at 99% confidence
errorbar(w, o, o_unc, o_unc, w_unc, w_unc, '.','MarkerEdgeColor','red')
title(append('Dataset ',num2str(i),' Decreasing Weight Load Cell Calibration'))
legend({append('best fit line: ',eq_d{i}),append('raw data points at 99% CI')}, 'Location',
'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on
end

%Decreasing Load Calibration for Load Cell 3 without blunder


output_mod = [output_avg(3,1) output_avg(3,7:-1:5)];
o_unc_mod = [output_unc(3,1) output_unc(3,7:-1:5)];
w_mod = [w(1) w(3:5)];
w_unc_mod = [w_unc(1) w_unc(3:5)];

p_mod = polyfit(w_mod, output_mod, 1);


f_mod = polyval(p_mod, w_mod);
eq_mod = "y = " + num2str(p_mod(1),4) + " x + " + num2str(p_mod(2),5);
figure(7)

13
plot(w_mod, f_mod, 'b')
hold on
% uncertainty at 99% confidence
errorbar(w_mod, output_mod, o_unc_mod, o_unc_mod, w_unc_mod, w_unc_mod,
'.','MarkerEdgeColor','red')
title(append('Dataset 3 Decreasing Weight Load Cell Calibration'),'removed blunder')
legend({append('best fit line: ',eq_mod),append('raw data points at 99% CI')}, 'Location',
'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on

% Reference Sensitivity
ref_sens = zeros(1,3);
for n = 1:3
ref_sens(n) = (output_avg(n,9) - output_avg(n,1))/168;
end

Q3
% Non-Linearity
dev = zeros(3,3);
m = zeros(1,3);
b = zeros(1,3);
z = zeros(1,3);
non_lin = zeros(1,3);
for i = 1:3
% slope of line between FSO and zero load
m(i) = (output_avg(i,5) - output_avg(i,1))/w(5);
% output at zero load
b(i) = output_avg(i,1);
for j = 1:3
% output at load based on line between FSO and zero load
z(j) = m(i)*w(1+j) + b(i);
% deviation of measured from expected output
dev(i,j) = abs(z(j) - output_avg(i,1+j));
end
% non-linearity is the maximum deviation
non_lin(i) = max(dev(i,:));
end

% Hysteresis
diff = zeros(3,3);
hyst = zeros(1,3);
for i = 1:3
for j = 1:3
% difference between increase and decrease load tests at same load
diff(i,j) = abs(output_avg(i,1+j) - output_avg(i,9-j));
end
% removing blunder
if i == 3
diff(3,1) = 0;

14
end
% hysteresis is maximum difference
hyst(i) = max(diff(i,:));
end

% Percentage of FSO
fso = zeros(1,3);
nl_p = zeros(1,3);
h_p = zeros(1,3);
for i = 1:3
%fso measured at out max load (W4) rather than max load of load cell
fso(i) = output_avg(i,5);
nl_p(i) = non_lin(i)/fso(i)*100;
h_p(i) = hyst(i)/fso(i)*100;
end

Q4
% Weight matrix to match concatenated datasets
w1 = [0 10*weight 20*weight 30*weight 40*weight 30*weight 20*weight 10*weight];
w1 = [w1 w1 w1];
w_unc1 = e.*[0 10 20 30 40 30 20 10];
w_unc1 = [w_unc1 w_unc1 w_unc1];
% Concatenate all three datasets
output_avg1 = [output_avg(1,1:8) output_avg(2,1:8) output_avg(3,1:8)];
output_unc1 = [output_unc(1,1:8) output_unc(2,1:8) output_unc(3,1:8)];

% All data points Calibration


% best fit line of output vs load
p = polyfit(w1, output_avg1, 1);
f = polyval(p, w1);
eq = "y = " + num2str(p(1),4) + " x + " + num2str(p(2),5);
figure(8)
plot(w1, f, 'b')
hold on
% uncertainty at 99% confidence
errorbar(w1, output_avg1, output_unc1, output_unc1, w_unc1, w_unc1, '.','MarkerEdgeColor','red')
title('Load Cell Output vs Weight: All Datasets')
legend(append('best fit line: ',eq),'raw data points at 99% CI', 'Location', 'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on

% Offset data points Calibration


output_avg2 = zeros(1,24);
for i = 1:8
output_avg2(i) = output_avg1(i) - output_avg(1,1);
output_avg2(i+8) = output_avg1(i+8) - output_avg(2,1);
output_avg2(i+16) = output_avg1(i+16) - output_avg(3,1);
end

p2 = polyfit(w1, output_avg2, 1);

15
f2 = polyval(p2, w1);
eq2 = "y = " + num2str(p2(1),4) + " x + " + num2str(p2(2),5);
figure(9)
plot(w1, f2, 'b')
hold on
plot(w1, output_avg2, 'o')
title('Load Cell Output vs Weight: Offset Data Points')
legend(append('best fit line: ',eq2), 'Offset Data Points', 'Location', 'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on

% Removing Blunder (Dataset 3, test 8)


output_avg3 = output_avg1(1:23);
output_unc2 = output_unc1(1:23);
output_avg4 = output_avg2(1:23);
w2 = w1(1:23);
w_unc2 = w_unc1(1:23);

% All data points Calibration with removed blunder


p3 = polyfit(w2, output_avg3, 1);
f3 = polyval(p3, w2);
eq3 = "y = " + num2str(p3(1),4) + " x + " + num2str(p3(2),5);
figure(10)
plot(w2, f3, 'b')
hold on
errorbar(w2, output_avg3, output_unc2, output_unc2, w_unc2, w_unc2, '.','MarkerEdgeColor','red')
title('Load Cell Output vs Weight: All Datasets','(removed blunder)')
legend(append('best fit line: ',eq3), 'Offset Data Points', 'Location', 'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on

% All data points Calibration with removed blunder


p4 = polyfit(w2, output_avg4, 1);
f4 = polyval(p4, w2);
eq4 = "y = " + num2str(p4(1),4) + " x + " + num2str(p4(2),5);
figure(11)
plot(w2, f4, 'b')
hold on
plot(w2, output_avg4, 'o')
title('Load Cell Output vs Weight: Offset Data Points','(removed blunder)')
legend(append('best fit line: ',eq4), 'Offset Data Points', 'Location', 'northwest')
xlabel('Weight [g]')
ylabel('Load Cell Digital Output')
grid on

Published with MATLAB® R2020b

16

You might also like