Electronic – Designing a Battery Charger With a PIC

battery-charging

I've designed the following circuit for a battery charger. With the PIC just turning the output on and off when it is charged. For the program design what would be better, to have the analogue input constantly checked? Or to have the output on for the charge time then to move to the second?
Battery Charger

Best Answer

your schematic contains more then one mistake. Any pin of the µC can only handle 5V. Going above 5V without limiting the input current will damage the µC. IN your circuit, this can happen when the battery fails open circuit or when the battery is removed. You should add a series resistor with the input and a capacitor to ground on the ADC pin. The resistor can be 100K and the capacitor 100nF. You will also need a diode connected between the ADC input pin and the 5V power supply and a 'dummy load' across the 5V supply. This will prevent the µC from powering itself from the battery trough the diode between the ADC input and the supply pin of the µC. 10K will do. (And that's the reason I've chosen the 100K resistor between the battery and the ADC input. The 100nF capacitor will correct the input impedance seen by the input of the ADC. (The ADC uses a sample and hold. Now the sample and hold capacitor can charge itself by stealing some charge from the 100nF capacitor and it also makes the input less sensitive to noise.)

Secondly, the drop-out voltage of the LM317 is to high if you want to charge 4 series connected cell's. The battery voltage will reach 6.2V and an LM317 needs 3V to operate (min. voltage between in and output). And then you also have the 1.25V drop across R1. That's 9V - 4.25V= 4.75V.

Oh, and while I write this it occurs to me that disconnecting the power supply while the battery is still connected will damage the LM317. You will need a diode between the battery and the LM317. That's an other 0.5V if you use a Schottky diode.

You might be better of using a PNP transistor and an op-amp to construct a low drop current source.

And there sure are more elegant ways to disable the current source. Over driving the ADJ pin can save you a power-mosfet. (It takes two small resistors and an NPN transistor with the appropriate biasing resistors.)

Regards enter image description here

Related Topic