There are two form of the linearization formula. Use whichever makes sense to you. The derivations are to allow you to take two measurements with the sensor, one close and one far away, and to plug them into the formula to get the constants needed to convert the inverse binary output of the sensor to a linear, calibrated output. On Dilbert I used 1/10" increments and a byte results which gave me a linear range of 0~25" (0 to 255). So, I measured at 5 inches (D = 50) and 20 inches (D = 200), recorded the raw output of the sensors, turned the crank on the calculator and came up with Kg and Ko.
The symbols are:
| D = Distance in whatever units you desire, I used 1/10 inch increments. | |
| Kg = Gain Constant, determines the shape of the inverse curve | |
| Ko = Offset Constant, shifts the inverse curve up and down | |
| X = output of Sharp sensor in Decimal. | |
| D' & X' are the second set of measurements |
The first form, the one I used in Dilbert