You are on page 1of 49

INDEX

Contents List of Figures List of Tables


ABSTRACT CHAPTER 2 : EMBEDDED
2.1Introduction 2.2Block Diagram 2.3Flow Chart

CHAPTER 3 : DESCRIPTION OF MICRO CONTROLLER


3.1 A Brief History of 8051 3.2 Introduction to AT89S52 3.3 Features 3.4 Pin Description 3.5 Memories

CHAPTER 4 : ULTRA SONIC SENSOR


4.1 Introduction 4.2 Features 4.3 Circuit explanationof Ultrasonic Distance Transmitter unit 4.4 Circuit explanationof Ultrasonic Distance receiver unit 4.5 Applications

CHAPTER 5 : DC MOTOR
5.1 Introduction 5.2 Types of D.C Motor 5.2.2 2-pole DC electric motor 5.2.1 3-pole DC electric motor

CHAPTER 6 : LCD Display


6.1 Introduction

6.2 Pin description 6.3 LCD basic commands

CHAPTER 7 :SCHEMATIC DIAGRAM


7.1 Schematic Description 7.2 regulated power supply 7.3 circuit features

CHAPTER 8 : SOFTWARE DEVELOPMENT


8.1 Introduction 8.2 Tools used 8.3 C51 Compiler & A51 macro assembler 8.4 Start vision 8.5 over view of Keil cross compiler 8.6 Benefits of Keil compiler 8.7 Flash magic

CHAPTER 9 : SOURCE CODE CONCLUSION FUTURE SCOPE REFERENCES

LIST OF FIGURES Figure No.


1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19

NAME
Block diagram Flow chart Micro Controller ATMEL 89S52 Pin diagram of ATMEL 89s52

Page No.
3 4 6 7 8 12 13 19 21 22 24 25 26 27 28 30 31 33 33

Functional block diagram of Micro Controller Oscillator and timing circuit Ultrasonic Sensor Ultrasonic Transmitter Ultrasonic Receiver D.C Motor 2-pole D.C electric motor 3-pole D.C electric motor 3-pole D.C electric motor 2x16 Line Alphanumeric LCD Display Interfacing of LCD Schematic Diagram IC Regulator Circuit diagram of power supply

Table NO.

Name

2.1Description of port 1 2.2Description of port 2

ABSTRACT KEEP DISTANCE WARNING SYSTEM


The project work keep distance warning system and speed control is designed for Automobiles, any vehicle ranging from motor cycle to heavy duty truck can adopt this system. The main purpose of this system is to alert the following vehicle whenever it came very close to the ahead vehicle; thereby to some extent accidents can be avoided. Many accidents at High-ways are taking place due to the close running of vehicles, all of sudden, if the in front vehicle driver reduces the speed or applied breaks, then it is quite difficult to the following vehicle driver to control his vehicle, resulting accident. To avoid this kind of accident, the warning system, which contains alarm and display system can arrange at rear side of each and every vehicle.Whenever the following vehicle came near to the in front vehicle, immediately the display board will be energized and it shows KEEP DISTANCE. At the same time motor speed will also be energized, the motor and display board both remains in energized condition up to some time depending up on the program prepared for microcontroller. For sensing the following vehicle, two ultrasonic sensors are used; these sensors are arranged side by side, from one sensor ultrasonic signal is delivered, this signal is transmitted in one line, whenever the following vehicle came close to the signal, the ultrasonic energy hits the vehicle and it is reflected, the reflected energy is detected by the another ultrasonic sensor, this is called as ultrasonic signal detector. SOFTWARE REQUIREMENT: 1. KEIL MICRO VISION-3 2. MICRO FLASH 3. ORCAD HARDWARE REQUIREMENT: 1. MICROCONTROLLER (89S52) 2. LM324. 3. ULTRASONIC SENSOR 4. LCD DISPLAY

