Jump to content
Click here if you are having website access problems ×

Fuel level sender - how to convert resistance to a 0-5v signal?


Shaun_E

Recommended Posts

  • Support Team

I've been searching for a solution to this ever since I fitted a Race Technology Dash 2 Pro. The standard K series fuel sender is a simple potentiometer and the standard fuel level gauge works with that (as did the Stack dash I had previously).

The Dash 2 only supports 0-5v inputs so I need to somehow convert the variable resistance to a 0-5v signal. The Race Technology instructions say to add a pull up resistor, the resistance value to be determined by the resistance of the sender. In my case, I believe that the sender is in the 0-200 Ohm range and that I should fit a resistor of about 100 Ohm. I've tried this and the voltage measured at the dash doesn't seem to follow any remotely linear curve. The wiring diagram and resistor values are shown here: http://www.race-technology.com/upload/DASH2_PRO_Default_Wiring_Web.pdf.

Does anyone know the actual resistance range of the Caterham sender and/or have suggestions on how I could get this to work?

It is possible to buy a 0-5v output fuel sender but the only UK supplier I can find is ATL and they want £200 for them! Similar are available in the US for about £35 *mad* 

Link to comment
Share on other sites

#2:  The resistances I logged were for my Duratec pump/sender.   I imagine you could do the same for a K sender.

#3:  I didn't pursue the Spiyda device because there were spurious voltages in the sender/gauge circuit that corrupted the gauge calibration.  If you are fortunate enough not to suffer from such voltages, the Spiyda may well work for you.  I have one on my spares shelf that you are welcome to try.  I'm away at the moment, but if you can wait a few weeks, I can send you the device to try out.

In the meantime, if you email the Spiyda folks with your problem, I'm sure they'd advise.

JV

Link to comment
Share on other sites

I'm not surprised it's very non-linear. Does the gauge expect a linear 0-5V for empty -full or something? It should be really easy to knock up a little unit with an Arduino (and not much else!) for peanuts that would read in the sensor voltage on one pin and output the the gauge voltage as PWM 0-5V on another pin. That way the calibration from input to output would just be set in software so you could make it anything you wanted. Give me shout if you want me to design / knock something up for you.

PS: Adding a bit of software filtering to get rid of any voltage noise or spikes would be trivial.

Link to comment
Share on other sites

OK I've not had time to give it a lot of thought so I might change my ideas on some things, but for the simplest case, where the 0-5V input to the gauge is a high impedance and therefore won't really load the circuit driving it, you could do something like this:

Unbuffered_0.thumb.png.84ef91b44236a5d8a116d21ad42a0f46.png

The Arduino Nano can do Analog to Digital Conversion on its A0 input. Instead of feeding the Sender with +12V through a gauge, I'd feed it with +5V (regulated output from the Arduino) through a resistor that was matched to the sender resistance at about half scale, so 100 Ohms. The combined parallel resistance of the sender and resistor would then be 50 Ohms at half tank, so a 220uF smoothing capacitor would give a time constant of 11ms (but variable defending on the fuel level). This should take out the worse short-duration noise spikes that might confuse things, but then I'd do some simple exponential smoothing in software. You probably want a long effective time-constant to take out the effects of fuel sloshing around, unless the gauge already does that (it probably does, in which case a much shorter time constant would be appropriate).

The Arduino specs say it will run off up to 12V recommended, 20V maximum, so it sounds like it would run straight off the car's +12V supply, but it won't. From experience, even 12V is pushing it; anything over that and the internal regulators just burn out in no time, and the car is likely to be running maybe 14.5V when charging. So I've included a 78L09 low power linear voltage regulator and a couple of filter capacitors for stability.

The PWM output on digital pin D3 is then smoothed with an RC filter to give a 0-5V feed to the gauge.

If the gauge puts any appreciable load on the RC network, it won't go to the full scale at one end or the other, in which case it would need a simple buffer adding:

Buffered_0.thumb.png.477fdac7ffadb31b1c982a10a83e1d20.png

