Today we will learn buck type switching power supply.

Why do we need a switching power supply

In the previous linear regulator tutorial, we learned how to use linear regulators like L7805. They are simple to use, but inefficient.

For example, if you try to power a linear regulator at 26 volts with an output voltage of 5 volts and a current of 3 amperes, you will end up producing 63 watts of heat. Such a huge waste of energy is unacceptable.

For high power items, you want to use what’s called a switching power supply. There are different types of switching power supplies that allow you to convert one voltage to another.

This paper mainly discusses Buck or step-down switching power supply. It is a power supply that can reduce a higher voltage to a lower voltage.

The principle of

Let’s start with a simple circuit. The circuit consists of a 10 volt DC power supply in series with a switch.

It doesn’t matter what the switch is. It could be a bipolar transistor, a MOS tube, or even a crazy person pushing a mechanical switch.

For efficiency reasons, the switches should use field effect (MOS) tubes. But now we still use the general switch symbol in the circuit. Next, let’s use a 50% duty cycle pulse width modulation (PWM) signal to control the opening and closing of the switch.

This will give us an output of a 50% duty cycle square wave, half the time at 10 volts, half the time at 0 volts, so that the average voltage is 5 volts.

Now let’s add an LC low pass filter. An inductor resists a sudden change in current and a capacitor resists a sudden change in voltage. The overall effect is that our LC low pass filter flattens the square wave and we get a relatively stable DC current of 5 volts on the output.

But there’s a problem with the top circuit. Suppose the switch has been turned off and our power supply is transmitting some current. This means that current is flowing through the inductor.

Now let’s turn off the switch. Since the current in the inductor cannot be changed immediately, this means that current is still flowing through the inductor for a short period of time after the switch is off.

But the left side of the inductor is not connected to anything, so it accumulates a lot of negatively charged electrons (which flow in the opposite direction to the conventional current). This creates a large negative voltage burr.

The voltage burr can reach hundreds or even thousands of volts.

Such a large negative voltage burr could burn out any switch connected here. If you want to learn more about this phenomenon, check out my other article: Inductor Burrs. In that article, one solution was to add a diode. With the diode in place, current can now flow in a complete path whenever the switch is turned off, and the voltage behind the switch is almost never below zero, because the diode is present, and the voltage to the left of the inductor is at most 0.7 volts below ground (diode drop voltage), and the Schottky diode is even lower.

Below is a classic step-down switching power supply circuit. You can use this basic circuit to reduce high Voltage DC to low Voltage DC in a more efficient way than a Linear Voltage Regulator.

Built with Arduino

We used Arduino to build a Buck Converter. This circuit is only used to learn the function of buck type switching power supply, it has no practical use. We can use the Square wave (PWM) output of Arduino as the control signal to build a simple buck type switching power supply on the bread.

There is no feedback

We use p-channel FET IRF9540 to switch on and off the main power supply, here I use the adjustable power supply output of 12 volts. Because the driving capacity of Arduino is insufficient to drive IRF9540 directly, we use an NPN type BJT transistor S8050 to drive IRF9540. We programmed the Arduino to output a control square wave at 31 K Hertz. The rotation potentiometer can change the duty cycle of the output square wave. In this way, when the Output of the Arduino D3 pin is high, the three pipe conducts, pulls down the gate level (G) of the N-channel field pipe, and conducts the field pipe; When the D3 output is low, the triode is disconnected, the field tube gate level is high, and the field tube is off.

One pin of the potentiometer is connected to the 5V pin of the Arduino, and one pin is grounded, so that the middle pin of the potentiometer can output 0 to 5 volts.

A0 pin: connect the middle pin of the adjustable potentiometer. Used to adjust the duty cycle of square waves.

Pin D3: Output 31K Hz control square wave, used to control switch IRF9540 off.

/* * This is the example code of the buck type switch power supply made by arduino. * We can also use Aruino Uno. Nano. * No feedback is connected here. */ int potentiometer = A0; Int PWM = 3; void setup() { pinMode(potentiometer, INPUT); pinMode(PWM, OUTPUT); / / pin 3 and 11, output PWM square wave frequency: 31372.55 Hz TCCR2B = TCCR2B & B11111000 | B00000001; } void loop() { float voltage = analogRead(potentiometer); int VALUE = map(voltage, 0, 1024, 0, 254); analogWrite(PWM, VALUE); }Copy the code

We assembled the circuit on the breadboard, using a 12-volt light bulb as the load. Oscilloscope probe CH1 is connected to the control square wave of the Arduino output, and CH2 is connected to the voltage output end. Adjust the potentiometer to adjust the output voltage, you can see that the bulb also brightened.

This circuit can maintain a stable voltage under constant load. But if the load changes, the output current changes, causing the output voltage to change. If you want to keep the voltage constant when the load changes, you need a feedback system, which will monitor the output voltage. If the output voltage becomes low, the duty cycle of the output square wave can be increased, and if the output voltage becomes high, the duty cycle of the output voltage can be reduced to keep the output voltage constant.

Have a feedback

