Thứ Sáu, 14 tháng 12, 2018

LED Light Bulb Controller using AVR Microcontroller

Previously before 10-15 years the majority of electrical lights were either light bulbs (with yellow light) or tube-light sticks (with white light). The major disadvantage of these lighting devices was they consume more electrical energy (in terms of Watt) and gives less luminance (brightness). Light bulb wastes their most of the energy in form of heat. Also the life time of such devices was also short.
Next comes compact fluorescent light (CFL) bulbs. They consume much less electrical energy than light bulbs and tube-light sticks and give more light. But their disadvantage is their intensity cannot be varied. Also their life time is limited to few thousand hours. But because their energy consumption is very less compare to light bulbs, they almost replace them.
Led
Now a days LED light bulbs are becoming more and more popular because they have several advantages over light bulbs and CFL bulbs. Some of their advantages are listed below
·         Their energy (electrical) consumption is much more less
·         Their luminance is more
·         Their intensity can be varied
·         Their life time is more

Looking at these advantages one might think LED light bulb must replace all CFL and other light bulbs but it is not so because there are some disadvantages also
·      They are much more costlier
·      They cannot be directly connected to AC, rectifier – converter is required
·      Additional DC driver circuit is required

However they will replace all other light bulbs because their energy consumption is very less. Today all the nations are facing crisis of electrical energy. The electrical energy generated using conventional energy sources like coal, petrol or diesel are becoming scares now. So any how to save such resources saving electrical energy is the ultimate requirement. So the LED light will be used everywhere in near future.

Here I am presenting the tutorial for controlling intensity of LED light using micro controller. The LED light intensity can be controlled by feeding PWM to it. As the width of applied signal increases the average voltage applied to LED increases that increases its intensity and vice versa. This can be done using any simple PWM generator IC like IC555 or IC741 etc any. But using micro controller the light intensity can be controlled in precise steps like 10%, 20%, 30%........ to 100%. Also the light intensity can be varied in accordance to sunlight (day light). Like during day with full sunlight the LED light is off. In the evening as day light decreases LED light intensity increases and in the night LED is fully ON.
So in this simple project 10 V LED light bulb is used. Its intensity is varied using PWM. PWM is generated using AVR micro controller ATMega16. Three push buttons are given to ON/OFF LED bulb and to increase / decrease its intensity. ATMega16 micro controller has built in 4 PWM channels. Out of these four one channel is used to vary intensity of bulb.

 Connections

Connections: - three push buttons are connected to PORTA pins PA0 – PA2. These pins are grounded through 1 K resistors so when push button is not pressed input to pins is 0. But when any push button is pressed that pin will get input 1. Two RED LEDs are connected to PORTC pins PC0 and PC1 with current limiting resistors. They indicate maximum and minimum brightness. White LED bulb is connected to PWM 0 channel output that is PORTB pin PB3. One 8 MHz crystal with two 22 pF capacitors is connected to crystal input pins XTAL1 and XTAL2. It provides 8 MHz clock for internal operation.
Operation: - initially bulb is ON. When 3rd button is pressed, the bulb becomes OFF. Alternatively pressing this button will make bulb ON and OFF. While bulb is ON, if 1st button is pressed the width of pulse is increased by 8%. If anyone keeps pressing this button then pulse width increases up to 98% of total time period. This is maximum limit. The bulb intensity is maximum. It is indicated by LED2. Similarly if any one keeps pressing 2nd button then pulse width decreases up to 4%. This is minimum limit. The bulb intensity is minimum. It is indicated by LED1. So pulse width is varied from 4% to 98% in 12 steps of 8% each. Same we can say for light intensity.


Further advancement:
The brightness (intensity) of LED bulb can be varied in accordance to daylight. Complete operation can be made automatic like bulb will be automatic ON/OFF, intensity increases/decreases etc as per daylight changes. The daylight can be sensed using LDR (or any other light sensor like photo-diode, photo transistor etc)
A solar operated LED street light can be build that can work as standalone automatic unit. Complete unit consist of solar panels, battery, charging circuit, LED driver-controller circuit and LED bulb. It can be installed at any place like in gardens, open air theatres, stadiums or in places where it is not feasible to lay down electrical cables


Circuit:

LED Light Bulb Controller Circuit Diagram
Code:

#include <avr/io.h>                 // necessary header files
#include <util/delay.h>
unsigned int duty=130,c=0;        // initialize duty cycle at 50%
int main(void)
{
      DDRB = 0x08;                  // PB3 pin as output
      PORTB = 0x00;                 // clear output
      DDRC = 0x03;                  // PC0 and PC1 pins as output
      PORTC = 0x00;                 // both LEDs OFF       
      TCCR0=0x6B;                   // start timer         
    while(1)
        {
            OCR0 = duty;           // PWM with current duty cycle             if(PINA==0xF1)          // if 1st button is pressed            {
             PORTC=PORTC & 0xFD;           // LED1 off
             if(duty<250) duty=duty+20;    // increase duty cycle
             _delay_ms(300);
             if(duty==250) PORTC=PORTC | 0x01;// LED2 ON for max                                                        limit
           }
           else if(PINA==0xF2)     // if 2nd button is pressed
           {
            PORTC = PORTC & 0xFE;         // LED2 off
            if(duty>10) duty=duty-20;     // decrease duty cycle
            _delay_ms(300);
             if(duty==10) PORTC=PORTC | 0x02; // LED1 ON for min                                                       limit
            }
            else if(PINA==0xF4)     // if 3rd button is pressed
            {
            c++;              // alternatively make
            if((c%2)==1) {TCCR0=0x00;PORTB=0x00;}     // PWM OFF                                                                or
            else TCCR0=0x6B;                          // PWM ON
            _delay_ms(300);
             }
         }             
  }

Không có nhận xét nào:

Đăng nhận xét

Bài đăng mới nhất

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01 # candientu ,  # fujihatsu ,  # candientufujihatsu  #candientu,  # candientufujhatsu , #fuji...

Bài đăng phổ biến