PIC10 Buck converter

Well! My new PicKit3 has just arrived and in my last RS order, I got some PIC10F320 chips. The reason I chose these chips out of the massive array of PIC microcontrollers is because it is from the cheapest range (PIC10), features a hardware PWM module and an integrated 8bit ADC.

I’m always interested in low power power converter implementations and one of the simplest converters is a standard non-isolated buck converter. This kind of converter is commonly used to reduce the voltage of a supply in an efficient manner – compared to linear regulation that is!

Theory
A switching buck converter is based around a switching transistor, a diode, an inductor and a smoothing capacitor. The switching cycle can be split into two different subcycles, the transistor on time and the transistor off time.

On cycle:
During the on cycle, the transistor is on allowing current to flow through the transistor, the inductor and into the load along with charging up the capacitor in parallel with the load.

ontime
Current flow during on time.

During this on time, the diode is reverse biased and therefore doesn’t conduct. Current flows through the inductor L1 and rises linearly.

ontimesim1.png
Current linearly rises. Inductor value increased to make simulation closer to theory.

As can be seen in the image above, the current doesn’t rise completely linearly. This is due to the on resistance of the switching MOSFET. In reality, this will cause large losses during the on time of the MOSFET.

The capacitor buffers these large current spikes, ensuring the load sees a much smoother current and voltage.

Off cycle:
When the transistor is turned off, current commutates from the MOSFET to the diode, ensuring that current doesn’t instantaneously change across the inductor (impossible!). During this time, current in the inductor linearly decreases and the capacitor once again buffers this change and ensures the load sees a smooth voltage and current.

offtime
Current flow during off time

offtimesim1.png
Current decreasing through the inductor

As can be seen in the simulation above, the current through the inductor reaches zero for a small period of the cycle. This mode of operation is known as discontinuous mode and is generally advised against. In this case, increasing the load will change mode of operation to continuous mode.

tsim1.png
Increasing the load increases total current though di/dt stays constant as this is determined by the inductance and switching frequency

As can be seen in the image above, operation is now continuous as inductor current doesn’t reach zero before the next switching cycle.

Operating conditions:
The output voltage is determined by the pulse width used to modulate the switching transistor. For ease of output design, I’ve used a P MOSFET, meaning when the gate is low, the transistor is on and when the gate is high, the transistor is off. If was to use a standard N MOSFET, I’d need some form of bootstrapping circuit to ensure I could bring the gate to Vgs(th) larger than the source. Without a boot strapping circuit, the source would only be able to go to Vcc-Vgs(th), limiting the upper output voltage. Under the ideal condition of lossless components, One could set the pulse width to a constant value and expect the output voltage to stay constant. Sadly, real life components aren’t ideal and feature finite resistances, for example the on resistance of a MOSFET or the winding resistance of an inductor. For this reason, a buck converter makes a great device to be controlled by a microcontroller in closed loop fashion. Proper buck converters will usually use some form of system controller e.g. a PI or PID controller.

Implementation
In my implementation, I’m using a quite slow controller that consists of incrementing and decrementing the duty cycle, when compared to a reference. This kind of controller is only one step up from a “bang bang” controller which would set a constant duty cycle and merely gate it. That kind of controller is even less efficient and can produce lots of switching noise which is dependent on the load.

The PIC10F320 only features 64bytes of RAM and 256bytes of program data so it was a reasonable challenge writing a program for this though it would’ve been much less restricting to have written in assembly vs C. Compiling with the free XC8 compiler uses up 12 bytes of RAM and 102 bytes of program memory. Loads of space left!

The data consumption could be reduced as I control the stepped load through software.

schematic
Buck converter schematic

RA0 is connected internally to PWM1 which is controlled by TMR2. RA1 is configured as a digital output and when set low, essentially pulls the stepped load to ground through D2. RA2 is used as an ADC input which allows the microcontroller to monitor the voltage at the output of the converter.

It is reasonably evident that this controller is poor from the amount of ripple present at the output. Peak to peak ripple under normal conditions is ~300mV and over/undershoot to a step response is ~500mV.

ripple2-step.pngRipple due to a short step response

ripple3-steplonger.pngRipple due to a longer step response – note the undershoot

As can be seen, the output has quite a lot of ripple on and is pretty noisy. This is mainly due to the use of poor components though scoping the duty cycle at the output shows that is changes quite fast. The speed of modulation could be changed by slowing down the controller. This controller could be used for a multitude of different applications, one of which could be used as a constant current controller for an LED.

P1010933.JPG
Implementation of the buck converter. Ignore the STM8 board, this is for power only!

The code for this buck converter can be found on my Github!

Advertisements

One response to “PIC10 Buck converter

  1. Pingback: PIC10 LED Buck Converter | Harris' Electronics·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s