Tuesday, 29 September 2020

Electronics design project - Bicycle Dynamo maximum power and battery charging manager

Changed; 13-04-2021, 12-04-2021 

This electronics design exercise is an addendum to Bicycle-hub-dynamo-maintenance-project  To optimise the power taken from the dynamo above the quoted power in order to run bicycle lighting and battery charging.  Including USB charger output or charging input, data outputs, controls and settings.  These additional features require the development of phone, tablet and desktop computer user interface applications.  This project will show how much more of the available power output from the dynamo can be obtained.

There is also a no-microcontroller solution.  The design includes controls for calibration made available, that would have been carried out in software otherwise.  This is a good solution with just a speedometer, power out and a few controls.
 
This blog goes into much greater depth than would occur in a real design project, in a real design project many avenues would not be explored to such detail.   This blog has been written going back and developing earlier ideas put aside a little more which is a realistic way to carry out design work.  



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 occasionally.  

  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.  


LED lighting set such as made by Bikemate front and rear lighting will function when powered from a USB charger.  I do not know if the light unit including its lithium cell would suffer harm if run this way normally and particularly with an AC component from the dynamo regulated to 5V, it is unlikely.  At least some waterproofing around the USB connector is required.  A disadvantage with this plan is that the lights probably will not dim in a useful way when the power is low but will turn off or may flicker.  Rear 3.7V 300mAH and Front 1200mAH lithium cell.



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 to a tablet or any computer.


The dynamo (such as a Sturmey-Archer GH6, made 1944-1983) is rated at 6V 1.8W, 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.  In order to get the maximum power from the dynamo, the current taken needs to be limited so that voltage does not drop severely.


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 up to 15W.  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.  Other variants for Lithium-fe-PO cell.  Therefore it is best not to remove the battery's in order to retain the battery state of charge and capacity.  Therefore use the USB port charging input preferably to taking the battery out for charging.
  • The USB port can also provide dynamo power output.
  • On PCB bootloader switch for fast programming via USB port plus software debug connector.
  • Software functions;
    • Switches to set Dynamo output power or USB battery changing power input.
    • Switch to turn the lights off/on/flashing. 
    • Battery charge status LED. 
    • USB connected status LED.

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 incandescent lights, such as pictured.  These lights do work in the dark if placed low down to light the curb, but the lighting law changed and this is not done now I guess because the light could be mistaken for a tail light?  In any case, a light should be placed higher so the cyclist can be seen.  Red rear lamps are difficult to attach to the rear rack if you have pannier bags fitted.


Software note;
LED dimming or intensity programming to be handled using a PWM at about 100Hz.


Proposed dynamo power input 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 from slowing machine motors generating power.  This circuit requires a 12V peak voltage to start so the bike needs to be moving at a good speed initially;

AL-0036-01F Power diagram based on motor control to operate at low-frequency boost 

switch-mode using the inductance of the motor.  The bike needs to be moving quite fast 

so that the dynamo voltage be high enough for the power supplies to start up but then 

 the circuit will continue to operate down to a low bike speed.  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 the inverters and motors in some modern electric 

trains whistle.  CAD used OrCAD cadence.


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.  The circuit will only work when the dynamo's output peak voltage is > 8V (about 6Vrms) for IC to start up, and with no current is a little less than the rated speed. The input boost section from the dynamo should be very efficient.  This solution is software-driven. 


Note the additional 0V screen cable bonded to the bike on both ends, the controller, and to the Dynamo to minimise electrical emissions.  This measure is fairly essential, with the above strategy.


It turns out that the dynamo's inductance is too high for this configuration to output any significant power when the voltage is boosted.  That is because the period of the chopping oscillator needs to be a few seconds in order to reach full current but the period of the AC output is much shorter 10 - 100mS consequently the power output would be very low.  Alternatively boost to a few thousand volts at a very low current in a few milliseconds would be impractical, and the losses would be too high.


The 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.   A modern motor drive and permanent magnet motor/generator the motor is usually wound for lower voltage high current.   Consequently, there is always a high input or output voltage that is reduced by the switching drive.  When generating the low voltage output is boosted with the switching drive but the apparent high inductance in the dynamo does not arise because the motor's inductance is low.


A GH6 dynamo has 5 ohms series resistance consequently at 6V, 300mA output that is 7.5V = 6V + (5R * 300mA) with no load.  The peak voltage no-load be 10.5V = 1.4 * 7.5V, at rated 6V minimum cycling speed ??.   For maximum power transfer, the maximum current drawn is <=300mA and the load presented be >5R.

The above diagram is a 2-phase boost converter with polarity switch AL-0036-02E driven by two 

PWMs 180' out of phase.  This is a low input/output noise and ripple current voltage step up.  

PWM mode is less efficient under lightly load conditions.  Another pulse-width-modulator (PWM) 

is used to step the high voltage down to 2-5V (Vdd).   At start-up, all drivers are switched off and 

the substrate diodes act as input rectifier providing start-up power.  The component values are 

not correct or complete.


Motor driver IC's are comparatively more expensive, lower frequency operating and therefore require larger inductors.  The benefit is the main source of electromagnetic emissions is reduced to <50% for this 2 phase design compared to the other strategies below at the same operating frequency.  For a 3-phase boost the RF emissions drop to <33%.  There are other sources of radio-frequency emissions, such as the switching transitions of the power supplies that need to be addressed.


There are advantages in using a buck regulator IC rather than software above, self-starting, protection, efficient, good regulation, good value for money.  The diagram below does not have to be a three-phase boost one inductor need not be fitted if cost-saving and lower switching losses of running one less phase is more optimal.  

The diagram AL-0036-03D, is a 3 phase multiphase boost pre-regulator.  Multiphase 

