Adjustable Voltage-stabilized Power Supply System based on Single Chip Microcomputer

In order to meet the demand of open and customized power supply in teaching experiment, taking PIC single chip microcomputer as the monitoring center, an adjustable voltage stabilized power supply of Buck circuit is designed, which integrates PID control, voltage monitoring and temperature monitoring. The switch tube of the Buck circuit is moved to the lower branch to simplify the drive circuit; the operational amplifier circuit is used for voltage sampling transformation to improve the anti-interference ability of the feedback signal; in order to improve the voltage steady-state control accuracy, two improved strategies are designed, namely the output voltage average filter and the PID control quantity scale transformation. The simulation and experimental results show that when the input voltage and load change greatly, it can be quickly stabilized on the preset value, and has high steady-state accuracy.


Introduction
In the teaching experiments of power electronics, control principle and single-chip microcomputer, it is necessary to design an open and customizable power supply platform.
At present, there are many types of switching power supply and linear voltage-stabilized power supply in the market, but these products are not easy to carry out secondary development, and it is difficult to carry out technical research and experimental teaching of adjustable voltage-stabilized power supply.
In this paper, PIC18F4520 single chip microcomputer is used as the control center to realize the functions of PID control, temperature and voltage monitoring and display of Buck circuit [1][2].
PID control [2] has positional, incremental and many improved algorithms. compared with advanced control algorithms such as robust control, neural network control and fuzzy control, PID algorithm has fewer parameters, simple design, does not depend on specific mathematical model, is directly related to the deviation state of input and output, and can be adapted to the closed-loop control of all kinds of systems.
Because the incremental PID control algorithm is only related to this deviation, it is not as easy to produce cumulative error as the positioned PID algorithm, and the amount of calculation is less, so the closed-loop feedback of the Buck circuit mainly adopts the incremental PID control algorithm [3][4].
In the experiment, it is found that there are two main factors that affect the steady-state performance of the system: first, the precision of the duty cycle generated by the control algorithm is too small, which affects the operation speed, the accuracy is too large, the output waveform overshoot is high, and the steady-state time increases.
Second, the control algorithm feedback detection processing method, the output waveform has a higher frequency of interference clutter, and the sampling frequency is too high, the feedback result in the unstable state of the system is not conducive to PID control adjustment, the sampling frequency is too low, it will affect the response speed of the system.
In view of the above two difficult problems, this paper improves and optimizes the PID closed-loop control algorithm as a whole, automatically adjusts the feedback sampling frequency and duty cycle variation precision according to the stability of the output waveform, and uses the median filtering algorithm to process the waveform.
Finally, the whole system is simulated by Proteus software, and the experimental circuit board is made for test and verification.

System circuit design
The whole circuit design of Buck adjustable stabilized power supply [5-7] system is shown in figure 1, which mainly includes two parts: Buck main circuit and control circuit.
The input voltage of the DC power supply vg is step-down by the Buck main circuit composed of Mosfet switch Q, diode D, energy storage filter inductor L and capacitor C. the constant DC voltage is output on the load R, and the switch Q is moved to the lower branch in the main circuit. The drive circuit does not need to use floating mode, which reduces the complexity of the drive circuit and switch voltage measurement. The control circuit transmits the feedback voltage vf detected and converted by the operational amplifier circuit and the reference voltage vr input manually by the potentiometer to the PIC single chip microcomputer. The single chip microcomputer compares the voltage between vr and vf to form a deviation, e, e.
Through the IR2101 power drive circuit, the PWM control signal is transformed into the closed-loop work of the signal drive control Q which meets the power requirement of the switch Q [8-10].
The normal range of Vr is 0~VCC (5V). When the sampled VR value is processed with the maximum amplitude in the single-chip microcomputer, the recognition range is 04V.
The power tube Q works in the high-frequency switching state, the on-state resistance of the switch tube is high, and the switch tube is easy to heat, which affects the working performance. On the one hand, the switch tube is equipped with a suitable size heat sink, on the other hand, a DS18B20 temperature sensor is installed close to the heat sink, and the surrounding temperature is detected and transmitted to the single-chip microcomputer, which is compared with the temperature alarm threshold in the single-chip microcomputer.
The single-chip microcomputer will control the PWM pulse to turn off the switch tube to achieve the cooling protection function, and use the buzzer to alarm the overheating.
The PIC single chip microcomputer displays the current voltage and temperature in real time through the LCD1602 liquid crystal display module.

