introduction
With the increasing abundance of various electrical appliances and instrumentation equipment, higher requirements are placed on the flexibility of power supply applications. Designing a universal power supply that is flexible, convenient and relatively cheap is becoming more and more needed by the market. Modern single-chip microcomputers are developing in the direction of faster processing speeds, richer peripheral resources and cheaper prices. Integrating single-chip microcomputers into the design of power supplies can greatly improve the performance and flexibility of power supplies. This article introduces a switching power supply design method of a single-chip microcomputer plus a PWM chip, which can not only retain the stable working performance brought by the PWM chip, but also use the control capabilities of the single-chip microcomputer to provide various human-computer interaction and communication interfaces. The power supply designed by the author is used as a universal power supply, which can provide flexible and programmable voltage and current outputs. In addition, it can be set to the mode of a lead-acid battery charger, which has broad application prospects.
1 System Function
By programming the power supply, the voltage output waveform shown in Figure 1 can be easily realized. Among them, V1, V2, T1, T2, dv, and dt can all be set by programming. The output range of the voltage value is 0 to 16 V, and the maximum output current is 10 A. The output voltage accuracy is 0.1 V, and the current accuracy is 10 mA. The current setting value refers to the maximum current allowed to be output, and can also be programmed to the same waveform as the output voltage.
Figure 1 Programmed output voltage waveform
In addition, the power supply can also work in the lead-acid battery charger mode (referred to as "LBC mode"). According to the characteristics of the lead-acid battery, when the power supply works in the LBC mode, the power supply will first output a larger charging voltage and current V1/I1, which will be maintained for at least 10 s; when the charging current drops below the set value I2, the power supply outputs a smaller charging voltage and current V2/I2. If the charging current has not dropped below I2 by the set time T1, the power supply output will also drop to V2/I2. When the output current is greater than I2 again, the power supply will output V1/I1 charging again. Among them, the V2 setting value must be less than 14 V. If it is set to greater than 14 V, the power supply will automatically set it to 14 V. The value of I2 must be greater than 1/8I1, otherwise it will be automatically set to 1/8I1. The LBC mode is shown in Figure 2.
Figure 2 LBC mode
The user can set the power output in 3 ways:
① Programming through the buttons on the power supply panel. Use the buttons to set the output voltage, current limit value, time, etc.
② Programming through the PC serial port. Connect the PC's RS232 serial port to the power supply serial port, and then run the serial port communication software on the PC to program the power supply.
③ Programming between power supplies. Connect the serial ports of two power supplies and operate the buttons on the panel of one power supply to program the other. The operated power supply is called the "master power supply" and the programmed power supply is called the "slave power supply". In this programming method, the parameters of the slave power supply can only be set to be exactly the same as the master power supply, and each parameter cannot be set separately. One power supply can only provide 100 W of power. This method can be used in situations where higher power is required. Two or more power supplies with the same settings can be connected in parallel to easily achieve power expansion.
2 Working Principle
Generally speaking, there are two types of microcontrollers used to control switching power supplies: The first is that the microcontroller provides a reference voltage to the power supply circuit by outputting PWM or DA, and the microcontroller itself does not intervene in the feedback of the power supply (this design uses this method); the second is to directly control the operation of the switching tube through the PWM signal output by the microcontroller, replacing the PWM chip, but this method has higher requirements for the microcontroller, and it needs to have a fairly high clock frequency to meet the requirements for output PWM frequency and resolution.
The system can be divided into two modules: power module and single-chip control module. The power module is an AC-DC converter with PWM chip as the core. The PWM chip uses ON Semiconductor's current-mode PWM controller NCP1200 as the control chip. The single-chip control module uses Microchip's PIC16F874 as the microcontroller, which mainly realizes the sampling, display, key input, serial communication of current and voltage signals, and provides voltage and current reference for the power module. The relationship between the two modules can be illustrated by Figure 3.
Figure 3 Working principle
In Figure 3, the grid voltage is supplied to the high-frequency conversion circuit after rectification and filtering, and the high-frequency conversion circuit generates output. The microcontroller outputs two PWM signals to provide the power module with a reference value for the output voltage and a current limit value. The power module outputs the voltage and limits the maximum current according to the reference value provided by the microcontroller. Although the microcontroller samples the output voltage and current for display, the microcontroller does not participate in the system feedback here. The feedback is realized through the power module (which will be discussed in detail in the following section).
3 Hardware Design
3.1 Power module circuit
NCP1200 is a current-mode PWM controller launched by ON Semiconductor. Its application circuit requires only a few peripheral components, making the design more compact. In addition, the chip integrates an output short-circuit protection circuit, which can further reduce the cost.
Figure 4 shows the structure of the power supply circuit with NCP1200 as the control chip. As can be seen from the figure, there are two types of feedback in the power supply module. The first is output voltage feedback. The output voltage sampling value VSS is compared with the set value provided by the microcontroller. The voltage of the FB pin of the NCP1200 chip is controlled by the optocoupler, and the pulse width of the PWM output by the DRV pin is adjusted to control the on and off time of the field effect tube, thereby achieving the purpose of adjusting the output voltage value. The other feedback is current limiting feedback. When the sampled output current value ISS exceeds the maximum current limiting value IPWM provided by the microcontroller, the comparator outputs a positive voltage to make the optocoupler conduct at the maximum, pull down the FB pin voltage, and reduce the output PWM pulse width of the NCP1200, thereby achieving the purpose of current limiting. When the output current is less than the current limiting value provided by the microcontroller, the current limiting feedback does not work.
Figure 4 Power module circuit structure
The auxiliary power supply in the figure provides a +12 V voltage, and generates a +5 V voltage through a three-terminal voltage regulator KA7805 (not shown in the figure) to provide power for the comparator and the microcontroller control module.
[page]
3.2 MCU control circuit
PIC16F874 is an 8-bit microcontroller from Microchip Technology, USA, with built-in 4K×14-bit Flash, 128 bytes of RAM and 64 bytes of EEPROM. In addition, it has rich peripheral resources, with a built-in UART module for serial communication, 2 CCP modules that can generate 2 independent 10-bit resolution PWM signals, and 8 10-bit A/D conversion channels. In addition, each I/O of the PIC series microcontroller can provide a driving current of 25 mA, which can save the driver circuit of the external transistor for the LED interface circuit.
The structural block diagram of the single chip microcomputer control module is shown in Figure 5.
Figure 5 MCU control module structure diagram
The main interface circuit of the single chip microcomputer control system:
① Key interface circuit. Use momentary touch switch input and resistor and capacitor to debounce.
② Digital tube and LED display circuit. The digital tube displays voltage, current, time and other information. The LED indicates the type of parameter currently displayed. The I/O of the PIC microcontroller can directly drive the digital tube and LED. The key input and display interface circuit is shown in Figure 6.
Figure 6 Key input and display interface circuit
③ A/D sampling and PWM output circuit. A/D is responsible for sampling the output voltage and current and sending them to the digital tube for display. The current current and voltage setting values provide a reference value to the power module through two PWM signals generated by the CCP module inside the microcontroller. The CCP module inside the microcontroller can be set to PWM output mode. By writing the values of the cycle register and pulse width register, PWM waveforms with different frequencies and duty cycles can be generated by hardware.
④ Serial communication interface circuit. The serial communication interface circuit uses the MAX232 chip as the RS232 transceiver.
4 Software Design
4.1 Software Process
The software is written in C language, using the PICC compiler provided by HighTech for the PIC series microcontrollers. When the system is powered on, the microcontroller reads the last set parameters in the non-volatile memory (EEPROM) and outputs current and voltage. In the software design, the concept of multiple tasks is adopted, which can simulate a simple operating system for task scheduling. A 5 ms interrupt is generated by the timer, and the flags of each task are activated in the interrupt program. For example, the display task is mainly responsible for A/D sampling, digital tube and LED refresh, and can be executed every 5 ms. The keyboard processing task is responsible for key scanning, software debounce, keyboard command interpretation and scanning, and can be executed every 10 ms. The PWM output task is responsible for PWM output according to the set value, and can be executed every 50 ms. If there is a PC or other power supply programming through the serial port, the microcontroller will receive the programming data in the UART interrupt, rewrite the settings in the EEPROM after receiving it, and force reset. If the programming through the key is received, the EEPROM settings are modified and reset in the key processing. The main flow of the program scans whether each task is executed at the time. If yes, execute the task; otherwise, skip the task. The main program flow is shown in Figure 7.
Figure 7 Main program flow
4.2 Serial port programming software
Software is designed on the PC to realize the communication between the PC and the single-chip microcomputer. Through this software, the power supply current and voltage output, timing and other parameters can be easily set. As long as the RS232 port on the power supply is connected to the PC serial port, communication can be achieved.
The serial communication software is designed using the Mscomm control in Visual Basic (only a brief introduction is given here). Data reception on the PC side is achieved through the Oncomm event. When the data in the receiving buffer reaches the value set by the rthreshold property, the Oncomm event is triggered. The data in the receiving buffer is read out in the interrupt program, and the received character data is converted into a string and sent to each text box for display. When sending data, the string in the text box is first read out, then converted into character data, and finally the data is sent to the sending buffer by clicking the "Send" button, thereby sending the data out from the serial port.
Conclusion
The single-chip control overcomes the disadvantage of the single output of the switching power supply and can provide flexible voltage output. Through the power joint expansion function, it can meet the requirements of different power occasions. The power supply can also be used as a lead-acid battery charger, which can automatically adjust the charging current and voltage, and has a wide range of applications.
Previous article:Introduction to the production principle of telephone amplifier based on PIC16C54 microcontroller
Next article:PICC18 command line driver based on HI-TECH C compiler
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- I want to make a circuit to transmit audio signals on DC18V. Does anyone have any good circuits to refer to?
- Layering of MCU Software
- LGSR-WIFI AT-free command-free format remote serial port transparent transmission module information
- Sun goods + STM32 development board + C8051 development board + FPGA development board + GigaDevice 51 development board + domestic LED driver board + high-precision temperature acquisition board
- SigFox Protocol
- TA0CCR0 interrupt of MSP430F6638
- The difference between circuit breaker control power supply and operating power supply
- [CY8CKIT-149 PSoC 4100S Review] + UART serial port usage
- Sub-library: Summary of official Chinese technical documents for electronic compass sensors
- Got a high-end product, Audi LiDAR