battery monitor + temperature measurement
the battery monitor is built around a PIC12F1840 which has all the ingredients that are needed for a low power voltage comparator with hysteresis and a temperature measurement.
- 10 Bit ADC used ratiometrically with VDD as reference for measuring the temperature sensor on GP1
- the ADC is also used together with the 2.048V reference to measure the divided (R23/R24) battery voltage
- the hysteresis is then done in software
- a low power watchdog timer (used all 250ms to wake up the processor and make measurements all 1 or 2 seconds)
- A UART on GP0 which outputs the measured values to a terminal or a dedicated sampling software.
- a internal precision RC-oscillator (1%) for the UART
Firmware description:
The watchdog wakes the processor all 250 ms (nominal with factor 0.6/1.6 as tolerance)
In on state every fourth wakeup (in off state every 8th to save battery) a measurement is done.
GP5 is switched on to supply the temperature sensor and to switch on the voltage divider for the battery measurement.
Also the ADC and internal 2.048V (nominal) reference are switched on.
First the 33K NTC which is linearized by a 27K resistor for the 10-40 deg C temperature range
(max 0.3 deg linearity error) is measured ratiometrically to VDD.
Then the battery voltage is measured.
The NTC is corrected (linear) by a slope factor (-0.93) and a offset (75,9 deg C for ADC zero)
to get a value in tenths of degree C which is converted to decimal and output as ASCII value on the RS232.
The battery voltage (divider+internal ADC reference) is also corrected by a factor from EEPROM.
Since I first wanted to use the 1.024V internal reference the calibration factors and measurement range 20.6V
are calculated from this value. A overall correction by factor 2 is done before the value is converted to decimal
and output as ASCII value on the LED.
; Sample #1+#2 EEPROM constants
;
de 0xD2,0x49 ; Correction 20/19.6*20.6/25.6V*65536
de 0xC2,0x73 ; Temperature offset 75.956 deg*655.36
de 0xED,0x05 ; Temperature slope 0.925857
; nominal values
; de 0xCE,0x14 ; Correction 20.6/25.6V*65536
; de 0xC2,0x73 ; Temperature offset 75.956 deg*655.36
; de 0xED,0x05 ; Temperature slope 0.925857
;
the corrected values are also used for the calculation of the on/off state (hysteresis) of the reference.
when the voltage is above 15V (1.25V/cell) GP2 is set high to switch on the supply of the reference via LT1763.
Below 13.8V (1.15V/cell) GP2 is set low to switch off the reference and protect the battery.
Between 13.8V and 15V there is also a voltage drop detection (0.6V per minute)
to detect if a single cell in the stack is flat and needs a quick switch off.
Cirquit details:
C9 compensates for the parasitic capacitance of the LED and speeds up the edges.
T2 is used to switch of the voltage divider of the battery measurement. (and save current)
T2 is a logic level FET with < 1.5V threshold voltage. So at 3V minimum supply voltage a voltage of up to 1.5V can be measured at the source of T2.
Power supply of the battery monitor can either be done by a 5V voltage regulator which needs around 4uA idle current or by a BF545C FET which is switched as voltage regulator with his gate pinch off voltage (around 3-5V depending on load). I usually use the FET because it needs zero idle current.
J2 can be used to program the PIC in cirquit or adjust the EEPROM constants. I use a PICKIT3 for this.
If T1 is used I activate the power supply from PICKIT.

with best regards
Andreas
Edit 30.03.2018: attached the firmware for the PIC and the PC-software with the necessary DLLs if you do not have VC6 installed.
Of course also a terminal program (e.g. HTERM) can be used for the first steps on the PC.
Edit 05.05.2018: Attached bug-fixed PC-Software (Rev 1: no readings in off-state of the AD587LW reference)