I tried reading the volts before and after converted into distance. The before is right, the after is wrong. There is something wrong with the conversion equation i came up with.
Selenaut:
So I made an equation to get a very close match to the actual GP2Y0A02YK0F sharp ir sensor voltage curve. It is:
y=(0.011x-sqrt(2.25)-0.16)^2+0.45
where y is volts and x is distance. Trying to make it into x= form, I got this:
x=(1000*sqrt(y+2.3056))/11
For reasons known to only the malevolent gods, the detailed response I just wrote went to the Great Bit Bucket in the Sky.
In brief, you appear to have made one or more algebraic errors in inverting the equation. I tried substituting your second equation into your first, but didn’t get an identity.
When I try to invert the first equation, I get:
y=(0.011x-sqrt(2.25)-0.16)^2+0.45
y=(0.011x-1.66)^2+0.45
y-0.45 = (0.011x-sqrt(2.25)-0.16)^2
sqrt(y-0.45)= (0.011x-1.66)
sqrt(y-0.45) + 1.66= 0.011x
(sqrt(y-0.45) + 1.66)/0.011 = x
which appears to work if you substitute it into the original equation.
This fit has a deviation (absolute error) of less than 2% for most regions, except for x=150cm (y=0.45) where the error is at about 5%. The mean absolute error is about 1.3%
Furthermore if you want accuracy it is a good idea to create your own curves as they may be different from Sharp’s.
One last thing: what do you mean “peak voltage” outputs? Isn’t your output similar to that appearing on Sharp’s datasheet? If so the voltage should be in the region: 0.45…2.75.