Having changed my degree title from Electronic engineering to Electrical and Electronic engineering, means that I have to take some power modules. While I don’t find mass power transfer particularly inspiring (HVDC links, the grid and power networks blah blah blah), I find small power conversions pretty interesting, the low power stuff that enables us to have phone chargers the size of normal plugs!
I’ve made a boost converter using the STM32F0 before, implementing a simple control loop but the issue here is for good regulation, an ADC measurement needs to be taken at the start of every PWM cycle. This obviously adds overhead and takes time away form mass processing. The reason I thought up the method I will describe later was in response of my current year long group project. I need a high voltage voltage source (where precise regulation isn’t a massive deal) and want to be able to generate this with minimal effort from the processor. My main aims for that were to generate a voltage of ~100V, large enough to drive the ultrasonic transducer that will be used for the ultrasonic measurements.
The way I’ve implemented this is extremely hacky. The inputs of the STM32F0 feature a Schmitt trigger. While the hysteresis is rated at 100mV, this is only through theoretical calculations and will vary from chip to chip – hence why this isn’t the most ideal method of designing a boost converter. If however, precise regulation isn’t a big deal, this will work fine. The inputs have a minimum voltage to register as a high input. Using this value roughly as a trigger point, a pulse skipping boost converter can be implemented.
Using TIM1 as a free running PWM output with a preset duty cycle and frequency, the output can be enabled and disabled through hardware using the “break” input. This input is normally used if there is a hardware fault, for example: an overcurrent condition with a 3 phase motor controller. In this instance, the timer produces a continuous PWM stream which drives a switching transistor, switching the current through an inductor. The inductor generates a magnetic field while the transistor is on and current rises. Once the transistor is turned off, the energy stored in the inductor – as a magnetic field – collapses. As a consequence, the inductor tries to force current through any available path. If the inductor was connected to the transistor and the transistor only, once the transistor is turned off, the voltage across it would rise at an instant, immediately blowing or at least damaging the transistor as the inductor finds the easiest path of current flow.
Obviously, the inductor therefore has the ability to raise the voltage across it to get this current flow. This is the basis of how a boost converter works: Current flows in an inductor creating a magnetic field. The magnetic field starts to collapse as the transistor is turned off and during this, the voltage across the transistor rises. A diode is connected from the transistor to a capacitor, where the inductor current can now flow and charge the capacitor up, increasing the voltage across it (Q = CV, if Q increases, V must increase for a constant C). The process of current flowing through the switching transistor to the diode is called commutation and can be seen in the simulation below.
Current commutation in a boost converter
As can be seen above from 40us to 50us, the current is flowing through the MOSFET M1. From 50us to ~51us, the current is commutated to the diode and flows into C1 and R1, recharging C1 and supplying the current for R1. This causes a minor increase in the voltage across C1. Eventually, the load losses will balance with the energy transferred per cycle and the voltage across the load will reach a steady state.
As proven by people much more intelligent than I am many years ago, the current through an inductor is governed by the voltage across it and the time this voltage has been placed across it. For a constant voltage, current through an inductor will rise linearly with time (ignoring series resistances) giving light to the equation: V(t) = Ldi/dt. If you want to calculate the time it will take for 1A of current across a 10uH inductor, with a supply voltage of 5v, the equation required would be: 10u*1/5 = 2us. Running a simulation will prove this to be true. The reason series resistance is ignored is because if series resistance is included, the current is no longer linear and will follow an exponential curve, introducing DEs!
One inefficient design method for this type of converter would be to ensure the PWM output was on long enough for the inductor to be charged to its maximum rated current, then off long enough for the inductor to discharge then skipping pulses when the output voltage was fine. If one knows the rough load requirements, their supply voltage, output voltage requirement and inductor value, the PWM frequency, and on time can be estimated. It can be shown that the output voltage is proportional to the duty cycle, where: Vin*D = Vout. Therefore, aslong as the inductor current starts and ends at the same point and doesn’t rise or fall over a cycle, the output will be in steady state. If the duty cycle is too high and the inductor doesn’t have chance to fully discharge back to the idle value, the current endpoint will increase with every cycle. Its only logical now that the end point of one cycle is the start point of another and voila! Current increases indefinitely (until limited by external parameters).
Here, ideal components will be used for calculations to add simplicity to a simple converter! The assumptions made here are: No inductor series resistance, no transistor on resistance and zero time switch speeds and zero time commutation speeds. In reality, these assumptions are all false but they simplify the maths a bit and make the boost converter conceptually easier to understand.
While most boost converter documentation states that the inductance is an easily varied parameter, unless you are winding your own, you’re generally stuck with off the shelf components which while a largely varied selection is available, everybody having a massive selection to hand isn’t so plausible. In my designs, I have a small set of inductors which I generally design around as changing the frequency and time constraints of the oscillator is generally easier than walking down to RS and buying a suitable inductor!
For this post, I have the set requirements to:
3V input voltage
12V output voltage
100uH inductor (165mA Maximum current)
Constant 100Ohm load
From this, I can get a quick estimate of my duty cycle required and frequency of oscillation, along with knowing the maximum current in my inductor. Proof of these equations can be found here. As stated previously, I’m using ideal equations.
Duty cycle: 1-Vin/Vout = 1 – 3/12 = 75%
Frequency: ((Vout – Vin)*(1-D))/(Iload(min)*L) = (12-3)*(1-0.75)/((12/100)*100u) = 187.5kHz
As a sanity check, its probably worth throwing together a quick simulation and looking at the results…
Looks fine! Not particularly well damped with massive overshoot… but the correct voltage!
Surely everything should be fine if I just throw this into action on my board right? Having configured TIM1, OC1N as the output and the break input to disable the output, my open loop converter should work right?
That doesn’t look like 12V…
Gah! What a let down. That isn’t a 12V output at all. It hasn’t even managed the supply voltage! This is the problem with ideal calculations. I’m using a pretty poor inductor with a DC resistance of ~3.4ohms, along with a 2N7000 mosfet with an on resistance of around the same. With a 100ohm resistor as the load, I don’t think this is even possible with this setup.
Removing the load fixes the voltage…
In the image above, the load has been removed and my “safety” potential divider is limiting the output voltage by breaking the timer output to a voltage of ~14V.
Pulse skipping design
Obviously, earlier I said that it is a bad idea to just design around a maximum inductor current but when your components are this poor, that is sometimes an approachable method (and now is when I get shot down by power engineers for ruining everything they stand for…). With this method, while the inductor is forever being potentially “overcharged” for a given load requirement, the fact that certain cycles are skipped somewhat averages this out. An inductor charging to 1A every cycle over 10 cycles is equal (on average) to an inductor charging to 2A every other cycle over 10 cycles. This obviously isn’t true in reality as resistive losses are equal to I*I*R which means the second method will have more losses to the square, hardly efficient! This does however give the opportunity for a set and go situation.
From my poor inductor, I know the rated current is 165mA so I will be designing around this. The time required to get a peak current of 165mA in 100uH inductor with a 3V supply voltage is: 100u*165m/3 = 5.5us.
To see if this method will ever be feasible, one can calculate the current required for their load under ideal conditions: Iin = Vout*Vout/(RLoad*Vin). For the 12V output with a 100Ohm load resistor, an (average) input current required at 100% efficiency would be 12*12/(100*3) = 480mA! Treating this as the average current, peak currents of ~960mA would be required, well above this inductors ability! I’m therefore reducing the requirements to a 1k load. This should reduce the peak current to 96mA.
From this, the off time can be calculated: Toff = L*di/(Vo-Vi) = 100u*96m/(12-3) = 1.07us.
Putting the on and off time together and taking the reciprocal gives a frequency of: 1/(1.07u+5.5u) = 152.2kHz. The duty cycle for an ideal case should therefore be: 5.5/(1.07+5.5) = 83.7%. It can be seen this design method will have a large ripple current and will just touch zero current under ideal conditions.
Sadly, I don’t think even these requirements can be achieved with these components. Because of the massive resistance involved, the currents just aren’t linear, voiding all forms of calculations involved.
Flat topped inductor and MOSFET current, nice…
While this whole situation doesn’t seem particularly appealing, when you just need to get the volts, for example to charge a capacitor bank, this works fine. In this case, set your on time to the maximum current supported by your inductor with the total PWM period being somewhat larger (a 75% duty cycle generally works). You can then calculate the required values for your potential divider input to your STM32F0. In this case, I want a ~12V output from 3V with minimal load requirements.
From the datasheet, for non 5V tolerant IO, the minimum input voltage for a low is: 0.3*VDDIO + 0.07 = 0.97V. A note here that this data is based on design simulation and not physically tested, hence the potential variability across devices. Using this voltage, one can design their potential divider.
0.97V = Vout*R2/(R1+R2).
Rearranging the above equation can give the value of R1, for a constant R2 and output voltage. In my case, I’ll be using a 1k resistor for R2:
12*1k/0.97 – 1k = 11.4kOhms
Obviously I don’t have this value and don’t really care for precision so I’m going to use a 10kOhm resistor! Putting this back into the calculation produces an output voltage of 10.67V.
In reality, the voltage is slightly higher as I measure my trip voltage to be 1.33V. This gives me an output voltage of ~13.8V. Quite a lot of error but I said I didn’t really care for the regulation! This stops it shooting up to some massive voltage. For safety sake, I also include a reverse biased diode from the pin input to the 3V supply. If there ever was a fault with the upper resistor of the potential divider, this diode should conduct high voltages to the 3V supply, hopefully saving my STM32F0!
Transient response of the converter
While the transient response sucks, at least it recovers to the same voltage! This circuit shouldn’t be used for any high performance systems requiring proper regulation as it just can’t provide it! It is useful however for a simple system where some reasonably somewhat regulated high voltage is required.
Wahoo! I told you it was simple! 8 component simple (9 including the STM32F0…). R2 is required to limit the gate drive current, along with stopping the switching currents coupling back into the STM32. L1 is the switching inductor which provides the voltage upstepping ability. D1 is the diode from which the MOSFET current is commutated to. C1 is the output supply capacitance, used to buffer the voltage spikes presented by the inductor discharging. R1 and R3 form the potential divider required for setting the output voltage. D2 is used to protect PA6 incase of R1 shorting out. PA7 is TIM1CH1N output and PA6 is the TIM1BKIN input.
The code for this really simple boost converter can be found on my Github, sorry for the long post!