You are on page 1of 47

MICROCONTROLLER BASED I.

R REMOTE CONTROL OPERATED ELECRICAL APPLIANCE CONROL SYSTEM

A PROJECT REPORT

Submitted by CHUDASMA RAVINDRA R. VAGADIYA RAJESH D. PATEL KIRAN

In fulfillment for the award of the degree of

BACHELOR OF ENGINEERING
in Electrical

Government Engineering College, Bhuj

Gujarat Technological University, Ahmedabad


April, 2012

Government Engineering College, Bhuj


Electrical Engineering Department 2012

CERTIFICATE
Date: This is to certify that the dissertation entitled

MICROCONTROLLER BASED I.R REMOTE CONTROL OPERATED ELECRICAL APPLIANCE CONROL SYSTEM has been carried out by following students under my guidance in fulfillment of the degree of Bachelor of Engineering in ELECTRICAL (8th Semester) of Gujarat

Technological University, Ahmedabad during the academic year 2011-12.

Name of Students 1. Chudasma Ravindra R. 2. vagadiya rajesh D. 3.patel kiran

Enrollment No. 080150109008 080150109059 080150109037

Guide: Prof. K.A.SONAGRA

Prof. H. D. Mehta Head of the Department

ACKNOWLEDGEMENT

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It would be impossible to name each and every individual who had offered the support encouragement and ideas which made this Industry Defined Project a possible thing. We are greatly thankful to our external guide MR. DHARMENDRA PARAMAR of automation engineers-ahmedabad who has given us a tremendous effort for shaping our ideas and knowledge according to the industrial requirements. He has helped us on reaching each and every milestone of the project, he has encouraged us in every failure during the project, and he has increased our confidence with every success in the project. On the other hand we are greatly thankful to our internal guide Prof. K.A.SONAGRA who has made us aware with the requirement of the industry from this project, what we should actually try to learn that idea was planted by her and we had grown it up during this period with their helps. We are also thankful to our H.O.D. Prof. H. D. Mehta and other professors of Electrical department of our college.

[i]

ABSTRACT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In current days it is a major problem that we may loss our key in normal locking system, we may forgotten to lock the device, office, home, empire, company etc. which results in the insecurity for our valuable data, instruments, devices, money or any valuable things. Hence this is the advanced locking system which uses infrared rays and a setup password will be done which provide a high security option in place of manual locking system. As the current days the smart card locking or opening security system are also available but this is the advance electronics device which uses remote control, and in all the devices are provided their separate password which we can use for opening that device. When the user provide their password to receiver through remote control, and the receiver transfer the received signal to the microcontroller. And if the user password matches with remote controls password then operation will be successful otherwise a buzzer starts and make alert to the security guards. Hence this is very convenient for using. The infrared remote controlled password security system is an advance electronic based security system; hence in future this system may be become too much common at everywhere. This provides high sense of security in all the way. In coming days this infrared system is high sensing in nature. Through this system the size of present days manual locking system can be reduced.

[ii]

LIST OF TABLES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Table No.

Table Description

Page No

Table 2.1...... Distribution of port pin 1... 9 Table 2.2.. Distribution of port pin 3....................... 10

[iii]

LIST OF FIGURES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Figure No

Figure Description

Page No

Figure 2.1 Basic block diagram .2 Figure 2.2 Power supply of circuit.....4 Figure 2.3.. ..Schematic diagram of main circuit....5 Figure 2.4 microcontroller (AT89S52)....6 Figure 2.5 pin description of AT89S52 microcontroller..........8 Figure 2.6 Mct2e optocoupler.....12 Figure 2.7.TSOP...13 Figure 2.8.Relay....13 Figure 2.9 Transistor......14 Figure 2.10...Diode...15 Figure 2.11.. Resister ......16 Figure 2.10...Capacitor.....17 Figure 2.11LED ......18

[iv]

LIST OF SYMBOL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Symbol

Symbol Description Capacitor Resistor Charge

Page No 17 17 17

C R Q

[v]

TABLE OF CONTENTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Acknowledgement (i) Abstract (ii) List of Figures . (iii) List of Tables (iv) List of symbol. (v) Table of Contents . (vi)

Chapter 1:

Introduction 1.1 Introduction .......1

Chapter 2:

