ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to Build a Buck Converter with a PIC Microcontroller

Updated on July 20, 2011

Constant Current Verification

Close up photograph of current (measured in milliamps) by the microcontroller in the buck converter circuit.
Close up photograph of current (measured in milliamps) by the microcontroller in the buck converter circuit.

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!

Overview of the microcontroller side of the circuit. The microcontroller multiplexes the 4 7-segment displays as well as controlling the proportional-integral software to monitor the buck converter.
Overview of the microcontroller side of the circuit. The microcontroller multiplexes the 4 7-segment displays as well as controlling the proportional-integral software to monitor the buck converter.

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!

Visible here is the main components of the buck converter, like the inductor coil, and switching Schottkey diode. The halogen bulb is brightly illuminated by it's high current output.
Visible here is the main components of the buck converter, like the inductor coil, and switching Schottkey diode. The halogen bulb is brightly illuminated by it's high current output.

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.

Overview of entire breadboard. All components can be seen here. The buck converter and ADC circuits are at the top, while the microcontroller and digital readout are at the bottom.
Overview of entire breadboard. All components can be seen here. The buck converter and ADC circuits are at the top, while the microcontroller and digital readout are at the bottom.

Auto Calibration

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!

Comments

    0 of 8192 characters used
    Post Comment

    • piccontroller profile image

      piccontroller 

      3 years ago

      what is the rating this buck converter?

    • npolynomial profile imageAUTHOR

      npolynomial 

      6 years ago

      30%!! Don't feel bad, it's a start. I progressively refined this circuit originally from 30%. When I reached 65% efficiency I was pretty excited, and it took a lot more work to get any higher. You need to choose quality parts and keep all traces on the circuit board to a minimal, lots of copper. On a breadboard efficiencies will always be less than on the finished circuit board. I never drew the schematic, but when I get some time I will post one.

    • profile image

      Jitin 

      6 years ago

      can you please mail me the circuit of just your buck converter. I wanna make a buck converter with high efficiency but could get only 30% efficiency

    • profile image

      Henk Hofstra 

      7 years ago

      hi

      Can you share this Project with me? I am looking for a buck convertor for a wind-mill.

      Thanks in advance.

      Henk@can-west.nl

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)