I have a potentiometer that we're using to measuring the sliding distance (0 to 15mm range) on a medical device.
Doing some testing we're seeing that the low and high end of the measurements are slightly off when measuring it on a measurement attached with known distances on it. I plotted the voltage readout vs the distance in excel to get a better idea of the sensor readout and it's linear for the most part but not the same slope as the in the 0-2 mm range as rest of the measurements afterwards.
So is there a way to build this calibration into the code?
You can calibrate the device by measuring the voltage at various intervals (the finer the better) and then fitting a curve to the result. This way you can find an empirical function to get distance from voltage.
Post a plot of your measurements, and forum members will be happy to suggest candidate functions and approaches for fitting the data.
ThomSal:
I have a potentiometer that we're using to measuring the sliding distance (0 to 15mm range) on a medical device.
Doing some testing we're seeing that the low and high end of the measurements are slightly off when measuring it on a measurement attached with known distances on it. I plotted the voltage readout vs the distance in excel to get a better idea of the sensor readout and it's linear for the most part but not the same slope as the in the 0-2 mm range as rest of the measurements afterwards.
So is there a way to build this calibration into the code?
If you disassemble a potentiometer, you will discover there is a physical connection made to each end of the resistive element. The connection cannot ever be linear close to the connection. Same will be found at the other end of rotation.
You need many more data points and I wouldn't be surprised if in the end you find out the best fit is after all a simple linear regression (for the 5-95% range at least, the ends of the range will likely give issues).
There are basically two types of pots: linear and logarithmic (the latter are used for volume controls and the like). Linear is of course never perfectly linear; you may find information in the part's data sheet on how close linearity you should expect.
The few data points you do have point to it pretty darn close to linearity to me.