Car battery charger with PIC12F683

This time I’m starting off with a device I already built, unfortunately there won’t be any photos from the actual build, just a quick article on how I imagined it and how it works.

A short story about how the whole thing started

My uncle has a nice little place at the countryside at about 50 kilometers away from where we live. Unfortunately there is no electricity in the house, so the lights, music, and anything else that’s electronic runs from a 12V car battery. The battery was charged before each trip with an old-school car battery charger, until the charger eventually broke. He brought it to me to get it repaired, but the two components it had inside both were dying so I decided to build him a new one. His birthday was coming, so I decided to make it as a present. I haven’t finished building it on time, but he was all-right with it!Car battery charger with PIC12F683

 

Step 1: Parts list

Here’s a list of the thing you will need to make a copy:

  1. Enclosure – buy the one you like the most, or make your own
  2. Transformer – think of the charging current, then make your decision about the amps. I have this one.
  3. Panel meter – must be able to measure your transformers maximum current. I have this one.
  4. Banana-plugs and sockets – buy in bulk off ebay.
  5. 220V cable socket – I bought this one.
  6. Fuse holder – I bought this one, this is for the transformers secondary winding
  7. Button – a random button, I’ve had this for ages
  8. LED – buy in bulk off ebay, I used a green and a red one, both 3 mm
  9. PIC12F683 – ebay link, buy more of these, they’re very useful for small MCU projects
  10. 220ohm resistors – protection resistors for the LEDs
  11. 4K7 resistor – pull-up resistor for the button input
  12. 1K resistor – series protection resistor for the NPN transistors base pin
  13. Voltage divider resistors – any kind of resistors with 1:4 dividing ratio
  14. LM7805 – TO220 voltage regulator, buy in bulk off ebay
  15. PicKit2 or PicKit3 – build or buy, I used my home-made PicKit2 for the job
  16. Wire terminal block – I used this kind of connectors
  17. NPN transistor – a random BC transistor that is able to handle 30 mA
  18. Relay – general purpose small relay, able to handle the charging current
  19. Screws – 4 mm screws for the transformer
  20. Drills, saw, sand paper and other hand tools
  21. Computer to write the firmware on.
  22. Extension chord for mains

Step 2: The enclosure

First, you need to imagine what the charger should look like, and get an enclosure that can fit in all the stuff you want. At first, I ordered one I thought was good, but when I saw it with my own eyes, I almost had a heart attack. Luckily the seller had this black enclosure on stock, I bought it without further hesitation. You can see how the two enclosures look like on the photo.

When you have both the enclosure and the clue how you want it to look like, you can start fitting in the components. I used my Bionic hand drill to drill a contour of the shapes I wanted to cut out, and snapped out the pieces of plastic. A small saw and sand paper was used to give the holes and slots their final form. After I cut these slots, I snapped in the components that supposed to go on the front and the back panels. The arrangement of components in and on the enclosure:

  • Front panel: panel amp-meter, banana sockets, two LEDs and a button
  • Back panel: 220V entry plug with fuses, fuse holder (for the transformers secondary winding), radiator and a current regulator (I changed my mind about this later on, but the holes were already there..)
  • Inside: transformer, prototype board, electronic circuitry

Step 3: The electronics

At first I wanted to make this an analog-only schematic, but later gave up on the idea. I’ve decided to use a small PIC12F683 I’ve had on stock anyway. I was already familiar with this processor, I used it as a control unit in many of my projects, including the One-wire lock. This time I needed two LED outputs, a relay-driving-transistor output, and a button input, so the pin count proved to be more than appropriate.

When driving LEDs from a power source, current limiting resistors need to be added for the protection of LEDs. The LEDs are driven from the PIC (a 5V source), the LED forward voltage is around 2V, and we want a current of 15mA to pass through the LED. That results in a resistor of R = 5 – 2 / 0.015 = 200 ohm. I picked the closest standard value, a 220 ohm resistor.

Car battery charger with PIC12F683

The relay is an RS-5 relay said to have a coil current of ~30mA. That current can be handled easily by a BC transistor in TO-92 package, I chose BC546. A base-current limiting resistor of 1Kohm was used to protect the transistor, at 5V that means a 5mA base-current. The base current is in strict relation with the collector current. Instead of looking at the amplifying capability of that transistor, I chose the resistor based on an old habit: “collector current is ten times the base current”. 50mA is more than enough to drive the RS-5 relay on and off.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter