Fuel gauge recalibrator project

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
Excellent work mate. I see you went all surface mount too by the looks, which is great!


BTW, the ADC voltage reading you did, are you using the 100ohm in series with the fuel gauge resistor? I am trying to find out the related fuel gauge resistance.

6.jpg
7.jpg
 

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
On that topic mate, that's a good idea. Hard to say how big the market is but when you're ready, me and the forum owner will help you set up advertisements to sell them. You happy to bear the load of also mailing them out (make sure you factor in shipping costs to anywhere in the world)?


Selling it or not is not that urgent. But let me show the schematic, and can give any kind of suggestion you have.

schematic_v1.0.jpg
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
Mate as I have said this is excellent work. Can you PM me so we can start chatting on Discord or something? I would like to push this project forward and also learn from you about using PCB design software. I downloaded Fritzing but I'm a complete n00b and your experience on how you decided to lay this out is really intriguing. I want to do a similar PCB for my cruise control interface kit for the Evo X steering wheel I have.
I don't know if I posted about that project anywhere on the forum but it's basically a simple circuit using Optocouplers. Also currently using a prototyping board and an Arduino Uno.
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
BTW, the ADC voltage reading you did, are you using the 100ohm in series with the fuel gauge resistor? I am trying to find out the related fuel gauge resistance.

Yes I used it in series as the circuit is a voltage divider, so that Pin A0 can use the voltage reading as a means of calculating the resistance. Well, more to the point I don't care about the resistance I only care about the volate which is a result of the combined resistance.
 

BCX

Administrator
Moderator
Premium Member
Location
SA
First Name
Bill
Drive
2000 Galant Type-V
1997 MK Triton GLS [6G74 conversion]
2019 i30 N-Line
Selling it or not is not that urgent. But let me show the schematic, and can give any kind of suggestion you have.


Looks good, couple of questions:

Why +5v being fed into A3?
What's the 5v/3v ref? Wouldnt you use the aref input?
What's D1 doing? Are you trying to protect the arduino or the mosfet?
What's the LM317 doing? Couldn't the same be achieved with resistor divider?
 
Last edited:

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
Yes I used it in series as the circuit is a voltage divider, so that Pin A0 can use the voltage reading as a means of calculating the resistance. Well, more to the point I don't care about the resistance I only care about the volate which is a result of the combined resistance.
I got your point. If the circuit is a voltage divider, it doesn't matter what resistance it is from the sender, as long as reading the voltage and adjust that and send out to the PWM.

I search around from internet about using Arduino to read low resistance, there is example using LM317, not voltage divider, I don't know why, maybe because of the current consumption or accuracy or prevent to damage the Arduino. (https://circuits4you.com/2016/05/13/low-value-resistance-measurement/) In that case, I need to know the resistance of the fuel sender, by using the webpage, https://www.falstad.com/circuit/ , I made a voltage divider with 100 ohm, and estimate the fuel sender resistance from that webpage simulation.

I maybe wrong doing this redundant measurement or using the LM317 to limit the current(around 15mA according to the simulation), but I just want to play safe to the fuel sender to avoid damaging it.

Est_Fuel_Sender_Resistance.jpg
Volt_divider_circuit.jpg
 
Last edited:

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
Looks good, couple of questions:

Why +5v being fed into A3?
What's the 5v/3v ref? Wouldnt you use the aref input?
What's D1 doing? Are you trying to protect the arduino or the mosfet?
What's the LM317 doing? Couldn't the same be achieved with resistor divider?
1) The reason why +5v being fed into A3 is because I am not sure how accurate of the +5V pin is from the Arduino. In normal case, the code is like:

Input_voltage = Input_ADC * (5.0 / 1024.0);

But let's say a bit exaggeratedly, if the +5v pin is only 4v output by unknown reason, so, in the formula of the code, divided by 5 definitely get wrong voltage. But I connect the A3 pin and +5v pin together, A3 pin will show 4v after the formula. In that case, +5v pin is not true 5v, so, just 4v only, and then when calculating the input voltage from fuel sender, should divided by 4, not 5. Of course, it could be something redundant. Therefore, the code could be like:

// Read ADC from the VRef pin, which is connected to 5v directly
Input_Vref_ADC = analogRead(A3);
// Assume it is 5v, so divided by 5, and use result as reference control value
Input_Vref_voltage = Input_Vref_ADC * (5.0 / 1024.0);
// Calc the input voltage by using the Vref as control
// Read ADC from input pin A0
Input_ADC = analogRead(A0);
Input_voltage = Input_ADC * (Input_Vref_voltage / 1024.0);

