introduction
LED has played an indispensable role in the process of urbanization. Various night scene light signs and advertising display screens are increasingly filling people's eyes with novelty. In the past, the luminous body of neon lights only had two states: on and off. The brightness changed suddenly, which often gave people a feeling of abrupt pattern changes; but now many neon lights have realized the gradual change of the brightness of the luminous body, so that the various neon patterns formed are softer and smoother. Controlling the brightness change of the luminous body can be generally divided into analog methods and digital methods. Among them, the method of controlling the brightness of the luminous body by controlling the D/A converter through a single-chip microcomputer has the characteristics of simple circuit, convenient maintenance and adjustment, and is the current development direction of neon light control. The luminous body of neon lights is mainly gas discharge lamp tubes. Now with the emergence of high-brightness light-emitting diodes, long-life and low-energy-consuming LED light signs are becoming more and more widely used. Here we discuss how to control the brightness changes of multiple light-emitting diodes under the control of a single-chip microcomputer using DAC0832.
1 Hardware Circuit Design
The brightness of the three light-emitting diodes is controlled by the single-chip microcomputer and the D/A conversion chip DAC0832 to change gradually in sequence, achieving a rotating lamp effect. The following three issues are mainly considered in the design:
(1) Design of interface circuit between DAC0832 and microcontroller.
(2) Design of reference voltage source.
(3) Circuit design that controls multiple LEDs to change their brightness according to different rules at the same time.
1.1 Interface circuit between DAC0832 and microcontroller
There are two ways to start ADC0832 to realize analog-to-digital conversion: single buffer and double buffer. The multi-buffer method is used when multiple ADC0832s are used together; in this design, only one ADC0832 is needed to complete the work, so the single buffer method is used. Input data to its 8-bit data input port, and then send a low-level pulse to its write trigger pin WR1. The chip will convert the received digital quantity into an analog output. Its output is a current input signal, and the control of the brightness of the light-emitting diode requires voltage, so an external current-to-voltage conversion circuit composed of an operational amplifier is required. The interface circuit between ADC0832 and the microcontroller is shown in Figure 1:
In the figure, since the chip selection terminal CS is connected to P217, when starting DAC0832 to start conversion, the P217 pin of the microcontroller needs to be set to a low level.
The output current is converted into voltage through the operational amplifier. If the digital quantity to be converted is B, the corresponding output voltage value is:
Among them, VREF is the external reference voltage, the highest output voltage is 0 V and the lowest is - VREF. If the reference voltage is 5 V, the lowest output voltage is - 5 V. In order to meet the requirements of negative voltage output, the power supply voltage VCC of the operational amplifier must be higher than 5 V and VEE must be lower than - 5 V. In this design, the operational amplifier uses the LM324 chip, the power supply voltage VCC is 10 V, and VEE is - 10 V.
1.2 Design of reference voltage
To ensure the precision and accuracy of DAC0832 digital-to-analog conversion, a highly stable reference voltage must be provided. In digital-to-analog converters, bandgap reference voltage sources or buried Zener regulators are generally used.
The LM336-5 buried Zener diode is selected in the design. It has the characteristics of low price and easy use. Its wiring is shown in Figure 2:
1.3 How to control the brightness of multiple LEDs simultaneously
The design needs to control three light-emitting diodes. The brightness and change pattern of each light-emitting diode are different. However, ADC0832 has only one analog output. In order to control the brightness of the three light-emitting diodes, a multi-way electronic switch is required. In this example, CD4051 is selected. The pin diagram of the chip is as follows:
This chip is a commonly used 8-way to 1-way multi-way electronic switch with a maximum operating voltage of 32 V. The three address pins ABC determine which channel is selected.
Because the voltage converted previously is a negative value with a minimum of -5 V, the operating voltage of CD4051 is VDD = 10 V, VEE = -10 V. The address control terminals A, B, and C are separately connected to the P210, P211, and P212 ports of the microcontroller to select a certain channel. The analog quantity after D/A conversion is connected to the voltage input terminal 3 pin of the multiplexer, and the output pins 13, 14, and 15 control the light-emitting diodes D1, D2, and D3 respectively.
DAC0832 has only one analog output. It is necessary to use time-sharing control to cyclically control the brightness of the three light-emitting diodes. When one LED is turned on, the other LEDs maintain their original brightness and cannot be turned off. In order to achieve this goal, an operational amplifier is used here to control the brightness of the LED in the form of a voltage follower, that is, a voltage follower is connected between each output of the multi-way electronic switch and the light-emitting diode, and a holding capacitor is connected to the positive input of the operational amplifier to keep the input voltage for a period of time. The wiring is as follows:
Since the input impedance of the operational amplifier is very large, the voltage on Ch2 can be maintained for a period of time. During the period when the output voltage of the digital-to-analog converter controls other light-emitting diodes, the output voltage of the operational amplifier can remain unchanged.
The hardware schematic diagram of the device is shown in Figure 5.
2 Software Design
The software mainly completes two functions. First, it completes the cycle lighting of each LED; second, it controls the change of the brightness of each LED through the program. In this example, the effect of light rotation is to be achieved, so the brightness of each LED changes in the form of a triangle wave, gradually becoming brighter, and then gradually dimming from the brightest when it reaches the brightest, and repeating this process; the brightness change of the three LEDs must have a time difference. If an LED changes from dark to bright and then to dark as a cycle, then D2 lags behind D1 by 1/3 cycle, and D3 lags behind D2 by 1/3 cycle.
2.1 Main program design
The main program loop is used to light up each LED in a cycle. The three data representing the brightness of the three LEDs are placed in three consecutive RAM units 30H, 31H, and 32H. The main program loop reads the data of these three units and sends them to DAC0832 for conversion. According to the different values in 30H, 31H, and 32H, the analog voltage output by the conversion is also different. The microcontroller controls the multi-channel electronic switch to send different analog voltages to different LEDs, so that each LED has different brightness. Since the P2 port is used to control the strobe of ADC0832 and the strobe of the electronic switch in this example, according to the wiring diagram, the P2 port data corresponding to the light-emitting diodes D0, D1, and D2 are 00H, 01H, and 02H respectively.
2.2 Interrupt Program Design
The control of LED brightness change is realized through the timer T0 timing interrupt program. The T0 interrupt changes the values of 30H, 31H and 32H to change the LED brightness. If the light rotation effect is achieved, the brightness of the three LEDs should change according to the curve in Figure 6.
The horizontal axis in the figure represents time. Within one cycle, the brightness of the light-emitting diode will change according to a triangular law. Assuming that each change cycle is T, the change of the second light-emitting diode D1 lags behind the first light-emitting diode D0 by one-third of the cycle, and similarly D2 lags behind D1 by one-third of the cycle.
The horizontal axis in Figure 6 represents brightness, that is, the corresponding digital value to be converted into analog value. In the main program, the values in the three bytes 30H, 31H, and 32H correspond to the brightness of the three light-emitting diodes, and the values of the three bytes 33H, 34H, and 35H are set to control whether the brightness of the three diodes increases or decreases (1 increases, 0 decreases). Assuming that at the beginning, the brightness corresponding to D1 is 0, and the brightness corresponding to D0 and D2 are both 170, then the brightness change of the three diodes should be that the brightness of D0 and D2 increases, and the brightness of D2 decreases. The values of the three brightness control bytes are 1 in 33H and 35H, and 0 in 35H.
The T0 interrupt is used to change the brightness of the three LEDs. Each timer interrupt will complete the following functions:
1) According to the values of the three bytes 33H, 34H and 35H, the values of 30H, 31H and 32H are increased or decreased by 1 respectively.
2) When the value of the brightness byte increases to 255, the corresponding control byte value is cleared to 0. When the value of the brightness byte decreases to 0, the corresponding control byte value is set to 1.
Since the working register R0 is used in both the main program and the interrupt subroutine, there is a process of saving and restoring the value in R0 at the beginning and end of the interrupt program.
The flow chart of the interrupt program is as follows:
That is: TH0 = F0H, TL0 = BEH3
3 Conclusion
This paper designs a system based on DAC0832 to realize LED control. Under the control of the single-chip microcomputer, the brightness of multiple light-emitting diodes is controlled by using a multi-way switch and a voltage holding circuit, and the light rotation effect of the LED lamp is realized. If this circuit is expanded and connected to more analog-to-digital converters and multi-way switches, various complex patterns can be realized. The method of using a voltage holding circuit can also be applied to analog control in other fields.
Previous article:Low-energy LEDs make automotive lighting more efficient
Next article:LED lighting technology knowledge: realization of step-down structure
Recommended ReadingLatest update time:2024-11-16 19:54
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- 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
- Ask a silly question
- Keeping an eye on all directions: A brief analysis of the development trend of TI's automotive surround view technology
- 【Project source code】 Altera DDR2 controller
- Many domestic chips now replace the STM series chips, which looks good in the short term. What do you think?
- High-speed circuit design practice
- [Evaluation of EC-01F-Kit, the EC-01F NB-IoT development board] Flash
- What do you think about the 360 annual meeting special prize exemption coupons?
- [Anxinke NB-IoT Development Board EC-01F-Kit] Part 1: Getting to know EC-01F-Kit
- [Jihai APM32E103VET6S development board] Evaluation 3, TFT LCD
- OV7670 simple driver for MSP430F5438A