regulators have lower radio frequency emissions.  Changing the driver IC to DRV8955 

will operate down to a lower voltage of 4.5V which works out that it will start up <50% 

of dynamo rated voltage/speed.  Both drivers are rated at 100KHz maximum 

so the inductors would need to be large.


The bridge driver proposed would be operating at maximum speed so are likely to have high losses.  By comparison, the buck converter IC is optimised for high-frequency operation so is a more efficient function block compared to the previous diagram.  It should not be necessary to use screen cable bonded on both ends a paired cable should be adequate to minimise radio frequency emissions.

 

These multiphase converters should be more efficient than the motor driver ICs they use external transistors - but may be unnecessary cost and complication;

LTC3871-1 may do 5-30V and possibly 1.2-100V (4.5V) two or more phases boost.  

LM5170 8.5V to 100V two-phase boost. 

ISL78227/9 5V to 55V two-phase boost.

ADI, Renesas, STM and On-Semi make a number of multiphase buck controllers (NCP4200, NCP81143,  PM6773, ISL6312) inverting the outputs and many other changes still do not look promising.



Comparison of motor drive or gate drive ICs;

  • L6201 ST 1-4A Motor drive bridge driver - 12V minimum, Operates up to 100KHz. This driver can only hold an output high briefly so it may not be suitable.
  • 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 de-rated current.  The maximum frequency is unknown and is oversized.
  • DRV8844 TI, 8-60V, 2.5A dual half-bridge motor driver. ??KHz.
  • DRV8955 TI, 4.5-48V, 2.5A, dual half-bridge, <100KHz. --- This is a reasonable solution because of the lower starting up voltage possible but the over-voltage protection would operate often with so a newer type dynamo.
  • DRV8412 TI, 11-50V, 6A, dual half-bridge, <500KHz. But for the high start-up voltage, this driver has a good operating frequency.
  • 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. 


 

Improved dynamo input power supply;

Putting aside a motor drive IC solution, but boost pre-regulator is drafted further below in AL-0002-02 to -05.  These solutions do not use PWM mode synchronous rectifier but use a simpler boost and rectifier in software.  Beneficially these circuits start-up at a lower bike speed.  Another variation is investigated;


An efficient input bridge-rectifier is considered, using transistor switches plus many discrete parts and IC's is possible.  A boost stage is not included and the risk of producing electrical interference, with care is low.

Simplified power diagram AL-0038-01E.  This design features no large step-up and smaller

 step-down voltages.  The micro-controller is powered directly from two rechargeable NiMh 

cells.  The rectified dynamo output ripple voltage will cause the LEDs to flicker slightly that 

may be perceivable at low speed.  CAD used CADSTAR.


This solution is similar to AL-0002-01? below does not have a high-frequency input boost pre-regulator that could cause electromagnetic interference in the cabling and with the dynamo inductance.  I have not got the experience to say?  

The first buck regulator could be replaced by a buck-boost regulator in order to improve the operating voltage range.  The power is taken from the dynamo also needs to be optimised under software.  A transformer-based flyback convert is investigated in AL-0038-02? further below.
 

Buck-boost configuration https://www.ijedr.org/papers/IJEDRCP1401022.pdf


One magnetic part is saved but cost many other parts.  The buck-boost configuration is an efficient solution that seems possible but difficult to implemented using microcontroller timers, software and half-bridge drivers but likely to be more costly and turn out not to be so efficient.  Here are some buck-boost controller IC's;

 

LT1810, ADI                4.5V to 100V (2.8V)
MAX20048, Maxim    4.5V to 36V (2V)
LM5176-Q1, TI           4.2V to 55V (2.5V) 
LTC3779, ADI            4.5V to 150V (1.2V)
ISL81601, Renasas  4.5V to 60V (0.8V)
ISL81801, Renasas  4.5V to 80V (0.8V)
 

Software for power input;
The dynamo current control software is likely to be difficult with a switch-mode power supply IC.  
  •  The power used must be adjusted continually with the AC input so that;
    • When the power reduces then the USB power output should be turned off,
    • The battery charging rate reduced and turned off but current not drawn from the battery,
    • The LED drive reduced and turned off when there is adequate average dynamo power,
    • At all time enough power must be provided for the microcontroller.
Versions that use a PWM boost supply should be a lot more straight forward because changes can be made more slowly.  The control of the boost voltage should be straightforward.  Measure boost rail voltage if;
  • Hardware over voltage protection occurs at >55V, may cause erratic operation?  Will return surplus power to the dynamo.
  • Over-voltage >50V then turn on both boost transistor, in order to return surplus power to the dynamo.
  • An efficient low side of a bridge rectifier is implemented by turning on the low side transistor alternately synchronously with the dynamo AC input.  This reduces voltage drop in the bridge rectifier low-side diode.   The other PWM drives the other transistor boost regulator.
  • The boost voltage be set so that at minimum the troughs are above 10V, say?
  • PWM for boost voltage creation is set proportionally with voltage.  This carried on steps in order to minimise the processor's workload.
  • If the current taken from the dynamo is above the optimum, its voltage will fall sharply, then reduce the current taken by setting the buck regulator power clamp DAC lower. 
    • Intelligent nudge up and down control - That is do not nudge the set-point if no more power is available but do nudge down to find out if more power can be taken.  That is take care to prevent set-point runaway.  Use indicators such as Pgood output.
    • If necessary, ask a support question to find out the voltage sensitivity and voltage range of the compensation pin.  Note that the simple transistor clamp circuit has a temperature coefficient.
  • The power priority is the same as the non-boost above but the adjustment and switching off does not need to be done quickly because power is stored in the boost rail reservoir capacitor that tide over AC voltage ripple.
  • The dynamo current is:  = I_out * V_boost / V_dynamo
 