System parameter design
The main parameters of the system are Buck main circuit LC filter network parameters, PID control algorithm parameters and feedback detection operational amplifier circuit parameters, and these parameters are related to the performance index of the system [11][12]. The main performance indicators that define the system are shown in Table 1. From Table 1, the range of PWM pulse duty ratio d=v/vg is 0-0.83. The higher switching frequency fs will reduce the volume of the filter equipment, but will increase the switching loss and electromagnetic interference. This article selects a moderate frequency of 5kHz that can meet the regulation index. The ripple coefficient of capacitor voltage and inductor current are relative to load R. The inductor current is not only distributed to the load, but also transduced by the capacitor, so the coefficient is larger; the capacitor voltage is consistent with the load voltage, and the smaller value reflects the voltage ripple.

Filter parameter
The size of the filter inductance L determines the ripple amplitude of the output current, and the size of the filter capacitor C determines the ripple amplitude of the output voltage [13-14]. The reference formula for filtering inductance and capacitance combined with index parameters is: (1)

Operational amplifier circuit parameters
The single power differential feedback detection circuit composed of operational amplifier LM224 and resistors R1, R2, R3 and R4 is shown in figure 2. The operational amplifier has the characteristics of high input impedance and low output impedance, which not only reduces the attenuation of the main circuit signal, but also increases the driving ability of the output. Figure 2 Voltage feedback detection circuit diagram v+ and v-are respectively connected to the positive and negative ends of the output voltage. Let R1=R3=10kΩ, R2=R4=100kΩ, the input and output relationship of the operational amplifier is: (2) The formula (2) can transform the range of the output voltage v into 0~4V level to facilitate the single-chip A/D sampling and identification.

PID control algorithm parameters
PID control is a classic robust control method in process control, which realizes closed-loop stable control through proportional, integral and derivative calculations of system input and output deviations [15]. Its Laplace transform mathematical expression is (3) In the formula, Kp, Ki (Ti), Kd (Td) respectively represent the proportional, integral, and differential coefficients. In order to quickly and effectively determine the three parameters, the "PIDTuner" tool that comes with Matlab is used to check the dynamic and static indicators of the system in real time through the step response, and determine the optimal Kp, Ki, and Kd parameters online. According to the system design principle of Fig. 1, the closed-loop control block diagram is established as shown in Fig. 3.

Figure 3 Buck circuit closed-loop control block diagram
The discrete simulation model is used to achieve similar effects to the one-chip computer experiment. The feedback sampling time Ts=0.1s is set in the one-chip computer, and the program flow of calling the "PIDTuner" tool in Matlab is shown in Figure 4. In Figure 4, the total transfer function G=Gm(s)Gvd(s), after calling PIDTuner, adjust the response time and transient behavior of the two sliders, so that the system overshoot is 0% and the steady state time is about 2.5 s, the rise time is about 1.4s, and the unit step response curve of the stable system is shown in Figure 5.  Figure 6 The overall flow chart of MCU programming

MCU programming design
The single-chip microcomputer is the core control part of the system operation. As can be seen from Figure 1, the system program function modules include: Buck circuit PID adjustment, DS18B20 temperature detection, buzzer temperature alarm, LCD1602 voltage and temperature display, etc. Among them, the Buck circuit PID adjustment module is also It is divided into reference voltage A/D detection, feedback voltage A/D detection, PID control algorithm, PWM control output and other sub-modules. According to the functional requirements, this article chooses a single-chip microcomputer of the PIC series with strong I/O drive capability, fast running speed and rich internal resources, namely PIC18F4520. The overall procedure of the one-chip computer programming is shown as in Fig. 6.
In Figure 6, the MCU and system configuration include MCU operating parameter configuration, system global variable definition and sub-function declaration, etc.; program initialization mainly completes the initial configuration of the underlying functional blocks, such as PWM module, A/D module, LCD module And DS18B20 temperature detection module initialization; temperature protection value is determined according to the performance parameters of the switch tube, the power tube Mosfet selects IRFP250, its operating temperature can reach 175℃, considering the long-term reliable work, the upper temperature limit in the text is set to 80℃, in line with DS18B20 The temperature detection range is -55℃～125℃; both the reference voltage and the feedback voltage are read by A/D, the feedback voltage reading time cannot be too fast, otherwise it will affect the PID adjustment effect, so set the sampling time to about 100ms, and use the counting cycle number extension The time method is implemented, and the multiple adjustment and maximum value limit are required after the reference voltage is read. The program design focuses on the feedback voltage detection processing and the realization of the PID algorithm.

