Developed a firmware driver for a travel sensor. This sensor connects to our Wheel Sensor Boards (WSBs) and is used to measure the position of our car's suspension while driving. This information helps us tune our suspension as well as other vehicle algorithms, such as traction control.
The sensors are essentially just potentiometers. They have a 5V supply voltage, which must be stepped down to 3.3V for our MCU. Unfortunately, they are not entirely linear, requiring a proper transfer function. The raw sensor behaviour is shown below.
To create this function, I measured the output voltages at 1/8 inch intervals for both a 2- and a 3-inch long sensor. I then created a 7th order interpolating polynomial for each using MS Excel and averaged them. This process can be seen in the following Excel sheet:
A final experimental check of my transfer function on both the 2- and 3-inch sensors gave me great confidence in the reliability of my function, which was accurate to 3 significant digits (in inches).