We add a feedback system to our switching power supply to keep the output voltage constant as the load changes. We use Arduino to monitor the output voltage, and if it’s low, we increase the square wave duty cycle to increase the output voltage; If the output voltage is high, we reduce the duty cycle, thus reducing the output voltage. Because the circuit output voltage ranges from 0 to 12 volts, and the Maximum input voltage of the Arduino ADC is 5 volts, the output voltage cannot be directly measured. We need to reduce the output voltage to less than 5 volts, and we do this using a simple resistor divider circuit.

The complete circuit with feedback is as follows:

A0 pin: connect the middle pin of the adjustable potentiometer. Used to adjust the duty cycle of square waves.

Pin A1: Connect feedback resistance for monitoring output voltage.

Pin D3: Output 31K Hz control square wave, used to control switch IRF9540 off.

With feedback step-down switch source code as follows:

/* * This is the example code of the buck type switch power supply made by arduino. * We use Aruino Uno. Nano is also possible. * A0 pin: connect the middle pin of the adjustable potentiometer. Used to adjust the duty cycle of square waves. * A1 pin: Connect feedback resistance. * D3 pin: Output 31K Hertz control square wave. */ int potentiometer = A0; Int feedback = A1; int PWM = 3; int VALUE = 0; void setup() { pinMode(potentiometer, INPUT); pinMode(feedback, INPUT); pinMode(PWM, OUTPUT); / / pin 3 and 11, output PWM square wave frequency: 31372.55 Hz TCCR2B = TCCR2B & B11111000 | B00000001; } void loop() { float voltage = analogRead(potentiometer); float output = analogRead(feedback); If (output > voltage) {// VALUE = VALUE - 1; VALUE = constrain(VALUE, 1, 254); } else if (output < voltage) {// VALUE = VALUE + 1; VALUE = constrain(VALUE, 1, 254); } analogWrite(PWM, VALUE); }Copy the code

One-stop solution

The buck type switch power supply above, Rory so, and square wave, and feedback, very troublesome. There e are a variety of buck type switching power chip on the market, providing one-stop solution. For example, this chip LM2576T-ADJ, the use of feedback resistance can be changed in the case of load, to ensure the output voltage unchanged.

The input can be in the range of 40 volts. Do not apply higher voltage or you may burn the LM2576T-ADJ module. In this case, we do not need an external switch, as the LM2576T-ADJ already has one inside. After connecting the voltage feedback pin to the output voltage divider, the LM2576T-ADJ will change the duty cycle of the output control square wave according to the high and low of the output voltage to keep the output voltage constant. In this case, the Schottky diode is used because it has a low forward voltage drop.

Welding up

Things like this, with high currents, and some of the devices requiring as close as possible to the pins of the chip, we don’t want to do it on the breadboard. We use the hole board.

First, the LM2576T-ADJ is welded in the middle of the hole board, leaving plenty of space around it for other components to be installed.

The filter electrolytic capacitor at the input is welded within a centimeter or two of the chip.

The output diode and inductor are welded in the same way, keeping the component line as short as possible:

After welding the output filter capacitor:

When welding the feedback resistance, try to keep the lead back to the chip as short as possible.

The layout at the bottom of the board is more important than the top. Note that my ground is a straight line, and the two blue ones are 100 nF filter capacitors, one input and one output:

The final effect:

run

Everything is ready. I will use 10 volts as the input voltage for my switching power supply. I’ll use my adjustable electronic load to see how it provides different amounts of current.

If you do this at home, you can use a 5 ohm 10 watt power resistor as a load.

First, let’s check that the output voltage is what we want. He is perfect at 5 VDC!

Now, let’s take a look at this node in the circuit, which is called the switching node, or pin 2 of the LM2576-ADJ:

You can see the familiar square waves of 0 to 10 volts with a switching frequency of 50.65 kHz. But you can see that the duty cycle is 59.5 percent, instead of the theoretical 50 percent, and the load current is 1 ampere.

If I increase the load to 2 amperes, the duty cycle increases to 63 %. At 3 amperes, the power loss is greater, and the controller must change the duty cycle to 67% to maintain a stable output of 5 volts:

Remember when I said we got a perfect 5 VOLTS? That’s not really the case. Let’s change the oscilloscope coupling to ac coupling and amplify the waveform. You can see that there is a small ac component on the output, because our low pass filter is not perfect. We call this the output ripple of the power supply. At 1 ampere load, we have about 10 millivolts of ripple and noise.

If I increase the load current to 3 amps, the ripple becomes more noisy, reaching 16.7 mV:

If I increase the input voltage to 26 volts, the ripple goes up to 33 mV.

Ideally, we want this ripple to be as small as possible. For most applications, peak-to-peak values below 100 millivolts are fine. But in general, you don’t want to use switching power to power sensitive circuits such as radio receivers.

Now let’s calculate the efficiency of our power supply. It is compared with linear regulator.

From an input of 26 volts, my desktop power supply provides 0.6889 amperes to the DC converter.

My multimeter measured an output of 4.905 volts.

I set the load to exactly 3 amperes. If you are operating at home using a resistor as a load, be sure to use a multimeter to accurately measure the output current.

Plugging the data into the formula, we found that our power efficiency was 82%, which is very good! This is why switching power supplies are commonly used for currents greater than 1 ampere.