Close

Resistor Fuel Gauge Simulator: The final design

A project log for Locost Electrics

Car electronics projects for home built cars and hot rods. It includes a capacitive fuel sender interface and a wiper synchronizer.

dave-whiteDave White 04/20/2017 at 22:240 Comments

I have been away traveling for a while so am only just catching up. I decided to use a different circuit with a INA219 high side current and voltage sensor used to measure the current and voltage. As before, I used an AOI518 MOSFET as the "variable resistor". Power MOSFETs aren't perfect for this application as they are designed for strict on/off operation, but it worked. I started with an Arduino ProMini to provide the feedback control but it turned out to be too slow and its PWM capabilities were insufficient for fine control. I had a spare Teensy LC and this turned out perfect for the job. Enhancements to the circuit included a gate bias circuit that increased sensitivity by biasing the MOSFET half way between full on and full off. This requires calibration but that is easy to do.

I started by setting up the INA219 module using the available Arduino library. I set up a test program to calculate the effective resistance using Ohms law and the measured current and voltage. It worked well for fixed resistors. I was aiming for a resistance range of zero (approximately) to 110 ohms. They I added the mosfet with the control logic. Initially, I used "bang/bang" control driving the gate with a digital pin and with a 10 microfarad capacitor on the gate to dampen the voltage. This didn't provide fine enough control so I moved to PWM control on a Pro Mini but a 255 step PWM was still not fine enough control.

Next I added the bias circuit so that the whole PWM range was being used effectively. The gate was biased half way between pinch off and full on, similar to MOSFET audio amps. The PWM pin then drives the gate using a resistor chosen to just cut off the MOSFET with zero PWM count and just fully turn on the MOSFET with a full PWM count. I also changed to a Teensy LC (quite reasonably priced at around $12). This both gave faster response and provided a 12 bit PWM (4096 steps). This ended up as the final hardware design. I will add the schematic later as I have time. As I wanted the INA219 range to be 16 volts and 400ma, I had to modify the library as it didn't provide a call to set the full range values. You should be able to run with the existing settings and the library has the code to set the maximum voltage and current, but that capability doesn't seem to be callable from Arduino.

The bottom line is that the final system works well. I can provide a 0.5 volts to 5 volts input (as per my capacitive fuel level sensor) and get a simulated resistor output that varies between around 0.5 ohms and 110 ohms corresponding to what the fuel gauge expects. The software allows calibration of the range and correction of non-linearity. I will be publishing the Arduino code shortly.

The next project is a windscreen wiper synchronizer which I have just completed. The circuit should work well for other applications where you want to keep two motors synchronized in both position and speed but where you only have a single point in the cycle for synchronization (the home switch for windscreen wipers). More details to follow....

Discussions