Implementing a low loss rectifier;
The high side rectifier is implemented using Schottky diodes or more efficiently using ICs such as; TAE1993TS, TAE1999TS, UCC24612 or SRK1001.  But with the boost, pre-regulator options further below the voltages are higher and the benefit is small and not worth implementing.

Dual synchronous rectifier ICs; TEA2095T, TEA2095TE.

The low voltage drop rectifier on the low side could be implemented using a cross-coupled, bistable-multi-vibrator. This feature would save 200mW compared to using a schottky diode bridge rectifier.  Alternatively, this is implemented in software.

Diagram right SiMetrix model; AL-0034-01B - dynamo battery lights manager Synchronous rectifier controller - outputs inverted to drive MOSFET gates (Red and Green waveforms).  Unlike a diode rectifier, this circuit ensures that one of the two transistors is nearly always on.


Design output files

 

Maximum power transfer;

Software and electronics combined diagram with a mixture of flow diagram symbols, electronic symbols and wires. The RC average is a simplification to show function but it is not correct but a sliding average of half or one cycle should be used. There are other signals that are not shown such as Pgood signal low can be used to indicate whether the main regulator is limiting due to high dynamo current. The proportional part of the loop gain due to the amplifiers as a guide should be < 50, that is a 2% change in any signal should result in less than 100% change in the output voltage.

Below 1.5V the dynamo's power output substantial looks like a voltage generator with series resistance in this case of 5 ohms.  The power obtained by implementing this would be largely lost in other losses such as diode voltage drop loss.  This feature to be added to the diagram.
Maximum power transfer strategy diagram AL-0043-01A.  Potentiometers set the maximum dynamo 
current and the output voltage limit, for battery charging.  The dynamo maximum current potentiometer 

should only be increased when the main power supply is limiting by that control in order to prevent 

set-point from running away. Similarly, the voltage output control is only effective when the power 

supply is limited by that control.  The potentiometers represent controls from other software functions.


Intelligent nudge - Calibration at the maximum power output;

  • At a steady speed test by increasing the current taken to see if the power increase or decreases - then adjust the maximum power accordingly.
  • The test can be carried out under varying speed conditions by testing using power x frequency or voltage.
  • A dummy load may need to be added.  Alternatively, keep the calibration strategy simple under variable speed and loading conditions available. 
  • The normal operation requires that the power factor be good when maximum power required and that not too much current being drawn from the dynamo.
I have drawn this diagram after developing circuits because I can now see more clearly how to show in a diagram what I am aiming for.   Consequently, the diagram is clear than my earlier abandoned attempts but also more closely fits with the circuits variants below.  It is also part of cross-checking those circuits AL-0002-???


Next step - build test rigs and test some of the functions


http://minisystem.blogspot.com/2011/11/ has carried out some of these tests with dynamo LEDs and discovered that the dynamo will produce at least 5V peak operating down to 12KPH the current is low though because much of the output will be under 5V. The circuit above and circuits AL-0002-01? should operate down to <3V and <10KPH although with very poor efficiency.

The graph right does not belong to me, so I have asked if I can use it? The green line is relevant so disregard the blue line.   I have cropped the graph.


The current was presumably measured in series with the  LED with a 5V drop so increases as the on-to-off duty cycle increase with the higher voltage generated by the dynamo.



Summary of full circuit and refinements;

The diagrams below are mostly worked through but for a software assessment of their viability.  The low-speed crystal oscillator is not used so four port pins including 2* 0V screen pins were made available.  Each PCB could be calibrated for temperature change using the on-chip temperature sensor, oscillator and microcontroller's oscillator trimming registers. 


Some basic functions are provided but more controls and features such as distance travelled log requires a tablet or other computer to be connected in order to access those features.  

Smiths BL/BMC (1960s-1970s) Mini speedometer, 

odometer, fuel gauge with other indicator lights 

Thank you for the photo https://www.digital-speedos.co.uk/

  • Battery charge rate and surplus power for USB power output control,
    • The tilt sensor senses the bikes inclination to determine if the bike is moving up or downhill so change the strategy between taking maximum or minimum power from the dynamo.  Programmed using:
    • When the battery's charge is very low the inclination control be overridden and the battery be charged at a higher rate.   
    • Learn mode to program the dynamo power taken strategy.
    • Control switches, LEDs and speedometer proposed;
      • Switch Dynamo power;
        • ON 1 Minimum dynamo power and minimal charging current.
        • OFF 2 Managed dynamo power for lights, managed battery charging and surplus for USB.
        • ON 3 Maximum dynamo power with the surplus to USB (out). 
      • Switch to turn on USB charging/Learn/Set 
        • ON 1 USB (in) to provide charging current.
        • OFF 2 USB (not in), Learn dynamo use strategy.
        • ON 3 USB (not in), Use learnt dynamo use strategy.
      • Switch to turn the lights on. 
        • Lights off
        • Lights on
        • Lights high or flashing.
      • Red/Yellow/Green - battery charge status LED.   
        • Steady indicates charging or dynamo power,
        • Flashing indicates discharging.
        • Cycling Red - Yellow - Green; Fault USB and dynamo charging or battery.
      • Blue - USB connected status LED.
        • Steady indicates charging and connected,
        • Flashing indicates connected.
      • Speedometer and possibly an odometer LCD display.
  • Alternatively;
    • LCD display and push buttons.

Display types;
  • LCD Transflective, 25x50mm (128x64 dots),  LED backlight 60mA 3.2V (switched off in good daylight), 64128K Display Tech systems.
  • OLED 55x27mm (128x64 dots),   20mA 13V,  I2C bus, W12864XA Electronic Assemblies. 
  • EPD 27.5x27.5mm (152x152), 2mA 3V, I2C bus, MT-DEPG0154BNS800F5 Microtips technology - no illumination.
  • 2x Seven segment LED displays plus bar graph and LEDs <100mA 2V.
Alternatively, a needle and scale type traditional moving coil meter could be used.  Fitted with a shunt resistor or large capacitor to damp the movement would only require 50-500uW (10uW for the movement). Eddy current and Air damper types are more robust.  These are not robust but the type in the car fuel gauge, above, is a hot wire type they are robust but they consume too much power.  Taut band types and also with damping are more robust.
 

Speedometer circuits AL-0041-01C. 
 
1-3. Simple a series resistor with the meter from PWM output to VDD - the PWM will need to be set according to speed and measure VDD
 
2-6. Have a damping resistor or capacitor.  A damped meter is a better option.

4-6. With regulators so do not require measurement and calibration for fluctuations in Vdd.

1-4. A buffer transistor may be required because the open-drain output of the microcontroller is fairly high resistance and may introduce a significant temperature coefficient when driving a higher current or shunt damped meter from a low voltage.


Software;
The switches selected are three positions on off on and they are tested by 
  • Turn on pull-up and testing the port pin for a low state. 
  • Turn on pull-down and testing for pin high state. 
  • If neither of those then the switch is in the open state. But if the microcontrollers port pin can not be configured with pull-down on the port output low drive be used instead.
  • The LEDs be driven from a high drive.  The blue LEDs from open-drain configured port.
STM32 Cube MX software project files; 
  • Some of the meter drivers above require that the PWM be output from a high drive open-drain port but the project files do not seem to allow this to be done?
    • Options requiring a high current open-drain port (6).
    • Options requiring the output port be set high drive; all except for (4) and (5).


The variants of the detailed circuits to choose between

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 design 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's output could be boosted to 7W when cycling fast.  But the non-boost variant similar to AL-0002-01? would work well although testing needs to be carried out before a final decision is made.  AL-0002-02? can be modified to work without the boost pre-regulator and is probably the best option.  Alternatively, more than one of the variants should be priced and could be made.

Picture right Sturmey-Archer, AG - 3-speed dyno-hub, dated July 1953;  3-speed wide variable gear hub and 6V, 2W generator.  40 spoke.
 
Anticipated behaviour based on a voltage limited current source in series with a 5-ohm resistance but discounting the 5.5H inductance in the case of a GH6 type dynamo. The test should also be carried out by the unit to characterise the dynamo fitted.  USB power input be considered and battery power be used, the over-voltage clamp (version -02? to -05?) could be used. Therefore monitor the frequency, light or no-load measure voltage and short out the dynamo to measure the maximum current. 
 
Software implications;
AL-0002-01? and -02? without the boost, pre-regulator power limiting is more complex.  The buck regulator compensation pin clamp voltage needs to increase and reduce with dynamo voltage increase and reduces to ensure that the limit of current is optimal but it must change continually.  A temperature coefficient is expected and a continual calibration process needs to be carried out under varying output condition consequently.

AL0038-02? There is a trade-off between fitting low-value inductors with high current and more electromagnetic interference issue OR higher value inductors and poorer power transfer efficiency (PFC).

Whereas all the other variants AL-0002-02? to -05? the current take is a constant sine-wave matching the voltage waveform by changing the PWM's mark-space ratio in steps.  The buck regulator's power limit does need to changed quickly as every 1mS perhaps?

 

The buck regulator compensation pin voltage characteristic is likely to follow a square law in AL-0002-???  Because of the voltage feed-forward feature.   Whereas voltage characteristic is likely to be linear in AL-0038-02?  Because of the regulator does not have a voltage feed-forward feature.


The power limiting mechanism is likely to be unstable when the current drawn is near the optimum maximum.  This is because the regulator with feed-forward or current mode will tend to take more current as the input voltage drops before software or other control has had time to react and reduce the current taken.  A simple voltage mode type regulator are less likely to become unstable this way.


Variants with the boost pre-regulator in which the buck regulators output and power take would be manage more slowly consequently instability should not be an issue.



Design files for all variants;

  • AL-0039-01E Op-amp Ibatt resistor and LED PSU resistor networks.ods spreadsheets.
  • AL-0040-01B  Dynamo Battery Manager - Microcontroller select - Software.odt  --- Updated document to follow.
  • AL-0042-03B LTspice power simulation for all circuits -- improved transistor switching circuits with graphs generated LTspice simulation.   The changes have not been incorporated into the circuits below.  More functions are included in this simulation so consequently, the simulation runs more slowly. Usually, the simulation would be better to break into smaller models but the purpose of the diagram is to put the refinements together but this larger simulation tests important functions operating together as well.
  • List of files; There is a spreadsheet list of files.

 

The decoupling strategy is to place 100nF ceramic decoupling capacitor's close the each IC power pins, internal power planes for the microcontroller VDD.  I/O has 1 - 10nF COG/NPO capacitor's near the connector pins.  There is an 0V power plane that provides screening for good EMC performance.

 

There are no thermal reliefs in the power and thermal planes. This also provides better electrical conductivity.


The part libraries are to an old standard that changed more than 25 years ago so many footprints should have the index in the centre but CADSTAR libraries have many parts with the index at pin 1. It is necessary to fix this before using the footprint or creating a footing. PCB assemblers can correct small discrepancies they have too but they can not correct for this error necessarily.



--- AL-0002-01 Basic bicycle dynamo battery and lights manager - Draft ---

  • AL-0002-01L Circuit and PCB's - draft.  The design should fit in under 100 x 100mm.
  • AL-0033-01F.ioc Micro-controller selector and configuration project file draft. ---
  • STM32L072C - 48 pin one test point but no spare pins.
This type of moving coil of meter pictured right is clear to see 
100-0-100uA, but a left hand zero type is required as a speed-o-meter.

Advantages and Disadvantages of this design; 
  • The input capacitor is electrically small but should be reduced in value.  The supply voltage varies with dynamo AC ripple thereby allowing dynamo current to match the AC dynamo voltage for better power factor and therefore more optimal power transfer is possible.  
  • A large capacitor is fitted to VCC, the main power to ensure that the microcontroller's power is not interrupted almost regardless of the condition of the battery or whether it is fitted.
    • Software is required to manage the modulation of the LED current first priority after microcontroller power, then USB output current if there is any power to spare at 2x dynamo output frequency.  The LED flicker may not be very noticeable. 
    • The battery will provide lighting power when the dynamo speed is low thereby allowing the light's to dim a little but preventing the lights from flickering severely at frequency's that are a health issue.  Perhaps dimming the light's but do not allow the lights to be off for more than 20mS?
  • This is an efficient solution with basic functions.
  • There is no input boost supply rail and so the circuit will not operate at as low bike speeds as other versions below do.  Consequently, radio-frequency emissions can be kept low.
Rectified sine-wave input - The white region is where power is unavailable, a smaller angle of power available as the speed drops.  From 2V power for the lights and the microcontroller, 3.5V is a high enough voltage to fully charge the battery.  A boost pre-regulator would provide power through the whole cycle and the software should be easier to manage the current taken to be below the maximum.  That is 420mA at 90' and 300mA at 45' and 135' but the voltage increases with bike speed.
  • The switch-mode power supply IC includes feed-forward compensation so it is not possible to fix the output pulse width period over the full period of the generator's AC output.  Consequently, a problem could occur with more current attempted to be drawn when the dynamo's output voltage is lowest and the least current is available.   
    • The main regulator's power is controlled by DAC and a transistor AND-ing the soft-start function.  The main regulator's output voltage clamp is set using a PWM output.   Fairly complex software is required in order to prevent such an issue perhaps using a triangle wave or rectified sine wave phase-locked loop in software.  The circuit is very simple and low cost consequently has a large temperature coefficient that must be continually corrected in software.
  • Speed-o-meter output - will drive a 0-50uA moving coil meter.   Scale illumination output needs to be developed. 
    • This is driven from an open drain PWM port pin will be compromised a little by the temperature and VDD coefficients of the port pins on-resistance (~50 ohms).

---  AL-0002-??? As above (01?) But with a different main regulator --- not developed --
  • Changed the main regular to lm76002-q1 TI, this is a more expensive IC,
  • Start-up down to 3.5V rather than > 4.3V with better external bias supply or-ing for lower start-up voltage.
  •  Also, the compensation pin can be over-driven to reduce the power output similarly to driving the soft-start pin in version -01?


--- AL-0002-02?  Software-driven boost input can be PFC for boost supply for lower voltage operation --- PCB size under 120x100mm 4 layer components on one side.  -- Draft ---

  • AL-0002-02M Circuit and PCB
  • AL-0033-02E CubeMX software project file. --- to be updated.
  • Vgen is boosted by PWM so that power is stored in the capacitor long enough to ensure that the LEDs do not flicker at 2x dynamo frequency.  The current drawn should be controlled approximately be proportional to the percentage of output peak voltage output.  That is in order to maximise the power transfer with some power factor correction.
  • STM32L052C6Tx 48 pin, microcontroller.  With one test point and no spare pins.
  • The meter driver is for the highest current type with a 240' movement.   The movement is 500uA so the power taken is ~8mW = 2.5mA * 3.3V.
  • This design and layout to be refined after software review. 
The diagram right above AL-0042-02A LTspice XVII simulation boost input pre-regulator LT1812.  Would be driven by microcontroller PWM outputs the non-boosting transistor is turned on to reduce power wasted in the input rectifier little but the series current sense resistors increase power losses.  The simulation shows that this type of IC responds slowly and is unlikely to respond quickly enough in this bicycle case to be useful.  On the other hand, control is smoother than A microcontroller that will need to operate in steps, which is not likely to be an issue, when changing the PWM frequency and pulse width.

Advantages and disadvantages;
  • Power Factor Correction is approximated by the software-driven varying Pulse Width Modulator boost supply.  But the drawback is that boosting to a high voltage then dropping to low voltage is inefficient.
  • Current regulators for LED drive instead of voltage regulators to improve efficiency has not been implemented.  This could be implemented in the lamp units from the 2-3V lights output. 
  • Two transistors for synchronous rectification and boost supply should be changed and the source pins connected to the sense resistor as simulated in AL-0042-03?  Gate drive steering logic is provided in software but the simulated circuit AL-0034-???, saving two microcontroller pins (PWM, and combing voltage o1 & o2). 
  • An earlier version of this design used ucc29910A PWM controller, which only requires a 5V power supply but this design looked unnecessarily expensive and has been abandoned.
Improvements;
  • To be refined after software review.
  • Add buck-boost SMP LED current drivers.  
  • This version is suited for evaluating both with or without a boost pre-regulator strategies, whereas version -03 is more efficient.  This version -02 but without boost pre-regulator is more efficient than version -01.
  • Modification to remove the input boost pre-regulator and thereby the circuit to become an improved version of -01 (above). 
    • The circuit may not operate to as low voltage but the risk of EMC non-compliance is reduced.
    • The input rectifier low side software-driven transistors have lower losses than diodes used in version -01. 
    • The two input inductors can be changed to smaller input filtering function only, and the two low side input diodes removed. 

-- AL-0002-03 This variant uses a better low side battery power switch. -- Draft ---
  • AL-0002-03N circuit and PCB. - This variant is similar to version -02?.
  • STM32L052C - 48 pin.  There are no spare pins but there is one test pin.
  • This variant has a more efficient battery charge/discharge sense power switch because an n-channel MOSFET is used and also the MOSFET is driven from the boost 3-5V supply.  But has a higher battery current when switched off although this should not be too significant.
    • This variant will not operate if the battery cells become shorted (I do not know if this is such a serious issue with NiMH cells compared to the older NiCd type).
  • This variant can directly control the main power supply in order to limit the maximum current but this feature has not been fully developed.  
    • The amplifier does not switch gain and current range for charge rating measuring but is suitable for measuring current and coulomb counting. 
  • VCC power supply is turned off when there is no dynamo or USB power.   USB power out is switchable to further save power.
  • The meter driver is simple but the most expensive variant or the most efficient.   The movement is 100uA but would work with a 30 or 50uA movement with better damping and lower voltage VDD.
Simulation AL-0042-03B of a boost pre-regulator driven by a fixed PWM shows more clearly than the 
PFC pre-regulator simulation above that the current peaks (purple) more sharply as the voltage peaks
 so has poor power factor.  The other waveforms are two dynamo inputs and the polarity detector.
  • This can circuit operate like version -01? but poorly. 
  • This design may offer a small improvement on version -02 in handling higher battery charging current and more straightforward trickle charging.
    • The battery switch transistor can be turned off so that the circuit will work partially and indicate battery or cell short circuit.

       

      -- AL-0002-04 this variant uses Lithium rechargeable (LiFePo4). Uses the micro-controller op-amp which is good enough but must be turned off when the unit is inactive to save power. -- Draft ---

      • AL-0002-04I   PCB and circuit. 
      • AL-0033-04C   MXcube microcontroller project. -- To be updated
      • Uses STM32L052C 48 pin. - One test pin but no spare pins.  
      • Lithium protection is less demanding than for a laptop because the cell is a safer LiFePo4 type.
      • 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 is more efficient only requiring charging 110% more power put back rather than 150% that a NiMH requires.
        • Rapid charging LiFePO4 is not possible but 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.
      The Moving coil meter pictured right above is not so 
      clear to see 0-1mA is not ideal as a speed-o-meter.
      • VCC power supply is disabled to save power when there is no USB power in or dynamo AC input.
      • Speed-o-meter output - to drive a 0-30uA moving coil meter.  There is also a scale illumination output but this needs to be developed.
        • This is driven from an open drain PWM port pin will be compromised a little by the port pins' on-resistance temperature coefficient.
      Advantage and disadvantages;
      • Lithium-ion Phosphate (LiFePo4) - is slightly lower capacity Li-ion, less raw materials used. 1.2Ah or higher.  Fewer 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.  
      • 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 the voltage is never too high to damage an LED if it were reverse connected. 
      • Using an STBB3JCC buck-boost switch-mode current regulator
      • STBB3JCC - 100mV Feedback +-10mV --- the part used.
      • 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.


       

      -- AL-0002-05 this variant uses Lithium rechargeable (LiFePo4). Uses the on micro-controller op-amp and another more accurate op-amp which is good enough but must be turned off when the unit is inactive to save power. -- Draft ---

      • AL-0002-05F circuit and PCB
      • AL-0033-05D.....ioc  STM32L151RCTx 64pin microcontroller project file -  has unresolved clock issues.
      • This variant is similar to -04?
      • Uses STM32L151R - 64 pin microcontroller.
      • This version is compromised because the microcontroller op-amps are used.
        • There could be a cost-saving.
        • Small signals are tracked across the PCB rather than amplified at the source then large tracked across the PCB.  This may not be an issue.
        • The op-amps are therefore not optimal and the input current is quite high.
      • A speed-o-meter moving coil meter output is provided.  The LED illumination drive needs to be developed.
         
        Pulse counter for mileage counting with set and reset. This counter
        is heavy, requires 24V pulses, counts down and so is unsuitable.
      -------------------------------
       
      -- AL-0038-02 no battery, no microcontroller. 5V outputs for lights, USB power output plus a speedometer. --
       
      A combination of above versions AL-0002-01? and -02? to -05? but using two transformer-coupled two boost regulators (SEPIC)

      The diagram right; AL-0042-01D power simulation (LTspice).  Fixed or slowly varying PWM drive gives good Power Factor with slightly over current drawn at the increasing edges of the sine-wave input.  
       
      The transistors alternate between switch mode power supply or synchronous rectifier function to save power.  Therefore the dynamo current needs to be calculated from the output current, but the waveform does not match the input current waveform, which does not matter in this case the control is to limit the average dynamo current.
       
      R8 + C1 are used for sensing the average input current in the waveform file.
      • Conveniently uses all low side switches instead of diodes shown for better low voltage efficiency. 
      • The output capacitor is of a lower value than above but Vcc will have a high ripple voltage as AL-0002-01?.
      • This also requires an extra voltage regulator to start-up.
      • A boost voltage mode type switch mode power supply controller is.  That is with no feed-forward and not current mode control would be the most manageable for optimum power transfer.
        • Buck controllers but using the high side driver to form a boost regulator, NCP1589A, NCP3020, NCP5269B, A6727, L6726A may work in this off application way?
      • A synchronous rectifier at the output to save power would make this an efficient solution.  This does not have the SEPIC capacitor so therefore requires a snubber network that will use some power
      Consequently, the dynamo input may be simplified and the power path may be more efficient?

      This design idea could be developed using evaluation boards and Veroboard prototyping.  Alternatively, a PCB be made by completing the design idea below with or without connectors to mount a microcontroller evaluation board.
      Circuit diagram and incomplete PCB AL-0038-02B (CADSTAR). 
      • The design is incomplete, component values and footprints are wrong.  The PCB shows an early design step of grouping functions together placing those groups and some routing to help to improve the placement.  Some footprints need to be defined to replace the temporary single inline connectors place holders.
      • The optimum current limit is set using a voltage clamp on the boost regulator compensation pin programmed with a potentiometer.  The output current is set as a proportion of input voltage, up to 2A.
      • The speedometer uses a capacitor in series with the dynamo output rectified to drive the meter. Alternatively, a switch allows the meter to be used to calibrate maximum power transfer. 
      • The circuit includes a dummy load to set the optimum power;
        • With the dummy load switched on keep the wheel spinning steady speed to keep the meter needle mid-scale.
        • Adjust the potentiometer for maximum meter deflection which is maximum power.  The potentiometer should then be reduced slightly.
        • You will observe that the power will increase or reduce with wheel speed.  The power will drop severely at very low speeds.  This poorer low-speed performance may be improved by reducing the potentiometer a little if required.
      The Speed-o-meter section of AL-0038-02B shows a trimmer potentiometer to calibrate the speed-o-meter for wheel diameter.  A jumper and a number of resistors for different wheel diameters could be provided instead. 
      The alternative switch position is for optimising the dynamo power, there is another potentiometer for this.  This shows some of the extra cost and complication is added in this case by not including a microcontroller.
      • Many of the analogue functions are likely to be unstable and some circuit modifications may be necessary if this is a problem.
      Improvements and outstanding changes;
      • Define missing PCB footprints, which have SIL connectors as place holders.
      • Complete PCB layout, including adding more decoupling capacitors.
      • Select a suitable SEPIC transformer. 
      • The circuit does not slightly increase the current taken with dynamo voltage increase.  This would have contributed little extra power output.
      • The circuit does not ensure the load is >5 ohms.  Consequently, not all available power will be gathered at low dynamo speed.
      • Lithium cell and L6924U, L6924D and probably other ic battery charging controller will work with AC ripple on the power input.
      -------------------------------


      Design output files


      ToDo - list all variants of AL-0002-??? and AL-0038-02?;

      • The microcontroller may need to be changed to a 64 or more pin device.  To provide function or design revision flexibility.
      • Add backlight power for the speedometer. 
      • Consider using smaller batteries. Therefore change the battery holders.
      • Main power supply compensation needs to be calculated. It is roughly based on the data-sheet examples. 
      • Consider selecting a higher current and higher Vgs_on pre-regulator transistor.   The options are not good but do allow sense R in Tr-S, but the boost supply must be increased to 4V.
        • SSM6K809R, SSM3K341 Toshiba, 1.5-2.5VGSoff, 4Von, nC, 9.3nC
        • MCH6445, CPH6444, CPH6442 On-Semi, 1.2-2.6VGSoff, 4Von,  6.8nC, 10nC, 20nC
        • NDT3055L On-semi, VGth <2V Von 120mR 4.5V but on below 3V, 60V.
        • Therefore the Tr will is less likely to turn on unintentionally due to negative switching pulses.
        • An NPN-PNP + e-b resistor 100R transistor gate buffer needs to be added.
        • SQ2364EES Vishay MOSFET shown in many circuits is still a good solution although the VGth is very low making switching off potentially poor.   It was chosen because of the low start-up voltage possible without a 5V supply, which is a little poorer compromise.

      Right above; From Dynamo Maintenance blog  AL-0035-01C (4) Simple Dynamo to 5V DC a regulated power supply such as USB power output.  The design returns surplus power back to the dynamo and therefore back to moving the wheel forward.  By comparison, the maximum power output is only; 1.5W = 300mA x 5V.  ST.COM recommend that an over-voltage transient absorber (TSV) such as SMBJ13A be added to this circuit.  I should say I think the issue is addressed well without the addition of a TSV.

       
      Which design to go forward with;

      The cost and benefit of using a more expensive microcontroller with more functions on-chip some people cost things on 5p per pin used whereas other high volume users tend to simply avoid integrated circuits where cheap discrete parts can be used.   It is not clear cut without asking a PCB maker and assembler to price some variants in the volumes you are likely to use.


      STM32L072R or STM32L052R are probably a good choice along with using an external dual operational amplifier.  For the Ibatt monitoring, it will be necessary to periodically turn off all major current inputs in order to calibrate the battery current measurement.   The A-to-D converter reference is VCC with a 1.25V internal reference connected to one channel so the VDD can be measured. This works over the entire voltage range of a two-cell NiMH battery.

       

      STM32L0??? And STM32L0??? Do not have op-amps which means much better optimised external op-amps are used.  STM32L151, by comparison, is more expensive has two op-amps but the cost of the extra parts saved may break even.

       

      STM32F303 (four op-amps) or STM32F072 (no op-amps) are lower cost, without the low power features but are low enough power but the higher minimum voltage will operate with the lithium cell variants.  Alternatively could be used with any variant if the boost regulator is used to also provide VDD via a regulator,  this is beneficial in providing an easier to manage stable supply voltage reference for the A/D.


      The op-amp PGA feature is only a simple 0V referenced set of fixed gain settings for the op-amps.


      STM32L433 some variants with 64 or more pins have a buffered reference output so the A to D converter can be referenced to that instead of VDD which is in any case varying.  In addition, there is an op-amp that can be used for better Dynamo current monitoring and being AC does not require a low offset voltage.  All variants of ST32L552 have two op-amps, a buffered reference output but in both cases, if the buffered reference is used it is only accurate with high VDD otherwise it reverts to tracking VDD.


      Another possibility is to have a number of variants developed and made.  Then have one or two of each variant on a panel of PCBs and putting as many different PCBs on a panel as possible. But this may not be worthwhile PCB makers now put as many different jobs together on  One panel in any case so  It is necessary to check?


      Have at least two PCBs made but not assembled but the cost difference of assembling just one or all may now be comparatively small.   That depends on if pick-and-place or manual assembly is chosen. It is necessary to ask each PCB supplier/assembler the same combination of questions?


      PCBs that are not assembled can be stored for up to 18 months and be assembled successfully.


      Prototyping with an STM32L433 (one op-amp) STM32L475 (two op-amps) variant with an on-chip reference buffer might be the best option.  Plus use an op-amp for better quality battery current measurement, which is compromised in any case by requiring ~100mV offset which has a significant temperature coefficient. 

      The multiphase two or three-phase boost pre-regulator (AL-0036-03?) has the merit of lower electrical emissions which are likely to be an issue.  The issue of emissions conducted out being more severe in a single-phase converter can be observed in simulations such as AL-0042-*. 
      Simulation AL-0042-03B shows a higher current transistor than is likely to be optimally 
      efficient for the boost configuration but are suitable for the SEPIC design.  The gate drive 
      is particularly fast and these Toshiba MOSFETS gate threshold is a little higher, requires 
      5V and is well suited.  For the boost design the others On-semî transistors listed suit 
      better.
       
      The SEPIC transformer's inductance needs to be lower than normal in order for the PFC function to work. This makes the current pulses high, the transformer ring and so RFI then becomes more of an issue and the efficiency a little less.


      Prototype and ad-hoc development;
      Is now more common than, plan, model and build right first time as above.  Taking the design process in smaller steps shows something working early.  The disadvantage is that you are not necessarily testing the nearest to final version early particularly the PCB layout.   Also if a design is not fully understood then why it works then fails later is not predicted.

      The all analogue solution AL-0038-02A could be developed or combined with a microcontroller and is a way of avoiding a lot of software work.  Software developers often ask for more hardware to save work.  A less optimal power transfer bridge rectifier, large input capacitor and SEPIC regulator instead of AL-0042-02? pre-regulator would reduce the risk of electrical interference.  May not be much more than expensive but makes development possible in easy compromised steps for example.   Lithium cell and charge bq25017 or L6924u also be added with very little software work required.

      ----------------------------------------------

       

      LED power supply for one or many identical LED's connected in parallel.   An LED running at 100mA is very bright and the maximum current available probably could be reduced.  White LED's voltage drop is 2.8V - 3.2V or <3.5V - 4.2V depending on the type but Red LEDs voltage drop is about 1.7V.


      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 connected 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-04D sheet 5 is the small red square near the centre of the PCB.


      The 2V to 3.5V output is suitable for a red LED + series resistor but the brightness will change depending on the state of battery charge and dynamo output. That brightness can be managed in software by Pulse Width modulating the output alternatively the programmable current in the data-sheet below BCR421U Diodes Ltd. will keep the current more stable over the voltage range.

      Data-sheet right; A single red LED will drop 1.7V consequently the LED current will reduce below 2.7V but not so severely as if a simple series resistor were fitted.  In any case, a simple resistor would be fine a 7:1 current changed would be noticed but would not be severe but 2:1 current changed would not be noticed.  BCR421U's current should be programmed by fitting a suitable external resistor between 10mA and 100mA but can be set to a higher current.


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


       

      Conclusion

       

      I have used this project as a design exercise to learn and formularise myself with some of the STM32 series microcontrollers and to keep myself, up-to-speed in using CADSTAR 18.  I have not got paid for support just now on that circuit and PCB CAD tool because I am not working. For example, there is a feature to click on a net and move promptly to other locations where it is used that I would like to use.

       

      I have not explored is whether I have chosen the best combinations of the microcontroller's peripherals for the functions required, particularly timers.  This is partly why the design options are marked draft, they require software review and some testing of some function blocks.


      I have also considered software solutions by drawing a solution in electronics, which software engineers tend to call hardware. A hardware model in springs, levers and wheels is good but the software solution could be very different.  A springy Reynolds steel sportbike frame can be applied in inductors capacitors and resistors but electronics works better with a stiffness of bonding 0V everywhere for screening but uses springiness as well, both giving immunity to road vibration or electrical interference and efficiency of power transmission.  Transmission line theory applies to electronics. Maths such as averaging a signal over one cycle of the dynamo output is easy in software. 

       

      Technical discussion on the electronics community.st.com/s

      --------------------------

       

      Power for a low power wireless long-range device.

       

      For smaller Internet of Things a D-Cell lithium primary cell may last up to a decade,  alternatively, an energy harvesting strategy can be used.  Depending on the power required.


      A much smaller sized variation of the above design could be developed.   http://www.rotalink.com/ http://www.rotalink.com/our-products/10/ac-motors-optional-gearboxes.html make geared motors with strong ball-bearing bearings.  For example;

      • 4116 synchronous motor (48V or 24V) + 227 gearbox (25:2) with ball bearings.
      • SB2513 bipolar 24V stepper motor + 222 gearbox (~7:1) with ball bearings.

      The bearing is strong enough to stand having a pendulum and weight fitted in order to create up to say 1W.


      A lower power, power supply based on a higher voltage say 24V 48V  motor based on the circuit AL0002-01? above may be suitable using a low power switch mode power supply.

      • 60V input, 50mA output switch mode power supply such as ADP2360 may be suitable?


      No comments:

      Post a comment