DAC0832 realizes LED brightness control system

Publisher:数字火花Latest update time:2014-03-08 Source: elecfansKeywords:DAC0832  LED Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  introduction

  Controlling the brightness change of the light source can be generally divided into analog methods and digital methods. Among them, the method of controlling the brightness of the light source 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 light source 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 use DAC0832 to control the brightness change of multiple light-emitting diodes under the control of a single-chip microcomputer.

  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 simultaneously controls multiple LEDs to change their brightness according to different rules.

  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 needed. In this example, CD4051 is selected. The pin diagram of the chip is as follows: [page]

  

 

  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 timer interrupt program. The T0 interrupt changes the values ​​of 30H, 31H and 32H to change the LED brightness. If the light rotation effect is realized, the brightness of the three LEDs should change according to the curve in Figure 6. [page]

 

  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, then 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, and 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

  If this circuit is expanded and connected with more analog-to-digital converters and multiplexers, various complex pattern changes can be realized. The method of using voltage holding circuit can also be applied to analog control in other fields.

Keywords:DAC0832  LED Reference address:DAC0832 realizes LED brightness control system

Previous article:Design of car anti-theft system based on GPS-GSM
Next article:Application of digital single pulse power supply in electroplating

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号