Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Ideas For Design]
Microcontroller Handles LED Brightness Control

Evgeniy Freidlin, Abel Raynus  |   ED Online ID #9254  |   December 8, 2004


Usually, an MCU is considered a digital device. By default, its output voltage level can be either high or low and nothing in between. With the requirement to create an LED brightness control, the first idea that comes to mind is using a standard digital-to-analog converter, or design a controlled resistor network. Luckily, most modern MCUs have built-in pulse-width modulation (PWM), and this leads to the easiest and cheapest way to solve the problem.

According to our project requirements, the brightness of two LEDs has to be gradually changed from minimum to maximum and back, in the opposite phase and in a time of about several seconds. Also, the several seconds of delay between the ramps should be as shown in Figure 1. During Ramp 1 time, the PWM signal's pulse width is incremented for LED 1 and decremented for LED 2. For example, let's have the ramp time equal 2 seconds and consist of 128 up/down steps. Thus, each step lasts about 16 ms. Note that the pulse-width change should occur only once during the PWM period. Hence, the PWM period should also equal 16 ms.

The low-end 8-bit Motorola MC68HC908-QT2 flash MCU with built-in oscillator is used. Its oscillation frequency equals 12.8 MHz, together with the prescaler programmed to a selection of 1:64, and supplies a timer clock period of 0.02 ms. Then, to generate a PWM with a 16-ms period, the number of clocks to be loaded into Timer Counter Modulo Register (Tmod) should equal 16/0.02 = 800, or $0320 in hexadecimal.

The maximum pulse width (PWMAX) can be less than or equal to the PWM period. Consider PWmax to be equal to about 15 ms. To get this maximum value from zero, for 128 steps, each step should have a value of 15/128 = 0.117 ms. By rounding it to 0.12 ms, we get PWMAX = 15.36 ms , i.e., 96% of the PWM period. Thus, in each step, the PW should ramp up/down on 0.12-ms increments, equal to 0.12/0.02 = 6 timer clocks.

Any type of MCU with PWM and any timing consideration can be used to implement this technique. Resistors R1 and R2 should be chosen according to the LEDs used. Pin pA2 is used to activate (pA2 =1) or deactivate (pA2=0) the brightness control.


Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?


  • A New Design Inflection Point
  • Forecasting Industry Growth For 2009 And Beyond
  • EDA Retools To Exploit Multicore Architectures
  • Design And Verification Move Up In Abstraction
  • EDA Retools To Exploit Multicore Architectures
  • A New Design Inflection Point
  • Design And Verification Move Up In Abstraction
  • Challenges Lurk For 22-nm Physical Implementation
    1) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (260 views today)
    2) 1-A Switching Regulators Operate With 96% Efficiency To Replace Linear Regulators
    (105 views today)
    3) 2008 BEST Electronic Design Winners
    (99 views today)
    4) Microcontroller-Based Sine-Wave Generator Has Crystal Accuracy
    (91 views today)
    5) What's All This Transimpedance Amplifier Stuff, Anyhow? (Part 1)
    (89 views today)
    ALL TOP 20



    Reader Comments

    see

    Eu -December 12, 2008

    its very good n the description given is exellent.

    Pawan -August 08, 2005   (Article Rating: )

    POST YOUR COMMENTS HERE
    Name:

    Email:
    Your Comments:

    Enter the text from the image below


    Please refresh the page if you have trouble reading this text.

    Search Electronic Design
         
      
     
    Web Seminar
    Sponsored By:
    Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
    Speakers: 
    Date: 07/01/08
    Register: 

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources