Close

Hardware -- Measuring the battery

A project log for Heartbeat Logger

A portable device that logs a snippet of your heart at the push of a button.

Ole Andreas UtstumoOle Andreas Utstumo 01/22/2016 at 14:164 Comments

Measuring the remaining capacity of the battery might be desirable to warn the user that it’s time to connect the device to a PC or voltage supply. The microcontroller’s ADC can measure the battery’s voltage, however, the microcontroller’s pins cannot be exposed to a higher voltage than Vcc + 0.5V (datasheet). With a Vcc of 3.3V, that becomes 3.8V, 0.5V less than the battery’s voltage of 4.2V at full charge. Also, we need to sample a voltage below the reference of 3.3V. A voltage divider will be needed. Since we don’t want to drain the battery through the divider, transistors controlled by the microcontroller will be used to turn the divider ON or OFF.

Two transistors are used. The microcontroller is powered by a 3.3V regulator, but the battery charges up to 4.2V. How then, do we switch a P-channel MOSFET connected to the battery's positive terminal completely off? That's the job of the robust BJT, which when not active releases the MOSFET's gate to be pulled up. Thanks to http://www.microbuilder.eu/ for the circuit.

Discussions

helge wrote 01/26/2016 at 08:21 point

Want so save some real-estate on the PCB? Check out the 

NTJD1155L from ON Semi. It comes in tiny a SOT-363 (SC-88) package and is a combined P+N channel FETs device in a single package. Should work a treat.

  Are you sure? yes | no

Ole Andreas Utstumo wrote 01/26/2016 at 18:34 point

Neat tip, helge! I'll look into it on the next revision. I also might
replace the whole battery circuit with high value resistors and a
capacitor at the ADC input.

  Are you sure? yes | no

helge wrote 01/26/2016 at 19:49 point

Not recommended ;-)
Bypass caps only provide low AC impedance, DC impedance will still be high and a nightmare w.r.t. ADC input bias current over the temperature range. For a 0-70°C or -10..+85°C product you'd  end up calibrating each device at a few temperature points to get rid of part variations. While not that relevant for wearable equipment that's generally still no fun to deal with. Humidity and contamination on the PCB may also ruin your day here (as is an issue with charge sensitive amplifiers).
These combined FETs are quite as close to space, cost and part count efficiency as it gets.
Maybe a dedicated fuel gauge chip would be nice but that feels like a little overkill to me. I use a single IRLML6401 FET and get away with it at 3.3V (Vg,th larger than 4.2V-3.3V).

  Are you sure? yes | no

Ole Andreas Utstumo wrote 01/26/2016 at 20:14 point

Yep, you've got some good points there. Thanks for saving me the trouble ;) A battery gauge chip would be a bit of a overkill with such a low current application, but I'm certainly taking the combined FET to the engineering change order.

  Are you sure? yes | no