I think the problem is that you are not taking into account the voltage at zero weight. Also, you can’t just set the actual position to zero when the weight is zero, because the actual position is in scaled position units, but the scale hasn’t been properly set yet, so it will be wrong. Anyhow, here is how to do it:
From the equation for a line, y = mx + b, the equations for calculating m and b are:
m = (y1 - y0)/(x1-x0)
b = y0 - mx0, or b = y1 - mx1
m is the scale, b is the offset, x is volts, and y is position.
The procedure for calculating these is just like our Position/Counts scaling method:
- With no weight (y0 = 0) on the scale, record the voltage (x0), call this something like VoltsZeroWieght.
- With the calibrated weight (y1), record the voltage (x1), call this something like VoltsCalWeight.
- Now, from the equation for m above, the scale is (CalWeight - 0)/(VoltsCalWeight-VoltsZeroWeight)
- From the equation for m above, the Offset is: 0 - Scale * VoltsZeroWeight