目 录CONTENT

文章目录

Synchronous Rectification Buck-Boost Digital Power Supply Based on STM32

zeruns
2024-11-12 / 0 Comment / 1 Like / 35 Views / 0 words / It is currently checking whether it has been included...

A four-switch Buck-Boost digital power supply based on STM32G474, supporting TypeC interface PD decoy input and DC5.5 interface input, with input/output voltage up to 48V10A. This is my graduation project, now open-sourced, including schematic, PCB, program source code, case 3D model, etc.

做得一般,勿喷,欢迎友好交流。

Demo video:https://www.bilibili.com/video/BV1Ui421y7ip/

Based on CH32V307 smart electronic load open source, embedded competition work open source:https://blog.zeruns.tech/archives/785.html

本项目的立创开源平台开源链接:https://url.zeruns.tech/noGf0

电子/单片机技术交流群:820537762

The download address of the materials is at the end of the article.

Source Article URL:https://blog.zeruns.tech/archives/791.html

Introduction

This article designs a synchronous rectification Buck-Boost digital power supply based on STM32, the power circuit of which consists of MOSFET driving circuit, 4 switch Buck-Boost circuit, signal conditioning circuit, PD fast charging protocol circuit, auxiliary power circuit, MCU control circuit, etc.

The power supply can be powered through DC interface or Type-C interface, and the Type-C interface supports communication with the charger through PD fast charging protocol, automatically requesting and obtaining the maximum 20V working voltage. The power supply uses STM32G474 MCU to monitor the input and output voltage and current in real time, and adjusts the output PWM duty cycle through PID control algorithm, as well as realizes overvoltage and overcurrent protection. It can also sample the motherboard temperature to achieve overtemperature protection. In addition, it can display the power parameters in real time through the OLED screen, and set the output voltage and current through the rotary encoder and button, or communicate with the host computer through another Type-C interface to view the power parameters and waveforms in real time.

Design Performance Parameters

​ 电源设计性能参数如下表:

Item Specification
Input Voltage Range 12Vdc~48Vdc
Input Current Range 0~10A
Maximum Output Power 450W
Output Voltage Range 0.5Vdc~48Vdc
Output Current Range 0~10A
Output Voltage Ripple 峰峰值≤200mV
Switching Frequency 181.333kHz

Physical object photo

Using VOFA+ as the host computer software, you can monitor real-time power supply parameters (input voltage and current, output voltage and current, motherboard temperature, MCU temperature, power conversion efficiency, etc.) and waveform changes as shown below.

System Framework Diagram

Hardware Circuit Design

Component Selection Calculation

Inductor Calculation

​In a synchronous Buck-Boost power supply, the calculation of inductance needs to consider the working conditions under both Buck and Boost modes to ensure that the circuit can meet the requirements in both modes. Typically, the selection of inductance is based on the mode that requires the higher inductance.

​When the power supply operates in Buck mode (voltage reduction), assuming the maximum input voltage is 48V and the minimum output voltage is 5V, the minimum PWM duty cycle is calculated:

D_{min} = \frac{V_{out\_min}}{V_{in\_max}} = \frac{5V}{48V} = 10.417\%

​Define the inductance current ripple (25% of the maximum rated current ripple, with the maximum rated current set as 10A):

\Delta I_L = 25\% \cdot I_{out\_nom} = 25\% \times 10A = 2.5A

​Calculate the minimum required BUCK inductor:

L_{minBuck} = \frac{V_{out\_min}}{\Delta I_L \cdot f_{switch}} = \frac{5V}{2.5A \times 181333Hz} \times (1 - 10.417\%) \approx 9.88\mu H

​When the power supply operates in BOOST mode (voltage boosting), with the rated input voltage of 24V as the calculation point, calculate the PWM duty cycle:

D_{Bo} = 1 - \frac{V_{in\_nom}}{V_{out\_max}} = 1 - \frac{24V}{48V} = 50\%

​In Boost mode, when taking 1A (I_{minb}), Boost enters continuous conduction mode (CCM), calculate inductance:

L_{minBoost} = \frac{V_{out\_max} \cdot D_{Bo}(1-D_{Bo})^2}{2 \cdot I_{minb} \cdot f_{switch}} = \frac{48V \times 50\% \times (1 - 50\%)^2}{2 \times 1A \times 181333Hz} = 16.544\mu H

