Preview only show first 10 pages with watermark. For full document please download

Automatic Room Light Controller With Sensors

"Automatic Room light controller with sensors" is mainly used to save power and saves the time .

   EMBED


Share

Transcript

Automatic Automatic room light light controll contro ller er with sensors A Mini Mini Project Report R eport Entitled On “ AUTOMATIC ROOM LIGHT CONTROLLER WITH SENSORS” A report Submitted in partial fulfillment of the Academic Academ ic requirements for the award of the degree of BACHELOR BACHELO R OF O F TECHNOLOGY in ELECTRONICS AND COMMUNICATION ENGINEERING by P.BHASKAR (11QM1A0469) T.SURESH (11QM1A0479) S.PRAVEEN KUMAR (11QM1A0475) (11QM1A 0475) Under the esteemed guidance of P.ANUSHA,M.Tech. Asst. Asst. Professor P rofessor DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 1 Automatic Automatic room light light controll contro ller er with sensors KG REDDY COLLEGE OF ENGINEERING & TECHNOLOGY CHILKUR CHILKUR (V), MOINABAD MOIN ABAD (M), RAN R ANGA GA REDDY DISTRICT (A.P) DEPARTMENT OF EL E LECTRONICS ECTRON ICS AND COMMUNICATION ENGINEERING CERTIFICATE This is to certify that the Dissertation entitled LIGHT CONTROLLER WITH SENSORS” “AUTOMATIC ROOM is a bonafide work done by P.BHASKA P. BHASKAR(11QM1A0469), R(11QM1A0469), T.SURESH(11QM1A047 T.SURESH(11QM1A0479), 9), S.PR S.PRAV AVEEN EEN KUMAR (11QM1A0475). in partial fulfillment of the academic requirements requirements for the the award of the degree of Bachelor of Technology in in ELECTRONICS AND COMMUNICATION ENGINEERING , submitted to the Department of ECE, KG REDDY College of Engineering & Technology, Hyderabad. INTERNAL INT ERNAL GUIDE P.ANUSHA, M.Tech.  Asst. Profe Professor ssor HOD OF ECE Mr.M.N.NARSAIAH,  M.Tech(Ph.D) Associate Professor EXTERNAL EXAMINER EXAMINER ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 2 Automatic Automatic room light light controll contro ller er with sensors ACKNOWLEDGMENT With great pleasure we want to take this opportunity to express my heart felt gratitude gratit ude to a ll the peop le who helped in making this p roject work a grand grand success. s uccess. We are very much thankful to Mr. Krishna Reddy . Honourable chairman for his help in  providing good good facilities facilities in ou o ur college We are highly indebted to Dr.Madhusudan Nair, Principal KGRCET for giving  permissio  permissio n to carry out this p roject in KGRCET. We would like to thank M.N.Narsaiah, Assoc. Professor Head of the Department of Electronics & Communication Engineering , for his moral support throughout the  period of o ur stud stud y in KGRCET. We are grateful to P.ANUSHA for  her valuable suggestions and guidance during the execu executi tion on of o f this project project work. We are very much thankful to KGRCET  for giving us this opportunity to do this project in embedded systems. We express our deep sense of gratitude to P.ANUSHA   for her constant guidance throughout the course of pro pro ject work. work. Finally we would like to thank the Teaching & Non- teaching staff of Department of Electronics & Communication Engineering , for their co-operation. P.BHASKAR T.SURESH (11QM1A0469) (11QM1A0479) S.PRAVEEN S.PRAVEE N KUMAR (11QM1A0475) ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 3 Automatic Automatic room light light controll contro ller er with sensors CONTENTS Abstract i List List o f figures figures ii List of table’s  table’s   iii List List o f screens iv CHAP CHAP TER NO. CHAPTER NAME 1. INTRODUCTION 1.1 1.2 1.3 1.4 1.5 2. Block Block d iagram iagram Explanati Explanat io n 6 Description o f Microcontroll Microcontro ller er Liq Liq uid Crystal Crystal Display Rela Rela y switc switc h I R sensors 9 13 18 23 SOFTWA SOF TWARE RE DESCRIPTION DESCRIPTION 4.1 4.2 4.3 4.4 5. 1 2 2 4 5 HARDWARE REQUIREMENTS 3.1 3.2 3.3 3.4 4. Abbreviation Abbreviation o f Embedded Embedded systems Examp Examp les and Embedded Embedded s ystem ste ms Embedded ‘C’ Firmware Firmware Operating systems BLOCK DIAGRAM 2.1 3. PAGE PAG E NO. Keil Com Co mp iler iler Pro Load Procedural steps for Co mp ilat ilat ion Simula Simula tio tio n and Dump Dump ing 4.3.1 Comp Comp ilat ilat io n and simulation simulatio n steps 4.3.2 Dumping steps Program Code 30 30 31 31 36 37 RESULT Result Analy Ana lysis sis ELECTRONICS & COMMUNICATION ENGG.(KGRCET) 40 Page 4 Automatic Automatic room light light controll contro ller er with sensors CONCLUSION 41 FUT FU TURE SCOPE 42 REFERENCES 43 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 5 Automatic Automatic room light light controll contro ller er with sensors ABSTRACT In the undertaken pro pro ject we have designed a circuit c ircuit that that swi s witc tches hes o n a nd swit sw itches ches off automatically whenever a person enters and leave the room respectively. The benefit of this circuit is that after entering the room person will not have to search for the light switch the the light light will automatically be turned o n and need need not to swit sw itch ch it o ff as the person leave the the roo m, the room light light will w ill be turned off automatically. When an object moves into a room it will be detected by the IR sensor ‘1’ this makes the microcontroller to switch on the light using relay switch by understanding that something has moved in to the room. if the last object moves out of the room it has  passes through thro ugh IR sensor sensor ‘2’ and microcontroll microcontro ller er will switch OFF the light using rela relay. y. Low cost, Easy to use. can be implemented in single door, Can be used to automatic room light control. Main advantage of this project is that it helps in energy conservation. Because when there there is nobody inside ins ide the the roo m the n lights lights are turned off. It is used only when one person cuts the rays of the sensor hence cannot be used when two two or more person perso ns cross the t he door simultaneously. When anybody is inside the room and we need to switch OFF the power then we have to do it ma ma nually. So, in this case we fa fa il to a uto uto matically matica lly control co ntrol the light. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 6 Automatic Automatic room light light controll contro ller er with sensors LIST OF FIGURES FIGURE NO. FIGURE NAME PAGE NO. 1.1 Embedd Embedded ed system 1 2.1 Block Block d iagra iagra m o f project 6 2.2 Circuit d iagra m o f power po wer supply 7 3.1 Pin d iagra iagra m o f 8051 9 3.2 Block Block d iagram iagram of 8051 10 3.3 Lcd d ispla ispla y 15 3.4 Lcd interfacing interfacing 18 3.5 Rela Rela y switc switc h 19 3.6 Internal Internal structure o f relay relay 20 3.7 4 Pin relay relay 21 3.8 Energized relay 21 3.9 De-Energized relay 22 3.10 Circuit diagram of relay 22 3.11 Circuit diagram of transmitter transmitter 25 3.12 Receiver 26 3.13 TSOP 1738 27 3.14 Block Block d iagram iagram of TSOP 28 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 7 Automatic Automatic room light light controll contro ller er with sensors LIST OF TABLES TABLE NO. N O. TABLE NAM NA ME 3.1 Descriptio Description n o f Port 3 10 3.2 Pin Descri Descr ip tion o f Lcd 14 3.3 Lcd Co mmand mmand codes 15 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) PAGE PAG E NO. Page 8 Automatic Automatic room light light controll contro ller er with sensors LIST OF SCREENS SCREEN NO. SCREEN NAME NAME PAGE NO. 4.3 Open keil ke il and start a new new p roject roject 31 4.4 Opening a new project 32 4.4 ATMEL (source (source code) cod e) 32 4.5 Creating a new project 33 4.6 Save it with “.c” 33 4.6 Adding Add ing file file s to gro gro up 34 4.7 Rebuilding all targets 35 4.8 Debugging the program progra m 36 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 9 Automatic Automatic room light light controll contro ller er with sensors CHAPTER 1 INTRODUCTION 1.1 EMBEDDED SYSTEM: An embedded system  is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few predefined tasks, usually with very specific requirements. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Personal digital assistants (PDAs) or handheld computers are generally considered embedded devices because of the nature of their hardware design, even though they are more expandable in software terms. This line of definition continues to blur as devices expand. With the introduction of the OQO Model 2 with the Windows XP operating system and ports such as a USB port  —   both features usually belong to "general purpose computers", —  computers",  —  the  the line of nomenclature blurs even more. Physically, embedded systems ranges from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, controllers, or the s ystems ystems controlling nuclear power plants. In terms of complexity embedded systems can range from very simple with a single microcontroller chip, to very complex with multiple units, peripherals and networks networks mo unted inside inside a large chass chassiis or en e nc lo sure. Fig 1.1. Embedded system ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 10 Automatic Automatic room light light controll contro ller er with sensors 1.2 Examples of Embedded Systems:  Avionics, such as inertial guidance systems, flight control hardware/software and other integrated systems in aircraft and missiles ● Cellular Cellular telephones te lephones and telephone switches ● Engine Engine contr co ntro o lle lle rs and antilock antilock brake b rake controllers for automobiles ● Home automation products, such as thermostats,air conditioners, sprinklers, and security monitoring monitoring systems. ● Handheld calculators ● Handheld computers ● Household appliances, including microwave ovens, washing machines, television sets, sets, DVD players players an a nd recorders ● Medical equipment ● Personal digital assistant ● Videogame consoles ● Comp Comp uter peripherals peripherals such s uch as routers and p rinters. rinters. ● Industrial controllers for remote machine operation. 1.3 What is an Embedded System? An embedded system is an application that contains at least one programmable computer and which is used by individuals who are, in the main, unaware that the system is computer based. Which Programming Language should you use? Having decided to use an 8051 processor as the basis of your embedded system, the next key decision that needs to be made is the choice of programming language. In order to identify a suitable language for embedded systems, we might begin by making the following observations. ● Computers (such as microcontroller, microprocessor or DSP chips) only accept instructions in ‘machine code’ (‘object codes’). Machine code is, by definition, in the language of the comp uter, rath rat her th t han that o f the pro pro grammer. Interpretation of of the code by the pro grammer grammer is difficult and a nd error pro pro ne. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 11 Automatic Automatic room light light controll contro ller er with sensors ● All software, whether in assembly, C, C++, Java or Ada must ultimately be translated translated into machin mac hinee code in order to be exec uted by th t he com co mp uter. ● Embedded processors  –   like the 8051  –   have limited processor power and very limited limited memory memor y available: available: the language used must must be effi e fficie cient. nt. ● The language chosen should be in common use. Summary of C language Features: It is ‘mid‘mid - level’, with ‘high‘high- level’ features (such as support for functions and modules), od ules), an a nd ‘l ‘ lo w- level’ features (such as good access to hardware via pointers). ● It is very efficient. ● It is popular and well understood. ● Even desktop developers who have used only Java or C++ can soon understand C syntax. ● Good, well-pro well-proven ven co co mpilers mpilers are avail a vailab able le fo fo r every embedded processor (8-bit (8- bit to 32-bit or more). Basic C program structure: //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //Basic //Basic blank b lank C progra progra m that that does nothing // Includes Includes //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include reg51.h> // SFR declarations Void Void main (void) (void) {  While While (1); (1 ); {  Body o f the loop // Infinite In finite loop  }  } // match the braces ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 12 Automatic Automatic room light light controll contro ller er with sensors 1.4 FIRMWARE: Firmware is a software program permanently etched into a hardware device such as a keyboards, hard drive, BIOS, or video cards. It is programmed to give permanent instructions to communicate with other devices and perform functions like basic input/output tasks. Firmware is typically stored in the flash ROM (read only memory) of a hardware hardware de vice. vice. It can be erased a nd rewritten. rewritten. Firmware was originally designed for high level software and could be changed without having to exchange the hardware for a newer device. Firmware also retains the  basic instruct instructiio ns for hardware devi de vices ces that make them op erative. Without firmware, firmware, a hardware device would be non-functional. Originally, firmware had read-only memory (ROM) and programmable read-only memory (PROM). It was designed to be permanent. Eventually PROM chips could be updated and were called erasable programmable read-only memory (EPROM). But EPROM was expensive, time consuming to update and challenging to use. Firmware eventually evolved from ROM to flash memory firmware; thus, it became easier to update and user friendly. friendly. levels levels of firmware: firmware: 1. Low Level Firmware: This is found in ROM, OTP/PROM and PLA structures. Low level firmware firmware is often read- only memo memo ry and cannot be ch c hang an ged or o r updated. It is sometimes referred to as hardware. 2. High Level Firmware: This is used in flash memory for updates that is often considered considered a s software. 3. Subsystems: These have their own fixed microcode embedded in flash chips, CPUs and LCD units. A subsystem is usually considered part of the hardware device as well as high level firmware. BIOS, modems and video cards are usually easy to update. But firmware in storage devices usually gets overlooked; there are no standardized systems for updating firmware. firmware. Fortunately Fortunate ly,, stora ge devices devices do not need to be updated often. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 13 Automatic Automatic room light light controll contro ller er with sensors 1.5 OPERATING SYSTEM: What is an operating system? An operating system (sometimes abbreviated as "OS") is the program that, after being initially loaded into the computer by a  boot  program,  program, manages all the other programs in a co mp uter. uter. The other programs are called applicat io ns or  application   application programs. programs. The application programs make use of the operating system by making requests for services through a defined application program interface (API). (API). In addition, users can interact directly with the operating system through a user interface such as a command language or a graphical user interface (GUI). (GUI). An operating system p erfo erfo rms these services services for app lications: lications: In a  a  multitasking operating system where multiple programs can be running at the same time, the operating system determines which applications should run in what order and how much time should be allowed for each application before giving another application a turn. It manages manages th t he sharing of internal internal memory among amo ng multip multip le applications. applications. It handles input and output to and from attached hardware devices, such as hard disks,  printe  printe rs, and dial-up dial-up port po rts. s. It sends messages to each application or interactive user (or to a system operator) about the status of operati operat io n and and any an y errors that that may have ha ve occurred. occurred. It can offload the management of what are called batch jobs (for example,  printing) so th t hat the initiating application is freed freed from this work. work. On computers that can provide parallel processing, an operating system can manage how to divide the the p rogram so tha tha t it runs runs on more t han one o ne processor at a time. All major computer platforms (hardware and software) require and sometimes include an operating system. Linux, Windows,  Windows,  VMS, OS/400, AIX,  AIX,  and z/OS are all examples of operating systems. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 14 Automatic Automatic room light light controll contro ller er with sensors CHAPTER 2 BLOCK DIA D IAGRAM GRAM In this “A “Automatic room light controller with sensors”  sensors”   project we have mainly used used hardware co mponents pon ents like like Relay switch, switch, I R se nsors, nsors, Lcd display displa y and Tsop Tsop 1738. And the automatic room light controller with sensors are explained with neat block diagram as shown below. IR sensor Receiver 1 1 IR sensor Receiver 2 2 LCD Display Micro Controller Relay Power Supply Fig2.1. block diagram 2.1 Block Diagram Explanation: In this section we will be discussing about the complete block diagram and funct functiio na l description of o ur project. And A nd also brief description of each bl b lo ck in the block block diagram. Micro controller: In this project work the microcontroller is plays major role. Microcontroller were originally originally used as components co mponents in complicated process-control process-co ntrol systems. However, becaus beca usee of their small size and low price, microcontrollers are now also being used in regulators ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 15 Automatic Automatic room light light controll contro ller er with sensors for individual control loops. In several areas microcontroller are now outperforming their analog counterparts and are c heaper heaper as well. Power Supply This section is meant for supplying Power to all the sections mentioned above. It  basically  basically consists o f a Trans Trans former to step step down do wn the 230V ac to 12V ac fo llo llo wed by diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to regulate the obtained dc voltage(5V). Fig.2.2. circuit diagram of power supply But here in this project two power supplies are used one is meant to supply operating voltage for Microcontroller and the other is to supply control voltage for Relays. LCD Display Section: This section is basically meant to show up the status of the project. This project makes use of Liquid Crystal Display to di d isplay spla y / pro mp t for necessary informatio informatio n. Relay Switch: Relay is a electrical to magnetic converting switch when input is high magnetic field is  produced  produced swit sw itch ch is on o n otherwise otherwise switch is off o ff.. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 16 Automatic Automatic room light light controll contro ller er with sensors CHAPTER 3 HARDWARE REQUIREMENTS 3.1 AT89C51 AT89C51 MICROCONTROLLER 3.1.1 Features Features ➢  AT89C51  AT89C51 based architecture ➢  8-Kbyt  8-K bytes es of on-chip Reprogra Reprogra mmab mmable le Flash Memory ➢  128 x 8 RAM ➢  Two 16-bit Timer/Counters ➢  Full duplex duplex serial ser ial channel ➢  Boolean processor ➢  Four 8-bit I/O ports, 32 I/O lines ➢  Memory addressing capability  – ➢ 64K ROM and 64K RAM  Power save modes:  – Idle and power-down ➢  Six interrupt sources ➢  Most instructions execute in 0.3 us ➢  CMOS and TTL compatible ➢  Maximum speed: 40 MHz @ Vcc = 5V ➢  Ind  Ind ustrial temperatu temperature re available ➢  Packages available:  –  40-pin  40-pin DIP  –  44-pin  44-pin PLCC  –  44-pin  44-pin PQFP 3.1.2 The T he Microcontroll Microcontroller: er: A microcontroller is a general purpose device, but that is meant to read data,  perform limited limited calcul calc ulat atiio ns on that data and contr co ntro o l its e nvironme nvironme nt based o n those calculations. The prime use of a microcontroller is to control the operation of a machine using a fixed program that is stored in ROM and t hat does not change o ver the lifet lifet ime ime of of ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 17 Automatic Automatic room light light controll contro ller er with sensors the system. The microcontroller design uses a much more limited set of single and double  byte instructions instructions that are used used to move ov e data and code from internal memory to the ALU. The microcontroller is concerned with getting data from and to its own pins; the architecture architecture a nd instruct instructiion set are optim opt imized ized to handle and le data data in bit and byte size. The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8Kbytes of Flash Programmable and erasable read only memory (EROM). The device is manufactured using Atmel’s high-density high-density nonvolatile memory technology and is functionally compatible with the industry-standard 80C51 microcontroller instruction set and pin out. By combining versatile 8-bit CPU with Flash on a monolithic chip, the Atmel’s AT89c51 is a powerful microcomputer, which provides a high flexible and costcosteffective effective solution so lution to ma ny embedded embedded control co ntrol appli app lications. cations. AT89C51 Bl B lock Diagram D iagram Fig3.1. block diagram of 8051 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 18 Automatic Automatic room light light controll contro ller er with sensors 3.1.4 Pin configuration of AT89c51 Microcontroller Fig3.1.2. 8051 micro controller ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 19 Automatic Automatic room light light controll contro ller er with sensors 3.1.5 Pin Description: VCC Supply voltage GND Ground Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL 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 access to external program and data memory. In this mode, P 0 has internal pullups. Port 0 also receives the code bytes during Flash programming and outputs the code  bytes during p rogram verifica verificatio tion n. Ext Exter ernal nal p ull ull-- ups are required d uring progra program m verification. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The port 1output  bufferss can sink/so ur  buffer urce ce fo ur TTL inputs inputs.. When 1s are written to po port rt 1 p in ins, s, they are  pulled high by the t he int inter ernal nal pullpull- ups ca n be used as in inp p uts. As input inputs, s, Por t 1 pins that are externally being pull p ulled ed lo w will will so urce current (1) beca us usee of o f the internal internal p ull ull-- ups ups.. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The port 2 output  bufferss can sink/so ur  buffer urce ce fo ur TTL inputs inputs.. When 1s are written to po port rt 2 p in ins, s, they are  pulled high by the int internal ernal pull pu ll-- ups can be us used ed as in inp p uts. As in inp p uts, Port 2 pins that are externally externall y being be ing pulled low will source current because of t he internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during access to DPTR. In this application Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that use 8-bit data address (MOVX@R1), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash  programming  programmi ng an a nd verific verificaa ti tio o n. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 20 Automatic Automatic room light light controll contro ller er with sensors Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The port 3 output  bufferss can sink/so ur  buffer urce ce fo ur TTL inputs inputs.. When 1s are wr writ itten ten to po port rt 3 p in ins, s, they are  pulled high by the t he int inter ernal nal pullpull- ups ca n be used as in inp p uts. As input inputs, s, Por t 3 pins that are externally externall y being be ing pulled low will source current because of t he internal pull-ups. Port 3 also also receives rece ives so so me control signals for for Flash F lash Progra Progra mmi mming ng an a nd ve verification. rification. TABLE 3.1 port 3 descri descr ip ti tio o n. Port pin Altee rnate Functi Alt Functions ons P3.0 RXD(serial input port) P3.1 TXD(serial input port) P3.2 INT0(external interrupt 0) P3.3 INT1(external interrupt 1) P3.4 T0(timer 0 external e xternal input) P3.5 T1(timer 1 external input) P3.6 WR(external WR( external data mem memo o ry write strobe) P3.7 RD(exter RD(ext ern na l da data ta memory read strobe) RST Rest input A on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG: Address Latch Enable is an output pulse for latching the low byte of the address during access 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/16 the oscillator frequency and may be used for external timing or clocking purpose. Note, however, that one ALE pulse is skipped d uring eac h access access to external e xternal Data memory. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 21 Automatic Automatic room light light controll contro ller er with sensors PSEN Program Store Enable is the read strobe to external program memory when the AT89c51 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 mem me mo ry.  __  EA /VPP External Access Enable (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 when 12-volt programming programming is selected. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL 2 Output from the inverting oscillator amplifier. 3.2 LIQUID CRYSTAL DISPLAY Liquid crystal displays (LCD s) have materials which combine the properties of  both liq liq uids uids and crystals. Rather than having a melting po int, they have have a temperature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped tog together ether in an orde ordered red form similar similar to a crystal. An LCD consists of two glass panels, with the liquid crystal material sand witc witc hed in betwee n them. them. The inner inner surface s urface o f the glass glass pl p lates are coa ted with transparen transpare nt electrodes which define the character, symbols or patterns to be displayed polymeric layers layers are present prese nt in between between t he electrodes elec trodes and the liquid crystal, which makes t he liq liq uid uid crystal crystal molecul olec ules es to maintain a defined orien orie ntation a ngle. ngle. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 22 Automatic Automatic room light light controll contro ller er with sensors One each polarisers are pasted outside the two glass panels. These polarisers would rotate the light rays passing through them to a definite angle, in a particular direction When the LCD is in the off state, light rays are rotated by the two polarisers and the liquid crystal, such that the light rays come out of the LCD without any orientation, and hence hence the LCD appears transparent. When sufficient voltage is applied to the electrodes, the liquid crystal molecules would be aligned in a specific direction. The light rays passing through the LCD would  be rotated rotated by the pol po larisers, which would result in activating ac tivating / highlighting highlighting the desired characters. The LCD’s are lightweight with only a few millimeters thickness. Since the LCD’s consume less power, they are compatible compa tible with low power electronic circuits, and can be power po wered ed for long durations. durations. The LCD s won’t generate light and so light is needed to read the display. By using backlighting, reading is possible in the dark. The LCD’s have long life and a wide operating temp temp erature range. range. Changing the display size or the layout size is relatively simple which makes the LCD’s more customer friendly. The LCD s used exclusively in watches, calculators and measuring instruments is the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCD s being extensively used in telecommunications and entertainment electronics. The LCD s has even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, graphics, and also in sma sma ll TV applications. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 23 Automatic Automatic room light light controll contro ller er with sensors Fig3.3 Fig3.3 Lcd displ disp lay LCD operation In recent years the LCD is finding widespread use replacing LED s (seven-segment LED or other multi segment LED s). This is due to the following reasons: 1. The declining declining prices p rices of LCD s. s. 2. The ability to display numbers, characters and graphics. This is in contract contrac t to LED s, whi w hicc h are limited to numbers and a few c haracters. haracte rs. 3. Inco Incorporation rporation of a refreshing controller into the LCD, LCD, th t here by relieving the CPU of the ta ta sk o f refreshing the LCD. LCD. In the contrast, contrast, the LED must must be refres refres hed hed by the CPU to to keep displaying d isplaying the data. 4. Ease Ease of progr pro graa mming for characters charac ters and graphi g raphicc s. LCD pin description The LCD discussed in this section has 14 pins. The function of each pin is given in table. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 24 Automatic Automatic room light light controll contro ller er with sensors TABLE 3.2: Pin description for LCD: Pin symbol I/O Description 1 Vss -- Gro Gro und 2 Vcc -- +5V power supply 3 VEE -- Power supply to control contrast 4 RS I RS=0 to select command register RS=1 to select data register 5 R/W R/W I R/W=0 R/W=0 for write R/W=1 for read 6 E I/O Enable Enable 7 DB0 DB0 I/O The 8-b it data b us 8 DB1 DB1 I/O The 8-b it data b us 9 DB2 DB2 I/O The 8-b it data b us 10 DB3 DB3 I/O The 8-b it data b us 11 DB4 DB4 I/O The 8-b it data b us 12 DB5 DB5 I/O The 8-b it data b us 13 DB6 DB6 I/O The 8-b it data b us 14 DB7 DB7 I/O The 8-b it data b us ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 25 Automatic Automatic room light light controll contro ller er with sensors TABLE 3.3: LCD Command Codes Code (hex) Command to LCD Instruction Register  1 Clear Clear d isplay spla y screen scree n 2 Return home home 4 Decreme Decrement nt cursor cu rsor 6 Inc Inc rement rement cursor 5 Shift d isplay isplay right 7 Shift d isplay left 8 Displa Display y o ff, ff, cursor o ff A Displa Display y o ff, ff, cursor o n C Displa Display y o n, c ursor off E Displa Display y o n, c ursor o n F Displa Display y o n, c ursor b link linking ing 10 Shift cursor position positio n to left 14 Shift cursor position positio n to right 18 Shift the e ntire d isplay isplay to the left 1C Shift the e ntire d isplay isplay to the right 80 Force cursor to beginning be ginning o f 1st  line C0 Force cursor to beginning be ginning o f 2n  line 38 2 lines and 5 x7 matrix Uses: The LCDs used exclusively in watches, ca lculators and a nd measuring instrume instruments nts are are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. The LCDs have ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 26 Automatic Automatic room light light controll contro ller er with sensors even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, graphics, and also in sma sma ll TV applications. Lcd Interfacing Sending commands and data to LCDs with a time delay: Fig 3.4. lcd interfacing To send any command from table 2 to the LCD, make pin RS=0. For data, make RS=1.Then place a high to low pulse on t he E pin to enable e nable th t he internal internal latch atc h of the LC LC D. 3.3 RELAY SWITCH A rela y is a n electrically operated switch. operated switch.   Many relays use an electromagnet an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid as  solid state relays - . Relays are used where it is necessary to control a circuit by a low-power ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 27 Automatic Automatic room light light controll contro ller er with sensors signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers . they repeated the signal coming in from one circuit and re-transmitted it on another circuit.Relays were used extensively in telephone exchan exchang ges a nd early com co mputer pu terss to perform logica l operations. Ex: A relay is used to control the air conditioner in your home. The AC unit  probably runs o ff o f 220VAC 220V AC at around 30A. That's That's 6600 Watts! The coil that co ntrol tro ls the relay may may only o nly need a few watts to to pull p ull the co ntacts ntacts to gether. gether. Fig 3.5. relay switch The internal structure of the relay is shown in the image above which is embedded inside the plastic covering. Relay switch switc h shown sho wn in the image above co nsists of five ter minals. Two terminals termina ls are used to give the input DC voltage also known as the operating voltage of the relay. Relays relay. Relays are available in different operating voltages like 6V, 12V, 24V etc. The rest of the three terminals are used to connect the high voltage AC circuit. The terminals are called Common, Normally Open (NO) and Normally Closed (NC). Relays are available in various types & categories and in order to identify the correct configuration of the ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 28 Automatic Automatic room light light controll contro ller er with sensors output terminals, it is best to see the data sheet or manual. You can also identify the terminals using a multimeter and at times it is printed on the relay itself. Working The working of a relay can be better understood by explaining the following diagram given below. below. Fig 3.6. internal struct struct ure The diagram shows an inner section diagram of a relay. An iron core is surrounded by a control coil. As shown, the power source is given to the electromagnet through a control switch and through contacts to the load. When current starts flowing through the control coil, the electromagnet starts energizing and thus intensifies the magnetic field. Thus the upper contact arm starts to be attracted to the lower fixed arm and thus closes the contacts causing a short circuit for the power to the load. On the other hand, if the relay was already de-energized when the contacts were closed, then the contact move oppositely and make an open ci c ircuit. As soon as the coil current is off, the movable armature will be returned by a fo rce back to its initial initial positi pos ition. on. This fo fo rce will be almos a lmostt eq ual to to half the strength of the magnetic force. This force is mainly provided by two factors. They are the spring and also gravity. Relays are mainly made for two basic operations. One is low voltage application and the other is high voltage. For low voltage applications, more preference will be given ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 29 Automatic Automatic room light light controll contro ller er with sensors to reduce the noise of the whole circuit. For high voltage applications, they are mainly designed to reduce a phenomenon called arcing. Relay Basics The basics for all the relays are the same. Take a look at a 4  –   pin relay shown  bel  be low. There There are two co lours ou rs shown. show n. The green co lo ur represents represe nts the co ntrol circuit a nd the red colour represents the load circuit. A small control coil is connected onto the control circuit. A switch is connected to the load. This switch is controlled by the coil in the control control circuit c ircuit.. Now let us take the different steps that occour in a relay. Fig 3.7. 4 pin relay Energized Relay (ON) As shown in the circuit, the current flowing through the coils represented by pins 1 and 3 causes a magnetic field to be aroused. This magnetic field causes the closing of the pins 2 and 4. Thus the switch plays an important role in the relay working. As it is apart of the load circuit, it is used to control an electrical circuit that is connected to it. Thus, when the relay in energized the current flow will be through the pins 2 and 4. Fig 3.8. Energized relay ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 30 Automatic Automatic room light light controll contro ller er with sensors De –  Energized  Energized Relay (OFF) As soon as the current flow stops through pins 1 and 3, the switch opens and thus the open circuit prevents the current flow through pins 2 and 4. Thus the relay becomes de-energized and thus in off position. position. Fig 3.9. De-Energized relay In simple, when a voltage is applied to pin 1, the electromagnet activates, causing a magnetic field to be developed, which goes on to close the pins 2 and 4 causing a closed circuit. When there is no voltage on pin 1, there will be no electromagnetic force and thus no no magneti magnet ic field. Thus T hus the switches switche s rema in open. ope n. BLOCK DIAGRAM: BLOCK DIAGRAM: Fig 3.10. circuit diagram of relay ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 31 Automatic Automatic room light light controll contro ller er with sensors Relay Applications Relays are used to realize logic functions. They play a very important role in  providing sa fety critical logic. Relays are used to provide time delay functions. They are used to time the delay open and delay close of contacts. Relays are used to control high voltage circuits with the help of low voltage signals. Similarly they are used to control high current circuits with the help of low current signals. They are also used as protective relays. By this function all the faults during transmission transmission and receptio n ca ca n be detected and isolated. 3.4 I R SENSORS An infrared sensor is an electronic instrument that is used to sense certain character character isti st ics of its surroundings b y either emitting and/or detect ing infrared infrared rad iation. It is also also capab le of o f measuring heat of an object objec t and detect ing motion. Infrared Infrared waves are not visible to the human eye. In the electromagnetic spectrum, infrared radiation is the region having wavelengths longer than visible light wavelengths, but shorter than microwaves. The infrared region is approximately demarcated from 0.75 to 1000µm. The wavelength region regio n fro fro m 0.75 to 3µm is termed as ne ne ar infrared, the t he region from 3 to 6 µm is ter med mid-inf mid- infrared, rared, and a nd the regi reg io n higher than 6 µm is is termed as far infrared. infrared. Infrared technology is found in many of our everyday products. For example, TV has an IR detector for interpreting the signal from the remote control. Key benefits of infrared sensors include low power requirements, simple circuitry, and their portable feature. Types of Infra-Red Sensors Infra-red Infra-red sensors are broad ly classified classified into into two types : Thermal infrared sensors –  sensors –   These use infrared energy as heat. Their photo sensitivity is independent of wavelength. Thermal detectors do not require cooling; however, however, they have slow response response t imes imes and low detection capab ility. ility. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 32 Automatic Automatic room light light controll contro ller er with sensors Quantum infrared sensors –  sensors –   These provide higher detection performance and faster response speed. Their photo sensitivity is dependent on wavelength. Quantum detectors have to be cooled so as to obtain accurate measurements. The only exception is fo r detectors detec tors that are used used in the ne ne ar infrared region. Working Principle A typical system for detecting infrared radiation using infrared sensors includes the infrared source such as blackbody radiators, tungsten lamps, and silicon carbide. In case of active IR sensors, the sources are infrared lasers and LEDs of specific IR wavelengths. Next is the transmission medium used for infrared transmission, which includes vacuum, the atmosphere, and optical fibers. Thirdly, optical components such as optical lenses made from quartz, CaF2, Ge and Si, polyethylene Fresnel lenses, and Al or Au mirrors, are used to converge or focus infrared infrared radiation. rad iation. Likewise, Likewise, to limit limit spectral spec tral respo response, nse, band-pass band- pass filters are ideal. Finally, the infrared detector completes the system for detecting infrared radiation. The output from the detector is usually very small, and hence pre-amplifiers coupled with circuitry circuitry are added to furt her her process the received signals. Applications * The follow follow ing are the key applicati applicat io n areas of infrared infrared sensors: sensors: * Tracking Tracking a nd art history history * Climatology, meteorology, and astronomy * Thermography, communications, and alcohol testing * Heating, hyperspectral imaging, and night vision * Bio Bio logical logical system s ystems, s, photob io modulatio modulatio n, and plant health * Gas detectors/gas detectors/gas leak detectio n * Water and steel a na lysis, lysis, flame detecti detect ion * Anesthes Anesthes io logy test testing ing a nd spectroscopy * Petroleum Petroleum e xplo xplo ration and underground solutio solutio n * Rail saf sa fety. et y. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 33 Automatic Automatic room light light controll contro ller er with sensors A ) TRANS  T RANSMITT MITTER  ER  IR Transmitter and Receiver pair can be easily made using using 555 Timer, IR LED and TSOP1738 IR Receiver. This can be used for remote controls, burglar alarms etc. TSOP1738 is a very commonly used IR receiver for PCM remote control systems. It has only 3 pins, Vcc, GND and Output. It can be powered using a 5V power supply and its active low output can be directly connected to a microcontroller or microprocessor. It has high immunity immunity a gainst a mbient light and othe ot herr electri electr ical d istur st urbances. bances. It I t is able ab le to transfer data up to 2400 bits per second. The PCM carrier frequency of TSOP1738 is 38KHz, so we want to des ign a astabl astab le multivibrator multivibrator of 38KHz. This This can be done by using 555 Timer. and TSOP1738 and TSOP1738 IR Receiver. This can be used for remote controls, burglar alarms etc. TSOP1738 is a very commonly used IR receiver for PCM remote control systems. It has only 3 pins, Vcc, GND and Output. It can be powered using a 5V power supply and its active low output can be directly connected to a microcontroller or microprocessor. It has high immunity against ambient light and other electrical disturbances. It is able to transfer data up to 2400 bits per second. The PCM carrier frequency of TSOP1738 is 38KHz, so we want to design a astable multivibrator of 38KHz. This can be done by using 555 Timer. Circuit Diagram of Transmitter Fig 3.11. circuit c ircuit diagram of transmitter In the above circuit, 555 Timer is wired as an Astable Multivibrator .  The 100μF st th capacitor (C1) is used to reduce ripples in the power supply. 1  and 8  pins of 555 are th used used to give power po wer Vcc and GND respect ively. ively. 4  pin is the reset pin which is active low ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 34 Automatic Automatic room light light controll contro ller er with sensors th input, hence it is connected to Vcc. 5  pin is the Control Voltage pin which is not used in this application, hence it is grounded via a capacitor to avoid high frequency noises through that pin. Capacitor C2, Resistors R1, R2 determines the time period of oscillation. Capacitor C2 charges to Vcc via resistors R1 and R2. It discharges through th Resistor R2 and 7  pin o f 555. The volta volta ge across capacitor C2 is connected to the nd th ed internal comparators via 2  and 6  pins of 555. Output is taken from the 3  pin of the IC. Please read the article Astable Multivibrator using 555 Timer for more detailed working. Charging time constant of the capacitor (output HIGH period) is determined by the expression 0.693(R1+R2)C2 and discharging time constant (output LOW period) is determined by 0.693R2C2. They are approximately equal. B ) RECEIVER  Fig 3.12. receiver For receiving signals send by the transmitter you need only TSOP1738. Connect 5V to Vs and Ground to GND pin of TSOP1738. The output will be active low. Output of    will be HIGH when no signals fall on it and the output will be LOW when TSOP1738  38KHz infrared rays fall on it. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 35 Automatic Automatic room light light controll contro ller er with sensors 3.4.1  TSOP1738 The TSOP 1738 is a member of IR remote control receiver series. This IR sensor module consists of a PIN diode and a pre amplifier which are embedded into a single  package.  package. The out o utp p ut of TSOP is active low and it gives gives +5V in o ff state. state. When IR wav wa ves, from a source, with a centre frequency of 38 kHz incident on it, its output goes low. Lights coming from sunlight, fluorescent lamps etc. may cause disturbance to it and result in undesirable output even when the source is not transmitting IR signals. A  bandpass filter, filter, an integrator integrator stage sta ge a nd an auto mati at ic ga in co ntrol are used used to suppress such such d isturbances. isturbances. Fig 3.13. tsop TSOP module has an inbuilt control circuit for amplifying the coded pulses from the IR transmitter. A signal is generated when PIN photodiode receives the signals. This inp inp ut signal is received control contro l (AGC). For a range ra nge o f inp inp uts, the o utput is fed fed back to AGC in order to adjust the gain to a suitable level. The signal from AGC is passed to a  band pass filter filter to filter filter undesired frequencies. After this, the signal signa l goes goes to a dem de modul od ulator ator and this this demodul demod ulated ated o utpu utputt drives an npn transistor. The collector outp outp ut of the trans trans istor is obtained at pin p in 3 of TSOP modul od ule. e. Members of TSOP17xx series are sensitive to different centre frequencies of the IR spectrum. For example TSOP1738 is sensitive to 38 kHz whereasTSOP1740 to 40 kHz centre frequency.y an aut a utomatic omatic gain ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 36 Automatic Automatic room light light controll contro ller er with sensors AVAILABLE TYPES FOR DIFFERENT CARRIER FREQUENCIES TSOP1730 30 K HZ TSOP1733 33 K HZ TSOP1736 36 K HZ TSOP1737 36.7 K HZ TSOP1738 38 K HZ TSOP1740 40 K HZ TSOP1756 56 K HZ B LOCK LOCK DIAGR DIA GRAM AM OF TS TSOP OP1738 Fig 3.14.block diagram of tsop 3.4.2  FEATURES OF TSOP1738 * Photo Photo detector de tector and preamplifier in one package * Internal filter for PCM frequency * Im I mproved shiel shie ld ing against electri electr ical * field disturbance * TTL and CMOS compatibility * Output active low * Low power consumption * High immun immunity ity agains againstt ambient light light * Continuous data trans missi mission on po ssib ssib le ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 37 Automatic Automatic room light light controll contro ller er with sensors (1200 bi b it/s) *Suitable burst length ≥10 cycles/burst ADVANTAGES AND FUTURE SCOPES * It can be used in our homes because we often forget to switch off our room lights * It help help s in energy conservat conservat io n * In future , we can send this data to remote areas using mobile or internet * Voice alarm sy s ystem ste m can be used to indi ind icate that roo m is full & person can’t enter inside inside * It can be used in various rooms like seminar halls , where the capacity of the room is limited limited and should no no t be exceeded. exceeded. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 38 Automatic Automatic room light light controll contro ller er with sensors CHAPTER 4 SOFTWARE DESCRIPTION This project is implemented using following software’s: ● KEIL Compiler-for compilation part ● Proload-fo Proload-fo r simulatio simulatio n part 4.1 KEIL Compiler: Keil compiler is software used where the machine language code is written and compiled. After compilation, the machine source code is converted into hex code which is to be dumped into the microcontroller for further processing. Keil compiler also suppo supports rts C language ang uage code. It’s important that you know C language for microcontroller which is commonly known as Embedded C. As we are going to use Keil C51 Compiler, hence we also call it Keil C. Keil C is not much different from a normal C program. If you know assembly, writing a C program is not a crisis. In keil, we will have a main function, in which all your application specific work will be defined. In case of embedded C, you do not have any operating system running in there. So you have to make sure that your program or main file should never exit. This can be done with the help of simple while (1) or for (;;) loop as they are going to run infinitely. We have to add header file for controller you are using, otherwise you will not  be abl ab le to access regi re gisters sters related to peripherals. peripherals. #include #include //header //header file file for 89C51 4.2 Proload P roload:: Proload is software which accepts only hex files. Once the machine code is converted into hex code, that hex code has to be dumped into the microcontroller and this is done by the Proload. Proload is a programmer which itself contains a microcontroller in it other than the one which is to be programmed. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 39 Automatic Automatic room light light controll contro ller er with sensors This microcontroller has a program in it written in such a way that it accepts the hex file from the Kiel compiler and dumps this hex file into the microcontroller which is to be programmed. As the proload programmer kit requires power supply to be operated, this power supply is given from the power supply circuit designed above. It should be noted that this programmer kit contains a power supply section in the board itself but in order to switch on that power supply, a source is required. Thus this is accomplished from the power supply board with an output of 12volts or from an adapter connected to 230V AC. 4.3 Procedural steps for compilation, simulation and dumping: 4.3.1 Compilation and simulation steps: To create create a project, pro ject, write a nd test test the pre vio vio us e xample xample sour so urce ce code, fo llow llow the following steps: start a new project. project. 1. Open Keil and start Fig 4.3: Step-1 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 40 Automatic Automatic room light light controll contro ller er with sensors 2. You will be prompted to choose a name for your new project, Create a separate folder where all the files of your project will be stored, choose a name and click save. The following window will appear where you will be asked to select a device for Target 'Target 1' 3. From the list at the left, seek for the brand name A T M E L , then under ATMEL, select AT89S52  . You will notice that a brief description of the device appears on the right. Leave the two upper check boxes unchecked and click OK. The AT89S52 will be called your 'Target 'Target device', device', which which is the final destination of your source code. You will be asked whether to 'copy stan dard 8051 star ' click No. star tu p code  Fig 4.4: Step-2, 3 ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 41 Automatic Automatic room light light controll contro ller er with sensors 4. Click File , New, and a nd so so mething similar to the t he fo fo llow llow ing windo window w should appear. Th T he  box named 'Te 'Te xt1' is where your code sho sho uld be written written later. Fig 4.5: Step-4 av e to click 'F ile, Sa ve as' a nd ch c hoose a file file na me for your source code 5.  Now you have ending with the letter '.c'. You can name as 'code.c' for example and click save. Then you have to add this file to your project work space at the left as shown in the following. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 42 Automatic Automatic room light light controll contro ller er with sensors 6.After After right-c licking licking o n 'sour ce gr oup 1  ',', click on 'A dd fi l es to group...', then you will  be prompted prompted to browse the file to to add to 'source group 1', choose the file that you just saved, eventually 'code.c' and add it to the source group. You will notice that the file is added to the project tree at the left. Fig4.6: Step-5, 6 7. In some versions of this software you have to turn ON manually the option to generate HEX files. make sure it is turned ON, by right-clicking on target 1, Options for target 'target 1', then under the 'output' tab, by checking the box 'generate HEX file '. This step is very important as the HEX file is the compiled output of your project that is going to  be transferred transferred to the microcon microco ntrolle tro ller. r. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 43 Automatic Automatic room light light controll contro ller er with sensors 8.  You can then start to write the source code in the window titled 'code.c' then before testing your source code; you have to compile your source code, and correct eventual syntax syntax errors errors.. In K EIL IDE, this this step step is is called called 'rebuild all targets' targets' and and has this this icon: icon: . Fig 4.7: Step-7 9.  If after rebuilding the targets, the 'output window' shows that there is   0 errors , then you are ready to test the performance of your code. In keil, like in most development environm environment, ent, this this ste step p is called called Debugging, Debugging, and has has this this icon: . After After clicking clicking on the debug icon, you will notice that some part of the user interface will change; some new icons will appear, like the run icon circled in the following figure: ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 44 Automatic Automatic room light light controll contro ller er with sensors Fig 4.8: Step-8 10.  Select the ports and click on the RUN Option. It will end up the compilation and simulation processes. 4.3.2 Dumping steps: After designing the project using Keil Compiler, to observe the output, the  program should be d umped umped in microcontroller microcontroller of your project using a d umper and the  procedure fo fo r dumping is as follows: ollows : 1. Install Install the Prol Pro load Softwar So ftwaree in the the PC. 2. Now connec connec t the the Programmer P rogrammer kit to the PC (CPU) thro ugh serial serial cable. 3. Power up the the programmer p rogrammer kit fro fro m the ac s upply pp ly throug through h adapter adap ter.. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 45 Automatic Automatic room light light controll contro ller er with sensors 4. Now pl p lace the microcontroller in the GIF socket provided in the Programmer k it. it. 5. Click on the proload icon in the PC. A window appears providing the information like Hard Hard ware ware model, com port, de vice vice type, Flash size etc. Clic C lick k on o n bro bro wse wse option optio n to to select select the hex file to be dumped into the microcontroller and then click on “Auto program” to  program the microcon microcontr tro o ller ller with that particular hex file. file. 6. The status of the microcontroller can be seen in the small status window in the bottom of the page. 7. After this process is completed, remove the microcontroller from the programmer kit and place it in your system board. Now the system board behaves according to the  program writte writte n in the microcontroller. microcontroller. 4.4 PROGRAM CODE #include #define LCD P2 sbit rs=P1^0; sbit rw=P1^1; sbit en=P1^2; sbit Ir1=P1^3; sbit Ir2=P1^4; sbit re lay=P1^5; void void delay(); d elay(); void void lcdcmnd(unsigned c har); void void lcddata(unsigned char); void main() { unsigned char E[]="b E[]="b ulb is on", M[]="bulb is o ff"; ff"; unsigned char lcmd[]={0x38,0x01,0x0E,0x06,0x80}; lcmd[]={0x38,0x01,0x0E,0 x06,0x80}; unsigned int i,z; for(i=0;i<5;i++) { LCD=lcmd[i]; ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 46 Automatic Automatic room light light controll contro ller er with sensors rs=0; rw=0; en=1; delay(); en=0; } while(1) { lcdcmnd(0x01); delay(); lcdcmnd(0x0C); delay(); z=0; for(i=0;i<1000;i++) { if(Ir1==1&&Ir2==0); { Relay=1; for(i=0;i<10;i++) { lcddata(E[i]); } ++z; } Else Else if(Ir1==0&&Ir2==1) if(Ir1==0&&Ir2==1) { --z; } } if(z==0) { ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 47 Automatic Automatic room light light controll contro ller er with sensors lcdcmnd(0x01); Relay=0; for(i=0;i<11;i++) { lcddata(M[i]); } } } } void delay() { int i; for(i=0;i<1000;i++); } ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 48 Automatic Automatic room light light controll contro ller er with sensors CHAPTER 5 RESULT RESULT ANALYSIS:  When an object moves into a room it will be detected detected by the IR sensor ‘1’ this makes the microcontroller to switch on the light using relay switch by understanding that something has moved in to the room. if the last object moves out of the room it has passes through IR sensor ‘2’ and microcontroller will switch OFF the light using using relay. rela y.  Low cost, Easy to use. can be implemented in single door, Can be used to automatic automatic room light light contr con tro o l.  Main advantage of this project is that it helps in energy conservation. Because when there is nobody inside the room then lights are turned off. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 49 Automatic Automatic room light light controll contro ller er with sensors CONCLUSION The goal goa l o f this project pro ject is to de velop a s yste yste m, whic h used to sa ve power automatically. This This project mainly co nsists of o f microco microco ntroller ntroller (89C51) a nd LCD which which helps helps the t he  project to to be cost effe e ffective. ctive. Even though the project was completed successfully but during the development some obstructions were faced like for loose connection we have got some erroneous output. Also due to some internal problem in the equipment we have not got desirable output. So, for for better output or for for better disp disp lay we we have to be very careful while doing the project. During the p roject it has has also b een ee n noticed noticed t hat It is is used o nly when one person cuts the the ra ys of the se nsor hence cannot canno t be used when two or more persons c ross the door simultaneously. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 50 Automatic Automatic room light light controll contro ller er with sensors FUTURE SCOPE Sensors can acts as alarm for security purpose. Mainly used for power consumption.It can be used in our homes because we often forget to switch off our room lights It helps in energy conservation In future, we can send this data to remote areas using mobile or internet Voice alarm system can be used to indicate that room is full &  person can’t enter inside inside   It can be used in various rooms like seminar halls, where the capac ity o f the room is is limited limited a nd should sho uld not be exceeded. e xceeded. ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 51 Automatic Automatic room light light controll contro ller er with sensors REFERENCES Muhammad Ali Mazidi-“THE Mazidi- “THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS SYSTEMS ”, Pea rson. Ayala-“ Ayala- “INTRODUCTION INTRODUCTION TO 8051 MICROCONTR MICROCO NTROLLER”. OLLER”. www.microcontroller8051.com www.miniproject.com www.howstuffworks.com www.instructables.com/id/cellphone-operated-robot/ www.dnatechindia.com www.answers.com ELECTRONICS & COMMUNICATION ENGG.(KGRCET) Page 52