Tuesday, 29 September 2020

Electronics design project - Bicycle Dynamo and battery charging manager

 Changed; 30-10-2020, 29-10-2020

 This electronic design exercise is an addendum to Bicycle-hub-dynamo-maintanance-project  Including USB output for speed-o-meter, battery status and cyclist dynamo loading priority controls.  These additional features require the development of a phone or tablet computer app.

1970's Eveready front light, Pifco rear light, unknown age Eveready rear light. The Eveready lamps are fitted 
with 2.7V 420mA bulbs that could be wired in series and run from the dynamo. The Pifco lamp's bulb is 2.5V 
300mA so this lamp could not be used with the dynamo without expecting bulbs to fail often. The Eveready 
lamps are clean and corrosion free inside so wires could be soldered to the brass contacts. The switches 
wired to short the lamp out in case a bulb fails so that the other lamp will operate.

 Plan for a bicycle dynamo lights and battery manager;

Microcontroller based bicycle dynamo light and battery manager with a speedometer.  Design idea and exercise with STM32 microcontroller.   With interface by USB cable for speedometer display on a tablet for example.

The dynamo will output up to 20V when the bike is ridden fast I understand.  If we assume the dynamo will deliver 300mA then the output power is 7W but we can probably count on getting at up to 5W.  In order to get the maximum power from the dynamo the current taken needs to be regulated so that voltage does not drop and the maximum power is transferred.

I also understand that modern bicycle hub-generators work from 2 MPH, produce up to 30V out and are rated 3W at 6V (0.5A).  That is 15W so you may count on up to 10W.  The firmware should include calibration of the many voltages such as a mechanism of zeroing when there is no current flowing but also quantifying the generator's maximum power transfer (the setting of maximum current of the particular generator connected) and storing these calibration constants.
  • Manage two cell NiMH battery charging using a coulomb counting method. Therefore it is best not to remove the battery's in order to maintain the battery state of charge and capacity.  Therefore use the USB port charging either direction.
  • On PCB bootloader switch for fast programming via USB port plus software debug connector.
  • Software proposed functions;
    • Switch to turn on surplus Dynamo power to the USB (out), turned off for USB to provide charging current (in)
    • Switch to turn the lights on. 
    • Red/Yellow/Green - battery charge status LED. 
    • Blue - USB connected status LED.
  • Manage maximum power transfer from a bicycle dynamo. 

Tilt sensor used to reduce the power taken from the dynamo using parameters set by the cyclist such as from a USB connected tablet computer.

LED lighting is much brighter than this but these do work in the dark if placed low down to light the curb. One should be placed high so the cyclist can be seen.  Red rear lamps are difficult to attach to the rear rack if you have panniers.

The power diagram;

Could be based on an industrial motor control system similar to that found in factories but also used to manage power from a wind turbine.  In this case without a power dump of excess power;

 AL-0036-01D Power diagram based on motor control to operate at low frequency boost switch mode 
using the inductance of the motor.  A voltage multiplier boosts the input voltage enough so that 
the power supplies to start up.  Most function blocks and parts are not shown and part values 
are not correct.  Expect the dynamo to whistle when running in the same way that an the inverters 
and motors in a modern electric train whistles.  The 5V and Vbatt operate as power in or out.
A dynamo power management based on an industrial motor control system but scaled-down looks promising but a solution based on standard IC type power supplies will probably be cheaper.  A flaw (shaded on the diagram) with this design is that the stepper motor driver ICs that might do the job would only operate at lower frequencies and be larger and less efficient for the Vbatt and 5V inputs outputs.  The voltage multiplier creates a high enough voltage at low speed for the IC to start.  The input boost section from the dynamo should be very efficient.  This solution is software-driven.  Note the additional 0V screen wire connection to the Dyno-hub to minimise electrical emissions.
Efficient but costly power design AL-0038-01C The design features no large
step up or step down voltages.  The micro-controller is powered directly 
from two rechargeable NiMh cells.

