Thursday, July 10, 2008

dynamo lithium ion battery charging


For a while now I've been obsessed with bicycle hub dynamos. Two of my three bikes are equipped with them. I ride quite a lot at night around the streets of Toronto, and for almost half of my year-round commute I ride home from work in the dark. A well designed dynamo-powered bicycle lighting system can provide a surprising amount of light with very little load on the rider and almost no extra drag while riding during the day with the lights off.

I bought my wife a very dilapidated 1966 Raleigh Superbe from a friendly street bike peddler with an enthusiasm for old English 3 speeds. The Superbe was the high-end model of the Raleigh 3 speed family and came equipped with a Sturmey-Archer GH6 6V 2W (some sources say 3W) Dynohub and a shiny chrome light set (unfortunately missing from this example).

I overhauled the Dynohub and was excited to find out that it still worked. After some hunting around on ebay I got lucky and managed to track down a NOS Sturmey Archer chrome light set for a reasonable price (some folks are willing to pay over $100 for a used set!).

Brand new out of the box (hand courtesy of the gentlemen who got far less than 100 bux for his shiny wares).

The original configuration did not throw out much light at low speeds and, of course, the lights went out completely when the bicycle came to a stop. A few modern dynamo lights have a supercapacitor that can power a small auxiliary LED while the bike is stationary (called a standlight). Busch & Muller even make a nice chrome retro-styled headlight with this feature but offer no matching rear light. I have one of these for my bike equipped with a modern 3W Shimano hub, but the old GH6 doesn't quite put out enough juice to satisfactorily light up the 2.4W halogen bulb. Being an obsessive weirdo this just wouldn't do, so I thought I'd try to build a modern dynamo lighting system with a standlight into the original Sturmey Archer lamps for my wife's Raleigh.

Step One: Finding Suitable LEDs

The GH6 has a lower output than modern dynamos, so using LEDs as the main lamps instead of the original incandescent bulbs makes good sense to get high brightness at low speeds. With a total power output of about 2W, I figured 1W front and rear should do. Bicycle dynamos put out AC, so an AC to DC conversion needs to be worked out as well - more on that later...

Scrounging around google, I found that there are several manufacturers that make drop-in LED replacements for flashlight bulbs. The TLE-1S is a 1W white LED with a screw base that fits the Sturmey Archer head lamp. $15.99 for a flashlight bulb? Only a crazy person would want this. They do brag about a 'power push' circuit which is supposed to suck every last drop of juice out of the batteries that are meant to power it without dimming. Most importantly, it accepts a fairly wide input voltage (3-9V) and presumably has some way of limiting the current going into the LED.

Finding an appropriate taillight proved more difficult. The Sturmey Archer tail lamp uses a bulb with an old fashioned automotive wedge base. There are LED replacement bulbs available in a rainbow of colours, but they all seem to be 12V only. I experimented with a mini maglight replacement bulb that used pin contacts and soldered them to the filament terminals of a broken wedge bulb base and then encased the whole thing in silicone, but unlike the TLE-1S the TLE-20 didn't seem to have suitable current limiting circuitry. Unfortunately it took blowing two $12 bulbs to learn this. bummer. :(

I finally settled on a 2V 350mA 1W jumbo red LED from digikey, but it's a bit steep at $5.17. This is just a LED so it will need a current limiting resistor.

Step Two: Designing a standlight

Many modern dynamo bicycle lights use a supercapacitor to power auxiliary low power LEDs, which provide some light while the bicycle is stationary. I only wanted to work with the main bulbs in the front and rear lamps and keeping 2W worth of LEDs lit for more than a few seconds would require some hefty supercapacitors. I originally tried to work out a design using a 120F supercapacitor, which is slightly shorter and fatter than an AA battery. The supercapacitor solution seems the most elegant, but with a typical supercapacitor rating of only 2.3V and the dynamo's output ranging from 3-20 VDC (after running it through a bridge rectifier) the design requirements quickly exceeded my ability.

Using a battery to power the LEDs and using the dynohub to recharge the battery seemed like a less elegant but more practical solution to keeping the lights on when stopped. There are a few resources for dynamo-powered battery chargers out there, but they were too complicated and bulky for my requirements. I needed a small charging circuit and a small battery that would fit together into the housing of the headlamp. High capacity 3.6V lithium ion CR123A camera batteries are a good fit and are available for only a few bucks complete with a built-in circuit to prevent over-charging, over-discharging and over-heating. I went with the Ultrafire Li-Ion from DealExtreme ($5.08 for two!)

Here's the 880mAh Ultrafire with its cover peeled off to reveal the protection circuitry.

Step 3: Design a regulated battery charging circuit

Single cell lithium ion batteries have very specific charging requirements. Just connecting the rectified output of the hub wasn't going to cut it. For starters, 3.6V Li-Ion cells need exactly 4.1 or 4.2V and carefully controlled current regulation during charging, but the GH6 throws out anywhere from 3V at low speeds to over 20V at higher speeds (based on my measurements of the rectified output).

Fortunately, there are several integrated circuits available that are designed specifically to monitor the charging of Li-Ion cells. I went with the simplest one I could fine: the National Semiconductor LM3622, available from Digikey for $3 (or you can ask National for samples). The LM3622AM-4.1-ND takes anything from 4.5V up to 24V and puts out exactly 4.1V. It controls the current going into the cell by monitoring the cell's charge status and in its most basic configuration requires only 5 external components. National even has a handy application note about it, which suggests exactly what components and values to use for the highest efficiency.