CHAPTER 1 INTRODUCTION.
1.1 Motivation
Most of the accidents in high-ways are happening due to the drowsiness of drivers, most often this symptom is found in long distance truck drivers, these drivers may take some time to recognize the opposite vehicle, which is running at low speed, resulting accident. This kind of accidents may happen due to the drunken drivers also. So to increase safety an electronic warning system is essential to alert the drivers. This kind of system can be installed in all types of vehicles, especially in commercial vehicles, so that accident rate can be minimized. The warning system designed here can be called as driver attention system, which raises an alarm and energizes the display board automatically when the following vehicle came near to the in-front running vehicle The system is designed with 89C51 microcontroller, the task is quite simple, the following vehicle detection circuit is designed with infrared sensors, when the IR signal is interrupted due to the following vehicle, the circuit generates high signal and it is fed to microcontroller. The detailed description is provided in the following chapters. Nowadays with the advancement of technology particularly in the field of micro-controllers, all the activities in our day-to-day living have become part of information technology and we find controllers in each and every application. Thus, the trend is directing towards micro-controller based project works.A micro-controller contains a CPU, clock circuitry, ROM, Ram and I/O circuitry on a single integrated circuit package. The Micro-controller is therefore, a self-contained device, which does not require a host of associated support chips for its operation as conventional microprocessors do. It offers several advantages over conventional multichip systems.There is a cost and space advantage as extra chip costs and printed circuit board and connectors required to support multi-chip systems are eliminated. The other advantages include cheaper maintenance, decreased hardware design effort and decreased board density, which is relevant in portable control equipment. Low cost high volume products requiring a relatively simple and cheap computer controller have traditionally characterized micro-controllers. The design optimization

parameters require careful consideration of architectural tradeoffs, memory design factors, instruction size, memory addressing techniques and other design constraints with respect to area and performance. Micro-controllers functionality, however, has been tremendously increased in the recent years. Today, one gets micro-controllers, which are stand alone for applications in data acquisition system and control. With the help of analog-to-digital converts, provided at the input of micro-controller, enables them direct use in instrumentation. Another type of micro-controller has on-chip communication controller, which is designed for applications requiring local intelligence at remote nodes and communication capability among these distributed nodes. Advanced versions of the microcontroller in 16-bit configuration have been introduced for high performance requirements particularly in applications where good arithmetical capabilities are required. In this project work ATMEL 89C51 micro-controller is used, this is 8-bit micro-controller.

1.2 Thesis organization


In view of the proposed thesis work, explanation of theoretical aspects and algorithms used in this work are presented as per the sequence described below. Chapter 1 describes about motivation, block diagram and flow chart. Chapter 2 discusses about at89s52 features and its pin description. Chapter 3 explains about the ultrasonic sensor and its features. Chapter 4 describes about D.C motor and its types. Chapter 5 goes with L.C.D display and its pin description. Chapter 6 explains about schematic diagram and power supply. Chapter 7 describes about software development. Chapter 8 deals with the source code of the project.

1.2 BLOCK DIAGRAM

POWER SUPPLY

LCD DISPLAY

AT 89S52 MICRO -CONTROLLER ULTRASONIC SENSOR

DC MOTOR

1.3 FLOW CHART


START

Initialization of Microcontroller

Initialization of LCD

Initialization of ultrasonic Yes ssss ssss ssss NO If object ssss is ssss detected ssss ssss SS SS SS Rotate dc motor SS SS SS SS Object detection is displayed on LCD SS SS STOP SsS STOP

CHAPTER-2 MICROCONTROLLER
2.1 A Brief History of 8051
In 1981, Intel Corporation introduced an 8 bit microcontroller called 8051. This microcontroller had 128 bytes of RAM, 4K bytes of chip ROM, two timers, one serial port, and four ports all on a single chip. At the time it was also referred as A SYSTEM ON A CHIP.The 8051 is an 8-bit processor meaning that the CPU can work only on 8 bits data at a time. Data larger than 8 bits has to be broken into 8 bits pieces to be processed by the CPU. The 8051 has a total of four I\O ports each 8 bit wide.There are many versions of 8051 with different speeds and amount of on-chip ROM and they are all compatible with the original 8051. This means that if you write a program for one it will run on any of them.The 8051 is an original member of the 8051 family. There are two other members in the 8051 family of microcontrollers. They are 8052 and 8031. All the three microcontrollers will have the same internal architecture, but they differ in the following aspects.

