I'm trying to emulate a fluid level sensor - Page 1
Forum section: electronics / beginners

author: skyjumper
author_rank: Regular Contributor
timestamp: October 06, 2019, 01:05:35 am
content: Hi All...Many marine tank level sensors have an output range of 240 to 33 ohms. Resolution depends on the type of sensor. I'm trying to figure out how to generate this signal from a microcontroller. I considered using a transistor switching array, or several of them, with a whole bunch of resistors but that seems inefficient, yet it would work. I looked at some digital potentiometer ICs but I didn't see one less than 1,000 ohms. Is there a batter approach? Thanks...

author: floobydust
author_rank: Super Contributor
timestamp: October 06, 2019, 01:41:37 am
content: It's a hassle because the currents are relatively large and it could go as high as the vehicle's voltage (12-24V).I've used an 8-bit discrete DAC and switched in resistors using small mosfets for each channel. 250, 125, 62.5 ohms and so on down.You could considerTPIC6AC596only has 1 ohm RDS on.Your sensor range is the same as automotive fuel tank sensors, such as Chevrolet.Please ensure your (gauge) design can never output hazardous current or voltage to the fuel tank sensor to prevent explosion or fire.edit: updated TI spec

author: skyjumper
author_rank: Regular Contributor
timestamp: October 06, 2019, 01:54:58 am
content: Thanks, I'll think about that. This is really just a simulator, it will never be exposed to actual fluid. Thanks for the warning, I'm just trying to simulate a water level sensor. I didn't realize the same type of sensor is used in an auto fuel tank.

author: floobydust
author_rank: Super Contributor
timestamp: October 06, 2019, 02:27:21 am
content: I had to emulate a level sensor for vehicles using alternative fuels (CNG or propane) where they wanted to keep using the stock gauge in the instrument cluster.So the MCU has the resistor DAC. 240-33 ohms is pretty standard for the float sensor. 240 can be full or empty depending on the manufacturer. The analog gauges are fairly high current devices so a resistor DAC needs 1/2W resistors. You can use lower number of bits, even 32 levels can be good enough.PWM I also used but it was a hassle because the gauge can make noise if the frequency is in the audible range. If it's not an analog gauge receiving the signal, say a digital gauge then PWM did not work.

author: ledtester
author_rank: Super Contributor
timestamp: October 06, 2019, 02:52:16 am
content: Update - changed 630R to 240R.1. How much resolution do you need? A 1K digital pot with 100 taps will still give you around 21 steps from 33R to 240R. Put a 33R resistor in series to get an additional 3 usable steps.2. You can always put a 33R resistor in series and a 240R resistor in parallel the digital pot. The result will not be linear, but you can account for the non-linearity in software.3. FETs and JFETs can be used as a voltage controlled resistor - VCR, so that would reduce the problem to generating a voltage from a microcontroller.There's a lot of writeups on VCRs on the web, for instance, this one:https://www.vishay.com/docs/70598/70598.pdfThe main problem to solve is finding a device which has the resistance range you are interested in. Some suggestions are given at the end of the above app note.

author: skyjumper
author_rank: Regular Contributor
timestamp: October 06, 2019, 02:53:53 am
content: It seems that, at 12V, the highest current is 364ma. Maybe I could use a ULN2003 (or a few of them) to switch resistors in and out? The collector current is rates at 500ma and there are 7 on the chip...http://www.ti.com/lit/ds/symlink/uln2003a.pdf

author: skyjumper
author_rank: Regular Contributor
timestamp: October 06, 2019, 02:56:31 am
content: Quote from: ledtester on October 06, 2019, 02:52:16 amI'll review that thanks! And I'm processing all this.I believe 20 steps would be fine.

author: floobydust
author_rank: Super Contributor
timestamp: October 06, 2019, 03:27:36 am
content: You could use ULN2003 but it has a 1V saturation. Drive it with a 'HC595 shift-register to save MCU pins.I figured a digital potentiometer would see 12V and high current and did not find one suitable.You could make a programmable constant-current source, an op-amp and transistor driven by MCU PWM or digital potentiometer. Measuring the output voltage, calculate the current setpoint to make a constant resistance.

author: skyjumper
author_rank: Regular Contributor
timestamp: October 07, 2019, 05:30:45 am
content: I'm researching (and trying to understand) all the suggestions, thanks everyone! I like the JFET idea, but I was thinking about a DAC made from discrete components and @floobydust said:Quote from: floobydust on October 06, 2019, 02:27:21 amThis comment makes me thing I'm misunderstanding how you would build a discrete DAC.If I use a shift register to control TPIC6A596 a bunch of resistors in series, starting with a 33 ohm and then a series of 10 ohm, and use the shift registers to select a point in the chain where I have the correct resistance, if the tank is empty (or full) i'll need just the 33 ohm resistor.So at 12V wouldn't this dissipate 4.36 watts, requiring a 5 watt resistor?UPDATE: I suppose I could use three 11 ohm resistors in series, but the power requirement for each would still be about 1.5 watts.QuoteYeah it needs to work with digital and analog gauges. Given that, does it matter if I vary the current or the resistance or is it all the same?

