First prototype of this system used an impractical "bottle" dynamo and didn't shine as much as it could. This is an improved version, which in addition can charge phones, cameras GPSs etc. via a built-in USB port when the lights are off.
3 W hub dynamo. I got rid of backup batteries, capacitors are enough to feed the taillight for a while after a stop.
The original LED mix on the bike stays unchanged, just the circuit is different. So there are the same 34 white diodes at the front, 10 red at the back and 12 blue all around the frame. There's also a socket that redirects rear lights to a trailer.
(USB pins are numbered as seen from outside)
D1 bridge rectifies the input alternating current. S1 switch cuts both wires, just to be sure. C1 and C3 capacitors must be big enough to smooth out the low-frequency voltage peaks from the dynohub. C3 in addition must power standlight LED6 for a reasonable time. S2 switches between lights and USB, the generator is not powerful enough to feed both at the same time. IO1 (proper English abbreviation would be IC1, of course) is an integrated stabilizer that outputs constant 5 V. From the efficiency point of view, some switching step-down converter would be better, but this was enough for my first try. D3 Zener diode protects the stabilizer from input overvoltage, but it can only absorb 5 W, so speed must be kept under 30 km/h for case the connected device stops charging (better use a bigger diode). C2 capacitor smooths out any leftover output spikes. D4 diode protects the stabilizer from reverse voltage when input leads get shorted out accidentaly.
D2 Zener diode protects LEDs from overvoltage when riding fast. Current consumption of the lights is designed so that the Zener current can't exceed its maximum rating. Riding speed is therefore unlimited. LED4/R4 is the decorative light around bottom bracket where strong light is not wanted, hence R4>R5. LED6 should be less power-hungry, this 14 mA beast drains the capacitor in 15 seconds. Maybe I'll give it a bigger resistor someday.
The circuit above has one safety feature more than my implementation: separate C1 and C3 capacitors. I used just one big capacitor between the rectifier and S2, but there's a big problem with that setup. There can be about 30 volts before the stabilizer and if S2 switches from charging to lighting, the capacitor discharges through D2 Zener diode and fries it. Burnt Zener conducts in both direction, so it shorts out the lights and you become a bike ninja instantly. Tested on myself, of course :-).
Disconnected jack socket routes positive pole from R6 to LED5. When connected, the positive pole goes through the jack, bypassing the LED5 and returning to the negative pole. Another set of LEDs with the same power input of 6.3 V / 60 mA is hooked to the jack (in my case they are four yellow and five reds on a trailer), so there is no need to change the circuit or limit riding speed.
Soldered on predrilled universal board. Metal support in the middle of the headlight shell suggested itself to be a heat sink for the stabilizer - it even had a screw hole in the right place. That determined the circuit board shape (cut out with a coping saw). The USB port is cut out from a PS2/USB mouse adapter I had lying around. The switches came from my scrapheap, origin unknown.
To route all the cables into the headlight shell, I used a 25-pin port from a computer wreck (LPT male, COM female). Mainly because it's difficult to solder a bunch of wires to a PCB when the other side of the bunch is already connected to something else. A nice side effect is the unmountability, though not very easy (the screws must be turned from inside the shell).
Together with the lighting upgrade, a complete overhaul was inflicted to the bike, including brake cables. So I moved the headlight from its funny perch above the handlebars down under the stem. With all three lights in the same height, potholes cast more prominent shadows and are better visible.
Everything fit neatly in the headlight shell until I realized the 16-volt capacitors are not enough for C1 - with unloaded charger the voltage can be twice that much. A little disadvantage of the new 35V ones is they don't fit inside. Long live duct tape :-).
Main switch got a rainproof shell made of hot glue and aluminium tape. By the way, be careful with the glue - if it gets inside the switch, it jams the mechanism (been there, done that; fortunately it could be pried away without damage). The generator has two terminals, so I run everything in cables, with no unreliable common ground on the frame.
Trailer socket is right above the hitch:
During acceleration, the voltage probably follows this green line:
Before we cross the threshold voltage (6.3 V for red series, 6.6 V for white and blue), LEDs don't shine and don't draw any current - voltage grows as with open circuit. At cca 5 km/h (slow walk) everything lights up enough to see where I'm going. With further acceleration voltage and current grows, usual working range is around 20 km/h. At 30 km/h, voltage reaches the 8.2 V threshold of the Zener diode which doesn't let it grow any further. All LEDs combined draw 470 mA at this voltage and the maximum short-circuit current of the dynamo is 520 mA, so the ZD never gets more than 50 mA, regardless of speed. That should make the lights totally indestructible.
Enough theory, here is a video from a test ride (recorded by a not very sensitive camera, it wasn't really that dark).
The new circuit is certainly better and I now like night riding even more than before :-).