89S51 has 4KB ROM, 128 bytes of RAM, two timers and 6 interrupts.
8031 has 128 bytes of RAM, two timers and 6 interrupts.

89S52 has 8KB ROM, 128 bytes of RAM, three timers and 8 interrupts.
In the concerned project 89C52 microcontroller is used. Here microcontroller used is AT89C52, which is manufactured by ATMEL laboratories.

2.2 Introduction to AT89S52


The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.

10

Figure 2.1 MICROCONTROLLER By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller, which provides a highly flexible and cost-effective solution to many, embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry.In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt

11

Fig: ATMEL 89S52 8031 has 128 bytes of RAM, two timers and 6 interrupts. 8051 has 4K ROM, 128 bytes of RAM, two timers and 6 interrupts. 8052 has 8K ROM, 256 bytes of RAM, three timers and 8 interrupts. Of the three microcontrollers, 8051 is the most preferable. Microcontroller supports both serial and parallel communication.In the concerned project 8052 microcontroller is used. Here microcontroller used is AT89S52, which is manufactured by ATMEL laboratories.

2.3 FEATURES OF 89S52


Compatible with MCS-51 Products 8K Bytes of In-System Reprogrammable Flash Memory Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 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 4.0V to 5.5V Operating Range Full Duplex UART Serial Channel Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer

12

Power-off Flag

2.4 PIN DESCRIPTION

Figure 2.3: PIN DIAGRAM OF AT89S52 IC Port 0 Port 0 is an 8-bit open drain bidirectional 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 highimpedance 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 pullups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification.External pullups are required during program verification. Port 1 Port 1 is an 8-bit bidirectional 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

13

high by the internal pullups 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 pullups. 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, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification.

Table 2.1:Description of port 1 Port 2 Port 2 is an 8-bit bidirectional 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 pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. 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 bidirectional I/O port with internal pullups.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 pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also

14

serves the functions of various special features of the AT89S52, as shown in the following table. Port 3 also receives some control signals for Flash programming and verification.

Table 2.2: Description of port 3


RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 96 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.
ALE/PROG

Address Latch Enable (ALE) is an output pulse for latching the low byte of the

address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, 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 (PSEN) is the read strobe to external program memory. When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

15

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. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier.

Figure 2.4: Functional block diagram of micro controller

16

The 8052 Oscillator and Clock The heart of the 8051 circuitry that generates the clock pulses by which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal frequency is the basic internal clock frequency of the microcontroller. The manufacturers make 8051 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz.

Figure 2.5: Oscillator and timing circuit

2.5 MEMORIES
Types of memory The 8052 have three general types of memory. They are on-chip memory, external Code memory and external Ram. On-Chip memory refers to physically existing memory on the micro controller itself. External code memory is the code memory that resides off

17

chip. This is often in the form of an external EPROM. External RAM is the Ram that resides off chip. This often is in the form of standard static RAM or flash RAM. a) Code memory Code memory is the memory that holds the actual 8052 programs that is to be run. This memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have 8K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA b) Internal RAM The 8052 have a bank of 256 bytes of internal RAM. The internal RAM is found on-chip. So it is the fastest Ram available. And also it is most flexible in terms of reading and writing. Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 256 bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 256 bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are numbered 00h to FFh. The user may make use of these variables with commands such as SETB and CLR. Special Function registered memory: Special function registers are the areas of memory that control specific functionality of the 8052 micro controller. a) Accumulator (0E0h) As its name suggests, it is used to accumulate the results of large no of instructions. It can hold 8 bit values. b) B registers (0F0h) The B register is very similar to accumulator. It may hold 8-bit value. The b register is only used by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets stored in B register. In div AB the quotient gets stored in B with the remainder in A.

