Feedback wanted on battery voltage measurement circuit - Page 1
Forum section: electronics / projects

author: HwAoRrDk
author_rank: Super Contributor
timestamp: June 08, 2019, 02:42:36 am
content: On an automotive project of mine, I want to add a feature for measuring vehicle battery voltage. However, one requirement is to minimise (or eliminate) current draw when my device is in standby mode. Because of this, a simple resistor voltage divider won't be suitable, due to its continuous current draw at all times. After browsing around for a while doing some research, I think that a circuit like the following should do the job. I would like some feedback on it.The node marked 'GPIO' will be connected to an AVR microcontroller I/O pin, which I will program to be PWM-ed with a 5V square wave at a fairly low frequency (< 100 Hz). If I make the duty cycle on-period long enough to provide adequate charge to the series AC-coupled capacitor, at the point it returns low, it will cause the P-FET to be pulsed on for a short duration - determined by the value of the pull-up resistor and cap itself. During this period will be when I take a voltage measurement with the microcontroller at the node marked 'ADC'.A few notes:- Through experimentation, I have determined that a 10K pull-up resistor and 0.1uF cap results in the FET being turned on for approx. 1 ms when given a 2 ms charge pulse to the capacitor. This should be plenty of time to make an ADC reading.- Given an ADC reference of 5V, the ratio of the resistor divider (0.319) should give me a reasonable resolution for battery voltages up to 15V.- Most common MOSFETs have Vgsmaximums of 20V, so in case battery voltage should ever rise above that, I have added protection to the gate in the form of a bi-directional TVS diode. I'll probably use an 18V-rated one so it has a standoff/working voltage of 15V.- Pair of schottky diodes to add protection to the ADC pin of the microcontroller, again in case battery voltage ever rises above 15V.I've breadboarded the circuit and it seems to work just fine.But there are some things I'm not sure about:- The P-channel MOSFET I was thinking of using is a common jellybean BSS84. This has a fairly poor RDSonof typically 5 Ohms, but I don't think this matters because the current passed will be tiny, and what's an extra 5R when you have 10K in series anyway?Should I use a different MOSFET, or stick with this one?- Should I keep the 10 nF capacitor? I added it to smooth the turn-on edge from the MOSFET and provide a bit of a buffer for the ADC. However, I'd rather keep the number of components to a minimum. I don't really think I need it in terms of buffering the ADC, as 10K is not particularly high impedance.- For the schottky protection diodes, two questions: a) if I use a BAT54S diode pair, will leakage current be an issue? b) Do I actually need them? Would the micro's internal protection diodes handle things? Given the prior 10K series resistance, I expect they should only have to cope with a few hundred microamps.Any other advice will be appreciated. Thanks.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: June 08, 2019, 03:02:54 am
content: Oh, and another related thing: is anyone familiar with the characteristics of the 1.1V bandgap reference on AVRs?When experimenting on the breadboard with an Arduino, in my code that takes the voltage reading, I first measure the Vref (which is AVCC) relative to the 1.1V bandgap, then measure the ADC input with that. However, I found that the bandgap voltage takes seemingly forever to stabilise. I needed to add a delay of at least 400 us after switching the ADC mux to that input, which goes contrary to what I have seen others do elsewhere. I have seen people using delays of around 200 us, and even an assertion that some spec somewhere says it should stabilise after "70 us max". Is this documented anywhere? I can only find bandgap voltage vs. VCC vs. temperature charts in the ATmega328P datasheet.Because of this 400+ us delay before taking my battery ADC reading, I'm already half-way into my 1 ms pulse period. I don't feel easy leaving it that 'late', because what if that pulse duration becomes shorter due to temperature, component tolerances, etc? Then I might be measuring on the tail-off, and get an incorrect reading.Perhaps if this is not unusual, I should change the value of pull-up resistor and series cap - for example 22K or 220nF. But, I don't use those values anywhere else in my device, so it would add to the BOM...

author: Ian.M
author_rank: Super Contributor
timestamp: June 08, 2019, 03:34:54 am
content: You are over-thinking this. A Lead Acid battery has a typical self-discharge of approx 5% per month. An average current drain of 0.5% C is therefore negligible. Lets assume the battery is 100AH. Your voltage monitor can use 0.5AH/month in standby without any issues. As long as the quiescent current isn't over 0.68mA, you'll achieve that even if the vehicle is unused all month. In fact the quiescent drain of factory fitted OEM equipment and systems is likely to be far higher, often exceeding the battery self discharge.If you use a 1Meg upper resistor and a 470K lower resistor in the potential divider, the divider will use under 10uA. Add a micropower 5V rail to rail OPAMP as a unity gain buffer to feed the ADC, and maybe a cap to ground at the OPAMP input to low pass filter it, an job done, using a tiny fraction of the permissible quiescent current budget. Use an OPAMP with built-in input protection, and that whole mess in your first post reduces to four parts.The AVR internal bandgap reference is entirely shitty, with a tolerance of approx +/-9%. The voltage regulator supplying the AVR MCU on your Arduino is far more accurate. Its only worth using the bandgap reference to check the Vcc voltage if the Arduino is USB powered or fed from a battery supply of less than 7V.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: June 08, 2019, 03:54:09 pm
content: Quote from: Ian.M on June 08, 2019, 03:34:54 amThis isn't for monitoring battery discharge. It's for monitoring the running voltage - i.e. alternator charging or not. Auxiliary electrical equipment can have different characteristics at 14V versus 12V, which is what I'm trying to take into account (or rather, allow the user to).Quote from: Ian.M on June 08, 2019, 03:34:54 amAh, that's a good idea. Thanks! Was focusing too much on making a switchable circuit to consider just using a very high resistance divider and then buffering the output.Can you recommend a suitable op-amp, ideally in a SOT-23 package? After a quick look it seems the MCP6041 could fit the bill (quiescent current < 1 uA). I see there is also a MCP6043 variant with a shutdown/enable pin (or 'CS' as they call it) for even lower standby current, but the worthiness of that looks negligible with such a low standard Iq.Quote from: Ian.M on June 08, 2019, 03:34:54 amI finally found the bandgap specs in the ATmega datasheet. You're right, it is quite poor: 1.0-1.2V specified range. The 5V regulator I'm using in my device does indeed have better tolerance, ±3%. Maybe I'll forget using the bandgap for measurement. Although, I did measure it for the chip in this particular Arduino board (set ADC reference bits to select 1.1V ref and output it on AREF pin), and it was almost bang-on at 1.097V. Also, I found the source of the 70 us figure, which is documented as the "maximum start-up time". I guess there is a difference between 'started-up' and 'stable', though.

author: nuclearcat
author_rank: Unknown
timestamp: September 09, 2019, 09:33:11 pm
content: Probably i am too late... but designing similar circuit for similar purpose. Funny enough i found many similarities and decided to ask advice, if such approach good as well.I did by pairing P-Channel and N-Channel.(B340 for burning fuse in case of reverse polarity mistake.BAT54A ADC over-voltage protection.)