- Computers & Software
How to Build a Buck Converter with a PIC Microcontroller
Constant Current Verification
Please Select an Efficiency
How does 10% efficiency sound? Pretty bad? I thought so too. I decided to build a buck converter circuit for an ultra miniaturized high power controller. When I say high power I'm talking about four channels, each at 25 watts, all enclosed on a 1" square PCB board. That's pretty power packed. My buck converter, designed and built from scratch, operates at 85% efficiency and generates virtually no heat to the touch as it sends high wattage to the circuits (shown in this demonstration as a halogen bulb, for example).
Modern buck converters can exceed this rating and it's not altogether uncommon for a 90% to 95% buck converter to be seen in the wild. I saw 97% in a datasheet recently. However, to build your own circuit, of such high efficiency, requires very specific component placing and small trace lengths between parts. It's almost impossible to do this without fabricating the whole circuit on a single silicon die. This is the advantage of buying monolithic buck converters, although they are more expensive.
One of the prominent features my design employs is a built in high precision internal current gauge, which it uses to attempt an auto efficiency calibration!
The picture above illustrates the four digit, 7-segment, display used on my circuit. I'm using the PIC18F2525, which is probably my favorite 8-bit microcontroller, but it doesn't have many I/O pins. So, I am forced to multiplex the screen, which worked nicely with my high brightness green displays. The number is read from top to bottom, which is left to right, in the photo. Currently, it says, 0620 milliamps (0.62 Amps), which is referring to the amount of current consumed in the output stage of the buck converter.
To read the current draw, I first send the output power through a 0.047ohm - 2 watt resistor, which hardly affects anything. Then, I measure the voltage across this resistor, which is close to zero. Instead of reading it directly with one of the microcontroller's ADC lines, I first send it to an op-amp for amplification. Then, the output is fed into the microcontroller and a simple multiplication factor is used to tune the read-out for the actual current consumption. I backed up these readings with a high precision multimeter. It works well over the full range!
The microcontroller also reads the voltage at the buck converter's output, in a similar fashion. By multiplying the voltage and current together, the power output (in watts) is immediately determinable. Then, I simply do the exact same thing for the input power line to the circuit, including the power used to drive the microcontroller and the op-amps themselves, and determine the total power input. This whole setup requires a total of 4 ADC lines, which fortunately the PIC18F2525 has.
Now... since efficiency is essentially output power (Pout) divided by input power (Pin), we determine the efficiency in percentage form as: Eff = Pout/Pin*100, which for my circuit was 85%. Of course, to get this high I went through days of tuning, calculating, recalibrating, redesign, theoretical research, until finally, I made it here!
Let there be LIGHT
The buck converter seems to have no problem driving a 25 watt halogen. This light bulb gets too hot to get close too, but the MOSFET, inductor, and switching diode, are all cool to the touch. In fact, I can't even tell if they're warmer than ambient by hand. By calculation, however, they should be about 5-10 degrees Celsius warmer than the room temperature.
My finished circuit has to have four independent circuits all potentially driving a 25 watt load. It is very important when space is limited, and power control is high, to have very good efficiencies.
While a set of formulas and a lot of electrical theory background would allow one to calculate the components' values which would yield the highest efficiencies, what happens when the situations dynamically change? In my example, the circuit must be able to take an input of any voltage from 3.6 to 25 volts. To complicate matters, the load output (LED, light bulb, etc.) may be selected arbitrarily. If the circuit has the power to drive it, then it needs to drive it! AND... it needs to do so with constant current regulation and overload protection.
To achieve the constant current part, I implemented a proportional-integral-controller, which automatically adjusts to maintain the brightness by adjusting the PWM duty cycle, based on the current output, measured by the ADC. The circuit does this over 10,000 times per second! Additionally, the circuit performs what I call, "experiments". These are it's own things it does, to maximize the efficiency. It attempts to modify the PWM frequency, MOSFET switching timers, and such, to raise that self measured efficiency rating. Then, with some genetic programming algorithms and a touch of intelligence, the software evolves to approach maximum efficiency.
ULTIMATELY: No matter what the input voltage, no matter what the output load, the circuit WILL adapt, staying cool, saving battery life, and controlling a lot of power!
Now I just have to build 3 more of these and cram them into a 1" square PCB! At least its double sided and 6-layered!