Literature Survey 2.1 Basic block diagram.......2 2.2 Hardware implementation ....4 2.2.1 Power supply Circuit 2.2.1.1 Schematic Diagram of Power Supply Circuit.....4 2.2.1.2 Distribution of power supply circuit:.........4 2.2.2 Schematic diagram of main circuit . ....5 2.2.3 Component Details .....6 2.2.3.1Microcontroller........6 2.2.3.2 Infrared Remote Control Transmitter - RC5 ....11 2.2.3.3 Mct2eOpto-Coupler....12 2.2.3.4 TSOP .....13 2.2.3.5 Relay...13 2.2.3.6 Transistor ...14 2.2.3.7 Diode .15 2.2.3.8 Resistor.....16 2.2.3.9 Capacitor....17 2.2.3.10 LED...18 2.3 Problem and solutions.....19 2.4 Advantages.................................................. .....20 2.5 Application of the infrared remote control system.....20 [vi]

Chapter 3:

Industry Defined Problem Formulation 3.1 Problem/Project Identification ....21

Chapter 4:

Hardware and Software 4.1 programming .....22 4.2 simulation .29 4.3 Hardware photograph .32

Chapter 5:

Conclusion....34

References...........35 Appendix............36

[vii]

[8]

CHAPTER: 1 INTRODUCTION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1.1 Introduction
In this competitive world human cannot spare his time to perform his daily activities manually without any fail. The most important thing he forgets to switch off the room lights wherever not required. With this, even they will be wasted up to some extent. This project gives the best solution for electrical power wastage. Also the manual operation is completely eliminated the industrial Appliances can be switched on using IR without actually going near the switch boards or regulators. The TV remote used in this project is IR remote. The loads like electronic appliances, power controlling system and also current through the loads can be controlled in this project. We can control all loads at a time from one place (control room) without connecting any physical wire between loads and control room. IR remote acts as the transmitter in this project. When a button is pressed in the remote, the signal will be passed and received by the IR receiver TSOP Receiver. This signal is sent to the microcontroller which decodes the signal and performs the corresponding action in accordance with the button pressed in the remote. This project uses regulated 5V, 500mA power supply. 7805 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac output of secondary of 230/12V step down transformer. The KEIL cross compiler is used to edit, compile and debug this program. Micro Flash programmer is used for burning the developed code on Kiel in to the microcontroller Chip. Here in our application we are using microcontroller AT89S52 which is Flash Programmable IC. This IC is one of the versions of 8051.

Page | 1

CHAPTER: 2 LITERATURE SURVEY


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.1 Basic block diagram

Fig: 2.1 Basic block diagram

Page | 2

Block Diagram Description This project is an implementation of-remote reception on an AT89S52 microcontroller. The received code is decoded and sent to the microcontroller software developed using high level graphical programming language (C). The project report focuses on the system which is designed by using the Microcontroller AT89S52. The infrared receiver have 3 pins in which two pins are for +5v supply and ground while the third pin is for data output. The IR receiver module receives the data sent by remote handset, amplifies, demodulates and converts it to MCU compatible voltage format and outputs it on its data output pin. All the above process is control by the Microcontroller AT89S52.The Microcontroller receives the infrared signals from the receiver and it decodes and finally a device will be switched on through relay. The range of the system is up to 10 meters. High power loads can also be connected by changing the Relay. The conditions of devices are stored in the EEPROM IC. And the devices will come to the original state after the power failure. The Microcontroller is used receive the Infrared signal from the Transmitter, the received signal is processed and sent to the relay driver circuit.

Page | 3

2.2 Hardware implementation 2.2.1 Power supply Circuit


2.2.1.1 Schematic Diagram of Power Supply Circuit

Fig:2.2. Power supply of circuit

2.2.1.2 Distribution of power supply circuit: To power the circuit, the system will be divided into two sections. The system will be powered via single phase with the required the 5V in section two obtained via a LM7805 5V voltage regulator. In this power circuit we use a one single phase transformer. Single phase supply (230 V) is given a single phase transformer and at secondary side output is 12 V. This output of 12V is filtered by capacitor and given to the 7805 IC. Which is convert the 12 V supply to 5 V dc supply. This 5V is again filtered by capacitor and given to VCC terminal of ATMEL 89S52 IC.

Page | 4

2.2.2 Schematic diagram of main circuit

Fig:2.3 Schematic diagram of main circuit

Page | 5

2.2.3 Component Details


