Design of single-phase online uninterruptible power supply based on STM32

According to the principle of UPS, an AC sine wave online uninterruptible power supply based on STM32 is designed. The system adopts mains power, outputs corresponding DC power through isolation transformer, autotransformer and rectifier module, and then connects to single-phase full-bridge inverter circuit after boosting through booster module to supply stable AC voltage to the load, which significantly improves the load regulation rate, The voltage sampling module collects the output voltage of the boost circuit in real time and feeds it back to the single-chip microcomputer, and uses PID algorithm to realize the voltage closed-loop control, which improves the reliability of the uninterruptible power supply system. The system has functions such as overcurrent protection, instant power switching, and battery undervoltage alarm.


Introduction
With the rapid development of science and technology, aerospace, communications, national defense, hospitals and other power-consuming departments, as well as important power-using equipment such as storage equipment, communication systems, have special requirements for power supply quality, such as voltage fluctuations, pulse interference and sudden Interruption may cause random storage data loss and program destruction, and even damage electronic devices [1]. Therefore, the stability and safety of power supply is of great significance. At present, UPS has been widely used in all walks of life that have higher requirements for city power [2].

The structure of on-line UPS
Uninterruptible power supply (UPS) continues to supply power to users for a period of time when the mains power supply is abnormal or interrupted. According to the new standard IEC (International Electrotechnical Commission), it is divided into three categories according to its structure and operating principle. The other two types of UPS, the online UPS has the advantages of good performance, high voltage and frequency stability, strong functions, etc. When the mains power grid is normal, it will be rectified and filtered into direct current (AC-DC), which is boosted Inverter (DC-AC), through the SPWM wave modulation technology direct current is converted into a stable alternating current output. When the power supply of the mains grid is suddenly interrupted or the voltage is lower than the set value, the system automatically connects to the DC voltage regulator circuit to supply power through

Overall scheme design
Considering the cost reduction, loss reduction and waveform distortion reduction, the following scheme is selected to construct each module of the system. (1) The basic Boost Boost circuit is used to amplify and stabilize the voltage. The output voltage is sampled by SCM and the duty ratio of switching tube is adjusted by PID algorithm to control the output voltage. The circuit structure is simple and cost saving.
(2) MOS driver in inverter circuit adopts LM5109 produced by TI Company.LM5109 is the latest highvoltage 1A peak half-bridge gate driver produced by TI Company. It is specially designed for driving high-side and low-side N-channel MOSFET with synchronous step-down or half-bridge configuration. The peripheral circuit is simple and stable, and the high-side driver can work under the voltage of up to 90V power rail. (3) Timely switching circuit: LTC4412, a low-power power supply switching control chip, realizes automatic switching of power supply by controlling an external P-channel MOSFET. The circuit structure and principle of the scheme is simple, the quiescent current is as low as 11μA, and the power consumption is low. Disconnecting the AC power supply can realize timely switching to the energy storage device side for power supply. The system uses STM32F407 as the main control, which is composed of rectifier filter circuit, Boost circuit, SPWM modulation full-bridge inverter circuit, and timely switching circuit. The overall block diagram of the system is shown in Figure 2.

Circuit analysis and calculation
2.3.1. The basic Boost circuit. The basic BOOST circuit is adopted to realize the voltage BOOST, and the duty ratio of the switching tube is adjusted to control the output voltage. The switching tube is switched off and turned on alternately. The inductance L will alternately store and release energy, and 3 the voltage rises after the inductance L stores energy, while the capacitor C will maintain the output voltage balance. The input and output voltage relationship is: The desired output voltage can be obtained by changing the on-off duty ratio of the switch.The schematic diagram is shown in Figure 3. The output filter element determines the stability of the power supply and is the most critical part in the design of DC-DC converter.It is important to select two components, the output inductance L and the output capacitance C.The most critical parameter that affects the stability of the power supply is the OUTPUT capacitance's ESR, generally the smaller the better.
Determine the value of capacitance and inductance by the above two formulas.

Single-phase full bridge inverter circuit.
Single-phase full bridge inverter circuit is the core of the whole system.The single-phase full-bridge inverter circuit can be regarded as a combination of two half-bridge circuits, with a total of four bridge arms, paired in pairs, and two pairs alternately conducting each on 180° at the same time. The circuit diagram is shown below.

Control software algorithm design
The output voltage of Boost Boost circuit can be changed by changing the duty ratio of grid-driven PWM control signal. The ADC of STM32F4 is used to sample Boost output voltage. In order to avoid excessive voltage, resistance voltage division is adopted. The duty cycle is adjusted after the error comparison between the sampling value and the set value, that is, PID is used for closed-loop control.

Normal AC power supply test.
Under the condition of AC power supply, ac U1=36V is obtained through the step-down of isolating transformer and autotransformer. Under the condition of full load, ac current Io=1A is measured, ac voltage Uo=30V, frequency is 50Hz, distortion degree is 3.0%, and load adjustment rate is 0.39% when ac current is output in the range of 0.1A ~1A.Some experimental data are shown in Table 1.

Conclusion
As more departments and equipment have special requirements on the quality of power supply, voltage fluctuations, pulse interference and sudden interruption of mains power may have serious consequences. According to the basic principle of UPS, this paper designs an ac sinusoidal on -line uninterruptible po wer supply based on STM32.The experimental results show that the system can output ac normally duri ng normal and abnormal mains power supply, and has certain practical application value.