Since it looked to me that the median value was the correct distance measurement, that is what I went with.
I am using the code from this blog post http://forum.arduino.cc/index.php?topic=53081.msg1160999#msg1160999
The code did not handle the float values for voltage measurement, so I used the raw analog input, resampled the data, and plugged the raw input into the fast mean code.
Here is the data from the raw analog numbers:
This is the data with some outliers:
This is the data with the large outliers removed:
and because I wasn't having much luck getting a good measurement with distances less than 10", this is the data from 10 to 60in:
From this I was able to fit a polynomial regression line:Call: lm(formula = newPinData$distance ~ newPinData$pin_measurement + I(newPinData$pin_measurement^2) + I(newPinData$pin_measurement^3)) Coefficients: (Intercept) newPinData$pin_measurement 8.992e+01 -6.168e-01 I(newPinData$pin_measurement^2) I(newPinData$pin_measurement^3) 1.796e-03 -1.805e-06
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.