2.2.3.1 Micro controller-AT89S52

Fig:2.4 microcontroller (AT89S52)

Features Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz 256 x 8-bit Internal RAM 32 Programmable I/O Lines

central processing unit - ranging from small and simple 4-bit processors to complex 32- or 64bit processors Three 16-bit Timer/Counters Other serial communications interfaces like IC, Serial Peripheral Interface and Controller Area Network for system interconnect Full Duplex UART Serial Channel Include analog-to-digital converters

Page | 6

Description The AT89S52 is a low-power, high-performance 8-bit microcontroller with 8K bytes of insystem programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with insystem programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes.

Page | 7

Pin Description

Fig:2.5 pin description of AT89S52 microcontroller

VCC Supply voltage. GND Ground. Port 0 Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 can also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code

Page | 8

bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.

Port 1 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current because of the internal pull-ups.
Table:2.1 Distribution of port pin 1

Port 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current because of the internal pull-ups. Port 3 Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current because of the pull-up. Port 3 also serves the functions of various special features of the AT89S52, as shown in the following table. Port 3 also receives some control signals for Flash programming and verification. Page | 9

Table:2 Distribution of port pin 3

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out. ALE/PROG Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) During Flash programming in normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. PSEN Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming.

Page | 10

XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier.

2.2.3.2

Infrared

Remote

Control

Transmitter

RC5

Protocol

This infrared remote control transmitter is based on Philips IC which is a RC5 protocol transmitter. Unit is powered by onboard 3V battery Range of the remote transmitter is around 10 meters (30feet). Features RC5 Transmitter with LED indication Power Save: 3V battery operation in sleep mode(Battery last around 2 years) Six RC5 commands can be transmitted on each key press RC5 address is set as 1 to prevent interference with TV remotes Carrier frequency of 36kHz or 38kHz Constant bit time of 1.778ms (64 cycles of 36 kHz), Different timing for 38 KHz Should be adjusted in decoder part by monitoring first two bits. Manufacturer Philips

Modulation In RC5 Modulation the protocol uses bi-phase modulation of a 36 kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with a burst of the 36 kHz carrier and the other half being idle. Protocol
The drawing below shows a typical pulse train of an RC-5 message.

Page | 11

Transmitted Data on each key press Switch Address Command Toggle (If key kept pressed toggle bit remains same, for new key bit changes)

Philips RC5 Protocol Philips is possibly the most used protocol by probably because of the wide availability of models. Cheap remote controls.

2.2.3.3 Mct2e Opto-Coupler The Mct2e Opto-coupler device consists of a gallium arsenide infrared emitting diode optically coupled to a monolithic silicon phototransistor detector.

Fig:2.6 Mct2e Opto-Coupler

Applications
General Purpose Switching Circuits. Interfacing and coupling systems of different potentials and impedances. Page | 12

I/O Interfacing.

Monitor and Detection Circuits.


2.2.3.4 TSOP The TSOP17 Series are miniaturized receivers for infrared Remote control systems. PIN diode and preamplifier are assembled on Lead frame, the epoxy package is designed as IR filter. The demodulated output signal can directly be decoded by a Microprocessor. TSOP17. Is the standard IR remote control receiver Series, supporting all major transmission codes.

Fig: 2.7 TSOP

Features

Photo detector and preamplifier in one package. Internal filter for PCM frequency Output active low 2.2.3.5 Relay

Fig: 2.8 Relay

Page | 13

A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism, but other operating principles are also used. Relays find applications where it is necessary to control a circuit by a low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to another. Relays found extensive use in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly drive an electric motor is called a contactor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device to perform switching. 2.2.3.6 Transistor

Fig :2.9 symbol of transistor

Types of Transistor There are two types of standard Transistors, NPN or PNP, with different circuits symbols, the letters refer to the layers of semiconductor material used to make the Transistor. Most Transistors used today are NPN because this is the easiest type to make from silicon. Transistors are manufactured in different shapes but they have three leads. The leads are labeled base (B), collector(C) and emitter (E). The base is the lead responsible for activating the transistor, the collector is negative lead, and the emitter is the negative lead.

Page | 14

Emitter It is more heavily doped than any of the other regions because its main function is to supply majority charge carriers to the base. Base It forms the middle section of the transistor, it is very thin as compared to either or collector and it very light doped.

