# Using a Mosfet to control current through a resistive network

I am trying to measure the voltage level of a battery with a microcontroller and a bit of circuitry (since the voltage level will be above 5V). A simple circuit like this can be constructed to measure the battery voltage with an MCU's ADC capabilities:

simulate this circuit – Schematic created using CircuitLab

However, I want the battery to be loaded by this external circuitry only when measurements are taking place. The circuitry in the schematic above will continuously load the battery with a leakage current flow from the zener diode (which is present to ensure the voltage level never exceeds 5V to safely measure with the MCU ADC).

So, I thought about using a enhancement mosfet as a switch. The design specification would be such that no load on the battery exists unless the mosfet is turned on. The only way I was able to successfully implement a mosfet was after R2 .. but that really defeated the purpose. In this way, without current flow (mosfet off), V1 appears across the zener and the device will significantly conduct current if it's > 5V (in this case it is). So that design is actually worse than not using a mosfet at all. Without the zener diode in place there is no protection from placing a high voltage (higher than 5V) at the terminals of the MCU.

simulate this circuit

I then tried to place the mosfet before R1, but experienced significant voltage drop across the device that I was not able to explain (I am not that fluent with these devices).

I could replace the zener with an integrated regulator, but they have load currents also and the voltage will be lower than 5V at times which causes non-linear output (compared to the zener which does not alter voltages under its breakdown).

Any ideas?

Something like this should work for you, at least down to under 7V battery voltage.

The zener you suggest isn't great- it will cause quite a bit of error if the voltage is near the 15 nominal. A better way might be a small schottky diode to the +5V rail, IF you can guaranteed there is more load on the 5V rail than can flow through R1. Or just divide it down to (say) 3V and live with losing a bit or so of resolution.

simulate this circuit – Schematic created using CircuitLab

Another solution is to use an analog switch with level shifting such as the DG447/448 Then you only need the divider, no level shifting.

Andy, who posted his very similar solution before mine, feels that the divider on the MOSFET gate is not necessary (the divider is calculated to allow the 15V line to rise to about 30V rather than 20V before violating the abs. max rating on the MOSFET gate. Not knowing where the 15V comes from (and fearing it might be something resembling an automotive electrical system with 100V transients) I might well use the divider and put a 12V zener across R3 in real life. The parts are almost free, and even a single failure could be very expensive. There is a cost (no free lunch) - another part is not quite free, and it will not work to as low a level on the 15V rail. Note that none of this has been specified explicitly.

I mention this to give you an idea of how two designers can take the same info and interpret it differently to come up with two different competent answers. (BTW, in reality, the gate will probably withstand about 60V before it perishes, but it could fail at 20.01V).

The source resistance seen at the microcontroller is R1 || R2 = $R1 \cdot R2 \over R1 + R2$. If your micro can tolerate 2.5K or even 10K, as can many PICs, you can increase the divider network resistance. With a 4:1 ratio (dividing down to 3V), you could use 12.5K & 3.125K (2.5K) or 50K + 12.5K (10K). That loads the divider less and means you'll get less error from the switch resistance.

To get a really low loading, you can use a circuit like the above (or below) and follow it up with a rail-to-rail voltage follower op-amp. That could allow you to increase the divider to hundreds of K ohms or meg ohms (and might even mean you could lose the switch entirely).

• Isn't this virtually the circuit I have posted approximately 14 minutes before you dear chap. I'll also add that as the BSS84 has +/-20V gate rating the R3/R4 potential divider isn't probably needed from a 15v supply. – Andy aka Jan 27 '14 at 22:20
• P.S. Seems to me there's a neat little single channel analog switch out there with level shifting, but darned if I could remember the number. – Spehro Pefhany Jan 27 '14 at 22:24
• Indeed, Andy, however it took a bit longer for me to make an original beautiful schematic and add the comment regarding the clamp. I have not copied your wonderful answer, rather great minds think alike (and fools seldom differ). – Spehro Pefhany Jan 27 '14 at 22:40

What you should consider is a P channel mosfet at the top and a bipolar transistor turning it on: -

This is an older circuit but for "battery" read "15V supply". Choose a P channel MOSFET with low Vgs(threshold) so that it still turns on all the way down to 5V. Ensure its gate voltage can handle 15+ volts (quite a few are rated for +/-20V maximum). Also check the leakage current specified in the data sheet. The 10k pull-up can be increased to 100k if needed.

I would also choose resistor values feeding the ADC that always meant the voltage into the ADC wasn't above supply rail of the MCU - if you are worried about resolution, averaging several readings (with noise) will give you a better resolution.

One more thing to look out for is the on resistance affecting the potential divider accuracy. Here's a typical common P FET characteristic showing drain current on the X axis and on resistance on the Y axis: -

At the low end of the battery supply voltage (maybe 5V) the on resistance may be about 7 to 10 ohms and this would introduce about a 1% error in your reading. I'd advise finding a FET that had sub-1 ohm on resistance for best accuracy. This is also a good reason why you should choose a FET with low $V_{GS(threshold)}$

• Regarding the 1% error you mention, the mosfet will add a resistance of 10 Ohm in series with the resistance of the divider which is 2k+1k=3k so the error will be 10/(3k+10)=0.33% – alexan_e Jan 28 '14 at 0:48
• @alexan_e very true - I possibly over-egged the importance with the circuit values in the OP's question – Andy aka Jan 28 '14 at 22:25