Feedback voltage processing program
Because PID adjustment [17] needs to be reflected to the system output, it takes a certain amount of time. In addition, the output voltage waveform has clutter interference. Therefore, the feedback voltage processing is to filter the data obtained by the op amp as the PID control input value. First, the loop count N is defined in the system global variables, and the one-dimensional 10-variable array FB[9] is set, and the initial value is 0. Because the main program runs for a cycle time of about 10ms, and the sampling period of the PID controller is 100ms, the number of cycles is 10 times.

Incremental PID algorithm program
Incremental PID algorithm is essentially to increase the positional PID algorithm to obtain two position changes, but the calculation formula of the change takes up less memory, and computer programming is easier to implement. Discretize the time domain PID formula before taking it The incremental PID algorithm formula is: (4)

Simulation and experimental verification
Using software simulation and hardware debugging combined verification, first use Proteus software to realize program design and circuit simulation, then make PCB board and build hardware circuit for joint debugging.

Figure 7 Simulation diagram of output voltage dynamic waveform under different reference voltages
Two sub-circuits are designed in Proteus: PIC18F4520 is selected as the single-chip sub-circuit, the crystal oscillator is 4MHz, the temperature measurement chip is DS18B20, the voltage and temperature display module is LM016 (fully compatible with LCD1602); the Buck sub-circuit Mosfet switch tube uses IRFP250, and the drive chip is For IR2101, MUR820 is used for the thread flow diode, and the operational amplifier is LM224. PID parameters Kp=0.06, Ki=0.6, Kd=0.0015. The simulation system focuses on testing the system's voltage stabilization process, and the measured waveforms are shown in Figure 7-8. In Figure 7, the input voltage vg is 48V, and the sliding rheostat is adjusted so that the reference voltage Vr is 1, 2, 3, and 4V, respectively, and the corresponding output steady-state voltage is 10, 20, 30, and 40V, respectively. It can be seen from the waveform diagram that after multiple dynamic adjustments, the output voltage can be well stabilized at the target value. The PID parameters remain unchanged during the adjustment process. Since the initial duty cycle of the switch tube is 0 and the microcontroller has a low level state for a long time during initialization, the PID algorithm will make the adjustment process have a certain oscillation overshoot, which is similar to Figure 5. There are differences in the theoretical simulation of Matlab.

Experimental verification
The experimental hardware circuit and test equipment are shown in Figure 9. The left hardware circuit includes the microcontroller control board, the BUCK main circuit board, the filter inductance and load resistance of the BUCK circuit; the right test system has an oscilloscope, power supply, isolation probe, and system under test. Wait.  Figure 10 shows the steady-state waveforms of the output voltage and the switching tube drive voltage when the input voltage changes. The reference voltage is 1.3V. When the input voltage is from 20V to 40V, the output voltage in the two figures a and b is about 13V, and the duty cycle is reduced by about half. Figure 11 Load change output voltage experimental waveform Figure 11 examines the steady-state waveform when the load changes. The load changes from 12 Ω to 24Ω, and the output voltage can be stabilized at 20V.

Conclusion
This article takes PIC microcontroller as the control core, and develops a Buck circuit adjustable regulated power supply that integrates temperature control and parameter display. First, the system parameters are designed, focusing on using the Matlab tool to quickly obtain the PID tuning parameters and theoretical calculations of the filter inductor and capacitor parameters; secondly, the software design is carried out by the single-chip microcomputer, and the feedback voltage filtering processing and incremental PID control algorithm dynamic scale changes are carried out. The design improves the robustness of closed-loop control and the rapidity of feedback adjustment; finally, through a large number of simulations and experimental tests, the steady-state performance of the system is verified. The system can reach a certain level in the process of large-scale changes in input voltage and load. Steady-state accuracy and fast adjustment speed.