Share this

Design of a digitally controlled DC current source based on AT89C52

2026-04-06 05:11:37 · · #1
Abstract: This design is a digitally controlled DC current source based on the AT89C52 microcontroller as the control core. A high-output voltage to current conversion circuit using a floating ground power supply is employed to realize the current source function. An A/D converter is built using an AD574, and two DAC0832 chips are selected for D/A conversion. A minimum system of A'1~9C52 microcontrollers is designed and built to complete the current control. It has "+" and "-" step adjustment functions, and can be adjusted in 10mA and 1mA steps. The output current range is 200mA~2000mA, and the output current is minimally affected by changes in load resistance. Furthermore, the ripple current is less than 2mA. Keywords: Current source, microcontroller control 1. Overall Design Scheme 1.1 Overall Design Idea Design a digitally controlled DC current source with an input AC of 200-240V and a 50Hz output DC that is continuously adjustable between 200mA and 2000mA. The design employs a microcontroller-based control system. The current source signal is sampled via A/D conversion, and then controlled via D/A conversion. A switch allows for switching the step current amplitude (10 mA and 1 mA). Two buttons, "+" and "-", respectively increase and decrease the constant current source output current in step control. 1.2 System Composition After comparing and demonstrating different schemes, the final system block diagram is shown in Figure 1. It consists of a main power supply, auxiliary power supply, DC current source, D/A converter, A/D converter, microcontroller system, display, and buttons. Figure 1 System Block Diagram 2. Unit Circuit Design 2.1 Current Source Circuit Design The current source is implemented using a high-output voltage to current conversion circuit of a floating ground power supply. As shown in Figure 2, the main power supply provides a DC voltage input of approximately 30V, which is divided by the input resistor U5 and R[sub]5[/sub] to form a voltage between 3-30V. After input to the inverting terminal of U5, the output becomes positive. Then, V1-V3 amplify and increase the output voltage. After passing through the load resistor, a stable output current is obtained. In typical constant current output circuits, if the load resistance increases, the voltage generated across the load resistor by the output current exceeds the power supply voltage, preventing the circuit from operating in a constant current state. However, this circuit uses two floating power supplies, providing a load voltage greater than 200V. Thus, even with an increased load resistance, the current source can still operate in a constant current state. Figure 2 shows the DC current source circuit. 2.2 Microcontroller System Circuit Design: The Atmel AT89C52 chip is used as the microprocessor. The AT89C52 is fully compatible with the MCS-51 series microcontrollers. It uses a static clock mode, which significantly saves power consumption. It contains internal Flash memory, allowing for easy program modification during system development; even incorrect programming will not render the system unusable. Furthermore, during system operation, even a sudden power outage can effectively preserve some data information. The AT89C52 microcontroller is connected to an external display button circuit, an A/D conversion circuit, and a D/A conversion circuit. The A/D conversion circuit is the signal input, while the D/A conversion circuit and the display button circuit are the signal outputs. To facilitate the use of the microcontroller pins, all pins are brought out via interfaces. The specific circuit is shown in Figure 3. The digital tube display is controlled by the microcontroller connected to P0.3 via J4 in the figure. The outputs of the "+" and "-" buttons are connected to the microcontroller's IN0 and INI interrupts via J3 in the figure, respectively. The input signals of the two analog switches are connected to the microcontroller's timers T1 and T0 via J3 in the figure, respectively. The D/A conversion circuit used to control the current source is connected to the microcontroller system via J4 in the figure. The sampled current passes through the A/D conversion circuit and is introduced to the microcontroller via J1 in the figure. Figure 3 Microcontroller System Circuit 2.3 A/D Conversion Circuit Design An AD574 is used to construct the A/D converter. The AD574 is a single-chip high-speed 12-bit successive approximation A/D converter launched by Analog Devices. It features a hybrid integrated converter chip with built-in bipolar circuitry, characterized by few external components, low power consumption, and high accuracy. It also has automatic zeroing and automatic polarity reversal functions, requiring only a few external resistors and capacitors to form a complete A/D converter. The AD574 has a 12-bit resolution and can meet the 1mA step requirement. The AD574 forms the core of the A/D conversion circuit, as shown in Figure 4. The sampling current from the current source is introduced into the A/D module circuit through the operational amplifier circuit LF356. The converted signal is then connected to the microcontroller system circuit through J2 in the figure. 2.4 Design of the D/A Conversion Circuit The D/A conversion section uses two DAC0832 chips. The DAC0832 is an 8-bit monolithic D/A converter manufactured using CMOS technology. It belongs to the R-2RT type resistor network 8-bit D/A converter category, with a settling time of 10ms. It is a current output type and includes an on-chip input digital latch. The circuit composition is relatively simple and can be implemented quickly. The D/A conversion circuit uses two DAC0832 chips, as shown in Figure 5. 2.5 Display and Keypad Circuit Design: LED digital tube display is used. The display principle is simple, and the circuit connection is convenient. It can be directly driven by a microcontroller, fully meeting the display requirements. In this system, a dynamic display method is used to drive a four-digit seven-segment display, which is used to display the output current value (mA). Two keys are used to implement "+" and "-" step control respectively, while two analog switches are used to switch between 10mA and 1mA step currents, as well as the output value and setpoint. As shown in Figure 6, a common anode digital tube is used, driven by an AT89C52 microcontroller input to the display module circuit via J1 in the figure. 2.6 Design of Main and Auxiliary Power Supplies This system uses two power supplies. One power supply uses an MC78H05 to convert 220V AC to approximately 30V DC for the constant current source. The other power supply generates +5V and ±12V DC voltages to power the microcontroller control system and analog circuits. This power supply design not only meets the different power requirements of each system but also ensures stable operation of the entire system. The main power supply circuit is shown in Figure 7. The 220V AC is converted to ±22V by a transformer, and then rectified by a full-bridge rectifier and three RC filters before outputting 30V DC to the current source. The auxiliary power supply circuit is shown in Figure 8. The 220V AC is converted to ±16V by a transformer, and then enters the auxiliary power supply through XS1 in the figure for rectification and filtering. Finally, ±12V and +5V DC are output from XS2 in the figure to power the microcontroller system, A/D conversion circuit, and D/A conversion circuit. 3. Software Design The system's software design uses assembly language to program the microcontroller and implement various functions. The key to the software design is the positive and negative step current control and display of the DC current source. The software implements the following functions: ① Controlling the output current to switch and adjust between 10 mA and 1 mA steps. ② Measuring and displaying the output current and setpoint. ③ Controlling the operation of the AD574. ④ Controlling the operation of the DAC0832. 3.1 Main Program Design The main program flowchart is shown in Figure 9. 3.2 IN0, IN1 Interrupt Program Design The IN0, IN1 port interrupt program design flowchart is shown in Figure 10. 3.3 12 2ms Time Interrupt Program Design The 12 2ms time interrupt program design flowchart is shown in Figure 11. 4. Conclusion The numerically controlled DC current source designed can achieve the following functions: ① Current output range: 200mA-2000mA, and display; ② It can be adjusted in 10mA steps by the "+" and "-" buttons, and display; ③ The step current can be changed to 1mA by the selection switch, and the adjustment result is displayed; ④ When the load resistance changes and the output voltage changes within 10V, the output current value error does not exceed 1%+10mA. After the numerically controlled voltage source was made, it was tested and used in practice, and it showed that it has the characteristics of high precision, convenient use, and simple hardware circuit. References [1] Chang Yuyan and Lü Guang, trans. Selected Japanese Electronic Circuits. Yezi Industrial Press. December 1989. First Edition. [2] Li Chaoqing, ed. Single-chip Microcomputer & DSP Peripheral Digital IC Technology Manual. Beijing University of Aeronautics and Astronautics Press. January 2003. First Edition. [3] He Limin. Advanced Single-chip Microcomputer Tutorial. Beijing University of Aeronautics and Astronautics Press. August 2000. First Edition. [4] Wang Furui. Complete Guide to Single-Chip Microcomputer Measurement and Control System Design. Beijing University of Aeronautics and Astronautics Press. First edition, April 1998. [5] Practical Electronic Circuit Handbook (Analog Circuit Volume) Editorial Group. Practical Electronic Circuit Handbook (Analog Circuit Volume). Higher Education Press. First edition, October 1991.
Read next

CATDOLL 135CM Lucy(TPE Body with Hard Silicone Head)

Height: 135cm Weight: 24.5kg Shoulder Width: 33cm Bust/Waist/Hip: 62/57/69cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22