On Fri, May 06, 2005 at 10:19:22AM +0200, Francois Robbertze wrote: > The archives and microchip lists intelligent battery chargers. I need > something simple and dont want to re envent the wheel, blah, blah... Simple is good. > The truth is that I know to little about batteries to even try at this > stage. The complexity depends on the battery type. > Can someone help me with a schematic and code to charge a 12Volt buckup > battery? Schematics are never the problem. Here is a whole page of them: http://www.hobbyprojects.com/B/Battery_Chargers.html The problem is figuring out which is appropriate. > The buckup battery is for a system that must generate SMS mesages via a GSM > module even in the event of a power failure. I have a gel-cell backup attached to my sunrise/sunset outdoor light controller. Emprical testing (unplugging the charger) indicates that it'll run for a couple of days on battery power. > The PIC must also generate a message when the battery needs replacement. Good. So you can actively incorporate the PIC into the design. > I am using a 16F628 but can go to other PIC if A/D is essential. The comparators are sufficient for the task. > > I see that the smart chargers measures the charge current, battery > temperature etc., but I dont know if the comparrators might be enough. Gel cell LED acids are very forgiving. Just don't overcharge them. Your charger doesn't have to be brilliant to be effective. > Start the charge whenm the battery ia below a certain voltage(?) and to > stop the charge when the battery reaches a certain voltage(?) In a backup situation it may be better to have a continuous trickle charge of 13.8V and the ability to do a full charge when needed, such as after an extended power outage. > I also dont know if it is best to run the system from the battery > constantly or if I must switch to battery in the case of a power failure. My system does the former: the charger charges the battery and the battery drives the circuit. But it's a hobby setup and not critical. I do know that you don't want to switch the battery in. If you want to keep the battery offline, then you'll want to use steering diodes between the main supply and the battery. I don't have time to draw a schematic but I think it's easy enough to explain. Vin will need to be in the 18V range to cover voltage drops. Also you'll probably want to have a buck switcher for you main regulator since the input voltages are going to be in the 12-18V range. Your main line will be Vin through a steering diode D1. It goes directly into the main regulator. D1 needs a current rating sufficient to handle the current required by the load+main regulator. The battery branch starts with Vin. You have a steering diode D2 going into the branch. This prevents the battery from trying to power your Vin cap and regulator (if it is regulated). D2 powers the charging circuit (described in a second), which charges the battery. Finally the battery is steered by a third diode, D3, which is also tied to the main regulator along with D1. Operation is simple: When power is available both D1 and D2 will have Vin - diode drop (about 17.4V) At their cathode. Since the battery will not have a voltage higher than that, D3 will not conduct and the battery is isolated from the main regulator. However when power fails, then D1 and D2 will drop to 0V at which point D3 starts conducting power from the battery. Now to the charger. Trickle is simple. Use an LM317 regulator to maintain the battery at 13.8V. You can charge at the voltage indefinitely without overcharging the battery. For a main charge it's a bit more tricky. The objective is the charge the battery to 14.4V, then maintain that 14.4V charge until the charge current is less that C/100. But the most important thing is that you cannot maintain the 14.4V charge forever. This is why chargers have to be "smart" as they have to cut back from 14.4V main charge to 13.8V trickle when the battery is charged. But in this setup you can still keep it simple by using the 628 and its comparators to give this smart operation. Here's a typical LM317 schematic: http://cnmv.ploiesti.roedu.net/~radu/articles/lm317/schematic.png You can replace the 5K pot with fixed resistors. Also you can have multiple fixed resistors in parallel. Whichever resistor is grounded will set the voltage. So you can use 2 of the 628 outputs to set the charging voltage. Have a 14.4V resistor and a 13.8V resistor and let the PIC choose the charging voltage. Now when do you charge? I'd use two methods. Low voltage on the battery (say 11V) and also whenever the battery is used for an extended period of time (say 20 minutes or more). That way whenever the battery is pressed into service, it'll autorecharge as soon as power is restored. Now to the comparators. Keep it simple and use a voltage divider. Set the divider so that 14.4V matches up with one of the Vref settings. That'll give you the code of what you need. Gel cell charging isn't complex and you have the PIC to do the job. On aside after writing this: while the comparators can do the job, it would be easier with because of the resolution. The Vref module doesn't output any easily dividable voltages. BAJ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist