I'm using the PowerPSOC to design a smart LED bicycle dynamo light system with the following features :
- smart power factor correction : when going fast, I can extract 10-15 watts @ 25V from a 6V/3W dynamo , and I can extract a decent few watts even at 10 km/h. I had a rather complex design based on AVR but the PSoC should replace all of it.
- two 18650 LiIon cells, charged from the dynamo during the day, to power the light when stopped at traffic lights or when going up some really nasty hill when the dynamo is useless at 3 km/h. The system is designed to work on 1 or 2 cells, empty or charged, so you can take one charged cell and put it in the helmet lamp (which will probably also contain a PSoC because capsense make excellent waterproof buttons !)
- front light : 3 Cree XP-G LEDs
- rear light : lots of red LEDs
- misc : day/night sensor, automatic behaviour (no buttons), etc
Right now I'm playing with the 4 color LEDs lighting starter kit and find it very easy to program.
Thermal management isn't a problem since the available power is proportional to the wind speed... a tiny machined aluminum enclosure housing 3 Cree XP-G LEDs becomes a really good heatsink at speed.
So, I will have a little watertight box housing the electronics and battery, connected to the dynamo, front LED module and rear LED module using cables. The bicycle frame isn't used as a conductor since this only causes corrosion and bad contacts.
The question I'm asking today is related to driving the white LEDs : 3 Cree XP-G in series is about 8-10V depending on power, current is between 0.1 - 1.5A (1.5A is a lot and only available when going downhill way too fast, fortunately this is when you need it the most). At realistic speeds (20-30 km/h) I aim for about 5 watts.
Now, a bicycle is a very hostile environment for electronics because the vibrations tend to break everything. Even DUCT TAPE and epoxy glue come off after a few thousand km of all-weather riding. Screws unscrew, etc. U-locks and fastening the bike to "urban furniture" means electric cables running along the frame have a dangerous life.
So, I need everything that goes out of the main PCB to be rugged and short-circuit protected.
Which means the floating load buck isn't going to be an option (alas). It is the simplest and efficiency is great but :
- shorting the 2 LED wires is OK
- shorting the top LED wire to GND blows the current sense resistor
- shorting the bottom LED wire to GND blows the current sense resistor and the LEDs
So, I'd like to use a synchronous buck (see attached schematic). This has the added bonus of boosting the efficiency.
On the schematic, the LEDs go on the right.
[*] LED current regulation between 0.1 and 1.5 amps
Easy with PSoC, the switcher is designed to operate above 0.5-1 amp, and I'll use PWM to go below that to low currents. The output smoothing cap has to be large enough so that the LED current is continuous, since LED efficiency is better at low currents, a constant low current is a lot better than high current pulses. Color accuracy isn't important here. The PSoC can generate a PWM of high enough frequency so that the switcher operates in short bursts at top efficiency and the LED current ripple is small.
Basically I connect the Hysteretic Buck output to the IN of the MOSFET Driver, and the Dimmer output (through FN_x) to the ENABLE of the driver. This driver switches both mosfets off hard when ENABLE is low, the freewheel diode takes over until inductor current falls to 0, and then we wait for the next burst. Switching frequency is about 200-300 kHz, PWM about 1-10 kHz.
[*] Open circuit protection
Consider a vibration-induced intermittent short : when the LED is disconnected, output voltage will rise to unsafe levels (potentially blowing the caps) and when the LED reconnects, if the caps are still alive they will discharge through the LED causing an unsafe current spike.
=> output voltage is sensed, and if it goes above a set limit, action is taken :
- Hysteretic controller's TRIP input can be used which quickly discharges the output cap (potentially harmful to the bottom MOS)
- It can also be done in software (there is enough time to react) : comparator -> interrupt -> cpu disables the mosfet driver
- or simply an AND gate can be inserted in the ENABLE line of the driver, using a comparator on the output voltage.
I am leaning towards the software solution, what do you think ?
Since I'm already using all FN_x pins, I can't use them to sense the output voltage. So I'll either use a CSA as a hacked voltage probe, or use an analog input if I can spare one.
[*] Short circuit protection & startup
This is where the problems begin... The current sense amps can't operate below 7V common mode.
I will use roughly the same circuit to charge and discharge the battery, but there I'll use a bidirectional current sense chip from AD which has no common mode problems. By the way I spent a lot of time looking for a way to implement a bidirectional buck (charge) / boost (discharge) until I found the PSoC which solves this problem in a rather elegant way !...
Question : when the common mode voltage at the inputs is below 7V, what does the output of the CSA look like ? Is it 0V ? Or something undetermined ? Or 5V ?
So, here, the first problem is startup : when the cap is at 0V, the current sense amp isn't operating, so its output is unknown. From the datasheet details about the CSA implementation it looks like its output should be 0V. So the hysteretic buck will force the top mosfet ON until the CSA detects enough current. However since the output cap is at 0V (or maybe we are starting up on a shorted load) the inductor will saturate and the top MOS will melt.
What I'm going to do is, on startup, set the hysteretic controller to have an always on output (so it can startup whatever the output of the un-biased CSA is) and set the Dimmer PWM to a short enough pulse length that the inductor current cannot rise above the allowed maximum. So the current in the inductor will be short pulses returning to 0 after each pulse. With this we don't need any current sense amp, it is inherently current-limited.
Then after a short time (maybe a millisecond or so), either the current pulses charged the cap to a usable voltage (above 7V), or the output is shorted. The cpu looks at this and decides. So, startup on a shorted load is solved.
Then, the hysteretic buck and dimmer are set to operate normally. However, if the load shorts after startup, then we have a problem : output voltage falls below 7V, the CSA powers off, and the hysteretic buck does undetermined things. Depending on the output of the powered off CSA this might be good or bad (constant on top MOS = boom).
Now, this is hard to solve, and there I need some help !
I'm thinking about the following options :
- insert another sense resistor above the top MOS and use another CSA to check for overcurrent and trip the HystBuck. This is the safest but not the most power-efficient.
- after the output voltage has reached 7V, use a voltage comparator to trigger the TRIP input of the HystBuck if the output voltage goes below 7V. I would really like to use this solution HOWEVER I've used all FN_x pins already !... Unless there is a way to use a non-FN_x pin but I don't think so.
- alternately I could use a current sense amplifier to sense the output voltage. But that depends, again, on what its output is when it is not powered.
- From the moment the output voltage falls below 7V and the CSA powers off to the moment the inductor saturates the system has about 2 µs to react (worst case), so a software interrupt might be possible but I'm not sure. Since I'll have a comparator on the output voltage to detect output overvoltage, I can use this.
Other questions :
I guess the InitialValue of the FN_x pins is the value at the output before the CPU initializes them ?... I will set this to 0 so it starts up with all MOSFETs off. Is this guaranteed throughout the power-up sequence (given that the MOSFET driver will operate from the same 5V supply as the PSoC) ?
Sorry for the length of this message, if you can help me on this, I'd be quite grateful !