Microcontroller-based resistor ladder for gas gauge

Menticol

Active Member
Hello everyone!

I'm working on repurposing a Chinese motorcycle dashboard for a racing simulator. I’ve successfully generated the 12V PWM signals to control the RPM and speedometer indicators as needed.



Now, I want to work on the fuel gauge. The gauge reads as "full" when its cable is shorted to ground and "empty" when it’s open. By precisely varying the resistance to ground, I aim to display intermediate levels such as 20%, 40%, and 80%.

The schematic below (apologies for the low quality) shows my approach. Each test point input is connected to an ESP32 micro-controller output, controlled programmatically. Only one transistor must be conducting at any given time.


Unfortunately, this circuit currently produces only random values on the gauge, and I’m not sure why. I’m aware this issue could be resolved with relays instead of transistors, but since I plan to use the same approach for the gearbox indicator, I would prefer to avoid the clicking noise and the wear and tear associated with relays on this application.

Any input (no pun intended) will be very appreciated
 
Last edited:
Fuel sender gauges are notoriously none linear. Try switching (and removing all others) one transistor at a time and gradually increase (resistance or number transistors turned on) until it starts to make sense.

Sorry can't be more help.

Mike.
 
Fuel sender gauges are notoriously none linear. Try switching (and removing all others) one transistor at a time and gradually increase (resistance or number transistors turned on) until it starts to make sense.

Sorry can't be more help.

Mike.
Good catch Mike! Indeed, the resistor values shift wildly between 0 and 96 ohm (I used 10 ohm imaginary resistor increments for diagram simplicity purposes).

The strange thing is, by using the resistors alone, the increases are perfectly predictable and repeatable. Only when the transistors are added the indication goes wild, from zero to 40% to empty to full. I wonder if the transistors are not properly saturated, or if they are adding their own resistance, throwing off the scale.

No need to stick to transistors. If you or any other collaborator has another way to accomplish this, it will be very welcome.

Thank you very much
 
I just noticed you have labelled all the ESP pins as INPUT - they should be outputs to switch the transistors.

There are chips which will behave like a resistor (google digital potentiometer). MCP4151 springs to mind. However these may be too high a resistance.

Mike.
Edit, I would move the resistors into the collector of the transistors and increment them (10,20,30 etc.) and ground the emitters.
Edit2. You could possibly use binary values of resistors (5,10,20,40 etc.) and put a binary value on the ESP pins.
 
Last edited:
Oh, that's a bad translation on my part. I meant that the ESP32 pins are configured as digital outputs, and are connected to each transistor base. But to make testing easier I temporarily got rid of the ESP and proceeded to inject 3.3v directly by hand, hence the test points. I wonder if 3.3 is enough to turn the transistor fully on.

Already checked digital potentiometers, but sadly only found 10K models
 
If you configure the outputs as open drain, scale the R's so not much current
is sunk in the output you can eliminate the transistors. Something like this -



The IRF530 just the symbol used for the ESP32 open drain configured outputs.

You can adjust the R's to emulate the non linearity of gas tank sensor.
 
A single transistor switch to ground & the lowest value resistor, fed with a PWM signal should work? If it does not work cleanly at that, you could add a 100uf ? cap across the circuit as well?

As long as the PWM frequency is high enough to keep the voltage at the gauge input constant, it should work as well as a proper sender.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…