The MCP6021 will run off the +5V supply and swing rail to rail (pretty much the full 0-5V range).

As for generic resistance-to-resistance at 12V ... let me think!

Link to comment
Share on other sites

I reckon for the case of just matching to a mechanical gauge of arbitrary calibration, I'd just go with a transistor switch to ground, with pulse width modulation, and let the gauge itself do the smoothing:

12VGauge_0.thumb.png.451a7b92ff806d022a26aa73bc036e3f.png

In this circuit, 100% output duty cycle would correspond to the transistor being permanently "on", and so the equivalent of the gauge input being shorted to ground, and a 0% duty cycle would correspond to the transistor being permanently "off", and so the equivalent of the gauge input being open circuit.

This would work equally well with temperature gauge and senders too, the 100 Ohm input resistor might need to be changed to better match the sender in question to give a reasonable resolution over the whole range though.

I just need to check my logic on the transistor rating. I think because it is being driven off a PWM digital output, it would always be fully "on" or fully "off". In the "on" case, assuming 14.5V and a gauge resistance of 100 Ohms, it would be passing  14.5mA with a saturation voltage of maybe 0.1V so only dissipating a tiny 1.45mW of heat. In the off case, the heat dissipation would be effectively 0. It would only be in the half-on, half-off state where heat would be an issue.

Finding the correct calibration table might be a matter of trial and error, but at the end of the day it would just come down to a simple table in the code with one column of input voltages and another column of output duty cycle numbers, so it could be tweaked to match any desired calibration curve.

All of these need a bit of software writing for the Arduino, but that's not a difficult job. And a circuit board layout designing. And actually building!

PS: Edited to add a flyback suppression diode as the guage is going to be highly inductive and switching it on and off repidly will generate nasty back emf.

Link to comment
Share on other sites

  • Area Representative

Shaun,

rather than adding any of the above devices, why not wire as RT suggest (Using the regulated 5V from the dash2 at the 5V reference), then fill the tank from empty, adding say 5lit at a time, measuring the voltage at each point, then add those values (litres and volts) into the RT configuration.

Its not linear, but you don't need to know the resistance, you only need to know the voltage at each step.

Link to comment
Share on other sites

  • Area Representative

From the RT  "VAR and CAN manager", for the appropriate analog input, in "sensor type", select "custom", then "generate an equation from a table", where the "Y" column is your volume of fuel added, and "X" is your voltage reading. (but, the RT software does not seem to like "0" as the lowest "Y" value :-(    ).

some thing like this.....

RTsensorbytable2.jpg.63743405beae6afb8599a94134ac7e0b.jpg

Link to comment
Share on other sites

  • Support Team

I can see everyone loves a challenge :-). Thanks for your ideas.

The sender gets a 5v reference feed from the dash so that takes care of any possible voltage fluctuations. The dash can do the mapping of voltage to litres as Richard has shown above - when I tried it the curve was so crazy that the software couldn't create an equation to match it! The dash can also damp the input so no need for the circuit to do that. The dash can read up to 20V on each analogue input but 0-5v is what the manual suggests.

The Spiyda device is neat (I already looked at it) but it just maps one resistance range to another so isn't ideal in this scenario. Although, if it was used to map to a much higher resistance and a suitable (~1kOhm) pull up resistor were used it should produce a much better result (that's what the Race Technology supplied temp sensors use).

I have it wired like this with a 100 Ohm pull up resistor - it should work according to RT but the values the dash receives don't map to any sensible curve. I'll plug the laptop in later and get the curve off it to show!

Dash2Fuelsenderwiring.thumb.png.967ffe5fbb25de580c9ca16cbac6fa4a.png

This is all theoretical right now due to the fact I have a prolapsed disc in my lower back so I can't actually work on the car :-( but as soon as I am fit again I'll be keen to get it working.

Link to comment
Share on other sites