Perfect! There's only one problem:

It only comes in a tiny 4.9mm x 3.9mm SOIC8 surface mount package. Having only ever soldered through hole components, I thought I'd hit a wall. But, it turns out that the SOIC8 is one of the larger SMD packages out there and that soldering with conventional techniques is not that bad (although I remained skeptical until I actually did it).

So, I designed the charging circuit, including a bridge rectifier, based on the design in National's application note. To make the schematic and layout the circuit board I used EagleCAD, a difficult to learn but ultimately useful FREE (for my needs at least) software package that can run on Mac OS 10. To make things even easier, Lady Ada has EagleCAD files on her site that include an LM3622 device used in her Wave Bubble, saving me the trouble of having to figure out how to configure custom devices in already hard-to-learn software.

Step 4: Test a prototype

I bought all the parts from Digikey, including an SOIC-8 to DIP-8 adapter (virtual robbery at $6.43 a piece) to facilitate the use of a prototyping breadboard.

Soldering the SOIC8 package to the DIP adapter proved to be easier than I thought. I was even drunk and shaky from too much coffee.

Using a regulated DC power source, I was able to get 4.09V over a range of input voltages and when connected to a discharged Li-Ion cell, the charging circuit drew about 180mA and took about 2 hours to drop the current to a couple hundred µA, indicating that the charge was complete. I tested a rectified AC source from the motor-crank assembly of a wind-up flashlight to roughly mimic the output of the dynohub (albeit with a much higher frequency) and the circuit worked fine. Success!

Now to see if the GH6 Dynohub could power the charger:

Even at low to moderate speeds, the GH6's output was good enough to power the circuit. Spinning the wheel as fast as I could made the voltage across the rectifier peak close to 20V, a little over 4V shy of the LM3622's maximum rated input. I doubt my wife will ever go that fast, even downhill in relatively flat Toronto.

Here is the complete parts list for the charger:

1 LM3622 IC
1 D45H8 transistor
1 MBRS130L diode
2 10 µF capacitor
1 0.22ohm resistor
1 1000 µF electrolytic capacitor
1 W02M 1.5A 200V bridge rectifier
1 CR123A 880mAh 3.6V Li-Ion battery

Step 5: Make a PCB

The charging circuit needs to be assembled into as small a package as possible to fit into the housing of the headlamp. Here's what I came up with:

With no mad PCB-routing skills, this is the best I could do for a single-sided design with large traces and pads suitable for DIY etching. Q1 is a large 10A power transistor and probably could have been swapped for a smaller SMD component such as the STN479 used in the design of the Wave Bubble. I decided to stick with the D45H8 suggested in National's application note, even if it was overkill. The final footprint of the PCB is a little less than 1.3" square. Download the EagleCAD project here.

Using a PDF (derived from the EPS output of EagleCAD's CAM processor), I made the etch-resist mask using the toner transfer method. This was considerably harder to master than advertised. After several attempts, I had a reasonable looking etch-resist pattern that still required a bit of touching up with a black Sharpie pen. I etched the board using ammonium persulphate (220g/L) which we have in the biochemistry lab where I work. Using a magnetic stirring hot plate to keep the the temperature at 60ºC and the solution in constant motion the board was nicely etched in less than 10 minutes.

A few minutes of soldering later, the circuit was complete!

I got a little too excited after finishing it and soldered in test pins, making the connection of the battery and dynohub leads a little sloppy.

Here's the bottom of the board with the surface mount LM3622 and diode. This time I was sober and coffee-free.

Step 6: Connect to the dynamo

Now the whole thing needs to be connected to the dynamo and stuffed into the headlamp.

All connected. On the upper right you can see a 6.8ohm 2W current limiting resistor connected in series with the rear light.

Wrap it all up in electrical tape and stuff it in there. Plenty of room left over.

Now for the rear light. The LED won't fit into the wedge socket by itself so I cut out a small piece of PCB and soldered it to the leads to approximate a wedge base bulb.

Fits snuggly in the socket. The bulb looks like it's a bit too long.

But the lens fits!

How's it look in the dark?

The rear light is super bright. Blinding, actually. Even brighter than the front, but using about half the current.

Final thoughts

Everything seems to work. The only problem I've had so far is that the battery wasn't fully charged when I installed it. The two lights discharge the battery faster than the dynamo can charge it, so on the first night out I wound up draining the battery completely, preventing the lights from staying on when stopped (the charging circuit seems to provide enough current to power both lights while the bike is in motion when the battery is dead). I expect a long ride during the day with the lights off should get it charged up sufficiently. That said, for long night rides this design is somewhat lacking. Under the conditions my wife is likely to ride, I suspect it will rarely be a problem.

Another potential design flaw is excessive battery charging time. Other charging circuits incorporate a timer so that after the battery is held at full-charge for a determined amount of time the circuit shuts off completely (I think). The LM3622 doesn't incorporate at timer; as long as the wheel is spinning the charging circuit is on. I think this is probably OK for the long term health of the battery because the LM3622 monitors the charge state and drops the current to a few µA when the battery is fully charged . If the bike was ridden for hours and hours with the lights off then there could be an issue with battery lifespan, but my wife's bike will never be taken out for more than an hour or so once or twice a week so I don't think it will be problem.

Finally, there is the issue of the dynamo's output exceeding the 24V maximum rating of the LM3622. This is an unlikely but not impossible scenario. I don't doubt that flying down a steep hill at top speed would probably blow the chip. A better design would incorporate voltage regulation.

Back to the drawing board...