Saturday, 29 September 2012

Automatic street lights using microcontroller Atmel 89S52 & LDR

         Well , the term automatic street lights indicates that the street lights will be switched on automatically during night time whereas they'll be switched off automatically during the day ! Its as simple as that !
This can be a good Electronics project.

WHATS THE NEED ?

         Many a times we find street lights left on even during the day time.If we look at the amount of energy wasted in keeping the street lights lit during the day time inspite of their need, well, its just tremendous!This energy can be fruitfully utilised  somewhere else !

HOW CAN THIS BE ACHIEVED?

          LDR(Light Dependant Resistor) is a special type of resistor whose resistance depends on the amount of light falling on it.
 
When a light level of 1000 lux (bright light) is directed towards it, the resistance is 400R (ohms).
When a light level of 10 lux (very low light level) is directed towards it, the resistance has risen dramatically to 10.43M (10430000 ohms). 
So there is massive change in resistance of LDR in Dark and in Light.
This is the basic principle of our Automatic Street Lights.

Secondly we require a transistor  as a switch.

Without a connection to the base wire of the transistor, base current will be zero, and the transistor cannot turn on. Click to get detail information about transistor as a switch.

Thirdly we are using a microcontroller Atmel 89S52 to process the input and give us the output accordingly.

 PIN Diagram

 
PIN Description
VCC (Pin 40)-
Provides voltage to the chip . +5V

GND (Pin 20)
          Ground.


XTAL1 (Pin 19) and XTAL2 (Pin 18)
          Crystal Oscillator connected to pins 18, 19.Two capacitors of 30pF value.
          Time for one machine cycle:11.0592/12=1.085 μ secs.

RST (Pin 9)
          RESET pin
1.       Active high. On applying a high pulse to this pin, microcontroller will reset and terminate all activities.
2.       INPUT pin
3.       Minimum 2 machine cycles required to make RESET
4.       Value of registers after RESETMINOR.

External Access: EA 31
1.                 Connected to VCC for on chip ROM.
2.                 Connected to Ground for external ROM containing the code Input Pin.

     Program Store Enable: PSEN 29
1.                 Output Pin.
2.                 In case of external ROM with code it is connected to the OE pin of the ROM.

          Address Latch Enable: ALE30
1.                 Output Pin. Active high In case of external ROM ,ALE is used to de multiplex (PORT 0) the address and data bus by connecting to the G pin of 74LS373 chip

I/O Port Pins and their Functions:
1.                 Four ports P0,P1,P2,P3 with 8 pins each, making a total of 32 input/output pins.
2.                 on RESET all ports are configured as output. They need to be programme to make them function as inputs.

PORT 0
1.                 Pins 32-39
2.                 Can be used as both Input or Output
3.                 External pull up resistors of 10K need to be connected
4.                 Dual role: 8051 multiplexes address and data through port 0 to save pins AD0-AD7.

External Access: EA 31
1.                 Connected to VCC for on chip ROM
2.                 Connected to Ground for external ROM containing the code Input Pin.

Program Store Enable: PSEN 29
1.                 Output Pin
2.                 In case of external ROM with code it is connected to the OE pin of the ROM.
3.                 ALE is used to de multiplex data and address bus.

PORT 1
1.                 Pins 1 through 8.
2.                 Both input or output.
3.                 No dual function.
4.                 Internal pull up registers.
5.                 On RESET configured as output .

PORT 2
1.                 Pins 21 through 28
2.                 No external pull up resistor required
3.                 Both input or output
4.                 Dual Function: Along with Port 0 used to provide the 16-Bit address for external memory. It provides higher address A8-A16.

PORT 3
1.                 Pins 10 through 17.
2.                 No external pull up resistors required .
For more information on microcontroller Atmel 89s52 refer Mazidi 

 

The output is taken from the collector of the transistor n is given to the input of the microcontroller.

Input Circuit

 

Depending upon the input as 1 or 0, the microcontroller will give output 
and accordingly the street lights will be switched

The ASM code for this project is
;here we have used P1 as the input port and P0 as the output port
;we are checking P1.0 bit and accordingly we are making P0.0 bit high or low 
 org 0000h
         mov p0,#00h
        mov p1,#0ffh
        ;mov p1,0feh
     L1:mov a,p1
        mov b,#11111111b
        CJNE a,b,L1
        setb p0.0
     L2:mov a,p1
        mov b,#11111110b
        CJNE a,b,L2
        clr p0.0
        sjmp L1
        end
The output from the P0.0 is given to the output circuit as shown below

The output circuit is
 
The big blue block here is the relay used to control the AC Supply
Relay is used As a switch to light the Street Lights
Max current passing through a relay is 10A.

No comments:

Post a Comment