Fork me on GitHub

Project Notes

#288 BasicInvertingBuckBoostAvrControl

Build and test an inverting buck-boost converter controlled by an ATtiny85.

Build

Notes

The basic inverting buck-boost circuit uses an inductor to build up an electromagnetic field during the switch-on period, and dump this energy into the capacitor during the switch-off period. The diode provides steering.

Build

I’ve based this circuit on the DIY Buck/Boost Converter video by GreatScott!

An overview of the circuit:

  • basic inverting Buck-Boost configuration
  • n-channel MOSFET low-side switching
  • ATtiny85 controls the MOSFET with PWM output proportional to the actual/desired output differential
  • rail-to-rail OpAmp provides actual voltage feedback, scaled to 0-5V for the ATtiny
  • L7805 taps a 5V supply for the ATtiny and OpAmp

It is important to note that the output voltage is inverted. Because low-side switching is used, it is also not referenced to either the positive or negative supply rails.

Modifications to the Original Circuit

I’ve added additional capacitive smoothing on the 5V rail. This counters the effect of the switching circuit interfering with a stable ground-5V supply.

The voltage dividers on the feedback circuit have been boosted to larger value resistors (100kΩ/22kΩ) from the original (20kΩ/5.1kΩ). This allows for a minimum voltage of around 1.7V.

I’ve only breadboarded this so far, and it works reasonably well - at least as an investigation of how inverting buck-boost converters actually work.

PWM Control

The BasicInvertingBuckBoostAvrControl.ino sketch is based on on original script from instructables.

The original sketch uses 8-bit Timer/Counter0 Fast PWM with no clock prescaling (CS=0b001). Using (non-default) internal clock of 8MHz, this generates a PWM signal on PB1 (pin 6) of 31.25 kHz [measured: 31.72 kHz].

It uses analogWrite to adjust the duty cycle:

  • value: the duty cycle: between 0 (always off) and 255 (always on), but is limited in code to a maximum of 203 max (~80% duty cycle).
  • note that analogWrite resets timer COM settings, so much of the setup in the original sketch is redundant

It is important to set the fuses on the ATtiny for the higher clock in order to achieve sufficient switching frequency - see LEAP#255 AvrHardwarePWM/ATtiny for details.

Performance Analysis

Settings (buck mode):

  • Vout = -9V
  • Vin = 12V
  • fs = 31.72 kHz
  • Rload = 10kΩ

Theoretical Performance - Buck Mode

Required duty cycle:

D = Vout/(Vout - Vin) = 42.86%

Output ripple voltage:

Ia = Vout/Rload = 0.9mA

∆Vc = Ia * D / (fs * C) = 0.05528mV

Average input current:

Is = Ia * D / (1 - D) = 0.68mA

Average inductor current:

Il = Ia / (1 - D) = 1.58mA

Inductor peak-peak ripple current:

∆Ii = Vin * D / (fs * L) = 4.913A

That’s quite a spike

Actual Performance

Here are some scope traces of the PWM and control signals in action.

  • CH1 (yellow).
  • CH2 (blue) is the feedback FB input
  • CH3 (red) is the buffered VSET input

In the first case, VREF is adjusted to the max PWM duty cycle (hitting the limit of 80%):

scope_max_out

VREF adjusted to a mid-point:

scope_mid_out

Construction

Breadboard

Schematic

Build

Credits and References

About LEAP#288 PowerATtinyArduino
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.