In order to minimize component count, stocked items in my junk box, and to improve efficiency as well as have software control of the power supply, I wanted to do away with inefficient, standalone linear regulators and instead use spare PWM pins on the microcontroller to generate voltages instead.

This library creates a simple feedback loop, where you specify the target voltage, and the microcontroller alters the PWM duty cycle to create the requested voltages.

In order to use this, you require the following in addition to your Arduino (prices are estimates based on 10/20 packs on Ebay):

  • Inductor (~$1.50)
  • Shottky diode ($0.50)
  • Output filter capacitor ($0.15)
  • N channel MOSFET ($0.25)
  • 2 Resistors ($0.30)

The MOSFET is connected to a PWM pin on the Arduino which has software control of the duty cycle. A resistor divider network is utilized to provide feedback to the Arduino via one of its ADC pins.

Calling the init() method of the library passes various parameters to it, such as the topology, target voltage, resistor divider values and the pins to use. This method only needs to be called once for each instance. Once initialised, you need to periodically call the regulate() method, which reads the voltage off the ADC pins and varies the PWM duty cycle accordingly.

This project was inspired by Spritemod's ucBoost.

Calculators & schematics for choosing component values are below:

LadyAda's DC/DC Boost Calculator

S. Przepioski's Buck Calculator
 

 

Todo

  • Add a "power good" method
  • Support buck-boost topologies.

Update 22 December, 2009

I played last night with connecting the supply of the boost converter to a 3.3V supply, and the output to the +5V line of the Arduino. Interestingly, the Arduino (Atmega168) self started from the 3.3V supply, without requiring a button to bootstrap the device (see Spritemod's ucBoost). This is quote cool, as it means you can run +5V projects from an 18650 battery.

I have noticed in buck mode that the best I can get out of the regulator is around 3V under the input voltage. My guess is that the N channel MOSFET is not being switched on fully. I'll have a crack at using a P channel MOSFET in a couple of weeks, when parts arrive.

Attachments