Design of LED brightness control system based on DAC0832

Publisher:快乐旅行Latest update time:2011-06-28 Source: 维库电子Keywords:DAC0832 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:DAC0832 Reference address:Design of LED brightness control system based on DAC0832

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

dac0832 c program to generate sine wave
The following is a sine wave generator made of a 51 single-chip microcomputer, using the oldest dac0832. The program is very valuable for reference, you can take a look at it. #include "reg52.h" #include "absacc.h" #include "math.h" typedef unsigned char uint8; typedef unsigned int uint16;
[Microcontroller]
Latest Power Management Articles
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号