Working adc to distance converter using curve fitting