Inside a lithium battery monitor (with schematic)