The most efficient solution is likely to be to use a buck-boost configuration synchronous rectified Dynamo output, buck-boost to 5V.   A large super-capacitor.  Then half bridge bidirectional 5V to Vbatt 1.8V to  3.5V but the function blocks are likely to be more costly and turn out not be so efficient.  Here are some buck-boost controllers; LM5118-Q1, LM5170, LM5174, TI, LTC3779 ADI, MAX20048 Maxim.
The voltage conversion ratios are low so which consequently this tends to make the efficiency higher.
Generator model is not simple - The series inductance is so high but the open-circuit voltage not so high, that very little power should transfer.  Alternatively, this is an incorrect the generator model is something like a very high voltage source clamped? 

 Comparison of motor driver or gate drive ICs;
  • L6201  ST 1-4A Motor drive bridge driver - 12V minimum, therefore, the dynamo would need to run at 10V AC out or the circuit would require a voltage doubler to start up from 5V AC but won't start up from 1.8-2.5V battery. Operates up to 100KHz. 
  • L6205, L6206, L6207  ST 8-52V (8-52V) 100KHz 2.8A dual bridge motor driver with various protection and current control options. These operate down to DC due to the Vboost charge pump.
  • L6225, L6226, L6227  ST 8-52V (7-52V) 100KHz 1.4A dual bridge motor driver with various protection and current control options. These operate down to DC due to the Vboost charge pump.
  • TLE9201SG Infineon 6A half-bridge motor driver - only operates to 20KHz, 8 - 28V.
  • L99MOD51XP, L99MOD54XP ST motor drive 3x half-bridge drivers 6A, 7-28V. 
  • BTN8962TA Infineon Half-Bridge motor driver - 30A, 8-18V or 5.5V-40V derated.  Maximum frequency unknown and is oversized.
  • DGD05463 Diodes Ltd. ISL6208, ISL6208B Renesas - Gate driver and discrete transistors. No significant frequency limit (500KHz) but requires more parts and is an expensive option. 
For Vbatt (1.8V - 3.5V) to 5V bidirectional - TC78H653FTG Toshiba dual half bridge up to 2A, 1.8V - 7.5V, 500KHz.  Provides the option for a better power path with shortest paths to and from the battery.  Unfortunately the IC can not be configured as simple half or full bridge drivers but only as a motor driver or use just use two of the four drivers.

Summary a power diagram;

It took a long time to find these parts for what I wanted to do originally and the solution based on power supply ICs is good and was found more quickly.  Most of the ICs can not be configured as simple drivers instead of motor drivers.

The final is likely to be based on a high frequency, inaudible, input boost power rail but using a bridge Power factor correction and power supplies will do the job well.  The dynamo could be boosted to 7W. 
Link to CADSTAR 18 and STMCube files

List of files;
There is a spreadsheet list of files *.xls

--- Basic bicycle dynamo battery and lights manager  ---
  • AL-0002-01D Circuit and PCB's - draft.  The design should fit in under 100 x 100mm.
  • AL-0033-01C.ioc Micro-controller selector and configuration project file draft (out of date).
Advantages and Disadvantages of this design; 
  • Large capacitor fitted is still not adequate to prevent the battery from needing to carry some ripple current so therefore the battery life is shorted.  A bigger capacitor could be fitted.
  • This is a simpler solution and shows the basic function.
  • This does not have a boost rail and so the operating range is not so wide and perhaps more suitable for a newer dynamo but is good for an old dynamo.
  • Supply voltage is too low to run the USB port.
  • THIS VERSION HAS NOT BEEN COMPLETED  --- to develop this further it may be better to start from version -03? remove and change the parts not required ---.

--- Software-driven boost input, can be PFC for boost supply for lower voltage operation --- PCB size under 120x100mm 4 layer components on one side.
  • The USB power output is created from a separate power supply directly from the dynamo.  This is a more expensive that software switching as surplus power becomes available.
  • There are a number of function blocks that were not used but could be useful.

--- Software-driven boost input, can be PFC for boost supply for lower voltage operation --- PCB size under 120x100mm 4 layer components on one side. 
  • AL-0002-03E
  • Circuit AL-0002-03C - Rationalised and uses cheaper high volume parts than AL-0002-02D. 
  • To  operate high-frequency boost or with some minor modifications lower frequency using the dynamo's inductance.   Low-frequency boost (if this works) with the input capacitors be reduced in value to say 10nF and other modifications.
  • Therefore to work from a lower voltage with a slow and loose voltage regulation should be efficient.
  • AL-0033-03? STM32L052C6Tx {£3.00 1off} 48 pin, STM cube micro-controller project file.  
  • AL-0039-01A spreadsheet models various PSU resistor networks.
  • This design and layout to be refined after software review. 
  • USB current monitoring to improve spare power control.