​Based on the calculated results derived from the formula, the minimum inductance value required to meet the predetermined ripple current requirement is determined. To ensure that this condition is met, an inductor with a value slightly higher than the calculated value should be selected. At the same time, it is essential to ensure that the saturation current of the selected inductor can withstand the highest peak current in the circuit. Since the efficiency factor was not considered in the calculation process, the actual duty cycle and peak current may be lower than the theoretical calculated values. Therefore, when making a selection, a certain safety margin should be taken into account to adapt to various conditions that may arise under actual working conditions.

​Taking into account the above factors, this design chooses a 1770 surface-mount package inductor with a saturation current of more than 10A and an inductance of 22μH as the inductor component for the BUCK-BOOST circuit.

Capacitance Calculation

To achieve a better output voltage ripple, the designed voltage ripple is taken as 50mV.

\Delta V_{out} = 0.05V

Given the previously selected inductor of 22μH, the calculation here will also use this inductance value:

L_{BB}=22\mu H

Calculate the minimum capacitance required for operation in BUCK step-down mode and BOOST step-up mode, respectively, as C_{minBuck} and C_{minBoost}:

C_{minBuck}=\frac{V_{out\_min}\cdot(1-\frac{V_{out\_min}}{V_{in\_max}})}{8\cdot L_{BB}\cdot \Delta V_{out}\cdot {f_{switch}}^2}=15.48\mu F
C_{minBoost}=\frac{I_{out\_nom}\cdot(1-\frac{Vin\_min}{Vout\_max})}{\Delta Vout\cdot fswitch}=413.6\mu F

The design requires a certain margin, as well as lower output ripple, so a low ESR 220μF solid-state capacitor is selected in conjunction with a 470μF conventional electrolytic capacitor, totaling 690μF.

MOS Selection Calculation

Within the rated input and output voltage range, calculate the effective value of the input MOS current as:

i_{mos\_rms}=7.098A

In the MOSFET selection, the rated current I_D of the MOS tube must be at least twice the maximum current that flows through the MOS tube (to prevent damage from excessive current during fault or short circuit conditions).

2×i_{mos\_rms}=14.196A

In the selection of MOSFET, the rated voltage V_{DS} should be greater than 1.5 times the maximum input voltage (to prevent spike breakdown).

1.5×Vin\_max=72V

After referring to the previous calculations, for conventional application scenarios, a MOSFET with a rated current exceeding 15 amperes (A) and a voltage rating of 100 volts (V) can be selected. The selection for the lower MOSFET should be the same as for the upper MOSFET. Considering the heat dissipation situation, to minimize energy loss during conduction and switching processes, MOSFETs with low on-resistance (R_{DS(on)}) and low output capacitance (C_{oss}) should be given priority.

The MOSFET model selected for this design is the CJAC80SN10, produced by Jiangsu Changjing Technology Co., Ltd., which is a domestically produced MOSFET. It has a drain-source voltage rating (V_{DS}) of 100V and a maximum drain-source current (I_D) of 80A. Its on-resistance (R_{DS(on)}) is as low as 6.2mΩ, which is beneficial for reducing power loss when the device is in the on-state. Additionally, the output capacitance (C_{oss}) of this device has a typical value of 420pF, which is advantageous for reducing dynamic losses during switching transitions. Therefore, the CJAC80SN10 not only meets the electrical characteristics required by the project but also effectively reduces energy loss and improves the overall efficiency of the system.

Power Supply Board Circuit Design

Main Power Circuit

The following diagram represents the main power circuit of the synchronous BUCK-BOOST power supply. The input is on the left side; the synchronous BUCK step-down circuit consists of MOSFETs Q2 and Q4 and inductor L1. The synchronous BOOST step-up circuit is made up of MOSFETs Q3 and Q5 and inductor L1. Each MOSFET has a 10kΩ resistor in parallel between the gate and source terminals to ensure that the gate is not floating and to prevent unintended conduction.

The main power circuit has a symmetrical structure on the left and right sides. Both the input and output ends are equipped with one 470μF/63V aluminum electrolytic capacitor and one 220μF/63V solid-state aluminum electrolytic capacitor. In addition, there are two small surface-mount MLCCs (Multilayer Ceramic Capacitors) with parameters of 10μF/50V to filter high-frequency noise interference at the ports. R9 and R10 serve as dummy loads for the input and output ports, allowing for the rapid dissipation of residual energy in the circuit when the power is disconnected. R13 and R14 are high-precision 5mΩ resistors used for current sampling, with a subsequent differential amplification circuit to amplify the input and output current signals. CNT1 and CNT2 are the output terminals. L1 and L2 are surface-mount 1770 package and through-hole magnetic core inductor packages, respectively; only one should be soldered, and both are drawn to facilitate testing the effects and performance of different inductors.