2) The Aref pin is the input pin, which is used to fed a voltage from external, correct me if I am wrong. I used the 5v/3v ref because I am not sure using 5v or 3.3 v as reference is better. Of course 5v has "wider" resolution for each ADC value, but 3.3v could consumption lower current thought the fuel sender. Changing software is much much easier than changing the circuit board, so I put that first when testing is needed. Again, I may not be used as well.

3) For the D1 and the LM317, to be honest, I am not an electronic guy actually, so I just look around and take references from the web. Eg, the D1 with the MOSFET from "https://circuitdigest.com/electroni...ching-circuit-how-to-turn-on-turn-off-mosfets", and LM317 from "https://circuits4you.com/2016/05/13/low-value-resistance-measurement/"
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
i maybe wrong doing this redundant measurement or using the LM317 to limit the current(around 15mA according to the simulation), but I just want to play safe to the fuel sender to avoid damaging it.
The 220 ohm resistor takes care of that. Also the MPM3610 regulator/convrter on the Nano every is rated to 1.2 amps, pretty close to the 1.5 amps of a 7805 (and without the heat). Both can cope with the current. I don't see how a resistor is any more likely to fail and go short circuit.

Besides, the 220 ohm resistor coupled with the range of between 4 and 120 ohms of the fuel senders resulted in a suitable accuracy for the measurements we're interested in.

If it aint broke, don't fix it - as they say.

The Nano Every is a good idea.
Using the Nano Every's MPM3610 rather than the 7805 is a good idea.

Not much else really needed to be changed. If anything, I would prefer that the PWM frequency was higher and 10-bit rather than 8-bit, but it's as good as it needs to be for the current circuit design.
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
All this recent activity and my work on the Wiki got me thinking - is there another way to *increase* the accuracy of the fuel gauge beyond what the current calibration circuit can do? I suspect we may be able to do it.

Essentially there is one more circuit we could leverage for greater accuracy under 10 litres of remaining fuel, and that's the Low Fuel light sender. This sender is specifically designed to measure the very low levels of fuel in the tank, plus it also has a separate ON/OFF switch which identifies when the passenger side of the fuel tank is low.

What this change would mean is using two more sensors on the Arduino, and one more PWM output:
- Detect open/closed circuit for passenger side low fuel switch
- Detect resistance of driver's side Low Fuel Light
- PWM output for Low Fuel Light control

Using the above, we can add the additional data into our calibration table to assist in improving the fuel gauge accuracy below about 1/4 of a tank, plus we can mimic the low fuel warning light stock behaviour, and possibly also increase its consistency.

For giggles, we could also pulse the low fuel warning light on and off at full brightness when the tank is really low.
 
Last edited:

BCX

Administrator
Moderator
Premium Member
Location
SA
First Name
Bill
Drive
2000 Galant Type-V
1997 MK Triton GLS [6G74 conversion]
2019 i30 N-Line
You also need to provide adequate protection for the power supply, but also inputs and outputs of the Arduino to protect from noise in the vehicle electrical system.

Here's a few examples from my VR-4:

1652147077430.png

This is when the air conditioner compressor kick on. Spike is approx. 20v.


1652147137064.png


This is with the engine at idle, spikes are when ignition coils fire (frequency increases with engine speed). Approx 18v

I've killed a few Arduinos using them in automotive setting due to this noise.

When I get a chance, I will share what I did to protect the Arduino that worked for me. (stuff like clamping diodes, etc)
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
You also need to provide adequate protection for the power supply, but also inputs and outputs of the Arduino to protect from noise in the vehicle electrical system.

Here's a few examples from my VR-4:
when the air conditioner compressor kick on. Spike is approx. 20v.
when ignition coils fire (frequency increases with engine speed). Approx 18v

I've killed a few Arduinos using them in automotive setting due to this noise.

When I get a chance, I will share what I did to protect the Arduino that worked for me. (stuff like clamping diodes, etc)
In this particular circuit, are those issues valid considering:
- +5V Power is provided via a 7805 regulator
- The fuel gauge circuit is switched by a MOSFET (how much can leak from the drain to the gate?)

There are no other connections to the car's electrical system.

