1 Design Task
Design and manufacture digital controlled DC current source. Input AC 200~240V, 50Hz; output DC voltage ≤10V.
Requirements: Output current range: 200mA ~ 2000mA; The output current given value can be set and displayed, and the absolute value of the deviation between the output current and the given value is required to be ≤1% of the given value + 10mA; It has a step adjustment function, and the step is ≤10mA; The ripple current is ≤2mA; When the load resistance is changed and the output voltage changes within 10V, the absolute value of the output current change is required to be ≤1% of the output current value + 10mA.
2 System Design
In view of the fact that the current digital control DC source generally adopts the current-voltage conversion circuit composed of operational amplifiers combined with single-chip microcomputers, most of the design schemes are open-loop systems. The main controller is only used for digital setting and display, and the output current is not detected and controlled. Based on the traditional circuit design, this paper uses the feedback and control principle in the control system to introduce current negative feedback, obtain the sampling voltage proportional to the current on the sampling resistor, and connect it to the reverse input terminal of the operational amplifier to achieve negative feedback and form a closed-loop control system with constant current output; in terms of software, the genetic algorithm with global optimization ability but slow convergence speed and the direct search method with fast convergence speed and strong local optimization ability are combined together to design a hybrid optimization algorithm based on the genetic algorithm and direct search strategy, which fully utilizes the global search ability of the genetic algorithm and uses it as the "rough adjustment" of the optimization process, and uses the good local search ability of the direct search method as the "fine adjustment" of the optimization process, which concentrates the advantages of both and overcomes the weaknesses of both. The objective function value obtained is better than the genetic annealing strategy, and the consistency is better. It has the advantages of fast tuning speed, short adjustment time, and small steady-state error when used for PID parameter tuning. At the same time, combined with the PID algorithm, a software closed loop is formed to achieve precise control of the output current.
The working principle of the system is as follows: the current value is preset by the keyboard and input into the single-chip microcomputer; the current signal collected by the sampling resistor is sent to the single-chip microcomputer through the A/D converter. When the absolute value of the difference between the two values is zero or not greater than the set value, no adjustment is made; when the difference between the two values is greater than the set value, the PID algorithm is used for adjustment, sent to the D/A converter, and the output current is adjusted until the difference is within the allowable range. The single-chip microcomputer controls the LCD to display the set value of the current, the actual output value and the current step value.
3 Hardware Circuit Design
The numerically controlled DC current source is composed of self-made power supply circuit, keyboard input circuit, display circuit, single-chip minimum system, D/A conversion circuit, constant current source circuit, A/D conversion circuit and output current acquisition module circuit.
3.1 Use the more suitable new Atmega128 microcontroller
At present, most of the constant current source design schemes use the 51 series single-chip microcomputer as the current source controller. This series of single-chip microcomputers has high cost performance, mature interface circuit development, and wide application. However, its execution speed is slow, the integrated circuit stability is poor, and it is easily disturbed. There is no internal watchdog circuit, which is easy to crash, and there is no integrated A/D, D/A conversion chip. Compared with the 51 series single-chip microcomputer, ATmega128 has high-speed processing capability, good circuit stability, a programmable watchdog timer with internal oscillator, and a 10-bit A/D conversion chip with 8-channel single-ended or differential input. This system uses ATmega128 as the current source controller, and uses a high-precision timer with comparison match interrupt function to implement a high-precision PID algorithm.
The controller mainly realizes the following functions: (1) Control keyboard input current setting value; (2) Control A/D conversion circuit to convert measured current value into digital value; (3) Compare the current setting value with the measured value, and adjust it according to the comparison result using PID algorithm; (4) Control D/A conversion circuit to convert the adjusted digital current into analog voltage; (5) Display the set current value, measured current value and step current value; (6) Record the fault duration.
3.2 Constant current source design
This design uses a linear constant current source with an integrated operational amplifier. The circuit consists of two low-drift operational amplifiers LM358, transistor TIP41C, load resistor R, current limiting resistor R3 and current feedback sampling resistor Rf made of 1mm diameter constantan wire.
The sampling resistor Rf adds the current signal to the input of the operational amplifier in the form of voltage, forming a current parallel negative feedback circuit, which reduces the impact of the subsequent circuit on the D/A, and can also obtain a constant current output, making the current source have better stability. TIP41C is a high-power transistor. When working in the linear amplification area, the maximum collector current is 4 A and the amplification factor is 20 to 70 times.
The load current is determined only by the input voltage and has nothing to do with the size of the load R. Due to the limitation of the op amp power supply, the load can only change within a certain range. When the input voltage remains unchanged, the load resistance changes within a certain range, and the output current will remain unchanged, forming a constant current source circuit.
Another feature of this solution is that the sampling resistor is made of constantan wire, which has a temperature coefficient of 5ppm/℃. The temperature rise caused by the current flowing through it will not have much effect on its resistance value, and the temperature characteristic is good. At the same time, it is wound into a hollow winding resistor using the reverse symmetrical winding method to reduce the additional inductance generated when winding the resistor, thereby achieving the purpose of reducing ripple current. To ensure sufficient VI conversion accuracy, each resistor in the circuit should use precision resistors.
3.3 A/D Converter Design
The current measurement part of this system is composed of a 12-bit A/D chip TLC2543, which is a 12-bit switched capacitor successive approximation A/D converter. The chip has 11 analog input channels. The chip's serial three-state output data terminal, input data terminal, and input/output clock control terminal can form a faster and more efficient serial peripheral interface with the microprocessor. The 12-bit A/D can meet the system's 1%+1mA accuracy requirement.
3.4 Sound and light alarm circuit
The digital controlled DC current source has an overcurrent protection function, that is, when the actual current output exceeds 4000mA, an alarm can be triggered and the output current can be reduced to 0mA.
3.5 Design of self-made power module
This design requires 12V and 5V DC voltage. The voltage of the whole system is connected to 220V AC voltage. The external voltage is passed through a rectifier transformer to obtain an AC voltage of about 15V, and then rectified by a bridge to obtain a DC voltage. The 15V DC voltage is filtered by a capacitor, and then converted to 5V voltage through a three-terminal voltage regulator block 7805, and 12V voltage is obtained through a three-terminal voltage regulator block 7812.
3.6 Human-computer interaction interface
Compared with digital tubes, LCD screens have the advantages of low power consumption, large visible area, high resolution, strong anti-interference ability, convenient character operation, easy programming, and few controller resources. This design uses LCD1602 to display 0-2300mA current. LED1 and LED2 indicate current measurement mode and current setting mode. When the two light up alternately, it means that the given value and measured value of the current are displayed alternately. LED3, LED4, and LED5 indicate three step sizes (1mA, 10mA, and 100mA).
Because the encoding keyboard scan adopts interrupt mode, it has the advantage of occupying fewer I/O ports. This design uses a 2×8 encoding keyboard with a total of 16 keys. The encoding keyboard uses hardware circuits instead of software to determine the key number. When a key is pressed, the keyboard encodes through the priority encoder. The encoder also sends an interrupt signal to the microcontroller. The microcontroller reads the key number and calls the key subroutine for corresponding processing. [page]
3.7 D/A Converter Design
In order to achieve the output current range of 10mA ~ 4000mA, step 1mA requirements, should choose a high-resolution DAC, this design uses MAX538 as the core device of the D / A conversion circuit.
MAX538 is a 12-bit serial digital-to-analog converter with the characteristics of fast conversion speed, high precision and low power consumption. This chip is an 8-pin serial port data input D/A conversion chip, which occupies less microcontroller pin resources, is easy to program and expand the peripheral circuit. Since MAX538 has an internal reference voltage of 4.096V, the formula () shows that the output voltage accuracy of MAX538 is 1 (mV), and it can be added to the two ends of the constantan wire resistor with a resistance value of 1Ω to generate 1 (mA) current (i.e., step 1mA). The test shows that it can meet the indicators.
3.8 System Composition
(1) Control device: ATmega128 microcontroller;
(2) Keyboard input circuit: 2 × 8 encoding keyboard;
(3) Display circuit: LCD1602;
(4) Constant current source circuit: LM358, TIP41C, sampling resistor Rf;
(5) Sound and light alarm circuit: light emitting diode and buzzer;
(6) Record fault time: built-in timer/counter of ATmega128 microcontroller;
(7) A/D converter: TLC2543;
(8) D/A converter: MAX538;
(9) Homemade power module: rectifier transformer, rectifier bridge, capacitor, three-terminal voltage regulator 7812 and 7805
4 Software Design
In the closed-loop control system of the digital constant current source, in order to keep the load current constant and there is no overshoot when the load current changes with the set value, and at the same time hope that the system has good anti-disturbance performance, this design uses a PID controller to improve the performance of the system. The specific control process is: ATmega128 reads the actual output current I through the A/D converter, and then compares it with the set current IS to obtain the difference Ek=IS-I. The main controller adjusts the PID controller according to the positive and negative size of Ek, calculates the increment △Ik of this current adjustment, and then calculates the output current this time according to the current Iq-1 output by the previous D/A chip. The parameters of the PID controller are determined by the self-designed hybrid optimal algorithm.
4.1 Hybrid Optimal Algorithm Design
In view of the fact that the genetic algorithm converges slowly, is prone to premature maturity, and has a high dependence on parameters, while the direct search method has good local search capabilities, this design makes comprehensive use of the excellent performance of the two algorithms to overcome their respective shortcomings. First, the genetic algorithm is used to perform a "global rough" search in a given area, and then the direct search method is used to perform a "local precise" search on some of the better individuals in the tiny area where these individuals are located to find its minimum value. Repeating this process can quickly find the global optimal solution for the PID algorithm parameters.
The controller ATmega128 is mainly used to realize the self-tuning of genetic algorithm parameters. The data storage device stores some expert experience to preliminarily determine the tuning target domain. It also stores the sample data and control parameters of each generation of the genetic algorithm.
Strictly speaking, there is no theoretical conclusion on when the iteration of the genetic algorithm should stop. In many application examples, if it is found that the evolution of individuals in the group has tended to a stable state, the iteration is terminated. For PID parameter self-tuning, the iterative algorithm is terminated when the adjustment process enters a relatively stable state. Therefore, the number of iterations equal to the maximum number of iterations M or the change in precision adjustment is less than a preset value is used as the condition for the algorithm to terminate.
4.2 Software Implementation
Based on the modular concept, the system software design part is written in a mixture of C language and assembly language, which takes advantage of the high efficiency and rapid development of C language and the flexibility of assembly language. The system software mainly completes the functions of output setting and current adjustment. It includes the main program, A/D sampling subroutine, D/A output current given value and key control, PID algorithm subroutine, hybrid optimal algorithm subroutine, LCD display and other subroutines.
5 System Function Test
(1) The system output current range is 10mA ~ 4000mA;
(2) The current step function has 3 optional step sizes, and the positive and negative step adjustments can be easily made through the "+" and "-" buttons;
(3) The given value and the measured value of the current can be displayed alternately. The absolute value of the actual measured output current error is ≤ 0.1% of the measured value + 1mA;
(4) When the load resistance is changed and the output voltage changes within 10 V, the absolute value of the output current is ≤ 0.1% of the output current value + 1 mA;
(5) Ripple ≤ 0.15 mA
6 Conclusion
This digital control DC current source system uses Atmega128 as the main controller and adopts the software and hardware double closed-loop feedback method to ensure the stability and output accuracy of the power supply, and realizes the steady current output with the ordinary voltage stabilizer. The output current of the current source can be set by pressing the button, and the step level setting is optional. In the process of system design, we strive to make the hardware circuit parameters reasonable, the circuit simple, and give full play to the flexible characteristics of software programming. Through multiple debugging, we continuously improve the accuracy of the system and the stability of the current to meet the design requirements of the system.
Previous article:Design of low power consumption system for wireless sensor network nodes
Next article:SPI-based MAX7221 connection with MCU
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
- The top 10 list of big companies with the highest salaries and 996 working hours is out! Netizen: Although it’s 996, the salary is quite high~
- I saw the RISC-V Linux system
- EEWORLD University Hall ---- Computer Vision Course Tsinghua University Wang Mingzhe
- Download to get a gift! Lots of exquisite gifts are waiting for you!
-
EEWORLD University Hall----Live Replay:
takes you to learn about ADI's digital health biosensor series - Switching power supply using microcontroller for loop control
- Carrier synchronization
- Popular Science Sharing - Detailed Explanation of the Working Principles of Starlink Satellites (Episode 3)
- [Recruitment] Shenzhen foreign companies are urgently recruiting RF antenna engineers, looking forward to your joining
- No more confusion! A guide to choosing a cordless vacuum cleaner