Collector
Its main function is to collect majority charge carriers coming from the emitter and passing through the base. In most transistors, collector regions made physical larger that the emitter because it has to dissipate much greater power. Because of this difference is no possibility the transistor. Use As a amplifier Oscillator. In integrated circuits.

2.2.3.7 Diode

Fig:2.10 Diode

In electronics diode is two terminal electronic component which conducts electric current asymmetrically or unidirectional that is it conducts current more easily in one direction than in the opposite direction. The term usually refers to a semiconductor diode, the most common type today, Page | 15

which is a two terminal semiconductor P-N junction. A vacuum tube diode, which was the first type of diode invented but is now little used, is a vacuum tube with two electrodes: an anode and a cathode.

2.2.3.8 Resistor

Fig:2.11 Resistor

A Resistor is a two-terminal electrical or electronic component that opposes an electric current by producing a voltage drop between its terminals in accordance with Ohm's law: The electrical resistance is equal to the voltage drop across the resistor divided by the current through the resistor. Resistors are used as part of electrical networks and electronic circuits. IDENTIFYING RESISTORS Most axial resistors use a pattern of colored stripes to indicate resistance. Surfacemount ones are marked numerically. Cases are usually brown, blue, or green, though other colors are occasionally found such as dark red or dark grey. One can also use a multi meter or ohmmeter to test the values of a resistor. Electronic Color Code Four-band identification is the most commonly used color coding scheme on all resistors. It consists of four colored bands that are painted around the body of the resistor. The scheme is simple: The first two numbers are the first two significant digits of the resistance value, the third is a multiplier, and the fourth is the tolerance of the value. Each color corresponds to a Page | 16

certain number, shown in the chart below. The tolerance for a 4-band resistor will be 1%, 5%, or 10%. 2.2.3.9 Capacitor In the capacitors non-conducting material is put between low conducting plates. The value of capacitors is measured in micro faraday, neon feared or Pico faraday. The value of capacitors and its working voltage printed on its body. The more the working voltage the more the size of capacitors, as the increase the frequency is has maximum resistor. Capacitor is used for the reserve the A.C. pulse and allowed is passed the constant D.C. Voltage

Fig:2.12 Capacitor

A capacitor consists of two conductors separated by a non-conductive region called the dielectric medium though it may be a vacuum or a semiconductor depletion region chemically identical to the conductors. A capacitor is assumed to be self-contained and isolated, with no net electric charge and no influence from any external electric field. The conductors thus hold equal and opposite charges on their facing surfaces, and the dielectric develops an electric field. In SI units, a capacitance of one farad means that one coulomb of charge on each conductor causes a voltage of one volt across the device. The capacitor is a reasonably general model for electric fields within electric circuits. An ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge Q on each conductor to the voltage V between them.

Page | 17

Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to vary. In this case, capacitance is defined in terms of incremental changes:

Uses Coupling capacitor Bipolar capacitor Blocking capacitor 2.2.3.8 LED

Fig:2.13 LED

LEDs are 'Light Emitting Diodes', a type of semiconductor. They are the newest item in today's lighting technology. Unlike other light sources, these LEDs can take a lot of punishment from vibration, heat and severe cold. LEDs can be made waterproof, and put into a lighting

package with 2 to 1000 LEDs. They can be used for street lights, sign lighting, spot lighting or anything else LEDs need 3.6V DC and use approximately 30 milliamps of current, a power dissipation of 110 mill watts. The positive power is applied to one side of the LED semiconductor through a lead Page | 18

and a whisker. The other side of the semiconductor is attached to the top of the anvil that is the negative power lead. It is the chemical makeup of the LED semiconductor that determines the color of the light that the LED produces. The plastic housing has three functions: it is designed to allow the most light to escape from the semiconductor; it focuses the light, and it protects the semiconductor from the elements.

2.3 Problem and solutions


PROBLEM 1:This system can operate with another same frequency I.R remote that anyone can interference with this system.

SOLUTION:That is the advanced locking system which uses infra red rays and a setup password will be done which provide a high security option in place of manual locking system.

PROBLEM 2:Limitation range of the IR remote control. SOLUTION:Infrared have a range like 10m, which is not so long. If we want to open the door at more than 10m then IR is not working. In this situation we should take radio frequency instead of IR which works more than 10m and avoid the problem of limitation of range and make the system more comfortable.