For comparison though, the UTCOMP uses AT90USB1286 and the board is shown below. Can you tell what they might be using for protection?
1652148561659.png
 

BCX

Administrator
Moderator
Premium Member
Location
SA
First Name
Bill
Drive
2000 Galant Type-V
1997 MK Triton GLS [6G74 conversion]
2019 i30 N-Line
without looking at the exact pinout, the top of the board looks to be a DC-DC converter which would clean the power supply up. Also looks to pass through a diode which would prevent damage is incorrectly wired.

Again, without pinout or ability to follow traces, the bottom of the board looks to be some form of protection for a bunch of inputs. Would need to know the specific parts and follow the traces to reverse engineer.

The oscilloscope readings where near the ECU where my flex board lives, so this will have most of the noise. I even see noise backfeed from the ECU's Rear O2 input, albeit not as bad.

Some noise is also inductive due to wires that are running parallel. The ATMega pins are tolerant to a certain extent, but eventually die/not work presumably due to electrical noise.
So any connection (whether is be an input or output, ground or power) needs to have some form of protection.

Easiest is clamping diodes. If you know your ADC can only tolerate 5v, then you would put a diode in reverse between input and ground, and another between input and 5v rail. This will clamp any spikes. You need to also have some capacitance to 'smooth' the noise a bit, like local bypass caps.
 
Last edited:

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
The 220 ohm resistor takes care of that. Also the MPM3610 regulator/convrter on the Nano every is rated to 1.2 amps, pretty close to the 1.5 amps of a 7805 (and without the heat). Both can cope with the current. I don't see how a resistor is any more likely to fail and go short circuit.

Besides, the 220 ohm resistor coupled with the range of between 4 and 120 ohms of the fuel senders resulted in a suitable accuracy for the measurements we're interested in.

If it aint broke, don't fix it - as they say.

The Nano Every is a good idea.
Using the Nano Every's MPM3610 rather than the 7805 is a good idea.

Not much else really needed to be changed. If anything, I would prefer that the PWM frequency was higher and 10-bit rather than 8-bit, but it's as good as it needs to be for the current circuit design.
BTW, you used 220 ohm or 100 ohm for the calibration table?

In fact, I searched around from google by the "voltage divider vs regulator", and of course using resistors as voltage divider is much simple and easy, but seems that using regulator are more pros, that's why I used the regulator method.
 

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
You also need to provide adequate protection for the power supply, but also inputs and outputs of the Arduino to protect from noise in the vehicle electrical system.

Here's a few examples from my VR-4:


This is when the air conditioner compressor kick on. Spike is approx. 20v.




This is with the engine at idle, spikes are when ignition coils fire (frequency increases with engine speed). Approx 18v

I've killed a few Arduinos using them in automotive setting due to this noise.

When I get a chance, I will share what I did to protect the Arduino that worked for me. (stuff like clamping diodes, etc)


Is it something like this? Using the diode and ferrite bead as filter? I saw this kind of voltage filtering circuit from web, and thinking about using this for my another project.

12v_filtering.jpg
 

kc427

Leaving Skid Marks
Lifetime Member
Location
HK
First Name
KC
Drive
VR4
without looking at the exact pinout, the top of the board looks to be a DC-DC converter which would clean the power supply up. Also looks to pass through a diode which would prevent damage is incorrectly wired.

Again, without pinout or ability to follow traces, the bottom of the board looks to be some form of protection for a bunch of inputs. Would need to know the specific parts and follow the traces to reverse engineer.

The oscilloscope readings where near the ECU where my flex board lives, so this will have most of the noise. I even see noise backfeed from the ECU's Rear O2 input, albeit not as bad.

Some noise is also inductive due to wires that are running parallel. The ATMega pins are tolerant to a certain extent, but eventually die/not work presumably due to electrical noise.
So any connection (whether is be an input or output, ground or power) needs to have some form of protection.

Easiest is clamping diodes. If you know your ADC can only tolerate 5v, then you would put a diode in reverse between input and ground, and another between input and 5v rail. This will clamp any spikes. You need to also have some capacitance to 'smooth' the noise a bit, like local bypass caps.
Just wondering, in this fuel gauge project, input signal from the fuel sender only a rheostat connected to the ground, also need diode for protection?
 

Tony_T