Advantages and disadvantages;
  • More functions of the input power supply and synchronous rectifier have been moved into a larger micro-controller. 
  • PFC function need not be implemented. A slow response loosely regulated boost is all that is required.
  • Current regulators for LED drive instead of voltage regulators to improve efficiency has not been implemented.
  • A battery isolation transistor to allow the dynamo to run the lights even if the battery has failed short circuit.   This is is not required for NiMH or NiCD battery safety and could be omitted.
  • STM32L052K {£2.93 1 off} 32pin
  • STM32L052C {£2.72 1 off} 48pin
  • STM32L072K {£2.96 1 off} 32pin
  • STM32L072C {£2.89 1 off} 48pin
  • STM32L151C {£4.04 1off} 48 pin also has two operational-amplifiers that would allow the I_Batt amplifier.  Has no USB_VDD so the VDD need to be increased to 3.3V and the battery protection transistor turned into a buck regulator or switch for battery operation.  This is likely to be more expensive.
  • STM32L433R {£4.20 1off} 64 pin and others have an operational-amplifier that would allow the I_Batt amplifier to be removed but this uC is likely to be more expensive than keeping the amplifier.  The cost and space difference is marginal. 
  • STM32L433C {£3.86 1 off} 48pin
  • STM32L552R {£4.85 ~ £5.50 1 off} 64 pins 2 op-amps. New product.
  • STM32L552C {£4.58 1 off} 48 pins 2 op-amps. New product.
  • To be refined after software review.
AL-0002-04B this variant has no advantages the cost is the same but it shows that the on micro-controller op-amp is practical although that op-amp has less margin.
  •  AL-0002-04B
  •  AL-0039-02A  modelling such as resistor networks.
  • Advantages and disadvantaged;
    • Probably more costly because there are more pins to be soldered although there are fewer parts to place. 
    • More issues in the earlier versions have been resolved.  
      • Such as protecting the 5V tolerant I/O from voltage differentials > 3.6V to VDD.
      • Extra protection to isolate the battery is not essential because the NiMH and NiCaD type will vent if over charged.
  • Use STM32F303CB {£4.04 1off} 48pin this does not have such wide voltage range low power of the STM32L series but this uC can be run at low enough power.  VDD needs to be increased to 3.3V in any case.
 Link to CADSTAR 18 and STMCube files
-- AL-0002-05 this variant runs LiFePo4. Uses the on micro-controller op-amp which are good enough but must be turned off when the unit is inactive to save power.
  •  AL-0002-05A   PCB and circuit.
  •  AL-0033-05A   MXcube microcontroller project.
  •  AL-0039-03A   modelling such as resistor networks.  Also lights 2 buck-boost SMP inductor.
  • Uses STM32L151C 48 pin IC and its internal oscillator. 
  • Lithium protect may is less demanding than for a laptop because the cell is LiFePo4
    • In this case the uC be permanently connected to the battery and software manage the battery protection. 
    • The power path is more efficient because the voltage is high so the step down from the dynamo is smaller.
    • The battery only requires charging 110% rather than 150% that NiMH requires.
    • Rapid charging LiFePO4  is not possible they charge at 0.3C, 0.5C or 1C (1-3 Hrs) depending on the type chosen.  By comparison NiMh cells can be charged at up to 0.4C (2.4Hrs) or NiCD 2C to 4C (15 or 30 minutes) depending on the type chosen.
Advantage and disadvantages; 
  • Lithium Ion Phosphate (LiFePo4) - is slightly lower capacity Li-ion, less raw materials used. 1.2Ah or higher.  Less safety precautions required eg a lead-acid like battery charging.
  • Does not support Lithium ion (Li-ion) - these require additional safety circuits within the battery that disconnects the battery if the supply voltage is too high or the cell voltage drops too low.   
  • 3x NiMh can also be used - normal but no special safety precautions required.  

  • The second lights regulator provides up to 500mA at 1.2V to 5V and is efficient because no series resistor should be fitted with the LED and and the voltage is never too high to damage an LED if it were reverse connected.  
    • Using a STBB3JCC buck-boost switch-mode current regulator
        • STBB3JCC - 100mV Feedback +-10mV --- the part used.
        • STBB3JR - 500mV Feedback +-10mV --- could be fitted by changing some parts so that the output is fixed but closer tolerance voltage regulated.
      • The current is set by Pulse-width-modulation
      • This regulator's current output could be re-configured by changing the programming resistor (Resistor = 100mV / Current_required).  
        • Resistor = 100mV / (Current_required - 50mA) this has a maximum output voltage of 5V.  The LED lamp is connected between Lamp- and Lamp+
        • Alternatively a regulated 5.2V can be taken from Lamp+ and 0V.

    LED power supply for one or many identical LED's connected in parallels.

    Average current limited set by pulse width modulator up to 450mA at 1.2-5V out suitable for white or any other not-pulsed LED.  The LEDs used if connect in parallel in the same assembly and from the same manufactures batch.  Alternatively lower voltage drop red LED's can be paired in series then multiple pairs connected in parallel.

    This current regulator could be duplicated and situated in the lamp.  2V - 5V input, 450mA set by R15.
    AL-0002-05A sheet 6 is the small red square near the centre of the PCB below.

    LED lights;   - see section of Bicycle-hub-dynamo-maintanance-project