Power Supply Input and Fast Charging Protocol Circuit

The following diagram represents the power supply's input interface and PD fast charging protocol communication circuit.

The power supply input features two types of interfaces: a DC5.5*2.5mm female connector and a Type-C female connector. The Type-C interface supports various fast charging protocols such as BC1.2, PD3.0/2.0, etc. The fast charging protocol chip used is the CH224K, which can communicate with fast charging chargers to output a voltage as high as 20V and supports up to 100W of power.

Diodes D1, D3, and D4 serve to prevent voltage backflow from the DC interface to the Type-C interface; the design does not allow both interfaces to be connected simultaneously. Diode D5 is used for reverse polarity protection. FH1 is the power input fuse holder, which accommodates a 12A fuse.

Driver Circuit

In the design of a synchronous BUCK-BOOST power supply, both the BUCK and BOOST circuits include high-side N-MOSFETs. Traditionally, the driving of these high-side N-MOSFETs is accomplished using transformer-isolated drivers, but this method increases the complexity of the circuit and enlarges the size of the circuit board.

This design selects two MOSFET driver chips with built-in bootstrap circuit functions, EG3112, to drive the MOSFETs of the BUCK and BOOST circuits. The EG3112 is a non-isolated complementary dual-channel driver chip; its 2A output driving current capability ensures that the MOSFET can turn on quickly; the chip also has a built-in dead-time control function to prevent shoot-through of the output driving signals, thereby enhancing the stability of the system. The specific circuit is shown in the figure below.

Taking the driving of the MOSFET in the BOOST step-up circuit as an example, PWM2L and PWM2H are PWM signals output from the STM32G474 microcontroller, which are sent to the LIN and HIN pins of the EG3112 driver chip. LO is the lower MOSFET driving signal output, and the driving resistor has a value of 10Ω. HO is the upper MOSFET driving signal output, and the driving resistor also has a value of 10Ω. D7 is the bootstrap diode for the upper MOSFET driving circuit, while diodes D9 and D11 are used to quickly discharge the gate charge, speeding up the turn-off speed of the MOSFET. C14 is the bootstrap capacitor.

The role of the driving resistor is to reduce oscillations that may occur on the PCB traces, distributed capacitance, inductors, and other components during the MOSFET switching process. By using a series resistor, these oscillations can be mitigated, improving the stability and reliability of the system.

Auxiliary Power Supply

The following diagram is the schematic of the power supply board's auxiliary power supply circuit.

The first-stage 12V output auxiliary power circuit uses the BUCK-type power chip TPS54360B, which integrates a high-side MOSFET, for its design. According to the chip's datasheet, a pull-down resistor on the RT pin can set the switching frequency; a 110kΩ resistor is selected here, corresponding to a switching frequency of 876.5kHz. A higher switching frequency allows for the use of a smaller inductor to save space. Based on this frequency, the inductance value should be greater than 9.75μH, so a 10μH inductor is selected, and SS310 is chosen as the freewheeling diode. C26 and C27 are input filter capacitors; feedback divider resistors R19 and R25 create a 0.8V reference voltage for the chip's FB pin to ensure the output voltage is maintained at 12V. C18 and C19 are the filter capacitors for the first-stage 12V output auxiliary power supply. The first-stage 12V output is mainly used to supply the input of the second-stage 6V step-down circuit, as well as the MOSFET driver circuit and cooling fan.

The second-stage 6V output auxiliary power circuit uses the synchronous rectification BUCK-type power chip SY8205, which integrates a MOSFET, for its design. According to the datasheet, the chip's switching frequency is fixed at 500kHz, and a 10μH inductor is selected for the auxiliary power BUCK circuit. C21 and C22 are input filter capacitors; feedback divider resistors R23 and R26 create a 0.6V reference voltage for the chip's FB pin to ensure the output voltage is maintained at 6V. C24 and C25 are the filter capacitors for the second-stage 6V output auxiliary power supply. Since directly using a linear regulator to step down from 12V to 5V would result in significant loss, a switch-mode power supply is first used to step down to a voltage close to 5V, and then a linear regulator is used to step down to the target voltage. This approach ensures higher efficiency and lower output ripple.

The second-stage output of 6V is stepped down to 5V by the linear voltage regulator chip AMS1117-5 to serve as the third-level auxiliary power supply. The voltage reference chip REF3033 is used for signal conditioning, OLED display, USB communication, and other functional circuits.

