After a great suggestion by Max, on yesterday’s post, here’s a another circuit to try:
It adds a capacitor and a resistor, but it allows using a P-MOSFET and a divider ratio which can now use the entire ADC range, not just 1 V or so as in yesterday’s circuit. Note however that if VCC is not fixed to the same value under all conditions, then the ADC’s reference voltage can float, and use of the 1.1V bandgap may still be needed.
Here’s the voltage at the top of the divider, showing how it switches on and off:
That’s with the pull-up resistor value R set to 1 MΩ, which takes 208 ms to turn the MOSFET back off. We don’t need that long, a 10 kΩ resistor for R will do fine:
That still gives us 2 ms to measure the supply level. Note that turn-off is automatic. DIO needs to be turned high again, but that can happen later. In my test code, I left it low for 1s to, then high for 7s.
Here’s a neat set of superimposed measurements (using persistence), while varying the high voltage from 3.5 to 12.0 V in 0.5 V steps:
Warning: for 12V, the divider ratio must be changed so the centre tap stays under VCC.
Note that with higher voltages, the MOSFET will turn off sooner – this is because there is now more current flowing through the pull-up resistor. But still plenty of time left to measure: 1 ms is more than enough for an ADC.
Tomorrow, an example of how these measurements can sometimes go awry…
This is a great solution, but I find it hard to source small-signal MOSFETs locally. Can anyone recommend a suitable P-MOSFET type for this application? Preferably thru-hole i.e. T092 package or similar. SMD is hard to handle on 0.1″ grid proto boards.
Probably just about any type P-MOSFET will work here, I expect. Keep an eye on the Vgs parameter, lower is better. Perhaps search for “p-mosfet to92” on Farnell?