author: Rerouter
author_rank: Super Contributor
timestamp: October 07, 2019, 05:41:44 am
content: Your after a circuit like this, I use them for testing instrument clusters, for the values on the schematic its control range is 6.7-1340 ohms, but this can be tweaked a little by adjusting the current measuring resistor, the 9V is only for programming addresses.You set the dac to use external Vref, you then end up with a constant resistance, and a maximum current limit, which helps things survive when you mess up.Essentially its a constant current source, but its scaled by the external voltage. this can work very close to 0V, but its rare that it is needed,In reality you could use a constant current LED driver and PWM its dimming input, most gauges are 0.5-10mA, with the resistance range only depending on the coil used inside the gauge,

author: skyjumper
author_rank: Regular Contributor
timestamp: October 07, 2019, 07:39:14 am
content: Quote from: Rerouter on October 07, 2019, 05:41:44 amThank you! I'll study this.QuoteThe gauges that low current? I didn't realize this, I thought they just measured the current directly.So then, a constant current LED driver? Great idea! This or something similar?Diodes Incorporated AL5816QThis is a 0 to 10ma out current controller that has PWM dimming capability...https://www.mouser.com/datasheet/2/115/AL5816Q-1522395.pdf

author: Rerouter
author_rank: Super Contributor
timestamp: October 07, 2019, 08:46:55 am
content: Probably best if you measure it first for the dimmer Idea, but for the modern cross coil gauges it tends to be full scale around 10mA, empty at 0.5, direction is influenced by how they wire the 2 coils internally, 1 coil is the bias (from supply to ground through a resistor), the other is the signal, with a lower current to rotate the pointer by 90 degrees,but depending on the age could be an older thermal bimetallic gauge which where sometimes up to 50mA, with a few rare audi gauges burning up to 100mA through the signal pin (because I assume they enjoyed the smell of melted plastic)

author: Zero999
author_rank: Super Contributor
timestamp: October 07, 2019, 10:29:50 am
content: The value of a digital potentiometer can be divided using an op-amp circuit.What's your budget? A ready made solution exists, but it's not cheap, see link below.https://www.kele.com/Catalog/24%20Transducers/PDFs/RES-1E%20Series%20Catalog%20Page.pdfCheck out the following thread:https://www.eevblog.com/forum/projects/ptc-resistance-output-from-0-10v-analog-input/

author: skyjumper
author_rank: Regular Contributor
timestamp: October 08, 2019, 04:09:42 am
content: Quote from: Zero999 on October 07, 2019, 10:29:50 amQuoteThat looks cool! I need several for my boat and a friend wants a few for his.QuoteThanks!

author: KMoffett
author_rank: Regular Contributor
timestamp: October 08, 2019, 02:56:45 pm
content: Since it's the current that actually determines the needle movement, could a simple voltage controlled current circuit work as an MCU controlled variable resistance?https://daycounter.com/Circuits/Current-Servo/Current-Servo.phtml

author: floobydust
author_rank: Super Contributor
timestamp: October 08, 2019, 06:12:52 pm
content: Depending on the era, older gauges were balanced coils and needed lots of current at up to 12V.As the car's system voltage moves around, current in both coils moves around yet the gauge reads the same. The (level sensor simulator) circuit needs to be constant resistance. How would you set a constant-current circuit to 100 ohms? You need to include the voltage too.I had trouble finding the gauge's current requirements and designed for pretty much anything using the discrete DAC. OP should confirm what type he dealing with, it could save money and complexity.Chevy Suburban dash uses a 250 ohm pullup to 5V, so 10-16mA typ. on 240R full, 33R empty sensor. That would be easy to interface to. VDO sensors are the opposite 240R empty, 33R full.

author: KMoffett
author_rank: Regular Contributor
timestamp: October 08, 2019, 06:36:06 pm
content: In my attached link the opamp drives the MOSFET so its resistance allows a current through R3 that causes a voltage drop that proportional the input voltage. At 12v the resistance of the MOSFET(variable) +R3(fixed) is a simulation of the fuel gauge resistance controlled by a scaled DC input to the opamp.

author: floobydust
author_rank: Super Contributor
timestamp: October 08, 2019, 08:56:31 pm
content: That circuit is a constant-current source, but we need constant resistance.Depending on the actual gauge, it could be 5,9,12,14V. So commanding a 40mA current could result in 125,225,300,350 ohms respectively.Rerouter's circuit is clever in taking voltage feedback to the DAC VREF pin, to give constant resistance.The Microchip DAC is very low cost, it would be a good solution.

author: KMoffett
author_rank: Regular Contributor
timestamp: October 08, 2019, 11:47:25 pm
content: For a fixed input voltage to the opamp, the constant current through the MOSFET+R3 is the equivalent to a constant resistance. For the current set by the input, the voltage drop across the MOSFET+R3 is essentially the same as the drop across the fuel gauge resistance in series with the gauge coils. Changing the input voltage changes the resistance of the MOSFET+R3. Am I wrong?