18

c) Stack pointer (81h) The stack pointer holds 8-bit value. This is used to indicate where next value to be removed from the stack should be taken from. When a value is to be pushed onto the stack, the 8052 first store the value of SP and then store the value at the resulting memory location. When a value is to be popped from the stack, the 8052 returns the value from the memory location indicated by SP and then decrements the value of SP. d) Data pointer The SFRs DPL and DPH work together work together to represent a 16-bit value called the data pointer. The data pointer is used in operations regarding external RAM and some instructions code memory. It is a 16-bit SFR and also an addressable SFR. e) Program counter The program counter is a 16 bit register, which contains the 2 byte address, which tells the 8052 where the next instruction to execute to be found in memory. When the 8052 is initialized PC starts at 0000h. And is incremented each time an instruction is executes. It is not addressable SFR. f) PCON (power control, 87h) The power control SFR is used to control the 8051s power control modes. Certain operation modes of the 8051 allow the 8051 to go into a type of sleep mode which consumes much lee power.

g) TCON (timer control, 88h) The timer control SFR is used to configure and modify the way in which the 8051s two timers operate. This SFR controls whether each of the two timers is running or stopped and contains a flag to indicate that each timer has overflowed. Additionally, some nontimer related bits are located in TCON SFR.

19

h) TMOD (Timer Mode, 89h) The timer mode SFR is used to configure the mode of operation of each of the two timers. Using this SFR your program may configure each timer to be a 16-bit timer, or 13 bit timer, 8-bit auto reload timer, or two separate timers. Additionally you may configure the timers to only count when an external pin is activated or to count events that are indicated on an external pin.

i) TO (Timer 0 low/high, address 8A/8C h) These two SFRs taken together represent timer 0. Their exact behavior depends on how the timer is configured in the TMOD SFR; however, these timers always count up. What is configurable is how and when they increment in value. j) T1 (Timer 1 Low/High, address 8B/ 8D h) These two SFRs, taken together, represent timer 1. Their exact behavior depends on how the timer is configured in the TMOD SFR; however, these timers always count up.. k) P0 (Port 0, address 90h, bit addressable) This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level. l) P1 (port 1, address 90h, bit addressable) This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.

m) P2 (port 2, address 0A0h, bit addressable)

20

This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level. n) P3 (port 3, address B0h, bit addressable) This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port 0 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level. o) IE (interrupt enable, 0A8h) The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of whether an individual interrupt is enabled by setting a lower bit.

p) IP (Interrupt Priority, 0B8h) The interrupt priority SFR is used to specify the relative priority of each interrupt. On 8051, an interrupt maybe either low or high priority. An interrupt may interrupt interrupts. For e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt always interrupts the system, even if another interrupt is currently executing.

q) PSW (Program Status Word, 0D0h)

21

The program Status Word is used to store a number of important bits that are set and cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the parity flag and the overflow flag. Additionally, it also contains the register bank select flags, which are used to select, which of the R register banks currently in use.

r) SBUF (Serial Buffer, 99h) SBUF is used to hold data in serial communication. It is physically two registers. One is writing only and is used to hold data to be transmitted out of 8052 via TXD. The other is read only and holds received data from external sources via RXD. Both mutually exclusive registers use address 99h.

CHAPTER-3

Ultrasonic sensor
3.1 INTRODUCTION

22

Parallax's PING ultrasonic sensor provides a very low-cost and easy method of distance measurement. This sensor is perfect for any number of applications that require you to perform measurements between moving or stationary objects. Naturally, robotics applications are very popular but you'll also find this product to be useful in security systems or as an infrared replacement if so desired. You will definitely appreciate the activity status LED and the economic use of just 1 I/O pin.

