You are on page 1of 16

Project Report

Automatic Street Light Switching


using PIC 16F877A, Keypad, LCD and LDR.

Group Members:

Asim Aslam BTE-FA10-085 Farooq Ather BTE-FA10-029

COMSATS INSTITUTE OF INFORMATION AND TECHNOLOGY, Lahore.

Table of contents
Section
1 1.1 2 2.1 2.2 2.3 2.4 2.5 2.6 3 3.1 3.2 3.3 4 4.1 4.2 5 6 7 7.1 7.2 7.3 Introduction Block Diagram Interfacing LCD Keypad Light Dependent Resistor Fixed resistor Crystal oscillator Light Emitting Diode Peripherals Microcontroller Core architecture of PIC 16F877A ADC Software Proteus Mikro C: Packaging Summary References Interface Schematic Software Flow Chart Data Sheets of LDR,PIC16F877A,

Paritculars

Page
3 4 5 5 5 6 6 7 7 8 8 9 9 9 9 10 10 11 12 13 14 15

-2-

1. Introduction: This project is mainly used to switch on/off the street lights automatically instead of doing manual by using LDR. The main consideration in the present field technologies are Automation, Power consumption and cost effectiveness. Automation is intended to reduce man power with the help of intelligent systems. Power saving is the main consideration forever as the source of the power(Thermal, Hydro etc.,)are getting diminished due to various reasons.

The main aim of the project is Automatic street light control system with LDR, this is the sensor to sense the illumination intensity. It can operate on five different levels of illumination intensity. LCD is used to show the current operating mode and to choose the option from menu. For security purpose the menu is protected through a password. Only authorized person can change the operating mode of the device. It can save the power by switching the street light on/off immediately on current illumination intensity level. We want to save power automatically instead of doing manual. So its easy to make cost effectiveness. This saved power can be used in some other cases. So in villages, towns etc we can design intelligent systems for the usage of street lights. We worked a lot on this project and we learned a number of lessons about practical filed work including purchasing of components, vendors of electronic devices. Farooq Ather worked a lot on programming end as well as purchasing the components from market. Asim Aslam did a bit programming but complete PCB designing on both software and hardware, soldering and troubleshooting all the components. We learned some basic techniques of trouble shooting. One of them is incremental checking of all components to find the faulty device. We team members remained in contact through out the complete duration of project making.

-3-

1.1. Block Diagram:

16*2 LCD

Street Lights

PIC 16F877A LDR Micro Controller

Keypad

-4-

2. INTERFACING: 2.1 LCD: Stands for "Liquid Crystal Display. It is used in this project to show the current operating level of the device.

LCD modules can be split into two groups: those that have built-in controller and driver chips, and those that have only driver chips. LCD displays that do not have controllers are typically used with powerful hardware, such as a laptop computer, where a video controller is available to generate the complex drive signals necessary to run the display. Most color and large (greater than 320x240) monochrome displays are of this type. The category of display modules that have built-in controllers can be split again into character LCD modules and graphic LCD modules. In this project LCD shows the current mode of device and it helps to change the current level with the help of keypad.

2.2 Keypad: In this project, Keypad is used to input the operating level of intensity of the device. The keypads circuit board consists of 12 switches in normally open condition. When any button is pressed the switch gets ON. Through defined row and column position algorithm the micro controller fetches the value of pressed one switch. We used the keypad for selection of certain items from the program menu in runtime and for password entry to authorize the right user of the device.

-5-

2.4 LIGHT DEPENDENT RESISTOR: Light Dependent Resistor changes its resistance value due to incident light illumination level. As illumination increases LDR decreases its resistance and vice versa.. It means that the resistance of semiconductors decreases with increase in the light intensity. Therefore, these semiconductors are called photoconductive cells or photo resistors or Light Dependent Resistors (LDR), since incident light effectively varies their resistance. In bright light the resistance of the cell can be as low as 80 ohm. When the cell is kept in darkness its resistance is called dark resistance. At 50 LUX (darkness) the resistance increases to over 1M ohm. Output voltages (Vo) are provided on Ao pin of the microcontroller. In full darkness there are 5v on output Vo whereas in full sunny day the voltage level reduces to 1v..

2.5 Fixed Resistence:


A resistor is a passive two-terminal electrical component that implements electrical resistance as a circuit element.The current through a resistor is in direct proportion to the voltage across the resistor's terminals. This relationship is represented by Ohm's law:

where I is the current through the conductor in units of amperes, V is the potential difference measured across the conductor in units of volts, and R is the resistance of the conductor in units of ohms.

-6-

2.6 Crystal Oscillator:


A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency. The resonant frequency depends on size, shape, elasticity, and the speed of sound in the material. High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork. For applications not needing very precise timing, a low-cost ceramic resonator is often used in place of a quartz crystal.

2.7 LED:
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in many devices and are increasingly used for other lighting. Appearing as practical electronic components in 1962,early LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet, and infrared wavelengths, with very high brightness.

-7-

3. Peripherals 3.1 PIC Microcontroller:


