Sunday, February 28, 2016

Low Power Voltage Sampling

The car computer project has taken a big detour for the last few months in lieu of my gaining more experience with microcontrollers and electronics. Carputer 2015 was mostly a system integration design to be achieved by plugging together existing modules. Carputer 2016 is about integrating complex pre-existing modules with customized sensing, communication, and control. Alas, this probably makes the project even less accessible for those wanting their own carputer. On the plus side, most of the people who hit my blog are finding it via web search. I hope electronics hobbyists can find something of use here.

I've lately been exploring very low power microcontroller applications. There are so many situations that fit the form:

  1. Take a sensor reading.
  2. Process, store, and/or respond to the sensor value.
  3. Sleep until interrupt, then repeat.
Such systems are often deployed with their own, limited power source. My specific application is normally powered via micro-USB with a 5.5V supercapacitor backup. I'd like the controller to monitor both its USB and capacitor voltage to be able to indicate charging, discharging, and out of spec power.

Simply powering a resistive voltage divider could take on the order of 100 microamps. That's actually significant compared to the sleep current of an ATmega328P controller. The typical solution is to switch the high side of the voltage divider with a P-channel MOSFET. The divider (or resistive sensor) can then be powered only for the duration needed to get a stable sample. See the following:

My application is constrained by the number of available connector and controller pins. What I really want is to pulse an analog pin and then read my sample on that same pin. I do this by adding an N-channel FET to momentarily discharge the 0.1µF cap on the P-channel's gate.

FETs with a low gate-source threshold voltage allow this circuit to function down to the 2.7V brown-out of my microcontroller. If you don't need low voltage operation, there are probably cheaper FETs that will work. I'm using a ZVP4424A and a ZVN2106A. As you can see, the sense output is connected to the gate on the N-channel FET. By dividing the output low enough, the gate will stay low/off. A timed low pulse on A0 should further guarantee a reset.

Reading from a µCurrent GOLD show single digit nanoamps when the divider is off and 1+ milliamps (I badly need a scope!) when on and charging the gate cap back up. Mission accomplished!