Figure 3.1: Ultrasonic Sensor The Ping sensor measures distance using sonar; an ultrasonic (well above human hearing)pulse is transmitted from the unit and distance-to-target is determined by measuring the time required for the echo return. Output from the PING sensor is a variablewidth pulse that corresponds to the distance to the target.Interfacing to the BASIC Stamp and Javelin Stamp microcontrollers is a snap: a single (shared) I/O pin is use to trigger the Ping sensor and "listen" for the echo return pulse. And the intelligent trigger hold-off allows the PING to work with the BS1! An onboard three-pin header allows the PING to be plugged into a solder less breadboard (on a Boo-Boo, for example), and to be connected to its host through a standard three-pin servo extension cable.

3.2 Sensor Features


The PING has only has 3 connections, which include Vdd, Vss, and 1 I/O pin. The 3-pin header makes it easy to connect using a servo extension cable, no soldering required. Several sample codes are available using the Ping sensor.

23

List of technical specifications:


Range - 2cm to 3m (~.75" to 10') Supply Voltage: 5V +/-10% (Absolute: Minimum 4.5V, Maximum 6V) Supply Current: 30 mA typ; 35 mA max 3-pin interface (power, ground, signal) 20 mA power consumption Narrow acceptance angle Simple pulse in / pulse out communication Indicator LED shows measurement in progress Input Trigger - positive TTL pulse, 2 s min, 5 s typ. Echo Pulse - positive TTL pulse, 115 s to 18.5 ms Echo Hold-off - 750 s from fall of Trigger pulse Burst Frequency - 40 kHz for 200 s Size - 22 mm H x 46 mm W x 16 mm D (0.85 in x 1.8 in x 0.6 in)

3.3 Ultrasonic Distance Transmitter unit


The circuit described generates (transmits) ultrasonic sound of frequency between 40 and 50 kHz. As with any other remote control system this circuit comprises of a mini transmitter and a receiver circuit. Transmitter generates ultrasonic sound and the receiver senses ultrasonic sound from the transmitter and switches on a relay.The ultrasonic transmitter uses a 555 based astable multivibrator. It oscillates at a frequency of 40-50 kHz. An ultrasonic transmitter transducer is used here to transmit ultrasonic sound very effectively. The transmitter is powered from a 9-volt PP3 single cell. The ultrasonic receiver circuit uses an ultrasonic receiver transducer to sense ultrasonic signals. It also uses a two-stage amplifier, a rectifier stage, and an operational amplifier in inverting mode. Output of op-amp is connected to a relay through a complimentary relay driver stage. A 9volt battery eliminator can be used for receiver circuit, if required. When switch S1 of transmitter is pressed, it generates ultrasonic sound

24

.
Figure 3.2: Ultrasonic transmitter

3.4 Ultrasonic Distance receiver unit


The sound is received by ultrasonic receiver transducer. It converts it to electrical variations of the same frequency. These signals are amplified by transistors T3 and T4. The amplified signals are then rectified and filtered. The filtered DC voltage is given to inverting pin of op-amp IC2. The non- inverting pin of IC2 is connected to a variable DC voltage via preset VR2 which determines the threshold value of ultrasonic signal received by receiver for operation of relay RL1. The inverted output of IC2 is used to bias transistor T5. When transistor T5 conducts, it supplies base bias to transistor T6. When transistor T6 conducts, it actuates the relay. The relay can be used to control any electrical or electronic equipment.

25

Figure 3.3: Ultrasonic receiver

3.5APPLICATI ONS A) Transducers


An ultrasonic transducer is a device that converts energy into ultrasound, or sound waves above the normal range of human hearing. While technically a dog whistle is an ultrasonic transducer that converts mechanical energy in the form of air pressure into ultrasonic sound waves, the term is more apt to be used to refer to piezoelectric transducers that convert electrical energy into sound. Piezoelectric crystals have the property of changing size when a voltage is applied, thus applying an alternating current (AC) across them causes them to oscillate at very high frequencies, thus producing very high frequency sound waves.

B) Detectors
Since piezoelectric crystal generate a voltage when force is applied to them, the same crystal can be used as an ultrasonic detector. Some systems use separate transmitter and receiver components while others combine both in a single piezoelectric transceiver.

26