Leaving Skid Marks
Location
Hamilton New Zealand
First Name
Tony
Drive
Legnum VR-4 1997
Hi to you both, I'm still reading this thread but haven't had anything to add.
I'll just throw some things in here relating to the current discussion.
@BCX's scope traces serve as a warning that the automotive environment is very electrically dirty. It has often been stated that on a typical 12 volt automotive system spikes as high as 200 volts can be possible on the power supply as it is common practice NOT to have flywheel diodes across any inductive loads so the full kickback from e.g. the starter solenoid will feed back along the power rail until the associated switching contacts have separated sufficiently to suppress the arc. A series diode for reverse polarity protection is very desirable, followed by an inductor in series and a capacitor in parallel will slow most spikes, a transient voltage suppressor diode will complete the effect, perhaps a 24 volt one. As TVS diodes fail to a short when over stressed a series fuse (F1) to protect the supply wiring is necessary.
Note that a 7805 has a maximum input voltage rating of 37 volts, LM317 will be very similar.

A MOSFET has a very considerable capacitance between the drain and gate electrodes. MOSFET's typically have a maximum gate voltage rating of 20 volts, the function of D1 and R2 are to provide protection to the gate oxide layer and to the driving circuit U2 from the spikes which will be capacitively coupled from the output circuit and its associated supply.

@BCX's comment above about the inputs is totally correct, the diodes should be right at the u2 input pins and it is good practice to include some series resistance between the input signal and those diodes, a value of something like 1k ohm is good as this will limit the maximum current that could flow if the input was accidentally shorted to the supply feed to a bit over 12 mA which shouldn't hurt anything. A single 5.1 volt zener on each input to ground will also work. The resistor shouldn't affect accuracy as inputs are normally very high resistance, 1k is insignificant.
A bypass capacitor can usefully follow the resistor to remove any high frequency noise / signals that may find their way onto the input wiring, a value of 0.01 or 0.1µF is very suitable.

7805 is only 1 amp rated, the TO-220 version of the LM317 is 1.5 amp rated.

U1 in that circuit is configured as a constant current source with a current of 1.25 volts divided by 82 ohms, this will give a very different calibration curve compared to the single resistor where the current varies with the tank level.

Aside, I wouldn't want any low-fuel light to flash or vary in brightness, just warn me if I'm dangerously low by coming on steady, but that's just me.

Wow, that's a bit of a book but I wish this project every success, presumably it's applicable to any 8G Galant or Legnum models with some recalibration for the different sender setups, even though it comes very many years too late since almost all of these cars have now left the road and presumably reside in scrap metal dealers' yards now. There was a time a few years back when it was impossible to go out anywhere and not see at least one Legnum of some type, often many, but now it's rare to see one at all. With my housemate having just purchased an Outlander I see that they're literally everywhere, even more common than the Legnums were. Nice vehicle, but not as nice as the VR-4 to drive.
 

djb160

Leaving Skid Marks
Lifetime Member
Location
NZ, Wellington
First Name
Dale
Drive
Legnum VR4 "Grimace"
Nissan Leaf
I'd vote for just a steady light once ~10lt gets crossed as well.
Although I might be open to a pulsing on/off light if you can detect ~5lt crossed as a more serious warning
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
I'd vote for just a steady light once ~10lt gets crossed as well.
Although I might be open to a pulsing on/off light if you can detect ~5lt crossed as a more serious warning
Yeah I suspect I might be able to. It will depend on some empirical measurements of the circuit.
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
@BCX I took some closer shots of the UTCOMP board. These are definitely inputs at the bottom of the board from the earlier image, however these are all digital inputs that are either ON/OFF or pulsing.
1652234912322.png


I need to keep searching for how they have protected the analogue sensors.
For those curious, the reason I am looking at how the UTCOMP board interfaces with the car circuitry is because the UTCOMP is extremely reliable, and we should follow (but no further) how the UTCOMP does it.
 

Kaldek

2 AYC Bars
Premium Member
Location
Melbourne
First Name
Ed
Drive
2000 Legnum VR4 Manual, Ford Territory family runabout, BMW K1300R.
OK @BCX and @Tony_T I have traced how the UTCOMP Analogue inputs are wired. They are wired as follows:
Input pin --> 10K resistor --> MCP6004 Op-Amp-->ADC pin on AT90USB1286.

(Ignore the pad damage I've done on the AT90USB. My probes are a bit chunky)
1652236225817.png


How - if at all - does that impact your previous statements and recommendations? Does the following excerpt from the AT90USB1286 datasheet clarify?
1652237263241.png
 
Last edited:
Top Bottom