5V DC is stepped down to 3.3V by the linear voltage regulator chip AMS1117-3.3 to serve as the fourth-level auxiliary power supply, used for MCU, buzzer, Flash chip, and other circuits.

The voltage reference chip REF3033 outputs a 3.3V reference voltage for the MCU's VREF pin, serving as the reference voltage for the MCU's built-in ADC to improve the accuracy of ADC sampling.

Signal Conditioning Circuit

As shown in the diagram above, the input and output voltage sampling and signal conditioning circuit of this design utilizes differential amplification technology. The differential amplification topology can effectively reduce the interference of high-frequency noise in the switching power supply on the signal conditioning circuit, enhancing the stability and reliability of the signal. In this circuit, the low-offset operational amplifier GS8558-SR is selected to improve the precision of the conversion. The GS8558-SR op-amp has excellent DC accuracy and low bias current characteristics, which are crucial for improving the performance of the entire signal conditioning circuit.

Differential amplification circuit feedback resistor:

R_{38}=4.7kΩ
R_{36}=75kΩ

Calculate the differential amplification gain:

K_V=\frac{R_{38}}{R_{36}}=0.062667

The MCU's ADC has a maximum sampling voltage of 3.3V, which is the reference voltage output by the voltage reference chip, so the maximum input and output voltage values that can be sampled can be calculated as follows:

V_{max}=\frac{3.3V}{K_V}=52.66V

To better suppress the interference of high-frequency noise from the switching power supply on the differential amplification circuit, decoupling capacitors C40 and C41 are added to the power supply pins of the operational amplifier for filtering. Capacitors are selected as MLCCs (Multilayer Ceramic Capacitors), which have a lower ESR (Equivalent Series Resistance) and ESL (Equivalent Series Inductance), thus providing better filtering effects for high-frequency noise. Additionally, an RC low-pass filter circuit is formed by adding resistor R35 and capacitor C39 at the output end to filter out high-frequency noise.

As shown in the diagram above, the input and output current conditioning circuits use a differential amplification method, and the output current sampling resistor is:

R_{14}=5mΩ

The feedback resistors in the differential amplification circuit are:

R_{48}=6.2kΩ
R_{46}=100Ω

Calculate the differential amplification gain:

K_I=\frac{R_{48}}{R_{46}}=62

That is to say, for every 1A of current output, there is a voltage of 310mV.

Given that the MCU's ADC has a maximum sampling voltage of 3.3V, provided by the voltage reference chip, you can calculate the maximum input and output current values that can be sampled as follows:

I_{max}=\frac{3.3V}{K_I \times R_{14}}=10.65A

MCU Control Circuit

The digital power supply design in this project uses the STM32G474RET6 chip as the controller, which has the notable features of a simple peripheral circuit, diverse control methods, and excellent expansion capabilities. To achieve an accurate clock signal, the controller uses an external crystal oscillator X1, which is a quartz crystal oscillator with a frequency of 25 megahertz (MHz). In addition, the circuit also includes multiple filtering capacitors, including C45, C51, C56, C46, and C52, which are used for different digital power supply pins of the microcontroller (MCU) to ensure power stability and reduce noise interference. Resistor R49 and capacitor C49 form a power-on reset circuit, and SW1 is the MCU reset button. U11 is a USB-to-serial chip, model CH340C, connected to the second Type-C interface, with the serial port connected to the MCU's USART1 interface. U10 is a Flash memory chip, model W25Q64, used to store parameter settings and other information, connected to the MCU's SPI3 interface. Q6 is the driving MOSFET for the buzzer, used to control the buzzer, with the MOSFET gate connected to the MCU's PB5 port. Terminal H1 is the SWD programming port. H2 and H4 are PH2.0 connectors, used to connect with the control panel, with connectors reserved for the USART2 interface, which can conveniently replace the control panel with a serial screen, and can also add an ESP32 to increase networking and wireless control functions. D13 is a 5V reverse polarity protection diode.

Cooling Fan Drive and Motherboard Temperature Sampling Circuit

The schematic diagram of the motherboard temperature sampling circuit and the cooling fan drive circuit is shown below. The principle of the power supply motherboard temperature sampling is to use an NTC thermistor R2 in series with a pull-down resistor R4 to output a voltage divider to the MCU's ADC port for sampling. The NTC thermistor used has a resistance value of 10kΩ and a B value of 3950K.

The cooling fan is driven using an N-MOSFET, model AO3400. A diode D2 is reverse-biased in parallel on the fan interface to prevent damage caused by the back electromotive force (back EMF) generated by the motor. When the motor is powered off, due to rotational inertia, the rotor of the motor will not stop immediately but will continue to rotate and generate a voltage. This voltage can potentially damage the transistors or integrated circuits in the circuit, especially when the motor is connected to these components through a semiconductor switch, such as an MOSFET.

Control Panel Circuit Design

The schematic diagram of the control panel circuit is shown below. SW1 is a rotary encoder used for setting parameters and the like, while SW2 and SW3 are buttons; SW2 is used to switch settings, and SW3 is used to control the power output's on and off. LED1 is the system operation status indicator light, which blinks at intervals of 500ms during normal operation. LED2 is the output status indicator light, which lights up when the output is on and turns off when the output is off. OLED1 is the OLED screen, used to display power supply parameters and status information, etc.

User Manual

You can adjust the output voltage and current values using the buttons and rotary encoder. As shown in the figure below, the inverse color display indicates the current setting digit. By rotating the encoder, you can increase or decrease the value. Pressing the encoder button allows you to switch to the next digit for setting. The SW2 button is used to switch between different settings. The set data will be automatically saved to the Flash memory chip, and the data will be read from the chip during the next power-up.

The SW3 button is used to turn the power output on or off.

You can switch to the data display page to view the current input and output voltage and current of the power supply, as well as information such as motherboard temperature and MCU temperature, as shown in the figure below.

You can switch to the settings page to configure the threshold values for over-temperature, over-current, and over-voltage protection, as shown in the figure below. The data set will be automatically saved to the Flash memory chip, and the data will be retrieved from the chip during the next startup.

Ripple Test

Use an electronic load and oscilloscope to test the power supply output performance and output ripple, as shown in the figure below. At an input of 36V and an output of 12V at 2A, the peak-to-peak ripple measured is approximately 42mV, as illustrated in the figure below.

Efficiency Test

The power supply conversion efficiency when inputting 20V and outputting 12V at 10A is measured to be 92%, as shown in the figure below.

MOSFET Gate Waveform

The following table shows the conversion efficiency at various input and output voltages, with the highest efficiency reaching 94.3%.

Input Voltage (V) Input Current (A) Input Power (W) Output Voltage (V) Output Current (A) Output Power (W) Efficiency (%)
20.003 4.035 80.712 15.010 5.000 75.050 92.985
47.999 5.335 256.075 24.040 9.900 237.996 92.940
48.000 7.875 378.000 36.020 9.900 356.598 94.338
48.000 9.860 473.280 45.030 9.900 445.797 94.193
23.998 8.835 212.022 48.070 4.000 192.280 90.689
23.998 9.830 235.900 35.998 6.001 216.024 91.574
12.099 9.166 110.899 24.070 4.000 96.280 86.817
20.008 2.645 52.921 4.970 9.000 44.730 84.522
20.008 10.550 211.084 24.030 8.000 192.240 91.073
36.000 6.418 231.048 24.010 9.000 216.090 93.526
36.000 10.540 379.440 35.950 9.800 352.310 92.850

Efficiency Test

The power supply conversion efficiency when inputting 20V and outputting 24V is tested on the gate waveforms of each MOSFET.

BUCK circuit upper and lower tube to ground voltage waveform diagram:

BOOST Circuit Upper and Lower Tube to Ground Voltage Waveform Diagram:

元器件购买地址

这个项目用到的大部分元件购买地址都在这里:

建议在立创商城里购买元器件:https://activity.szlcsc.com/invite/D03E5B9CEAAE70A4.html

在立创开源链接里的BOM表那点立即到立创商城下单可将用到的元器件一键导入到购物车。

The following links include materials such as: EasyEDA project files, schematic diagram PDFs, datasheets for each chip, source code project compressed package, and some reference program codes.

123云盘不限速下载地址:https://www.123pan.com/ps/2Y9Djv-8yevH.html

百度网盘下载地址:https://url.zeruns.tech/MW2d1

项目程序Gitee开源地址:https://gitee.com/zeruns/STM32-Buck-Boost

项目程序GitHub开源地址:https://github.com/zeruns/Synchronous-Rectification-Buck-Boost-Digital-Power-Supply-Based-on-STM32

求点个Star和点个赞。

Known Issues

  1. The SY8205 chip in the auxiliary power supply enters PFM (Pulse Frequency Modulation) mode at low load, resulting in a lower frequency and thus generating slight noise.
  2. The PID control program for constant current mode is not well written; it only remains stable under pure resistive loads. (Constant voltage mode is not problematic.)

推荐阅读

1

Comment Section