Professional Documents
Culture Documents
ABSTRACT
This Project Automatic Room Light Controller with Visitor Counter using Microcontroller is a reliable circuit that takes over the task of controlling the room lights as well us counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays. The microcontroller does the above job. It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller AT89S52 continuously monitor the Infrared Receivers, When any object pass through the IR Receiver's then the IR Rays falling on the receivers are obstructed this obstruction is sensed by the Microcontroller.
CONTENTS
CHAPTER 1: INTRODUCTION
1.1 Aim of the project 1.2 Project Overview 1.3 Methodology
6.2 Infra-Red Light 6.3 Modulation 6.4 The Transmitter 6.5 The receiver
CHAPTER7: RELAY CIRCUIT CHAPTER8: SOURCE CODE CHAPTER9: FUTURE EXPANSION CHAPTER10: APPLICATIONS, ADVANTAGES AND DISADVANTAGES CHAPTER11: REFERENCES
CHAPTER 1 INTRODUCTION
The microcontroller does the above job. It receives the signals from the sensors, and this signal is operated under the control of software which is stored in ROM. Microcontroller AT89S52 continuously monitor the Infrared Receivers, When any object pass through the IR Receiver's then the IR Rays falling on the receiver are obstructed, this obstruction is sensed by the Microcontroller.
1.3 Methodology:
According to our project requirements, the following modules are essential. Power supply Microcontroller IR sensors Relay
of the following essential blocks. 1. Power Supply 2. AT89S52 micro-controller 3. Entry and Exit sensor circuit 4. Relay driver circuit
1. Power Supply:
Here we used +12V and +5V dc power supply. The main function of this block is to provide the required amount of voltage to essential circuits. +12 voltage is given. +12V is given to relay driver. To get the +5V dc power supply we have used here IC 7805, which provides the +5V dc regulated power supply.
2. 89S52 Microcontroller:
It is a low-power, high performance CMOS 8-bit microcontroller with 8KB of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured using Atmels highdensity nonvolatile memory technology and is compatible with the MCS51TM instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with Flash on a monolithic hip, the Atmel AT89S52 is a powerful microcontroller, which
provides a highly flexible and cost effective solution to so many embedded control applications.
3.2 Characteristics:
Two major areas of differences are cost and power consumption. Since many embedded systems are produced in the tens of thousands to millions of units range, reducing cost is a major concern. Embedded systems often use a (relatively) slow processor and small memory size to minimize costs.
The slowness is not just clock speed. The whole architecture of the computer is often intentionally simplified to lower costs. For example, embedded systems often use peripherals controlled by synchronous serial interfaces, which are ten to hundreds of times slower than comparable peripherals used in PCs. Programs on an embedded system often must run with real-time constraints with limited hardware resources: often there is no disk drive, operating system, keyboard or screen. A flash drive may replace rotating media, and a small keypad and LCD screen may be used instead of a PC's keyboard and screen. Firmware is the name for software that is embedded in hardware devices, e.g. in one or more ROM/Flash memory IC chips. Embedded systems are routinely expected to maintain 100% reliability while running continuously for long periods, sometimes measured in years. Firmware is usually developed and tested too much stricter requirements than is general-purpose software, which can usually be easily restarted if a problem occurs.
3.3 Platform:
There are many different CPU architectures used in embedded designs. This in contrast to the desktop computer market, which as of this writing (2003) is limited to just a few competing architectures, mainly the Intel/AMD x86, and the Apple/Motorola/IBM PowerPC, used in the Apple Macintosh. One common configuration for embedded systems is the system on chip, an application-specific integrated circuit, for which the CPU was purchased as intellectual property to add to the IC's design.
3.4 Tools:
Like a typical computer programmer, embedded system designers use compilers, assemblers and debuggers to develop an embedded system.
Software companies that specialize in the embedded market Ported from the GNU software development tools. Sometimes, development tools for a personal computer can be used if the embedded processor is a close relative to a common PC processor. Embedded system designers also use a few software tools rarely used by typical computer programmers. Some designers keep a utility program to turn data files into code, so that they can include any kind of data in a program. Most designers also have utility programs to add a checksum or CRC to a program, so it can check its program data before executing it.
3.6 Debugging:
Debugging is usually performed with an in-circuit emulator, or some type of debugger that can interrupt the micro controllers internal microcode. The microcode interrupt lets the debugger operate in hardware in which only the CPU works. The CPU-based debugger can be used to test and debug the electronics of the computer from the viewpoint of the CPU. This feature was pioneered on the PDP-11. Developers should insist on debugging which shows the high-level language, with breakpoints and single stepping, because these features are widely available. Also, developers should write and use simple logging facilities to debug sequences of real-time events. PC or mainframe programmers first encountering this sort of programming often become confused about design priorities and acceptable methods. Mentoring, code-reviews and ego less programming are recommended.
3.8 Start-up:
All embedded systems have start-up code. Usually it disables interrupts, sets up the electronics, tests the computer (RAM, CPU and software), and then starts the application code. Many embedded systems recover from short-term power failures by restarting (without recent selftests). Restart times under a tenth of a second are common. Many designers have found one of more hardware plus softwarecontrolled LEDs useful to indicate errors during development (and in some instances, after product release, to produce troubleshooting diagnostics). A common scheme is to have the electronics turn off the LED(s) at reset, whereupon the software turns it on at the first opportunity, to prove that the hardware and start-up software have performed their job so far. After that, the software blinks the LED(s) or sets up light patterns during normal operation, to indicate program execution progress and/or errors. This serves to reassure most technicians/engineers and some users.
State machines may be implemented with a function-pointer per statemachine (in C++, C or assembly, anyway). A change of state stores a different function into the pointer. The function pointer is executed every time the loop runs. Many designers recommend reading each IO device once per loop, and storing the result so the logic acts on consistent values. Many designers prefer to design their state machines to check only one or two things per state. Usually this is a hardware event, and a software timer. Designers recommend that hierarchical state machines should run the lower-level state machines before the higher, so the higher run with accurate information. Complex functions like internal combustion controls are often handled with multi-dimensional tables. Instead of complex calculations, the code looks up the values. The software can interpolate between entries, to keep the tables small and cheap. One major weakness of this system is that it does not guarantee a time to respond to any particular hardware event. Careful coding can easily assure that nothing disables interrupts for long. Thus interrupt code can run at very precise timings. Another major weakness of this system is that it can become complex to add new features. Algorithms that take a long time to run must be carefully broken down so only a little piece gets done each time through the main loop. This system's strength is its simplicity, and on small pieces of software the loop is usually so fast that nobody cares that it is not predictable. Another advantage is that this system guarantees that the software will run. There is no mysterious operating system to blame for bad behavior.
entry"). A touch-screen or screen-edge buttons also minimize the types of user actions. Another basic trick is to minimize and simplify the type of output. Designs should consider using a status light for each interface plug, or failure condition, to tell what failed. A cheap variation is to have two light bars with a printed matrix of errors that they select- the user can glue on the labels for the language that she speaks. For example, Boeing's standard test interface is a button and some lights. When you press the button, all the lights turn on. When you release the button, the lights with failures stay on. The labels are in Basic English. For another example, look at a small computer printer. You might have one next to your computer. Notice that the lights are labeled with stick-on labels that can be printed in any language. Really look at it. Designers use colors. Red means the users can get hurt- think of blood. Yellow means something might be wrong. Green means everything's OK. Another essential trick is to make any modes absolutely clear on the user's display. If an interface has modes, they must be reversible in an obvious way. Most designers prefer the display to respond to the user. The display should change immediately after a user action. If the machine is going to do anything, it should start within 7 seconds, or give progress reports. If a design needs a screen, many designers use plain text. It can be sold as a temporary expedient. Why is it better than pictures? Users have been reading signs for years. A GUI is pretty and can do anything, but typically adds a year from artist, approval and translator delays and one or two programmers to a project's cost, without adding any value. Often, a clever GUI actually confuses users. If a design needs to point to parts of the machine (as in copiers), these are labeled with numbers on the actual machine, that are visible with the doors closed. A network interface is just a remote screen. It needs the same caution as any other user interface. One of the most successful general-purpose screen-based interfaces is the two menu buttons and a line of text in the user's native language. It's used in pagers, medium-priced printers, network switches, and other mediumpriced situations that require complex behavior from users. When there's text, there are languages. The default language should be the one most widely understood. Right now this is English. French and Spanish follow.
Most designers recommend that one use the native character sets, no matter how painful. People with peculiar character sets feel coddled and loved when their language shows up on machinery they use. Text should be translated by professional translators, even if native speakers are on staff. Marketing staff have to be able to tell foreign distributors that the translations are professional. A foreign organization should give the highest-volume distributor the duty to review and correct any translations in his native language. This stops critiques by other native speakers, who tend to believe that no foreign organization will ever know their language as well as they.
The power supply unit is used to provide constant 5 V dc supply to the peripherals. The 230 V ac is converted into 9 V ac by using a transformer and then a bridge rectifier rectifies it to a 9 V dc with ac ripples. This is then filtered by electrolytic capacitors used across the rectifier output. LM7805 regulator is employed to obtain a constant 5 V dc at the output.
This is a digital IC used as a regulator for regulating the output. LM7805 provides a constant 5V dc supply as output. For this it needs at least 8V dc as input.
4.3 DESCRIPTION:
A variable regulated power supply, also called a variable bench power supply, is one where you can continuously adjust the output voltage to your requirements. Varying the output of the power supply is the recommended way to test a project after having double checked parts placement against circuit drawings and the parts placement guide. This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite important because one of the first projects a hobbyist should undertake is the construction of a variable regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to have a variable supply on hand, especially for testing. Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need to build a regulated 5 volt source. Usually you start with an unregulated power supply ranging from 9 volts to 24 volts DC (A 12 volt power supply is included with the Beginner Kit and the Microcontroller Beginner Kit.). To make a 5 volt power supply, we use a LM7805 voltage regulator IC (Integrated Circuit). The IC is shown below.
The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin.
Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA
Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot
Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation
Availability of components: Easy to get, uses only very common basic components
Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Unregulated DC 8-18V power supply Power supply current: Needed output current + 5 mA Component costs: Few dollars for the electronics components + the input transformer cost
The input to the circuit is applied from the regulated power supply. The a.c. input i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output obtained from the rectifier is a pulsating d.c voltage.
So in order to get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.
4.5.1Transformer:
Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.
4.5.2Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification
4.5.3Filter:
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.
4.5.4Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels.
5.1 Features:
8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes
5.2 Description:
The AT89C52 is a low-power, high-performance CMOS 8bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer, which provides a highly flexible and cost-effective solution to many embedded control applications.
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 loworder 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 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 bi-directional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL 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 (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively. Port Pin Alternate Functions P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control
Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL 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 (I IL ) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), 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 and verification.
Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull ups. The Port 3 output buffers can sink/source four TTL 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 (I IL ) because of the pull ups. Port 3 also serves the functions of various special features of the AT89C51. Port 3 also receives some control signals for Flash programming and verification.
Port Pin Alternate Functions P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe) P3.7 RD (external data memory read strobe). RST Reset input. A high 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 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. However, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.
PSEN Program Store Enable is the read strobe to external program memory. When the AT89C52 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
External Access Enable (EA) must be strapped to GND in order to enable the device to fetch code from external pro-gram memory locations starting at 0000H up to FFFFH. 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 12V programming enable voltage (VPP) during Flash programming when 12V programming is selected.
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
5.5
ARCHITECHTURE
OF
8052
MICROCONTROLLER:
5.5.1 Oscillator Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier, which can be configured for use as an on-chip oscillator, as shown in Figure #3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure #4. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. 5.5.2 Idle Mode In idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.
Fig. 5.3 Oscillator Connections Note: C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators
CHAPTER 6 IR SENSORS
6.3 Modulation :
Modulation is the answer to make our signal stand out above the noise. With modulation we make the IR light source blink in a particular frequency. The IR receiver will be tuned to that frequency, so it can ignore everything.
Fig. 6.1 Modulation In the picture above you can see a modulated signal driving the IR LED of the transmitter on the left side. The detected signal is coming out of the receiver at the other side. In serial communication we usually speak of 'marks' and 'spaces'. The 'space' is the default signal, which is the off state in the transmitter case. No light is emitted during the 'space' state. During the 'mark' state of the signal the IR light is pulsed on and off at a particular frequency. Frequencies between 30 kHz and 60 kHz are commonly used in consumer electronics. At the receiver side a 'space' is represented by a high level of the receiver's output. A 'mark' is then automatically represented by a low level. Please note that the 'marks' and 'spaces' are not the 1-s and 0-s we want to transmit. The real relationship between the 'marks' and 'spaces' and the 1-s and 0-s depends on the protocol that's being used. More information about that can be found on the pages that describe the protocols.
The transmitter usually is a battery powered handset. It should consume as little power as possible, and the IR signal should also be as strong as
possible to achieve an acceptable control distance. Preferably it should be shock proof as well. Many chips are designed to be used as IR transmitters. The older chips were dedicated to only one of the many protocols that were invented. Nowadays very low power microcontrollers are used in IR transmitters for the simple reason that they are more flexible in their use. When no button is pressed they are in a very low power sleep mode, in which hardly any current is consumed. The processor wakes up to transmit the appropriate IR command only when a key is pressed. Quartz crystals are seldom used in such handsets. They are very fragile and tend to break easily when the handset is dropped. Ceramic resonators are much more suitable here, because they can withstand larger physical shocks. The fact that they are a little less accurate is not important. The current through the LED (or LEDs) can vary from 100mA to well over 1A! In order to get an acceptable control distance the LED currents have to be as high as possible. A trade-off should be made between LED parameters, battery lifetime and maximum control distance. LED currents can be that high because the pulses driving the LEDs are very short. Average power dissipation of the LED should not exceed the maximum value though. You should also see to it that the maximum peek current for the LED is not exceeded. All these parameters can be found in the LED's data sheet. A simple transistor circuit can be used to drive the LED. A transistor with a suitable HFE and switching speed should be selected for this purpose. The resistor values can simply be calculated using Ohm's law. Remember that the nominal voltage drop over an IR LED is approximately 1.1V. The normal driver, described above, has one disadvantage. As the battery voltage drops, the current through the LED will decrease as well. This will result in a shorter control distance that can be covered. An emitter follower circuit can avoid this. The 2 diodes in series will limit the pulses on the base of the transistor to 1.2V. The base-emitter voltage of the transistor subtracts 0.6V from that, resulting in constant amplitude of 0.6V at the emitter. This constant amplitude across a constant resistor results in current pulses of a constant magnitude. Calculating the current through the LED is simply applying Ohm's law again.
Fig. 6.3 IR Receiver Many different receiver circuits exist on the market. The most important selection criteria are the modulation frequency used and the availability in your region.
In the picture above you can see a typical block diagram of such an IR receiver. Don't be alarmed if you don't understand this part of the description, for everything is built into one single electronic component. The received IR signal is picked up by the IR detection diode on the left side of the diagram. This signal is amplified and limited by the first 2 stages. The limiter acts as an AGC circuit to get a constant pulse level, regardless of the distance to the handset. As you can see only the AC signal is sent to the Band Pass Filter. The Band Pass Filter is tuned to the modulation frequency of the handset unit. Common frequencies range from 30 kHz to 60 kHz in consumer electronics. The next stages are a detector, integrator and comparator. The purpose of these three blocks is to detect the presence of the modulation frequency. If this modulation frequency is present the output of the comparator will be pulled low. As I said before, all these blocks are integrated into a single electronic component. There are many different manufacturers of these components on the market. And most devices are available in several versions each of which are tuned to a particular modulation frequency.
Please note that the amplifier is set to a very high gain. Therefore the system tends to start oscillating very easily. Placing a large capacitor of at least 22F close to the receiver's power connections is mandatory to decouple the power lines. Some data sheets recommend a resistor of 330 Ohms in series with the power supply to further decouple the power supply from the rest of the circuit. There are several manufacturers of IR receivers on the market. Siemens, Vishay and Telefunken are the main suppliers here in Europe. Siemens has its SFH506-xx series, where xx denotes the modulation frequency of 30, 33, 36, 38, 40 or 56 kHz. Telefunken had its TFMS5xx0 and TK18xx series, where xx again indicates the modulation frequency the device is tuned to. It appears that these parts have now become obsolete. They are replaced by the Vishay TSOP12xx, TSOP48xx and TSOP62xx product series. Sharp, Xiamen Hualian and Japanese Electric are 3 Asian IR receiver producing companies. Sharp has devices with very cryptic ID names, like: GP1UD26xK, GP1UD27xK and GP1UD28xK, where x is related to the modulation frequency. Hualian has it's HRMxx00 series, like the HRM3700 and HRM3800. Japanese Electric has a series of devices that don't include the modulation frequency in the part's ID. The PIC12042LM is tuned to 36.7 kHz, and the PIC12043LM is tuned to 37.9 kHz
IR Advantages:
Low power requirements: therefore ideal for laptops, telephones, personal digital assistants Low circuitry costs: $2-$5 for the entire coding/decoding circuitry Simple circuitry: no special or proprietary hardware is required, can be incorporated into the integrated circuit of a product Higher security: directionality of the beam helps ensure that data isn't leaked or spilled to nearby devices as it's transmitted Portable Few international regulatory constraints: IrDA (Infrared Data Association) functional devices will ideally be usable by international travelers, no matter where they may be High noise immunity: not as likely to have interference from signals from other devices
IR Disadvantages:
Line of sight: transmitters and receivers must be almost directly aligned (i.e. able to see each other) to communicate Blocked by common materials: people, walls, plants, etc. can block transmission Short range: performance drops off with longer distances Light, weather sensitive: direct sunlight, rain, fog, dust, pollution can affect transmission Speed: data rate transmission is lower than typical wired transmission
RELAY CIRCUIT:
A single pole dabble throw (SPDT) relay is connected to port RB1 of the microcontroller through a driver transistor. The relay requires 12 volts at a current of around 100ma, which cannot provide by the microcontroller. So the driver transistor is added. The relay is used to operate the external solenoid forming part of a locking device or for operating any other electrical devices. Normally the relay remains off. As soon as pin of the microcontroller goes high, the relay operates. When the relay operates and releases. Diode D2 is the standard diode on a mechanical relay to prevent back EMF from damaging Q3 when the relay releases. LED L2 indicates relay on.
#include #include #define LCD_clear() LCD_command(001) /* Clear LCD Display #define LCD_orgin()LCD_command(002) /* set to orgin LCD #define LCD_row1() LCD_command(080) /* Begin at 1st line #define LCD_row2()LCD_command(0xc0) /* Begin at 2nd line sbit port10=P1^0; //IR Sensor Input sbit rs=P3^6; //Lcd Register Select Pin sbit en=P3^7; //Lcd Enable Pin static unsigned char counter; void lcd_en() //Funtion for LCD Enable { en=1; en=0; } void LCD_delay(unsigned char ms) //Function for create Time Delay { unsigned int n,i; for(n=0;n<ms;n++) { for(i=0;i<1536;i++); } }</ms;n++) void LCD_command(unsinged char command) //LCD Command Pass Funtion { rs=0; P0=command; lcd_en(); LCD_delay(1); } void LCD_init() //LCD intialization funtion { LCD_command(0x38); LCD_command(0x06); LCD_command(0x0c); LCD_command(0x01); } void LCD_putc(unasigned char ascii) { rs=1; P0=ascii; lcd_en(); LCD_delay(2); }
void LCD_puts(unsigned char *lcd_string) { while(*lcd_string) { LCD_putc(*lcd_string++); } } void disp(unsinged char name1) { rs=1; P0=name1; lcd_en(); lcd_delay(300); } void main() { port10=0; //make P1.0 as init=0, initially all port pins are high P2=0; //make low for P2 LCD_init(); //call LCD initialization function while(1) //Run forever always true { if(port10) //check condition P2.0 is high P2.0==1 { LCD_command(0x80); //LCD command for display first line LCD_puts("visit count="); //String display in the LCD { disp(((counter%10000)/1000)+48); disp(((counter%1000)/100)+48); disp(((counter%100)/10)+48); disp(((counter%10)/1)+48); } } P2=counter; // 8 LED's conneted in PORT 2 LCD_comman(0xc0) //LCD command for display 2nd line } }
By using this circuit and proper power supply we can implement various applications Such as fans, tube lights, etc.
By modifying this circuit and using two relays we can achieve a task of opening and closing the door.
Applications
For counting purposes For automatic room light control
Advantages
Low cost Easy to use
Disadvantages It is used only when one single person cuts the rays of the sensor hence
it cannot be used when two person cross simultaneously.
CHAPTER 11 REFERENCES
1. Embedded Systems - Raj Kamal 2. www.wikipedia.com 3. INFRARED DETECTORS AND EMITTERS Peter capper and C.T.Elliot
4. http://www.embed4u.com