C) Use in medicine
Medical ultrasonic transducers (probes) come in a variety of different shapes and sizes for use in making pictures of different parts of the body. The transducer may be passed over the surface of the body or inserted into an body opening such as the rectum or vagina. Clinicians who perform ultrasound-guided procedures often use a probe positioning system to hold the ultrasonic transducer.

D) Use in industry
Ultrasonic sensors are used to detect the presence of targets and to measure the distance to targets in many automated factories and process plants. Sensors with an on or off digital output are available for detecting the presence of objects, and sensors with an analog output which varies proportionally to the sensor to target separation distance are commercially available.

CHAPTER-4

DC MOTOR

27

1 Introduction
DC motors are configured in many types and sizes, including brush less, servo, and gear motor types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is maintained using either permanent magnets or electromagnetic windings. DC motors are most Motion and controls cover a wide range of components that in some way are used to generate and/or control motion. Areas within this category include bearings and bushings, clutches and brakes, controls and drives,encoders and resolves, Integrated motion control, limit switches, linear actuators, linear and rotary motion components, linear position sensing, motors , orientation position sensing, pneumatics and pneumatic components, positioning stages, slides.

Figure 4.1: DC MOTOR Motors are the devices that provide the actual speed and torque in a drive system. This family includes AC motor types (single and multiphase motors, universal, servo motors, induction, synchronous, and gear motor) and DC motors (brush less, servo motor, and gear motor) as well as linear, stepper and air motors, and motor contactors and starters.In any electric motor, operation is based on simple electromagnetism. A currentcarrying conductor generates a magnetic field; when this is then placed in an external magnetic field, it will experience a force proportional to the current in the conductor, and to the strength of the external magnetic field. As you are well aware of from playing with magnets as a kid, opposite (North and South) polarities attract, while like polarities (North and North, South and South) repel. The internal configuration of a DC motor is designed to

28

harness the magnetic interaction between a current-carrying conductor and an external magnetic field to generate rotational motion.

4.2 Types of DC Motor


4.2.1 2-pole DC electric motor Let's start by looking at a simple 2-pole DC electric motor (here red represents a magnet or winding with a "North" polarization, while green represents a magnet or winding with a "South" polarization).

Figure 4.2: 2-pole DC electric motor Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, commutator, field magnet(s), and brushes. In most common DC motors (and all that Beamers will see), the external magnetic field is produced by high-strength permanent magnets1. The stator is the stationary part of the motor -- this includes the motor casing, as well as two or more permanent magnet pole pieces. The rotor (together with the axle and attached commutator) rotates with respect to the stator. The rotor consists of windings (generally on a core), the windings being electrically connected to the commutator. The above diagram shows a common motor layout -- with the rotor inside the stator (field) magnets. The geometry of the brushes, commutator contacts, and rotor windings are such that when power is applied, the polarities of the energized winding and the stator magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the stator's field magnets. As the rotor reaches alignment, the brushes move to the next commutator contacts, and energize the next winding. Given our example two-pole motor, the rotation reverses the direction of current through the rotor winding, leading to a "flip" of the rotor's magnetic field, and driving it to continue rotating.

29

In real life, though, DC motors will always have more than two poles (three is a very common number). In particular, this avoids "dead spots" in the commutator. You can imagine how with our example two-pole motor, if the rotor is exactly at the middle of its rotation (perfectly aligned with the field magnets), it will get "stuck" there. Meanwhile, with a two-pole motor, there is a moment where the commutator shorts out the power supply (i.e., both brushes touch both commutator contacts simultaneously). This would be bad for the power supply, waste energy, and damage motor components as well. Yet another disadvantage of such a simple motor is that it would exhibit a high amount of torque ripple" (the amount of torque it could produce is cyclic with the position of the rotor). 4.2.2 3-pole DC electric motor So since most small DC motors are of a three-pole design, let's tinker with the workings of one via an interactive animation (JavaScript required):

