circuit smart charger battery nimh atmega8
https://www.angelfire.com/electronic/hayles/charge1.html
I used PIC16F628A ( no XTAL needed ). LM317 forms a constant current supply switched on and off by a micro-controller . A 5V rail for the PIC is developed through a LM7805 3-pin regulator. T he LM317 will maintain 1.25V between the OUT pin and the ADJ pin. I used a large 5W resistor here to ensure a constant 1.5A supplied. You can select this value as suits your batteries ( charge current should be no less than C/2 where C=battery capacity [mA] ) . Just use Ohms law and divide the 1.25Volts by the current that is recommended for full charge. For example 0.68 ohms will provide about 1.7A ( 1.5A actually because LM317 is limited internally to 1.5A ) and 1.2 ohms will provide about 1A.
"The IN5404 diode ensures that the circuit charges the battery, and prevents the battery running the circuit, should the input power be accidentally turned off! If this does occur with a fully charged pack, the diode isolates the circuit and upon turn on the charger will find the battery peak again and return to a trickle charge after just a few minutes."
"When the transistor is biased on, it effectively takes the ADJ pin to about 0.2V. This means the output voltage of the whole unit is about 0.5V. The transistor is biased on by default, to ensure that the unit is "fail-safe". The PIC can turn the transistor off by shorting the base to ground, and this allows the LM317 to provide a regulated, constant current output. The drive current for the PIC, the transistor base and the transistor collector are all in the order of 1mA which is within the rated range of the PIC and transistor."
"A final feature of the software is that there is a Built-In-Test (BIT) upon power up that effectively tests all of the components except the capacitors (more than 80% of the components). During power up, if no battery is detected the output is turned on for 1 second and the voltage checked, and then the output is turned off. "
The bridge rectifier and capacitor should produce about 1.4 times the AC RMS input. So if using a 10VAC supply, the main rail should be about 14VDC. . At least 2.5V is dropped through the LM317, current sensing resistor and output diode. Also check that the 5V rail is regulating properly. LM317 will need to be mounted on a heat sink .
"If you power up the charger with no batt in it will display E A . "
" - If the switch is closed ( RA5 is low ) then the charger will skip the discharging faze.
- If the switch is open (RA5 is high ) the charger will perform as usual ( discharge and then charge ) "
Thank you Wicked Witch for your observations .
a: "The remedy is (like with most linear regulators that exhibit oscillations) a 47-100nF ceramic cap from the output (i.e. pin 2 of LM317) to ground. "
b: "Second I assume that the 4K7 resistor from G to S of IRF530 is counterproductive when ...."