Hi, I am wondering how to control [the signal wire of a] fuel gauge with a microcontroller.
Supply voltage is 12 VDC [anywhere from 9 to 32 VDC] There is 5 VDC on the signal wire. The signal wire is to go through a variable resister [0 - 190 Ohm. Though can be changed to American standard of 240 - 33 Ohm]. At 5 VDC and 190 Ohm, there will be 30 mA going through the signal wire.
Using a digital potentiometer like a AD8400ARZ1 [1 kO 256 position AD8400ARZ1 data sheet my limited understanding is that the pot is limited to 2.1 mA between A&B. I do not know if there are other digi pots that would suit.
I have tried to search for other options. Not sure if a JFET is an option, though a JFET does have a min open resistance of probably 30-50 Ohms, and the range that I am looking for is around 200 Ohms, not kO’s.
The reason controlling the gauge with a microcontroller is that capacitance probe output is mapped to suit a non-linear tank.
Can someone point me in the right direction to control the gauge.
Hi, I am wondering how to control [the signal wire of a] fuel gauge with a microcontroller.
I don’t quite know what you are trying to do here.
How stable is the 12V
Is the “variable resistor” actually a variable resistor or a potentiometer. They are quite different.
If it is a variable resistor the 5V will only be 5V at one resistor position. Not stable.
Are the 2 resistors you have circled existing now or to be calculated.
A bit more info would be handy.
Hi ( I have edited my original drawing)
The 12 VDC supply is automotive.
The gauge was bought online. The default setting of the gauge is to suit a 0-190 Ohm fuel sender. By pressing and holding a button, you can change to suit a different fuel sender.
The green circle is the gauge.
The gauge is a sealed unit. The resisters inside the gauge is my understanding of how it works.
There may well be some other internal item so that any supply voltage between 9 - 32 VDC gives a stable supply voltage of ?? Volts!!
I have measured 5 VDC on the signal wire [or very close to]. (12 VDC supply, earth wire earthed, and volt meter between the signal wire and earth, nothing else connected to the gauge, just measuring voltage on the signal wire)
By changing the value [resistance] on the signal wire to ground between 0 and 190 Ohms will give the gauge a reading between empty to full [on the gauges default setting].
I am wishing to replace the use of a fuel sender [purple rectangle] with something that can be controlled with a microcontroller.
This is all a learning to me. I thought that a potentiometer was/is a variable resister. Still learning.
Fuel gauge document 2.pdf (805.0 KB)
The device you need is a digital potentiometer. This is an electronic form of a potentiometer that can be controlled by signals from a MCU.
You will need to convert 12v from the vehicle battery to 5v for the digital pot. There are many options available for this.
The 10K digi pot will only give 4 or 5 set points (on 8-bit, what ever that is) in the 0 - 190 ohm range. Nowhere near sufficient. Imagine that your car fuel gauge only gave, full, 3/4, 1/2 1/4 and empty reading, no value in between.
I am hoping to have at least 30 set points over 200 Ohms.
I gather that it will allow 100 mA through source & drain.
Will a 0 - 5 Volts from a microcontroller not be able to drive the digi pot?
That makes more sense. I have had a look at that “owners manual”. They don’t give much away do they. The ability to read Chinese would help.
A potentiometer can be connected as a variable resistor by only connecting the slider and one of the 2 outer connections. A variable resistor may have only 2 connections and can take many forms, even compressed carbon. For higher power applications both are usually wire wound as against a carbon resistive element.
Looking at this application the “sending unit” HAS TO BE A VARIABLE RESISTOR. Without knowing EXACTLY what is inside the gauge and how it works ( a tall ask) I can see no other alternative. You would have to find some device to emulate this. The sender obviously SINKS current supplied from pin 2 of the gauge. Without knowing the source impedance of the supply at pin 2 this is going to be a bit of a challenge. The 5V measured with sender open circuit will probably not remain 5V. It will diminish to 0V as the resistance lowers. You are thinking of emulating this current sink with a microprocessor. I don’t know how. Sinking current is the only way to do this unless you can find exactly what goes on inside the gauge. Is it measuring this current or voltage change to operate.
It may be possible by using a PWM signal to sink current. I believe Arduino can sink 40mA. By changing the pulse width the AVERAGE current will vary. If the gauge responds to this in a linear manner you could try this method but make sure the voltage does not exceed 5V. It would be an advantage also to know or measure the source impedance to make sure the microprocessor is not asked to sink more than its capability.
You still have to have some means of telling Arduino or whatever how full the tank is.
As a point of interest did the level sender come with the gauge.
If this is a fuel tank keep the risk of explosion well in mind. Variable resistors with a sliding contact could spark.
For that particular component you would need to provide offset resistors. But there are many varieties of digital potentiometer that are available and it is likely that you would be able to find a device more directly suited to your application. See, for example:
AD5171 Digital Potentiometer
The digital potentiometer requires 3-5v to drive it. If your question is whether the 5v output from a MCU board would be adequate, then the answer is Yes. But the MCU needs a DC supply, and the 12v from a motor vehicle battery is not suitable, as it can range up to 14 volts or more, and is very noisy. Whether it is for the digital potentiometer or for the MCU, you will need some form of power converter.
Thanks for your reply Bob.
Still in the ‘thinking’ stage. I only have the gauge. Rather a ‘steam’ gauge than electronic, and 270 degree sweep.
I envisage using a capacitance fuel probe which gives an accurate reading over the whole range, as apposed to a fuel sender with reed switches that will switch at each point (like the image in the owners manual). I can then map the input value from the probe in the microcontroller to suit the non-linear tank. Probably also add flashing led function for low fuel indication.
Yes, I would say voltage through the signal wire would change depending on the resistance of the sender.
I would not know if the gauge is like a stepper motor, and depending on the voltage on the signal wire, gives the gauge reading, or if it is current based.
The voltage divider setup inside the gauge I had seen on some previous place on the internet (cannot remember where) that someone had drawn as to what ohm value fuel gauges are like.
How can/does an Arduino sink current?
As mentioned, my knowledge is limited ATM.
I cannot work out how the Arduino link or data sheet on the Digi Pot can control the amount of resistance passing through it.
Yes, Will put a controlled 10 V supply to the microcontroller/Arduino.
Kind regards… Rossco
There sender is a variable resistor. The switch in the owners manual turns the back light on or off.
Would not matter. The works in the gauge process the information from the sender then drive the meter accordingly. It would not be driven directly by the current through the sender.
So would I.
When the PWM signal is high it can source current (40mA). when it is low it can sink current from an external source (40mA)
If you can get a probe that gives a suitable output and the PWM to sink current works then you could certainly re-map and use the result to control the PWM signal. I would try the PWM idea first and see if it operates the meter ok. Don’t worry if it seems to work in reverse, that can be fixed in the Arduino sketch or mapping.
Resistance does not pass through anything. Resistance restricts (resists) the current passing with a given voltage. Similar to turning a tap partly off, the water pressure does not change but the flow rate does.
The gauge reads the resistance between the signal (pin 2) and earth. The equivalent to the digital potentiometer would be an ordinary manual pot with a servo attached to the shaft and the Arduino controlling the servo using PWM (which was actually the way it was built in the first high-end audio amplifiers that had remote volume control). But instead of a pot it is a digital switch that switches different combinations of resistors in any out of circuit, and instead of PWM it is a serial communication channel.
If the gauge was reading resistance to the supply voltage you would be able to substitute a variable voltage for the variable resistance, perhaps by integrating a PWM signal. But it is reading resistance to earth, so the option of using a voltage source doesn’t exist. Motor vehicles will always use a sender that varies resistance to earth because it makes the device a single wire connection, and the supply voltage varies too much anyway.
Yes I think it is doing that by passing a current through the resistance from pin 2 which by measurement is 5V open circuit. Probably from a constant current source. That way you will get a linear voltage progression from 0Ω to 190Ω. The gauge innards would then process this information and do whatever it takes to operate the meter, Stepper or current, it doesn’t really matter.
You may find the fuel gauge in old cars sometimes had the resistance and meter as elements in a sort of wheatstone bridge to minimise battery voltage fluctuations. Later cars had a pulse system of some sort down the signal line. Don’t know how that worked. Modern cars would be on the CAN or other bus and handled by one of the many computers (my 2008 Peugeot has something like 6) and all the meters in the dash probably be tiny steppers.
The image of the fuel sender in the owners manual would be something like this.
Which would have internal reed switches (resisters) that would switch as the floating magnet passes.
But that is not here nor there. [don’t know how to quote text above]
Yes, resistance (ohms) is the restriction of current.
Anyway, unless someone can advise of a digi pot that can restrict current with about say 30 points in a 200 Ohm range, and handle 30 to 40 mA, not sure if that is an option.
Was not sure if JFET would do in Ohmeric ranges (spelling??)
So, if I paired two IO pins to have the same code, I could send the signal wire to two pins and use as current sink.
Is it possible to use two IO pins in parallel so that the current is shared?
Voltage would not be shared (still be 5 volts won’t it), is this bad?
Is there some way to protect the microcontroller/Arduino form over current/voltage?
Would there not be some internal resistance of the IO pins? (remembering 0 - 190)
The Arduino and fuel gauge probably should have the same power supply, because if the gauge has power and the arduino does not, the Arduino or the IO pins will be stuffed, I gather.
Just had a look at the Wema web site in the UK. Apparently these senders do have lots of reed switches inside a tube operated by a magnet floating up and down outside it. Apparently the early versions had a switch every 20mm inside the tube but with modern tecniques this has been reduced to 10mm. Thes seem to come in various lengths so I would assume that a 400mm tube would have 40 switches. The tube length is specified to suit your tank depth. So if you wanted a resolution of 30 measuring points this would be obtainable with a length of 300mm or more.
At the end of the day this may be your easiest approach.
No I don’t think so. Although specs are quoted as 40mA each there is an overall limit which i don’t think is a great deal more. You will have to look up Arduino specs. I don’t think this is a good idea anyway. If more current is required it is usual practise to use the Arduino to drive an external device, Mosfet etc.
`Not really as long as max current is not exceeded all OK. “0-190” has nothing to do with this. You are getting confused I think.
The Arduino needs nice 5V or between 7 and 12 (max) V as an external input which has an on board regulator. Grounds for both systems to be connected.
If you can get enough measuring points with a proper sender why complicate the issue. Before you make too many electronic plans you need to establish what the maximum current is out of pin 2 at 0Ω.
If you just connect a Digital multimeter or something else from pin 2 to ground this will simulate this. Use the 10A range and if it is more than this you may blow the fuse in the meter but because reed switches don’t handle much I doubt it will be anyway near this. If it is a constant current supply as I suspect the current will be the same as 190Ω or about 26mA. DO NOT use the mA ranges on a DMM as the internal meter resistance is too high and will be a false reading.
Hi Bob, I had looked at level switches with reed switches. For an 800 mm long prob, I had asked about getting the switches installed at different distances to suit my tank. It was not an option.
A great option would be if I could get a volt gauge that read 0 - 5 volts, 270 degree sweep.
Don’t know if a manufacturer would be interested in a one off.
May after work tomorrow get a chance to go back around to a leccie if he is not busy and test the gauge.
He did say that there was 30mA, but I don’t remember if that was with no resistance or 190 Ohm.
From the information you provided that type of level sensor is what marries up with your gauge. If you require an 800mm probe and the reed switches are 10mm apart you will have 80 measurement points. You indicated you would like at least 30. Even with 20mm spacing that is 40 points. Seems to fulfil all your requirements except maybe the shape of your tank. Is it so far out that it is going to be a problem. A lot of car tanks have a funny shape to fit in with body style and they don’t have much of a problem. I think most common liquid level gauges are pretty approximate anyway except for the full and empty points.
As these probes seem to be an “off the shelf” item I am not surprised.
Now I am really confused. What are you going to do with that??? If you look hard enough you will find meters with 270º movement. Not sure about 5V though. I assume you mean DC. I still have no idea what you would use it for although I have my suspicions. If I am right I would advise to forget it.
Do you not have a multimeter and know how to use it?? If you have to go find a “leccie” every time you need to measure something you are going to be a long time getting anywhere.
Need to know what the current is with 190Ω and 0Ω and maybe a couple of points in between would be useful. The current meter MUST have a very low internal resistance. 10A should be lowest range used and should still get milliamp resolution. The internal resistance of the meter on the mA ranges will be too high for the readings to be meaningful. Trying to establish if the supply from pin 2 is constant current or not. I suspect that it is.
Add on from last post.
What do you mean by “no resistance”?? You are a bit confusing. Do you mean 0Ω as in sender to ground is 0Ω or not connected as in open circuit??
Please clarify and indicate which condition you mean.
gauge readings .pdf (40.5 KB)
The mA readings may not have been that accurate.
Suspect that the gauge reads the voltage, and can feel the gauge vibrate as values change, stepper motor as apposed to current and bimetallic strip. (and the gauge sweeps to full and then back to empty when powering up)
If fuel gauges could be bought that read voltage, then the Arduino 0 to 5 Volts would drive it. Run PWM through a DAC (4.7 K and 10 uF cap)
We did play around and send through an opto and a 547 NPN transistor. The needle on the gauge was a bit jumpy (moving a bit without input changes)
Suspect that to be the case. You originally said 5V, 190Ω and 30mA. Does not equate.
Probably is a stepper motor. The sweep from Full to Empty would be calibration and initial zeroing.
Where does the “bimetallic strip” come from.
Almost all analog meters are current operated moving coil type and the movement is stated as fsd (full scale deflection) in µA or mA. 50µA 100µA and 1mA being common.
A voltmeter will have a “multiplying” resistor in series.
An Ammeter will have a “shunt” meter in parallel.
The only other difference is the V or A and the numbers on the face.
You seem intent on complicating things. If you wish to continue down this path I have nothing further to add.
As I see it in simple terms this is what you are trying to do.
You have a liquid level gauge. This is designed to operate with a stepped resistance of 0Ω to 190Ω on pin 2.
You want a sensor to replace the stepped resistance with an output analog or digital that you can input to Arduino or similar.
Whatever form this takes has to be converted to a string of numbers corresponding to 0 to 190.
These numbers have to be manipulated to suit the shape of your tank. This may require some form of look up table.
Output has to emulate 0Ω to 190Ω variable resistor with PWM current sink, digital potentiometer or some other means.
Forget about 270º volt meters, opto couplers and other fancy devices and how your gauge works and how it displays what it does. All you have to concentrate on is how you are going to simulate a 0Ω to 190Ω variable resistor and the gauge will do the rest.
Hi Bob, and others,
Yes, That i what I have asked for. Something that can take a signal from a microcontroller/Arduino or such, to control the gauge which is controlled by a resistance of 0 - 190 Ohm on the signal wire.