PIC stands for Peripheral Interface Controller. This powerful (200 nanosecond instruction execution) easy-to-program (only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller PIC16F877A packs Microchip's powerful PIC architecture into an 40-pin package and is upward compatible. The PIC16F877A features 256 bytes of EEPROM data memory, self programming, an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, the synchronous serial port can be configured as either 3-wire Serial Peripheral Interface (SPI) or the 2-wire Inter-Integrated Circuit (IC) bus and a Universal Asynchronous Receiver Transmitter (USART). All of these features make the PIC16F877A ideal for more advanced level A/D applications in automotive, industrial, appliances and consumer applications. A PIC's instructions vary from about 35 instructions for the low-end PICs to over 80 instructions for the high-end PICs PIC16F877A Memories Flash (KB) RAM (Bytes) Data EEPROM (bytes) PIC16F877A Features Program Memory Type CPU Speed (MIPS) Flash 5 14 368 256

Digital Peripherals

Communication 1-A/E/USART 1MSSP(SPI/I2C)

Capture/Compare/PWM Peripherals Timers ADC Comparators Operating Voltage Range (V)

2 CCP 2x8-bit 1 x 16-bit 8 ch, 10-bit 2 2 to 5.5 -8-

3.2 Core architecture


The PIC architecture is characterized by its multiple attributes:

Separate code and data spaces A small number of fixed length instructions Most instructions are single cycle execution (2 clock cycles, or 4 clock cycles in 8-bit models), with one delay cycle on branches and skips One accumulator (W0), the use of which (as source operand) is implied (i.e. is not encoded in the opcode) All RAM locations function as registers as both source and/or destination of math and other functions A hardware stack for storing return addresses A small amount of addressable data space (32, 128, or 256 bytes, depending on the family), extended through banking Data space mapped CPU, port, and peripheral registers ALU status flags are mapped into the data space

3.3 ADC:
It stands for Analogue to Digital Converter. PIC 16f877a has two 10 pin ADC in it. We used this ADC to convert the analogue values from LDR to digital values for comparing with user input value. We used port A as analogue input. We dont take the digital value on output. We compared the converted values with user input values while keeping both of them in some registers. We have configured ADCON0 register to use built in register.

4. Software:
We used Mikro c as a compiler for c program and Proteus for simulation of microcontroller, LCD, keypad and LEDS.

4.1 Proteus
Proteus is software for microprocessor simulation, schematic capture, and printed circuit board (PCB) design. It is developed by Lab center Electronics. ISIS Schematic Capture - a tool for entering designs. PROSPICE Mixed mode SPICE simulation industry standard SPICE3F5 simulator combined with a digital simulator. ARES PCB Layout - PCB design system with automatic component placer, rip-up and retry auto-router and interactive design rule

-9-

checking. VSM - Virtual System Modeling lets co simulate embedded software for popular microcontrollers alongside hardware design. System Benefits Integrated package with common user

interface and fully context sensitive help.

4.2 Mikro C:
Mikro C is a development tool which is made by Mikroelektronika. Mikroelektronika was founded in 1997. by Neboja Mati, Serbian entrepreneur, owner and General Manager. The company's slogan "making it simple" depicts efforts to make products easy-to-use and suitable for beginners. Company's first development system EPIC1, initially constructed for

PIC16F84A microcontroller today is succeeded by 7th generation system Easy PIC v7, which was symbolically launched on October 7, 2011. Its 6th generation system EasyPIC6 is widely known in PIC development community. Mikroelektronika's products grew to be internationally recognized, and now it has distributors in over 38 countries across the globe, according to company's official distributors list. As of August 2011, company announced Mouser Electronics as its first world-wide distributor. Mikroelektronika is an official consultant on PIC microcontrollers and third party partner of Microchip Technology.

5. Packaging:
We did not directly solder the terminals of any device (LCD, Microcontroller and Keypad) on printed circuit board. We used the 40 pin base for microcontroller, 16 pin base for LCD and 7 pin base for keypad. By using theses bases device can be plugged in or out easily without de-soldering of printed circuit board. Then we used thermo pore sheet to make a foundation for the PCB. The PCB cannot be short circuited from lower side if it is placed on any conducting material like steel or iron etc.

- 10 -

5. Summary
The project is made to automate the street lights. It senses the ambient illumination level through LDR. We have used LDR in series of a fixed resistor. As LDR gives analogue values on its output in the form of volts. This value is then converted to digital value using the inner analogue to digital converter of the microcontroller PIC16f877a. Keypad and LCD are used to take the input the operating level of the device. It simultaneously shows the user keypad value as well as LDR value on screen during the operation. In the device, five different levels are available (1 to 5) where 5 is the lowest level of illumination. If user wants to switch on the street light before the sunset then he should select lower level.

- 11 -

6. References:

http://en.wikipedia.org/wiki/Crystal_oscillator http://en.wikipedia.org/wiki/Led http://technology-electronic.blogspot.com/2010/05/fixed-resistors.html http://electronicsclub.info/vdivider.htm http://en.wikipedia.org/wiki/PIC_microcontroller http://en.wikipedia.org/wiki/Keypad

- 12 -

7.1 Interface Schematic:

8.
- 13 -

7.2 Software Flow Chart:

Initialization

Takes user input through keypad

Takes value from LDR

If user value is less than LDR value

Lights Off

Lights ON

- 14 -

7. 3 Data Sheets of LDR,PIC16F877A

- 15 -

- 16 -

You might also like