Abstract: A digital switching power supply based on a 68HC08 microcontroller combines the high efficiency of switching power supplies with the intelligent control of digital chips, and uses appropriate algorithms to adjust voltage and current and protect the entire circuit. Experimental results verify that the power supply has high output accuracy. Keywords: 68HC08 microcontroller; digital switching power supply; intelligent control 0 Introduction Compared with linear power supplies, switching power supplies have many advantages: because the main power transistors operate in switching mode, their losses are low, and the overall efficiency is greatly improved; the use of ferrite high-frequency transformers greatly reduces the size and weight of the power supply, and lowers the cost. The emergence of some dedicated power chips such as TL494 and UC3842 has also made the design of switching power supplies simpler and more reliable. However, switching power supplies made using only dedicated chips usually have a single output state, and the hardware circuit must be modified to change the output state. The author designed and implemented a single-chip microcontroller-controlled digital switching power supply, which effectively improves the above problems. 1 Design Principle of Digital Switching Power Supply The digital switching power supply designed by the author has a rated power of 120W. The system uses a switching power supply as the basic circuit and a high-performance microcontroller as the control system. With the support of a control algorithm, it samples the output voltage and current in real time and compares them with software-defined values to control and adjust the operating state of the switching power supply to obtain the desired value. It mainly includes five parts: input rectification and filtering correction, power conversion, auxiliary power supply, drive circuit, and microcontroller control system. The power conversion section uses a single-ended flyback converter circuit. The auxiliary power supply provides power to the drive circuit, which amplifies the PWM signal from the microcontroller to drive the main power transistor. The microcontroller system is the control core of the entire circuit, controlling the duty cycle of the output PWM in real time through changes in the sampled values. The entire design strives for optimal performance and lowest cost. Its structure is shown in Figure 1. 1.1 Main Circuit Analysis The power conversion section uses a single-ended flyback circuit, as shown in Figure 2. When the excitation pulse applied to the primary power switch Q1 is high, turning Q1 on, the DC input voltage is applied across the primary winding. Since the secondary winding phase is negative at the top and positive at the bottom, the rectifier diode D1 is reverse-biased and cut off, and the primary inductor stores energy. When the excitation pulse is low, turning Q1 off, the voltage polarity across the primary winding reverses, the secondary winding phase becomes positive at the top and negative at the bottom, the rectifier diode is forward-biased and turns on, and the energy stored in the transformer is released to the secondary side. During this switching process, the high-frequency transformer serves both as a voltage isolation transformer and as an inductor for energy storage. 1.2 Microcontroller Control System The microcontroller control system is the core of the entire digital power supply. The microcontroller used is the Freescale 68HC908SR12, which has abundant internal resources, integrating 12k of program memory, 2 timers/counters, a 14-channel 10-bit A/D converter, PWM output, and an internal temperature sensor. The block diagram of the microcontroller control system is shown in Figure 3. ATD0 and ATD10 are voltage and current sampling pins, respectively, converting the sampled analog signals into digital signals and sending them to the CPU. The CPU performs control adjustments every 1ms to output a PWM signal with an appropriate duty cycle. The PWM signal, after isolation and amplification by the driver circuit, directly controls the switching transistors of the main circuit. Since the 908SR12 has a built-in pulse width modulation module, the maximum PWM frequency reaches 125kHz, which is perfectly suitable for high-frequency switching power supplies. The 8-bit resolution ensures the accuracy of the output voltage and current. The keyboard uses contact-type key switches, allowing users to adjust the output voltage and current values arbitrarily within the rated power range. The entire circuit employs a dual closed-loop control system. Under normal conditions, the voltage loop feedback keeps the output voltage constant. Once the output current exceeds its maximum value, the current loop reduces the output voltage while maintaining the output current at its maximum value. The display can consist of a digital tube or an LCD. In this system, the system uses keypad selection to display voltage, current, power, temperature, and energy metering, with indicator lights indicating different states. If an open circuit or short circuit occurs during operation, the indicator lights will display an alarm status, and the CPU will immediately initiate a protection program to shut down the main circuit. At the same time, the internal temperature of the power supply is constantly monitored to prevent the overall temperature rise from being too high. 1.3 Drive circuit design Since the 5V1vrL level output by the microcontroller is insufficient to drive the main power switch, and the primary and secondary sides are completely electrically isolated in the entire circuit, the PWM signal output by the microcontroller cannot be directly connected to the main power switch. In addition, the temperature rise of the main power switch directly affects the stability and service life of the entire equipment. Improving the turn-on and turn-off speed of the switch is the most essential and effective way to solve the temperature rise problem of the switch. This requires the drive circuit to have the following characteristics: (1) It can provide a sufficiently large drive current, that is, the charging resistance of the drive circuit should be sufficiently small to shorten the conduction time; (2) It has sufficient leakage current capability, that is, the discharge resistance should be sufficiently small to improve its turn-off speed; (3) Appropriate drive voltage, the drive voltage is generally more suitable at 12V. Considering the electrical isolation of the primary and secondary sides, the following drive circuit was designed, as shown in Figure 4. PWM is the duty cycle signal output by the microcontroller, which is connected to the primary side through an optocoupler, thus satisfying the electrical isolation requirements of the primary and secondary sides. Inverter U2 converts TTL levels to CMOS levels. When the PWM signal is high, U2 outputs a high level, T1 conducts, T2 is off, and the drive power supply charges the gate-source capacitance of the switching transistor, quickly reaching the turn-on threshold voltage, causing the transistor to turn on rapidly. When the PWM signal is low, U2 outputs a low level, T1 is off, T2 conducts, and the gate-source capacitance of the switching transistor is quickly discharged through T2, achieving rapid turn-off of the transistor. This drive circuit has a simple structure, stable performance, and high drive speed, and can replace more expensive drive chips. 2 System Software Flowchart The system flowchart is shown in Figure 5: To improve the dynamic characteristics and stability of the system, upper and lower limits are specified for the PWM duty cycle in the data processing program to prevent large deviations during continuous sampling, and the PWM is limited. In addition, if an unexpected situation occurs, the microcontroller will shut down the PWM in time to prevent excessive output voltage or current from damaging the transistor. 3 Conclusions After collecting and analyzing a large amount of data, the following conclusions were drawn: When the switching power supply is working in constant voltage mode, the output value and the expected value error do not exceed 30mV. When it is working in constant current mode, the output value and the expected value do not exceed 40mA. The overall efficiency is above 85%, the temperature rise of the main power switching tube is about 40℃, and the temperature rise of the high frequency transformer is below 60℃, which is fully suitable for the power supply requirements in general situations. The switching power supply with a microcontroller as the core not only helps to improve the accuracy of the switching power supply, but also makes the switching power supply more intelligent. Intelligentization is also a future direction of power supply development. Therefore, the programmable power supply with a microcontroller as the core designed in this paper has high application value. [b]References:[/b][1] Zhang Zhansong, Cai Xuansan. Principles and Design of Switching Power Supplies (Revised Edition) Beijing: Electronic Industry Press, 2004 [2] Liu Shengli, Practical Technology of Modern High Frequency Switching Power Supplies. Beijing: Electronic Industry Press, 2001 [3] Duan Yeta1. Digital controller design for switch-mode power converters. IEEE 14th Appl. Power Electron, 1999, 2(4): 967-973. Click to download: Digital Switching Power Supply Design