PROBLEM3:Direction of operating. SOLUTION:If we want to operate system for that we must take remote control in direction of sensor then system should operate otherwise sensing is not done and system not operates. By the use of radio frequency we can overcome problem of line of site. Page | 19

2.4 Advantages
We can operate device at any place. Not go to that switch. We can also save time at in farm, industry etc. We can save our lives because this is shock proof. Project coast is less. More easy to operate because it is user friendly

2.5 Application of the infrared remote control system


Now days the system is required in Major industries, Banks, Companies, Empire, Cyber world, Offices, Multiplexes, Educational department and many more.

Page | 20

CHAPTER: 3 INDUSTRY DEFINED PROBLEM FORMULATION


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3.1 Problem/Project Identification
In the modern world the automatic systems are used on large scale. This is a simple approach to control the home appliances by IR remote control without making physical contact with AC/HEATER we can on /off the devices connected. This concept is also used in big plants. In very big plants operator has to go here and there to make various machines on and off. It is a problem to handle various machines when less staff is present.

Page | 21

CHAPTER: 4 SOFTWARE AND HARDWARE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


4.1 programming
// // // // // // // Remotecontrol lock system IMPORTANT NOTE : press '0' (zero) P3_2 (INT 0) used for sensor input P0 used for LCD data P2_0 = RS, P2_1 = RW, P2_2 = EN P2_4 used for LOCK P2_3 used for BUZZER after four digit password

#include <REGX51.H> #define #define #define #define #define #define #define #define #define #define YES 1 NO 0 TRUE 1 FALSE 0 LOCK P2_4 BUZZER P2_3 OPEN 0 CLOSE 1 CLRSCR lcdcmd(0x01) CRSRBLINK lcdcmd(0x0F)

bit firsthalf,secondhalf,sample,isfirstdigit,codeisnotcorrect,cmpflag,next; unsigned int unsigned unsigned unsigned unsigned unsigned char char char char char buffer,counter,memberno; rxdigitcounter; rxpassword[4]; userpassword[4][4] = {"3865","5489","7412","3091"}; currenthighbyte,previoushighbyte; currentlowbyte,previouslowbyte;

sbit rs = P2^0; sbit rw = P2^1; sbit en = P2^2;

void lcdcmd(unsigned char x); void lcddata(unsigned char y); void Millisecdelay (unsigned int k);

Page | 22

code unsigned char prompt[16] = "*ENTER PASSWORD*"; code unsigned char welcome[4][16] = {"WELCOME Ravindra", "WELCOME Rajesh..", "WELCOME Kiran...", "WELCOME HOD sir."}; code unsigned char accessdenined[16] = "|ACCESS DENINED|"; code unsigned char initial_line_add[4] = {0x80,0xC0,0x90,0xD0};

