Design of program-controlled power supply based on C8051F040

Publisher:星辰古泉Latest update time:2011-02-28 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

In various electronic circuit experiments, a voltage-stabilized power supply is an indispensable instrument. Currently, most of the power supplies used in experiments have only fixed voltage outputs (for example, commonly used ones are: ±5V, ±12V or ±15V). The disadvantage is that the output voltage cannot be changed artificially, and the output accuracy and stability are not high.

With the rapid development of science and technology, the requirements for power supply reliability, output accuracy and stability are getting higher and higher. The program-controlled power supply designed by using the high resolution of D/A converter and the automatic detection technology of single-chip microcomputer has shown its superiority. The program-controlled power supply can conveniently input and select the preset voltage value, has high accuracy and stability, and can realize programmable monitoring of the power supply, which brings great convenience to circuit experiments and improves work efficiency.

2 C8051F040 microcontroller

With the rapid development of microelectronics technology, CPU has become a low-cost device. Where possible, various electromechanical devices have been or are being embedded in embedded systems composed of CPUs. The C8051F series of single-chip microcomputers launched by Silabs in the United States pushed the 80C51 series of single-chip microcomputers from the era of microcontrollers (MCU) to the era of system on chip (SOC), bringing single-chip microcomputers with 8051 as the core to a new level. SOC is the abbreviation of system on chip, which means that some commonly used digital cores and analog peripherals of computers are all built on a chip, making it a complete analog data acquisition and control system.

This design uses C8051F040 as the main control chip. C8051F040 is a powerful single-chip microcomputer, a fully integrated mixed-signal system-level chip, with a microcontroller core compatible with 8051, and fully compatible with the MCS-51 instruction set. In addition to the standard 8051 digital peripheral components, the chip also integrates analog components and other digital peripherals and functional components commonly used in data acquisition and control systems. Peripherals or functional components include ADC, DAC, voltage reference, programmable counter array, etc. It has better performance than the 51 series single-chip microcomputer, and the cost is not high. The C8051F040 single-chip microcomputer is a truly independent system-on-chip (SOC).

3 Working Principle

After transformation, rectification and filtering, 220V AC power is converted into 100V high-voltage DC power, which is then converted into the required 12V DC voltage through a DC-DC conversion circuit. In addition to supplying power to the constant voltage control circuit and the current limiting control circuit, 12V also passes through a DC-DC converter (LM2596S) to obtain 5V DC power, which is then used to power the microcontroller module.

The control circuit is the core part of the entire programmable power supply. Users can set the output voltage and maximum output current of the switching power supply through the keyboard according to their needs. The single-chip computer system samples the output voltage and current of the power supply and compares them with the data given by the user. Then, it controls the switch adjustment circuit according to the set adjustment algorithm to make the output voltage of the power supply meet the given value. The switch control circuit adjusts the output voltage of the power supply and detects the output current of the circuit at the same time. When the output current exceeds the given value, the current value is limited so that it does not exceed the maximum current value initially set, thus realizing the protection function. The real-time voltage and current values ​​are displayed on the LCD.

The C8051F040 has an internal integrated programmable counter array PCA. The PCA generates PWM, which is based on the PWM (pulse width modulation) control of the microcontroller. It outputs PWM pulses through an I/O pin, directly drives the external regulator tube, and changes the on/off time of the power switch tube to stabilize the output, thereby achieving the purpose of stabilizing the output voltage.

The current limiting control loop samples from the output end and compares it with the set upper current limit value. If the current on the load is higher than the set current value, current limiting protection is performed to keep the output current value at the upper current limit, and the voltage value drops to the corresponding value.

4 Hardware Circuit Design

4.1 Auxiliary power supply circuit

The power supply system designed this time is ultimately required to output the voltage we want in real time, so we need a DC power supply system with stable voltage. This system converts 220V AC power into +5V (microcontroller minimum system) and +12V (voltage stabilization, current limiting control module) DC voltages.

As shown in Figure 1, 220V AC is converted to 100V AC through a power transformer. The task of the rectifier circuit is to convert AC into DC. A bridge rectifier circuit is used here. The filter circuit is used to filter out the ripple in the rectifier output voltage. A compound filter circuit composed of capacitors and inductors is used here. Since the reactance element has an energy storage function in the circuit, the capacitor and inductor have a smoothing function. Then two resistors (R1, R2) and a voltage regulator (W1) are added to stabilize the voltage at approximately 12V DC.


Figure 1 Schematic diagram of rectification, filtering and voltage regulation

Figure 2 shows a DC-DC converter (LM2596S) and its peripheral circuits. It takes 12V as input voltage and outputs a stable 5V DC voltage after conversion. LM2596S consists of a comparator, a reference voltage source, an oscillator, a driver, etc. C16 is an input filter capacitor, FS1 acts as a protection circuit, and L4, D15, and C17 are energy storage parts.


Figure 2 DC-DC converter

4.2 Control circuit This module uses the basic circuit of the switching voltage regulator, with the high-performance single-chip C8051F040 as the main control element, to form a data processing circuit. With the support of detection and control software, it adopts a dual closed-loop control system. The control closed loop is a voltage loop or a current loop. The control loop samples the output current and voltage from the output end and compares them with the set reference, so as to adjust and control the working state of the switching power tube and change the on/off time of the power switch tube to stabilize the output. At the same time, the output current is monitored and the current limiting function is realized through the system software. Figure 3 shows the schematic diagram of the constant voltage control module and the schematic diagram of the current limiting control module.

