I’m building an ebike battery and I want to wire up a 12v fuel gauge to display the remaining “fuel”.
I have wired it up with a pot and playing around reveals empty on the gauge is around 6v and full is 10.5v.
I’m planning on having a step down module (input needs to take the variable battery voltage 30vdc-50vdc) and output 12vdc for the gauge and a second one to reduce that 12vdc to 5vdc for the MCU. (or a separate one taking the battery voltage and stepping down to 5vdc).
The MCU with monitor the battery voltage, convert and output a signal to the gauge.
My question is, how can I provide the 6 to 10.5vdc needed to drive the gauge? Most results I can find are overly complicated and use different approaches.
Hi gogreenpower
First question. Why do you need an MCU. What is wrong with converting the battery straight to Fuel gauge requirements.
Secondly what is the actual battery voltage. 30V to 50V isa pretty fair spread. Is it 50V full and 30V empty or exactly what.
Thirdly would not 0V to 12V for your gauge be OK. Like anything above 10.5V = OK and below 6V = Flat ??? Not quite sure exactly what this gauge is.
Cheers Bob
This will make the output at 50V around 10.16V and at 30V it will output 6.01V, which should be within the range for your gauge to read the charge correctly.
Hi Samuel, gogreenpower.
Like I said. Don’t know exactly what the “Fuel Gauge” is. It might need 12V separately to work. If so this should not be hard to arrange with some sort of step down converter.
Cheers Bob
Good point, I don’t need a microcontroller if I can convert the battery voltage to a range that suits the gauge. Speaking of which, it’s a generic automotive fuel gauge that operates on 12v. I have tested the gauge with 0-12v input and it displays from empty to full in the range of 6v - empty, 10.5v full, above and below this there is no movement on the gauge.
That might be the easiest way, I will be including a MCU for mqtt reporting of the battery to my Home Assistant instance. Keeping both functions seperate might be the way to go.
Speaking of the battery, it’s 36v nominal but will vary from 30v (cutoff/flat) to 42vdc (fully charged).
So, how to build a circuit that supplies a signal of 6-10.5v based on the battery voltage of 30-42vdc?
You could still use a voltage divider for this with different values, changing out the 20KΩ for a 3.3KΩ and the 5.1KΩ for a 1KΩ will give you 6.96V at 30V and 9.74V at 42V.
While it isn’t going to be exactly the right voltages for the gauge its going to be pretty close.
I’ll play around and see where these values put the needle. But I’m not gonna lie, it will need to be on or over the full and on empty at the low end. Might have to go down the MCU route otherwise
A bit difficult.
At the 42V end your division ratio is 4 while at the 30V end your division is 5.
A voltage divider has a fixed division ratio and so is linear.
I see no reason why the meter movement should not be linear.
The only reason I can see is the use of a potentiometer to apply a varying voltage to the meter. The outcome here would be the meter resistance in parallel with the lower half of the divider and so alters the ratio of the pot as doing it this way you are effectively changing the value of 2 resistors.
If you can determine the resistance of the fuel gauge you would have a chance of calculating the required resistance.
Another method which would give closer results would be to make a divider with fixed resistors then apply a variable voltage (say 25V to 45V) to this divider and log the result and adjust from there. This will NOT be the same as using a potentiometer but will be closer to the real world application. But you will need a variable supply to do this. Most bench supplies only go to 30V but if a dual supply there should be provision to connect the 2 in series. If you do this measure the voltage applied to the top of the divider NOT at the meter input.
Another point. This meter will be designed to operate with a particular tank “sender” unit with the appropriate scale. The tank unit might be connected as a rheostat and not a potentiometer. I don’t know how these things work these days. It can’t be just a resistance and series meter as the reading would go up and down with battery charging voltage. Is the printed meter scale linear ?? Maybe not .
This is just a sample of what I think would work. Basically it is a 1mA full scale deflection (FSD) meter movement configured as an expanded scale voltmeter. With the example shown it will read from 30V (zero) to 42V (full scale).
To configure your meter we need to know something about it.
Are there any markings on the scale like “fsd” or a type number.
Where does the needle come to at rest with no power applied at all. Below “Empty” or at the Empty mark. It is quite possible it has some sort of zener built in as you say it reads empty at 6V
Need to know some more things so if you can could you set it up like this.
If possible use a variable voltage supply. DO NOT use a potentiometer unless there is no other way. If the voltages are too low for reliable measurement increase the resistor to 10k or 5k. Use 1% or better types. Just note the value.
Measure and record the voltage at “A” and “B” under the following
Zero voltage applied (should read “0”
With the meter needle on Empty.
With the meter needle on Full.
With the meter needle as far as it will go (Full scale) in the case of this point being above the “Full” mark.
This should tell pretty much just what that meter is and if it could have a zener or something else built in.
Cheers Bob
Another thing to bear in mind is that both LiPo and LiFePo4 batteries don’t have a linear voltage in relation to their remaining charge.
Generally speaking the output voltage will drop significantly between 100% and 80% with then very little change in voltage until ~20% where the voltage drops rapidly. Below is a graph for a single cell LiPo, the graphic will maintain a similar shape with increased cells just with the voltage increasing.
I’d say that with the gauge you have it would likely display that it is on the upper end of full most of the time before rapidly dropping down.
I would agree with that. But gogreenpower seems keen on trying to use this “fuel gauge” which sounds a bit ike an automotive device.
I am not convinced it is going to work too good. I don’t think this meter is a straightforward moving coil meter. I believe there is some other skulduggery going on. I think the fuel gauge system in my car is a series of pulses of some sort but how this is processed at the end of the day is anybody’s guess.
That is why I have asked gogreenpower to do the few measurements, to give us a better idea of what this meter actually is.
Even if this meter does work it will be a basic volt meter and as such will be a linear measurement. As you point out, the discharge of a Lithium cell is anything but linear and this meter is probably going to spend most of its life at about 3/4 full with a rapid decrease at the end.
I don’t quite know how these LED “fuel Gauges” work. Like the 4 indicator LEDs on a power bank. The first one and the last one might be close to the mark but I think the 2 middle ones are an educated guess. I must try to find out how they do this one day soon. The only way I could guess is they know the mAhr capacity to start then measure the mAhr usage and work on that. But that would depend on a complete charge every time. Or they might use a VERY sensitive volt meter.
e will see what these measurements I asked for show up.
Cheers Bob
All good if it was linear
The upper battery voltage is 42V not 40V which becomes non linear.
I think there might have been a measurement problem using a pot as a variable voltage divider to provide a variable voltage. This would be greatly affected by the meter resistance. But there is something funny going on which might become clearer when the results of the measurements I requested are known. If the meter is a moving coil type it should be linear. Something was not so with that measurement.
Cheers Bob
Hi gogreenpower
Why can’t you use that. All I wanted is for you to connect a variable supply to the ikΩ (or higher if needed). Connect the other end of the resistor to the meter pos (+). Connect the meter neg (-) to ground then do the measurements using the variable supply as the source.
You are going to get yourself into a mess doing that. For a voltage divider to be accurate and predictable they ideally should be driven by a low impedance source and have a high (read very high) impedance load. you can’t achieve this by hanging voltage dividers indiscriminately all over the place. Connected in some sort of tandem arrangement each network will affect the one before it and probably the one after. In other words a hopeless mess. If the impedances are high even your DMM will interfere and what you read will not be correct for the real world.
If I know exactly what the meter is I can come up with a circuit for you. But as the meter will be basically measuring voltage I need to know exactly what that meter movement is. You have already established it requires 10.5V for a full reading and 6V for empty.
But this was established using a pot as a variable voltage divider. Due to the unknown resistance of the actual meter I don’t trust that. Using your variable supply for this check will fulfil the requirement for a low impedance source. If you do the measurements I asked for I can establish what this meter is.
For instance:
This tells me that is not an “expanded scale” meter with a built in zener diode but is probably just a moving coil meter with maybe an internal multiplier and simply a scale printed to suit the use it was designed for.
Cheers Bob
Hi gogreenpower
I have been re reading this thread and have become a bit confused.
It would seem that you might need to connect this meter somehow to 12V to get it to work. Is this so?? A moving coil meter is basically a passive device. That is it does not require power to work. It may need power for any lamp globes used for night illumination but the meter itself is passive.
If 12V is required this would indicate some sort of electronics inside the device. This could change the thinking a little bit but probably does not matter much.
If as you say you need the power supply 12V and need a potentiometer to get a varying voltage to get the measurements I requested this will be OK as long as you isolate the pot with an OpAmp. To implement Michael’s formula you are going to need one (or probably 2) at the end of the day anyway to scale the input to suit that meter.
An OpAmp for this use would have to be “rail to rail” which means the output can swing to within a few mV of the power rails. An “ordinary” device will have to have VCC a few volts above expected output value and a negative supply to get anywhere near ground. A good one I have used many times is the LMC6484 (quad) or the LMC6482 (dual). I note Jaycar no longer stock the LMC6482 so this series might be being retired, don’t know. Unfortunately the trend seems to be going for surface mount devices. This is doable with a pin pitch of 2.54mm so a photo board can be used but most I have looked up have been 1.27mm (or less) pitch which makes the hobby business a bit (read very) difficult.
Anyway to use a potentiometer (suggest 10kΩ linear or curve B) Get one of these ICs (Jaycar stock code ZL3484) and connect as follows, pretty simple.
Connect “top” of pot to 12V, “bottom” to ground
Select one of the 4 amps.
Connect pot slider to non inverting (+) input
Connect inverting input (-) directly to output
Connect output to meter +
Connect meter - to ground.
Connect IC+ (Vcc) to 12V
Connect IC- (Gnd or -) to Gnd
Connect ALL unused inputs to ground. DO NOT connect unused outputs to anything. This IC is a very high input resistance (10TΩ) so this will prevent any instability.
Measure at the IC output (meter input)
This configures the IC as a voltage follower and isolates any influence the meter input resistance will have on the divider operation, essential as the divider is variable in this testing phase. Will be a good thing at the end of the day in the final configuration anyway.
Cheers Bob
Sorry, this is all getting too complicated and more importantly too time consuming. I’ve decided to gut the gauge and use a stepper motor to position the needle.
I’ve taken some pictures of the inside just incase that helps satisfy your curiosity on how it was working.
Thanks for that. Made me more curious than ever. The components are a 68Ω what looks to be about 2W resistor and a diode of some variety. There is a coil with looks like many turns which does not appear to be attached to the pointer it would be if it were a moving coil meter. I know a fuel gauge is not simply a moving coil movement in series with a resistance in the tank and should be independent of actual battery and charge voltage. I am not sure exactly how they worked as I have never bothered to find out. I will now do so out of curiosity.
I believe that is just what the modern Auto meter is these days. A tiny stepper to position the pointer probably under instructions from the computer (s) system.
If you come up with any more info re that meter please let us know. Any markings on the panel might help.
And you are right . This could get a bit messy but doable.
Because the required ratio of the battery voltage change is different to the meter required ratio Michael’s formula would have to be used.
Thi bit in brackets “(Vb*0.375)” can be done using a resistive divider but the bit "-5.25 would require a suitable OpAmp configured as a difference amplifier. This would need about 20V Vcc which is another complication. Could be done with Vcc 12V but would need more electronic massaging with the complication of more components.
No other way out as I see it to implement the original proposal. Nothing is easy is it.