void extinterrup0(void) interrupt 0 { unsigned char i; next = YES; EX0 = 0; // desabling further interrupts during the current subroutine TR0 = 0; // stop timer0 // wainting for 2.5 remote pulses 2.5 * 796 = 1990 last 12 bits // 65536 - 1990 = 63546 = 0xF83A TL0 = 0x3A; TH0 = 0xF8; TR0 = 1; // start timer0 while(TF0 == 0){}// wait for 2.5 remote pulses TF0 = 0; TR0 = 0; // stop timer0

buffer = 0; for(i=0; i<12; i++) { firsthalf = 0; secondhalf = 0; // wainting for 740 clks // 65536 - 740 = 64796 = 0xFD1C TL0 = 0x1C; TH0 = 0xFD; TR0 = 1; // start timer0 while(TF0 == 0){}// wait TR0 = 0; // stop timer0 TF0 = 0;

Page | 23

firsthalf = P3_2; // firsthalfdata to firsthalf TL0 = 0x1C; TH0 = 0xFD; TR0 = 1; // start timer0 while(TF0 == 0){} // wait

TR0 = 0; // stop timer TF0 = 0; secondhalf = P3_2;// secondhalfdata to secondhalf

sample = secondhalf; if(i < 11) buffer = buffer << 1; }

buffer = ~buffer;// changing from active0 to active1 currentlowbyte = buffer%256; currenthighbyte = buffer/256;

if(isfirstdigit == YES) { rxpassword[rxdigitcounter] = currentlowbyte; previoushighbyte = currenthighbyte; previouslowbyte = currentlowbyte; isfirstdigit = NO; rxdigitcounter++; lcdcmd(0xC0);// set cursor at line1 position 1 Millisecdelay(1); lcddata('*'); }

if( (previoushighbyte != currenthighbyte)||(previouslowbyte != currentlowbyte)) { if((rxdigitcounter > 0) && ( rxdigitcounter < 4)) { rxpassword[rxdigitcounter] = currentlowbyte; previoushighbyte = currenthighbyte;

Page | 24

previouslowbyte = currentlowbyte; rxdigitcounter++; lcddata('*'); } if(rxdigitcounter == 4 && currentlowbyte == 0) { cmpflag = 1; rxdigitcounter = 0; } }

END: EX0 = 1; // enabling return; }

next interrupt

void main (void) { unsigned char i,j,k; IE = 0x83; // enabling timer0 overflow interrupt and enabling INT0 1000 0011 TCON = 0x01; // desabledtimer to run and enabling edge trigger INT0 TMOD = 0x01; // mode 1 16 bit counter for timer0 0000 0001 P2 = 0xFF; P3_2 = 1; INT0 = 1; lcdcmd(0x38); lcd Millisecdelay(1); lcdcmd(0x0C); Millisecdelay(1); // display on cursor off //2 line & 5*7 matrix also valid for 4 line

lcdcmd(0x06); Millisecdelay(1);

// increment cursor, shift cursor ?????

RESTART: CLRSCR; // clear display screen Millisecdelay(1);

for(j =0; j<4; j++)

Page | 25

rxpassword[j] = 0; isfirstdigit = YES; LOCK = CLOSE; BUZZER = 1; //Buzzer off codeisnotcorrect = TRUE; rxdigitcounter = 0; previouslowbyte previoushighbyte currentlowbyte currenthighbyte = = = = 10; // not in the range 0 to 9 10; // not in the range 0 to 9 0; 0;

cmpflag = 0; // cmpflag is set in interrupt function //********************************** new block1 starts

// setting initial line address lcdcmd(initial_line_add[0] ); Millisecdelay(1); // displaying prompt for(k =0; k<16; k++) { lcddata(prompt[k]); Millisecdelay(1); }

//********************************** new block1 ends

while(codeisnotcorrect) { if(cmpflag == 1) // cmpflag is set in interrupt subroutine { for(memberno =0; memberno<4;memberno++) { for(i = 0; i<4; i++) { if( (userpassword[memberno][i]) != (rxpassword[i] + 48) ) break; } if(i==4) break;

Page | 26

if(i == 4) { LOCK = OPEN; codeisnotcorrect = FALSE; // setting initial line address lcdcmd(initial_line_add[0] ); Millisecdelay(1); // displaying of welcome for(k =0; k<16; k++) { lcddata(welcome[memberno][k]); Millisecdelay(1); } } // if(i < 4) if(memberno == 4) { // setting initial line address lcdcmd(initial_line_add[0] ); Millisecdelay(1); // displaying access denined for(k =0; k<16; k++) { lcddata(accessdenined[k]); Millisecdelay(1); } BUZZER = 0; } cmpflag = 0; } } /* next = NO; while(next == NO) { ; } */ // Buzzer on

Page | 27

Millisecdelay(10000); goto RESTART;

void lcdcmd (unsigned char ldata) { P0 = ldata; // put data on the pins rs = 0; rw = 0; en = 1; // strobe the enable pin Millisecdelay(1); en = 0; return; } void lcddata (unsigned char ldata) { P0 = ldata; // put the data on the pins rs = 1; rw = 0; en = 1; // strobe the enable pin Millisecdelay(1); en = 0; return; } void Millisecdelay (unsigned int k) { unsigned int i,j; for(i=0; i<k; i++) { for(j=0; j<100; j++) {;} } }

Page | 28

4.2 Simulator
KEIL Micro Vision is an integrated development environment used to create software to be run on embedded systems (like a microcontroller). It allows for such software to be written either in assembly or C programming languages and for that software to be simulated on a computer before being loaded onto the microcontroller. The software used is c programming

Page | 29

Kiel Vision3 is an IDE (Integrated Development Environment) that helps write, Compile, and debug embedded programs. It encapsulates the following components:

A project manager. A make facility. Tool configuration Editor.

A powerful debugger. To create our project in uVision3: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project Select Device and select a device from Device Database. 4. Create source files to add to the project 5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add the Source files to the project. 6. Select Project - Options and set the tool options. Note that when the target device is selected from the Device Database all-special options are set automatically. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target. To create a new project, simply start micro vision and select Project=>New Project from the pulldown menus. In the file dialog that appears, a filename and directory was chosen for the project. It is recommended that a new directory be created for each project, as several files will be generated. Once the project has been named, the dialog shown in the figure below will appear, prompting the user to select a target device. The chip being used is the AT89S52, which is listed under the heading Atmel. Next, Micro Vision was instructed to generate a HEX file upon program compilation. A HEX file is a standard file format for storing executable code that is to be loaded onto the Microcontroller. In the Project Workspace pane at the left, rightclick on Target 1 and select Options for Target 1 .Under the Output tab of the resulting options dialog, ensure that both the Create Executable and Create HEX File options are checked. Then click OK.

Page | 30

Next, a file must be added to the project that will contain the project code. To do this, expand the Target 1 heading, rightclick on the Source Group 1 folder, and select Add files Create a new blank file (the file name should end in .c), select it, and click Add. The new file should now appear in the Project Workspace pane under the Source Group 1 folder. Double-click on the newly created file to open it in the editor. To compile the program, first save all source files by clicking on the Save All button, and then click on the Rebuild All Target Files to compile the program as shown in the figure below. If any errors or warnings occur during compilation, they will be displayed in the output window at the bottom of the screen. All errors and warnings will reference the line and column number in which they occur along with a description of the problem so that they can be easily located. When the program has been successfully compiled, it can be simulated using the integrated debugger in Kiel Micro Vision. To start the debugger, select

Debug=>Start/Stop Debug Session from the pulldown menus. At the left side of the debugger window, a table is displayed containing several key parameters about the simulated microcontroller, most notably the elapsed time (circled in the figure below). Just above that, there are several buttons that control code execution. The Run button will cause the program to run continuously until a breakpoint is reached, whereas the Step Into button will execute the next line of code and then pause (the current position in the program is indicated by a yellow arrow to the left of the code).

Page | 31

4.3 Hardware of project

Page | 32

Relay driver circuit

Receiver circuit

Page | 33

CHAPTER: 5 CONCLUSION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From this project we can understand that security becomes high rather than older security system, due to this we can save time, we also can handle this system from as far as 10 meters.

It is useful where there is high security required like bank offices, etc.There cannot be hack this system due to use of password system. For every user there are predefined passwords, so that it becomes easy to use and it becomes very comfortable then older security system. Due to use of infrared rays there is no interference in transmission. Due to use of RC5 protocol transmitter there is no interference with T.V remote.

Page | 34

REFERENCES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WEBSITE: 1.http://www.keil.com/dd/docs/datashts/atmel/at89s52_ds.pdf 2. http://en.wikipedia.org/wiki/Transformer 3. http://en.wikipedia.org/wiki/Diode

Page | 35

APPENDIX-COSTING OF PROJECT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. Name of the components IC AT89S52 (with socket) MCT2E(with socket) 12 V DC single cont relay Resistor Transistor(BC547) Diode Capacitor(1000f/35V) Capacitor(100f/25V) Capacitor(10f/16V) Capacitor(0.1f) Crystal(11.0592MHz) IC LM 7805 LED(3mm) Push Button Switch(Micro) Connector(10 pin Rely mate type) Adaptor 12V (DC) / 1 Amp PCB mounted 3 pin connector Microcontroller Card Relay card(Automation Engineers) Bridge Rectifier (1 Amp) Quantity 1 4 4 15 5 10 1 1 2 5 1 1 5 1 1 1 4 1 1 1 Price(Rs.) 130.00 36.00 32.00 25.00 5.00 5.00 6.00 1.00 4.00 2.00 9.00 8.00 12.00 5.00 4.00 160.00 28.00 300.00 1250.00 10.00 Page | 36

21. 22. 23. 24. 25. 26. 27. 28.

10 pin Rely mate connector Sensor TSOP 1738 TV remote with battery 5 m Flexible wire 2 pin plug Acrylic plate 3 mm (16" * 16") Pull up resistor Bulbs

1 1 1 1 1 1 1 4

10.00 25.00 100.00 35.00 3.00 120.00 10.00 80.00

TOTAL: 2410 (Rs.)

Page | 37