Well I think I'm going to do a Mastermind: "I've started, so I'll finish!". I think a little module that will map any old resistance profile onto any old gauge using an arbitrary calibration curve will be useful, especially for those people who don't have programmable dashes, just mismatched sensors or highly non-linear gauge responses. Not least ... me! My fuel gauge tends to over-read until it gets down to about 1/4 and then drop like a stone, so being able to linearise it would be nice. The number of times I've been touring and been fooled into thinking I've still got quite a bit of fuel, only to see it disappear alarmingly over the next few miles.

Hopefully it looks like you won't need it, so I'll probably start another thread for it. I was planning to use a lookup table with linear interpolation rather than try to fit a curve to the points. It should be perfectly accurate enough and should avoid introducing "fitting artifacts". I'll make it so that you can upload as many or as few points as you need and I'll make a little Windows app for reading out the sensor voltage as you add fuel and uploading the calibration points over USB. I think my design should be useful for temperature and pressure sensors too.

Shaun, if it turns out the built-in calibration system doesn't work for you for some reason, give me a shout. But I suspect if the curve is so far off being smooth and sensible that it can't fit a curve to it, there might be a problem with the sender? Do make sure that the pullup resistor you choose is a reasonable match for the sender resistance to make it more useable. If the resistor is too low in value, the output voltage will rise very rapidly as the sender resistance starts to increase and there will be very little resolution at anything other than bottom end of the sender resistance scale. If too high, it will be quite linear but only use a fraction of the available voltage range. Something similar to the resistance of the sender at half scale would probably work reasonably well, but bear in mind that that if the pullup resistor is P x (Full Sender Resistance) then the output voltage will only range from 0 to 1/(1+P) times the 5V reference you are feeding it with, so in the case of a resistor that matches half the full resistance of the sender (P=0.5) the output voltage will only range from 0V to 3.33V. A lower resistor will use more of the available voltage range at the cost of being less linear. You can never map to the full 5V range with a fixed pullup resistor.

Link to comment
Share on other sites

  • Area Representative

Andrew 

reading small voltage changes shouldn't be a problem for the RT dash.

I'm using a DL1club data logger that uses 0-25v analog inputs, and currently have a brake pressure sensor with an output of 0.5 to 4.5v for 0-250 bar. 
However, the maximum pressure I normally see when competing is significantly less than 50bar, but we can still see even the lightest touch of the brake pedal.

I'm Sure the DL1 and dash2 share very similar technology.

Link to comment
Share on other sites

  • Area Representative

Shaun,

When you entered the X & Y values that produced the equation :-

Y = ([(285.28 * (* ^ 3)) - (1471.89 * (× ^ 21) + (2529.77 * )] - 1439.34
 

Did you save a copy of those values?

if so, what were they?

Link to comment
Share on other sites

  • Support Team

Hi Richard - I thought I had them written down somewhere but I can't find them. If I find them, I'll post them here. I'll probably have to go through the calibration process again :-(

Link to comment
Share on other sites

  • 1 month later...
  • Area Representative

Shaun,

We've recalibrated Tom's Stack dash following refitting his standard (2001) tank, but, as we added fuel 5lit, at a time, I also disconnected the sender and measured the resistance at each stage.

Using a 100 ohm pull up resistor, I've calculated the values in the following RT screen shot.

RTfuellevelsettings.jpg.4470e72f07be8e3e262b28c7a9cd1138.jpg

Link to comment
Share on other sites

I used the same as richard I recall, 100 ohm resistor then added fuel and measured the minute voltage plotted against fuel level into the equation generator. It seems to work ok, remember in the software to slow the sampling rate so your fuel level doesn't constantly change through corners-inf, braking and accelerating to effectively 'damp' the signal. 

Link to comment
Share on other sites

  • Support Team

Thanks Richard and Danny. I did fit a 100 Ohm pull up resistor - either I got the value wrong or fitted it wrong - will have to check again. Now have plenty of time as the engine is off for a rebuild :-(

@Jonathan - it was this thread that got Andrew started but as I am the only one needing a 0-5V gauge output, he rightly chose to go the route he did. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...