Figure4.3: 3-pole DC electric motor You'll notice a few things from this -- namely, one pole is fully energized at a time (but two others are "partially" energized). As each brush transitions from one commutator contact to the next, one coil's field will rapidly collapse, as the next coil's field will rapidly charge up (this occurs within a few microsecond). We'll see more about the effects of this later, but in the meantime you can see that this is a direct result of the coil windings' series wiring: There's probably no better way to see how an average dc motor is put together, than by just opening one up. Unfortunately this is tedious work, as well as requiring the destruction of a perfectly good motor.

30

CHAPTER-5

LCD DISPLAY
5.1 INTRODUCTION
To display interactive messages we are using LCD Module. We examine an intelligent LCD display of two lines,16 characters per line that is interfaced to the controllers. The protocol (handshaking) for the display is as shown. Whereas D0 to D7th bit is the Data lines, RS, RW and EN pins are the control pins and remaining pins are +5V, -5V and GND to provide supply. Where RS is the Register Select, RW is the Read Write and EN is the Enable pin.The display contains two internal byte-wide registers, one for commands (RS=0) and the second for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the character RAM) that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h will be chosen.Port1 is used to furnish the command or data type, and ports 3.2 to3.4 furnish register select and read/write levels.The display takes varying amounts of time to accomplish the functions as listed. LCD bit 7 is monitored for logic high (busy) to ensure the display is overwritten.Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. The most common type of LCD controller is HITACHI 44780 which provides a simple interface between the controller & an LCD. These LCD's are very simple to interface with the controller as well as are cost effective.

Figure 5.1: 2x16 Line Alphanumeric LCD Display The most commonly used ALPHANUMERIC displays are 1x16 (Single Line & 16 characters), 2x16 (Double Line & 16 character per line) & 4x20 (four lines & Twenty characters per line). The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on data lines depends on the mode of operation.

31

5.2 PIN DESCRIPTION


Pin 1 2 3 4 5 6 7-14 15 16 Symbol Vss Vdd Vo RS R/W En DB0-DB7 A/Vee K Function Ground Supply Voltage Contrast Setting Register Select Read/Write Select Chip Enable Signal Data Lines Gnd for the backlight Vcc for backlight

When RS is low (0), the data is to be treated as a command. When RS is high (1), the data being sent is considered as text data which should be displayed on the screen. When R/W is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively reading from the LCD. The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. The below figure shows LCD interfacing.

Figure 5.2: Interfacing of LCD

CHAPTER-6 SCHEMATIC DIAGRAM

32

Figure 6.1: Schematic Diagram 6.1 Schematic 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.

6.2 REGULATED POWER SUPPLY

33

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 .

Figure 6.2: IC Regulator 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.

34

Fig: Block Diagram of Power Supply

Figure 6.3: Circuit Diagram of Power Supply Above is the circuit of a basic unregulated dc power supply. A bridge rectifier D1 to D4 rectifies the ac from the transformer secondary, which may also be a block rectifier such as WO4 or even four individual diodes such as 1N4004 types. (See later re rectifier ratings).The principal advantage of a bridge rectifier is you do not need a centre tap on the secondary of the transformer. A further but significant advantage is that the ripple frequency at the output is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes filtering somewhat easier.As a design example consider we wanted a small unregulated bench supply for our projects. Here we will go for a voltage of about 12 - 13V at a maximum output current (IL) of 500ma (0.5A). Maximum ripple will be 2.5% and load regulation is 5%.Now the RMS secondary voltage (primary is whatever is consistent with your area) for our power transformer T1 must be our desired output Vo PLUS the voltage drops across D2 and D4 (2 * 0.7V) divided by 1.414.This means that Vsec = [13V + 1.4V] / 1.414 which equals about 10.2V. Depending on the VA rating of your transformer, the secondary voltage will vary considerably in accordance with the applied load. The secondary voltage on a transformer advertised as say 20VA will be much greater if the secondary is only lightly loaded.If we accept the 2.5% ripple as adequate for our purposes then at 13V this becomes 13 * 0.025 = 0.325 Vrms. The peak to peak value is 2.828 times this value. Vrip = 0.325V X 2.828 = 0.92 V and this value is required to calculate the value of C1. Also

