Friday, February 6, 2015

Bicycle speedometer using hub dynamo to supply and as a speed signal

Idea
So I got one of this cool hub dynamos. I really like that it's quiet and efficient way of generating energy for bicycle lamps. I considered adding USB charger to my bicycle to be able to supply my mobile phone while cycling but this is not trivial topic because of low output frequencies from dynamo. Another problem is relatively low output voltage, 6V is to low to use LDO reliable, under low speed condition output voltage may be lower than 5V so eventually a step-up step-down converter would be useful. Additionally rectifying low voltages is kind of tricky, I mean you can do this easily but to do this efficiently is already a challenge because of immanent power loses in diodes (0.7V drop at 6 V input is already more than 10% loss).
As a byproduct of such consideration I drawn a simple circuit which uses LCD display and tiny micro to track frequency, which is directly proportional to the bicycle speed. I like the idea of using dynamo output voltage as a supply and a signal at the same time. You will never need to replace battery, and you don't need additional sensor on the wheel.

Circuit description


The speedometer is supplied from a hub dynamo. D1, C7 and C8 form a half-wave rectifier. C4 is ESD protection and D2 is a Zener diode which should be short-term overvoltage protection. IC1 is an LDO voltage regulator, carfuly chosen to have low quiescent current, C5 is output capacitor of the voltage regulator. Hub dynamo produces pseud-sinusoid signal with a frequency which rises with speed. At low speeds at big wheels frequency can go as low as 5Hz, and C7 and C8 have to store energy for the device.

Input waveform when supplied from signal generator.

Signal at SPEED node. Voltage limited to the value safe for microcontroler digital input. Not very "digital" but thanks to microcontrolers Schmitt input it's not a problem. Circuit supplied from signal generator.
Waveform shows signal at SPEED node. Circuit supplied from a real hub dynamo (Shimano DH-3N31-NT).

Measurement
Because of required low power consumption micro has to run with 32[kHz] clock. The micro is actually measuring period, not frequency so division is needed. Fixed point arithmetic is used with assumptions that the speedometer shows integer part of the speed with proper rounding up and precision not worse than 0.1[km/h].
to be continued
(verification of fixed point arithmetic)

Prototype
First prototype supplied from signal generator

First prototype supplied from a real hub dynamo driven by a DC motor
Software
Currently there is a github repository where you can download software and compiled.hex file. However this software doesn't show speed yet. It shows period in milliseconds before rising edges on SPEED signal. Stay tuned, new revisions are coming.

PCB
I designed a simple one-sided PCB using Cadsoft Eagle. Designing PCB with one layer only (the red top layer are wire connections which will be soldered manually) required changing association between mirocontroler pins and LCD segments. This is "layout friendly" now, software will have to compensate for this. Eagle files and gerber production files are packed along with software and can be obtained from github repository.





Todos
Add buttons
Add possibility to set up wheel circumference
Add captive touch sensor instead of mechanic switches
Add LED to back light the display while driving
Print a housing
Find a neat way of connecting the speedometer to the bicycle (electric and mechanical solution)

Housing trials
I've drawn a simplest housing ever, it consists of one part, PCB will be put in and sealed with epoxy. There is rounded part to fix the housing on the bicycle handlebar and fixing area to secure it with cable binders. Just click on "play" button to see it.

I didn't realize that this shape is actually not printable, the result can be seen here:


My buddy convinced me that using cable binders is not perfect way of holding stuff on the bicycle. Second housing will be fixed with an o-ring. I was thinking how I could make o-ring less visible while keeping model printable, but I changed strategy, if I can't make something unvisible, I will intentionally make it visible.



This is freshly printed housing with an LCD put in to if dimensions are right

3 comments:

  1. I just ran across this while considering building a similar system for charging a li-ion battery which can then be used for running lights, charging cell phones, etc. May I ask why you don't believe a hub dynamo will output sufficient voltage for charging via USB? In my experience hub dynamos can easily top tens to hundreds of volts, it's just a matter of controlling the current draw to keep the voltage at a desirable level. 6V is only nominal.

    ReplyDelete
    Replies
    1. Generally speaking you can supply your smartphone from a hub dynamo, you will quickly get promising results by connecting rectifier and voltage regulator to a dynamo but:

      1. At lower speeds this will work pulse-wise, this won't be a constant DC voltage, you will see that smartphone charges but it will take more time because equivalent current will be much lower than 500mA.
      2. If you could guarantee that loaded hub dynamo will generate voltage higher than desired 5V then you could use LDO or step down converter. If you would knew that dynamo always generates voltage lower than desired 5V then you use step up converter, but you don't have such guarantee, which means: sometimes you must convert to higher, sometimes to lower voltages. It complicates the circuit (step up + linear regulator means power loss, sepic converter means non trivial circuit)
      3. A dynamo without load will generate higher voltage, your circuit must be clever enough to sustain tens of volts.
      4. The circuit would need to be quite efficient, relatively high voltage is there, but how much current you can get, or more precise, how much power? A typical 6V dynamo provides 3W, a USB powered device (USB 2.0 5V, 0.5A) requires 5V*0.5A=2.5W, there is 0.5W margin which is not much knowing that rectifying low voltages is by nature not efficient...

      For a bicycle with bigger wheels and for lower speed frequency of AC voltage generated by a dynamo is relatively low. For my 28 inch wheel at 10km/h the dynamo is generating around 18Hz.

      A loaded dynamo is generating rather low voltage, let's asume 9V peek value. Half-wave rectifier with voltage drop of 0.7V will cause 8% power loss, full-wave rectifier 16%. Let's assume you take full wave rectifier, in this case output frequency from rectifier will be doubled: 18Hz*2 means 32Hz, period of 32ms. During this 32ms output has to be supplied from filtering capacitors, it means we are looking for a capacitance which loaded with 500mA (USB 2.0 rated current) will decrease its voltage by less than approximately 2V.
      knowing that C=q/U and I=q/t we can get a equation for calculating required capacitor
      C=I*T/deltaU, for 0.5A, 32ms and allowed voltage drop of 2V I got 8000uF.
      So for 10km/h to provide really DC output current you need at least 8000uF. Doesn't sound like big capacitor, but it should be rated for more than highest expected voltage you can get from a dynamo to avoid distroyng capacitor when there is no load, this can be done by using, let's say 25V capacitor and some additional over-voltage protection.

      The real problem ESR which will prevent capacitor from fully charging and will decrease efficiency introducing voltage drop. You could try using hybrid capacitors instead of electrolytic but they are really expensive and finding something around 1000uF will be a challenge.

      The more detailed analysis the more difficulties, it's all possible but will be tricky to get an elegant solution (stable 5V under 500mA load, over-voltage protection, compact form, temperature weather and vibration proof...)

      Delete