4.2.1 Constant voltage control circuit

In order to achieve the purpose of stabilizing the output voltage, the system output voltage is continuously detected, and the PWM wave is output according to the difference between the power supply output voltage and the set value, which directly controls the duty cycle of the regulating tube M2 to stabilize the output voltage. The C8051F040 has an internal integrated programmable counter array PCA, which is based on the PWM (pulse width modulation) control of the single-chip microcomputer. It outputs PWM pulses through P0.0 (set by the digital cross switch) to directly drive the external transistors Q4 and Q3, thereby changing the conduction frequency or conduction/cutoff time of the power switch tube M2 to stabilize the output and achieve a voltage stabilization state. The voltage stabilization circuit works, and DS1 is on and appears red.

4.2.2 Current Limiting Control Circuit

The current limiting control loop samples from the output end and compares it with the set upper current value. If the current on the load is higher than the set current value, current limiting protection is performed to keep the output current value at the upper limit value, and the voltage value drops to the corresponding value. In the current limiting state, DS2 lights up and appears green.

Figure 3 Control circuit schematic

5 Algorithm Introduction

The main program mainly includes the processing of the key value returned by the timer interrupt, the processing and adjustment of the sampled voltage and current values, etc.

The voltage sampling part utilizes the analog-to-digital conversion (A/D) function of C8051F040. A 12-bit ADC is used, and the relevant registers are set to work in single-ended mode. The voltage reference is taken from the VREF0 pin, and the gain is 1. The voltage reference of this design is 2.44v, and there is a formula:

Conversion code =

Where: single-ended mode n = 12; differential mode n = 11.

The sampling voltage value Vd is: Vd=conversion code×2.44/4096;

By analyzing the circuit, we know that the relationship between the real-time current Io and the sampled voltage Vdi is: Io=Vdi/11/1.1; from the voltage division relationship between R20 and R19, we know that the relationship between the output voltage Vo and the sampled voltage Vdv is: Vo=Vdv×101.

The above three equations can be used to obtain the real-time voltage and current values ​​according to the conversion codes in the registers ADC0H and ADC0L related to ADC0.

The current control part uses the digital-to-analog conversion (D/A) function of C8051F040. C8051F040 has two on-chip 12-bit voltage-mode digital-to-analog converters (DACs). The output swing of each DAC is 0V to VREF, and the corresponding input code range is 0x000 to 0xFFF. Since the output swing and input code are linearly related, the relationship between the output voltage CCadj and the input code Mda is: Mda = CCadj/2.45×4096

From the circuit diagram, we can see that the relationship between the limiting current Imax and the output voltage Vda is: CCadj = Imax × 1.1 × 11; from the above two equations, we can get the relationship between the limiting value and the input code is Mda = Imax × 1.1 × 11 × 4096 / 2.45

This formula can be used to limit the output current value, and the current of the circuit can be limited by comparing the limit value with the actual current value of the circuit, thereby protecting the programmable power supply and completing the current limiting function of the programmable power supply.

Since the design is a switching power supply, the voltage control part uses the pulse width modulation function (PWM) of C8051F040. C8051F040 has a programmable counter array PCA integrated inside. The programmable counter array PCA can work in pulse width modulation (PWM) mode. Based on the PWM function, C8051F040 can output a control signal to control the ratio of the opening and closing time of the power switch tube (MOSFET, IGBT) of the switching power supply, so that the switching power supply outputs the set voltage value. When the load carried by the power supply changes and the output voltage changes, the output voltage can be stabilized by adjusting the duty cycle of the output signal according to the sampling feedback of the output voltage.

In this design, the C8051F040 operates in 16-bit pulse width modulator mode. In this mode, the 16-bit capture/compare module defines the number of PCA0 clocks for the low-level time of the PWM signal. When the PCA0 counter matches the value of the module, the CEXn output is set to a high level; when the counter overflows, the CEXn output is set to a low level. In order to output a waveform with a variable duty cycle, the writing of the new value should be synchronized with the PCA0 CCFn match interrupt. Setting the ECOMn, PWMn, and PWM16n bits in the PCA0CPMn register to '1' will enable the 16-bit pulse width modulator mode. In order to output a waveform with a variable duty cycle, CCFn should be set to logic '1' to enable the match interrupt. The duty cycle of the 16-bit PWM is calculated as follows: Duty Cycle = (65536 − PCA0CPn)/65536

According to the principle of the switching power supply in the circuit, a regulation function can be obtained: duty cycle = f (∆E), where ∆E is the difference between the set voltage value and the sampled output voltage value. Therefore, the duty cycle can be continuously adjusted to reduce ∆E so that the output voltage reaches the set value and stabilizes at the set value, thus completing the constant voltage function.

6 Conclusion

The design of programmable power supply uses C8051F040 single-chip microcomputer as the control core. Programming is done in C language in the IDE development environment of PC, and the program is downloaded to the single-chip microcomputer through the development board for joint debugging. The joint debugging results basically meet the output voltage and current values ​​(0~100V, 0~1A). Due to the accuracy of the selected devices, there are still certain errors. Selecting devices with high parameters and the same functions can expand the range of output voltage and current.

Reference address:Design of program-controlled power supply based on C8051F040

Previous article:Design of low-cost data acquisition device based on C8051F340
Next article:Design of Magnetorheological Controller Based on C8051F

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号