35

required for this calculation is the time interval for charging pulses. If you are on a 60Hz system it it 1/ (2 * 60) = 0.008333 which is 8.33 milliseconds. For a 50Hz system it is 0.01 sec or 10 milliseconds.Remember the tolerance of the type of capacitor used here is very loose. The important thing to be aware of is the voltage rating should be at least 13V X 1.414 or 18.33. Here you would use at least the standard 25V or higher (absolutely not 16V).With our rectifier diodes or bridge they should have a PIV rating of 2.828 times the Vsec or at least 29V. Don't search for this rating because it doesn't exist. Use the next highest standard or even higher. The current rating should be at least twice the load current maximum i.e. 2 X 0.5A or 1A. A good type to use would be 1N4004, 1N4006 or 1N4008 types.These are rated 1 Amp at 400PIV, 600PIV and 1000PIV respectively. Always be on the lookout for the higher voltage ones when they are on special 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. 6.3 Circuit Features: 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

36

CHAPTER 7

SOFTWARE DESCRIPTION
Click on the Keil uVision Icon on Desktop The following fig will appear

37

Click on the Project menu from the title bar Then Click on New Project

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

38

Then Click on Save button above. Select the component for u r project. i.e. Atmel Click on the + Symbol beside of Atmel

39

Select AT89S51 as shown below

Then Click on OK The Following fig will appear

Then Click either YES or NOmostly NO

40

Now your project is ready to USE Now double click on the Target1, you would get another option Source group 1 as shown in next page.

Click on the file option from menu bar and select new

41

The next screen will be as shown in next page, and just maximize it by double clicking on its blue boarder.

Now start writing program in either in C or ASM For a program written in Assembly, then save it with extension . asm and for C based program save it with extension .C

42

Now right click on Source group 1 and click on Add files to Group Source

Now you will get another window, on which by default C files will appear.

43

Now select as per your file extension given while saving the file

Click only one time on option ADD


Now Press function key F7 to compile. Any error will appear if so happen.

44

If the file contains no error, then press Control+F5 simultaneously. The new window is as follows

Then Click OK

45

Now Click on the Peripherals from menu bar, and check your required port as shown in fig below

Drag the port a side and click in the program file.

Now keep Pressing function key F11 slowly and observe. You are running your program successfully

46

FUTURE SCOPE
This system is a rapidly growing field and there are new and improved strategies popping up all the time. For the most part these systems are all built around the same basic structure, a central box that monitors several detectors and perimeter guards and sounds an alarm when any of them are triggered.This system is best for guiding the perimeter of a house or a business center the points where an intruder would enter the building. In this system IR sensor is used to detect the intrusion. Similarly the vibration and temperature sensors recognize vibration disturbances and accidental fires respectively.This project provides an efficient and economical security system. This system finds applications in industries, banks and homes. Incorporating the features discussed below can further enhance the system This system can detect intrusion only at discrete points. This system detection feature can be extended to scanning a complete area. Thus the intrusion into the building can be detected with much more efficiently. The redialing feature can also be incorporated such that if the call is not put forward the first time, the auto dialer will dial the same number until the call is successfully completed. A pre-recorded voice message can delivered to the owner notifying him about the intrusion into the premises. The addition of the above discussed advancements certainly builds this project into a much flexible and reliable security system.

47

REFERENCES
The 8051 Microcontroller and Embedded Systems By Muhammad Ali Mazidi Fundamentals Of Embedded Software By Daniel W Lewis www.howsstuffworks.com www.alldatasheets.com www.electronicsforu.com www.knowledgebase.com www.8051 projectsinfo.com Datasheets of Microcontroller AT89C52 Datasheets of 555 timer Datasheets of TSAL 6200 Datasheets of TSOP 1356 Datasheets of BC 547

48

Datasheets of DTMF Generator UM 95089

49

You might also like