capstone project 2 final

Upload: amarjeet-singh

Post on 03-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Capstone Project 2 Final

    1/35

    Page | 1

    CHAPTER 1

    INTRODUCTION

    The techniques of distance measurement using ultrasonic in air include continuous wave and

    pulse echo technique. In the pulse echo method, a burst of pulses is sent through the

    transmission medium and is reflected by an object kept at specified distance. The time taken

    for the pulse to propagate from transmitter to receiver is proportional to the distance of

    object. For contact less measurement of distance, the device has to rely on the target to reflect

    the pulse back to itself. The target needs to have a proper orientation that is it needs to be

    perpendicular to the direction of propagation of the pulses. The amplitude of the received

    signal gets significantly attenuated and is a function of nature of the medium and the distance

    between the transmitter and target. The pulse echo or time-of-flight method of range

    measurement is subject to high levels of signal attenuation when used in an air medium, thus

    limiting its distance range. A simple ultrasonic range finder using 8051 microcontroller is

    presented in this article. This ultrasonic rangefinder can measure distances up to 2.5 meters

    at an accuracy of 1 centi meter. AT89s51 microcontroller and the ultrasonic transducer

    module HC-SR04 forms the basis of this circuit. The ultrasonic module sends a signal to the

    object, then picks up its echo and outputs a wave form whose time period is proportional to

    the distance. The microcontroller accepts this signal, performs necessary processing anddisplays the corresponding distance on the 3 digit seven segment display. This circuit finds a

    lot of application in projects like automotive parking sensors, obstacle warning systems,

    terrain monitoring robots, industrial distance measurements etc.

    The means for the measurement of distance of the target and for different other applications

    Ultrasonic distance sensors are used to detect the presence of flaw by measuring the distance.

    They do so by evaluating the echo of a transmitted pulse with concern to its travel time. Time

    dependent control of sensitivity is used to compensate the distance dependency of the echo

    amplitude, while different reflection properties are compensated by an automatic gain

    control, which holds the average echo amplitude constant. Echo amplitude therefore has very

    little influence on the accuracy of the distance measurement provided the signal to noise ratio

    is not very low. By considering whether the echo has been received within a time window,

    i.e. a time interval, which can be preset by the user, the distance range is given in which the

    sensor responds to the presence of an object. Using this technique, interference can be

    suppressed and relevant objects are monitored more reliably.

  • 7/28/2019 Capstone Project 2 Final

    2/35

    Page | 2

    CHAPTER 2

    OBJECTIVE OF THE PROJECT

    The object of this work is to replace the old traditional range detector, used in several

    applications. In present work the object position is measured electronically by using seven

    segment displays by replacing the heavy and bulky circuits with the compact circuits using

    intelligent Microcontroller. The bulky pressing switch is replaced by the small and one touch

    tactile switch. It saves electric consumption, saves the no. of man power, through seven

    segment display and one microcontroller as well as ultrasonic receiver & transmitter sensors.

    CHAPTER 3

    ULTRASONIC DISTANCE METER

    There are several ways to measure distance without contact. One way is to use ultrasonic

    waves at 40 kHz for distance measurement. Ultrasonic transducers measure the amount of

    time taken for a pulse of sound to travel to a particular surface and return as the reflected

    echo. This circuit calculates the distance based on the speed of sound at 25C ambient

    temperature and shows it on a 7-segment display. Using it, you can measure distance up to

    2.5 meters. For this particular application, the required components are AT89C2051microcontroller, two 40kHz ultrasonic transducers (one each for transmitter and receiver),

    current buffer ULN2003, operational amplifier iM324I inverter Ca4M4VI four T-segment

    displays I five transistors and some discreet components. The ultrasonic transmitter- receiver

    pair is shown in Ultrasonic generators use piezoelectric materials such as zinc or lead

    zirconium tartrates or quartz crystal.. The velocity of sound in the air is around 330 m/s at

    0C and varies with temperature.

    In this project, you excite the ultrasonic transmitter unit with a 40kHz pulse burst and

    expect an echo from the object whose distance you want to measure. Fig. 2 shows the

    transmitted burst, which lasts for a period of approximately 0.5 ms. It travels to the

    object in the air and the echo signal is picked up by another ultrasonic transducer unit

    (receiver), also a 40 kHz pre-tuned unit. The received signal, which is very weak is amplified

    several times in the receiver circuit and appears somewhat as shown in Fig. 2 when seen on a

    CRO. Of course, the signal gets weaker if the target is farther than 2.5 and will need a higher

    pulse excitation voltage or a better transducer. Here the microcontroller is used to generate 40

    kHz sound pulses. It reads when the echo arrives; it finds the time taken in microseconds for

  • 7/28/2019 Capstone Project 2 Final

    3/35

    Page | 3

    to-and-fro travel of sound waves. Using velocity of 333 m/s, it does the calculations and

    shows on the four 7-segment displays the distance in centimeters and millimeters (three digits

    for centimeters and one for millimeters).

    3.1. BLOCK DIAGRAM OF ULTRASONIC DISTANCE METER

    Figure 1 : Block Diagram of Ultrasonic Distance meter

  • 7/28/2019 Capstone Project 2 Final

    4/35

    Page | 4

    CHAPTER 4

    THEORY OF OPERATION

    The Ping sensor detects objects by emitting a short ultrasonic burst and then "listening" for

    the echo. Under control of a host microcontroller (trigger pulse), the sensor emits a short 40

    kHz (ultrasonic) burst. This burst travels through the air at about 1130 feet per second, hits an

    object and then bounces back to the sensor. The PING sensor provides an output pulse to the

    host that will terminate when the echo is detected, hence the width of this pulse corresponds

    to the distance to the target.

    Figure 2: Transmitting and Receiving Waves

    4.1. ULTRASONIC WAVES

    Sound waves with frequency range from 20 Hz to 20 KHz are responsive to the human ear.Vibrations above this frequency are termed as ultrasonic. Ultrasonic signals are affected by

    the properties of the medium. Thus while passing through a particular medium these signals

    get attenuated. The attenuation of ultrasonic signal is taken as the means for the measurement

    of distance of the target and for different other applications Ultrasonic distance sensors are

    used to detect the presence of flaw by measuring the distance. They do so by evaluating the

    echo of a transmitted pulse with concern to its travel time. Time dependent control of

    sensitivity is used to compensate the distance dependency of the echo amplitude, while

    different reflection properties are compensated by an automatic gain control, which holds the

  • 7/28/2019 Capstone Project 2 Final

    5/35

    Page | 5

    average echo amplitude constant. Echo amplitude therefore has very little influence on the

    accuracy of the distance measurement provided the signal to noise ratio is not very low. By

    considering whether the echo has been received within a time window, i.e. a time interval,

    which can be preset by the user, the distance range is given in which the sensor responds to

    the presence of an object. Using this technique, interference can be suppressed and relevant

    objects are monitored more reliably.

    A variety of ultrasonic presence sensors with different operation frequencies are designed for

    different distance range and different resolution. Such sensors are employed in the

    automation of industrial processes as well as in traffic control systems, for example to

    monitor, whether car parking places are occupied. Ultrasonic distance meters are used for the

    measurement of the filling level in containers or the height of material on conveyor belts.

    Ultrasonic waves are generally used two types which are given as :-

    4.1.1LONGITUDINAL WAVES

    Longitudinal waves exist when the motion of the particle and the medium is parallel to the

    direction of propagation of the waves. These types of waves are referred as L waves. Since

    these can travel in solid, liquid and gases. These waves can be easily detected.

    4.1.2TRANSVERSE WAVES

    In this case particles of the medium vibrate at right angle to the direction of propagation of

    the waves. These are also called shear waves.

    4.2. ULTRASONIC DISTANCE SENSORS

    Ultrasonic sonar sensors actively transmit acoustic waves and receive them later. This is done

    by ultrasonic transducers, which transform an electrical signal into an ultrasonic wave and

    vice versa. The ultrasound signal carries the information about the variables to be measured.

    The task for the ultrasonic sensors is not merely to detect ultrasound, as intelligent sensors

    they have to extract the information carried by the ultrasonic signals efficiently and with high

    accuracy. To achieve this performance, the signals are processed, demodulated and evaluated

    by dedicated hardware. Algorithms based on models for the ultrasonic signal propagation and

  • 7/28/2019 Capstone Project 2 Final

    6/35

    Page | 6

    the interaction between the physical or chemical variables of interest are employed

    (munich,1994).

    Furthermore, techniques of a sensor specific signal evaluation are being applied. Ultrasonic

    sensors can be embedded into a control system that accesses additional sensors, combines

    information of the different sensors, handles the bus protocols and initiates actions.

    Figure 3: Ultrasonic Transducer (Transmitter and Receiver)

    CHAPTER 5

    CIRCUIT DESCRIPTION

    Figure 4 shows the circuit of the microcontroller based distance meter. The 40kHz pulsebursts from the microcontroller are amplified by transistor T5. Inverting buffer CD4049

    drives the ultrasonic sensor used as the transmitter. Three inverters (N1, N2 and N3) are

    connectedin parallelto increase thetransmitted power.This inverted outputis fed to another

    set of threeinverters (N4, N5and N6). Outputsof both sets of parallelinverters areapplied as

    a push pulldrive to theultrasonic transmitter.

    The positive goingpulse is applied to one of the terminals of theultrasonic sensorand the

    same pulseafter 180-degreephase shift is applied to another terminal. Thus the transmitter

    poweris increased for increasingthe range.If you want toincrease the rangeup to 5 meters,

    use a ferrite-core step-up pulse transformer, which steps-up the transmitter output to 60V

    (peak-to-peak).The echo signal received by thereceiver sensor after reflection is veryweak.

    It is amplified by quad operational amplifier LM324. The first stage (A1) is a buffer with

    unity gain. The received signal is directly fed to the non-inverting input (pin 3) of A1 and

    coupled to the second stage by a 3.3nF (small-value) capacitor. If you use the ubiquitous

    0.01F capacitor for coupling, there will be 2-mega-ohm resistor for feedback. The third

    stage is a precision rectifier amplifier with a gain of 10.

  • 7/28/2019 Capstone Project 2 Final

    7/35

    Page | 7

    Figure 4: Circuit Diagram of Ultrasonic Distance meter

  • 7/28/2019 Capstone Project 2 Final

    8/35

    Page | 8

    Pin13 is the other pin of the comparator used for level adjustment using preset VR1. The

    ultrasonic transducer outputs a beam of sound waves, which has more energy on the main

    lobe and less energy (60 dB below the main lobe) on the side lobes as shown in Fig. 4. Even

    this low side-lobe signal is directly picked up by the receiver unit. So you have to space the

    transmitter and receiver units about 5 cm apart. The two units are fixed by cello tape on to a

    cardboard, with the analogue circuit at one end. Microcontroller AT89C2051 is at the heart of

    the circuit. Port-1 pins P1.7 through P1.2, and port-3 pin P3.7 are connected to input pins

    through 1 to 7of IC2 (IC ULN2003), respectively. These pins are pulled up with a 10-kilo-

    ohm resistor network RNW1. They drive all the segments of the 7-segment display with the

    help of inverting buffer IC2. Port-3 pins P3.0 through P3.3 of the microcontroller are

    connected to the base of transistors T1 through T4 to provide the supply to displays DIS1

    through DIS4, respectively. Pin P3.0 of microcontroller IC1 goes low to drive transistor T1

    into saturation, which provides supply to the common- anode pin (either pin 3 or 8) of

    display DIS1. Similarly, transistors T2 through T4 provide anode currents to the other three

    7-segment displays. Microcontroller IC1 provides the segment data and display-enable signal

    simultaneously in time-division multiplexed mode for displaying a particular number on the

    7-segment display unit. Segment data and display-enable pulse for the display are refreshed

    every 5 ms. Thus the display appears to be continuous, even though the individual LEDs used

    in it light up one by one. Using switch S1 you can manually reset the microcontroller, while

    the power on reset signal for the microcontroller is derived from the combination of capacitorC4 and resistor R8. A 12MHz crystal is used to generate the basic clock frequency for the

    microcontroller. Resistor R16 connected to pin 5 of DIS2 enables the decimal point. The

    comparator is inbuilt in microcontroller AT89C2051. The echo signal will make port-3 pin

    3.6 low when it goes above the level of voltage set on pin 13. This status is sensed by the

    microcontroller as programmed. When port-3 pin P3.6 goes high, we know that the echo

    signal has arrived; the timer is read and the 16-bit number is divided by twice the velocity of

    sound and then converted into decimal format as a 4-digit number.

    5.1 POWER SUPPLY

    Figure shows the circuit of the power supply. The 230V AC mains is stepped down by

    transformer X1 to deliver the secondary output of 15V-0-15V, 500 mA. The transformer

    output is rectified by a full-wave bridge rectifier comprising diodes D3 through D6, filtered

    by capacitors C8 and C9 and then regulated by ICs 7815 (IC5), 7915 (IC6)and 7805 (IC7).

    Regulators 7815, 7915 and 7805 provide +15V, -15V and+5V regulated supply,

  • 7/28/2019 Capstone Project 2 Final

    9/35

    Page | 9

    respectively. Capacitors C10 through C12 bypass the ripples present in the regulated power

    supply.

    Figure 5: Power Supply Circuit Diagram

    5.2 CONSTRUCTION AND TESTING

    An actual-size, single-side PCB for the microcontroller-based distance meter is shown in Fig.

    6 and its component layout in Fig. 7. Assemble the PCB and put the programmed

    microcontroller into the socket. After switching on the power supply and microcontroller

    automatically getting reset upon power-on, pin 8 will pulse at 40kHz bursts. This can be

    seen using an oscilloscope. Give this signal to channel 1 of the oscilloscope. Adjust the time

    base to 2 ms per division and set it to trigger mode instead of normal mode. Adjust the

    potentiometer on the oscilloscope labeled level such that the trace starts with the burst and

    appears steady as shown. Connect the transmitter and receiver ultrasonic units either by a

    twisted pair of wire or by a shielded cable to the board. Give the received signal to channel 2

    of the oscilloscope. Then, place an A4-size plastic sheet in front of the ultrasonic transducers

    and observe the echo signal. It will appear as shown. The two transducers can be fixed to a

    thick cardboard with two wires leading to the circuittwo 40cm long shielded cables will do.

    The laser pointer is fixed such that it is axial to the transducers. Channel 2 is connected to pin

    12, which is the positive non-inverting terminal of AT89C2051s comparator. The negative

  • 7/28/2019 Capstone Project 2 Final

    10/35

    Page | 10

    inverting terminal (pin 13) is connected to a preset reference. Adjust the preset such that the

    voltage is 0.1V-0.2V at pin 13. This will enable detection of weak echoes also. When the

    echo signal goes above the level of reference voltage set on pin 13, it will make P3.6 low; the

    arrival of echo is sensed by the program using jnb p3.6 (jump not bit) instruction. Software

    The software is \ written in Assembly language and assembled using 8051 cross-assembler. It

    is well commented and easy to understand. The pulse train for 0.5 ms is started by making

    pin 8 high and low alternately for 12.5 microseconds so that the pulse frequency is 40 kHz.

    After 25 such pulses have passed, a waiting time is given to avoid direct echoes for about 20

    s. Then the signal is awaited, while the timer runs counting time in microseconds. When the

    echo arrives, port-3 pin P3.6 goes high, the timer reads and the 16-bit number is divided by

    twice the velocity and converted into decimal format as a 4-digit number. If the echo does not

    arrive even after 48 milliseconds, the waiting loop is broken and the pulse train sequence is

    started once again. If the echo comes within this time, it is displayed for half a second before

    proceeding to another measurement. Thus, the display appears continuous and flicker-free.

    Other uses Simply by changing this program, the same unit can be made to detect moving

    objects (such as cars racing on the street) and find their range and speed. It can also be used

    with suitable additional software as a burglar alarm unit for homes or offices.

    Figure 6: Transmitted and Received Pulses

  • 7/28/2019 Capstone Project 2 Final

    11/35

    Page | 11

    CHAPTER 6

    SOFTWARE USED FOR PROGRAMMING

    The software is written in Assembly language and assembled using 8051 cross-assembler. It

    is well commented and easy to understand. The pulse train for 0.5 ms is started by making

    pin 8 high and low alternately for 12.5 microseconds so that the pulse frequency is 40 kHz.

    After 25 such pulses have passed, a waiting time is given to avoid direct echoes for about 20

    s. Then the signal is awaited, while the timer runs counting time in microseconds. When the

    echo arrives, port-3 pin P3.6 goes high, the timer reads and the 16-bit number is divided by

    twice the velocity and converted into decimal format as a 4-digit number. If the echo does not

    arrive even after 48 milliseconds, the waiting loop is broken and the pulse train sequence is

    started once again. If the echo comes within this time, it is displayed for half a second before

    proceeding to another measurement. Thus, the display appears continuous and flicker-free.

    KEIL U-VISION 3.0

    Keil Software is used provide you with software development tools for 8051 based

    microcontrollers. With the Keil tools, you can generate embedded applications for virtually

    every 8051 derivative. The supported microcontrollers are listed in the microvision. Keil

    development tools for the 8051 microcontroller family support every level of developer from

    the professional applications engineer to the student just learning about embedded software

    development. The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-

    time Kernels, and Single-board Computers support ALL 8051-compatible derivatives and

    help you get your projects completed on schedule. Vision is an IDE (Integrated

    Development Environment) that helps you write, compile, and debug embedded programs. It

    encapsulates the following components:

    Multiple Monitor - flexible window management system. System Viewer - display device peripheral register information. Debug Views - create and save multiple debug window layouts. Multi-Project Workspace - simplify working with numerous projects. Source and Disassembly Linking - the Disassembly Window and Source Windows

    are fully synchronized making program debugging and cursor navigation easier.

    Memory Window Freeze - store the current Memory Window view allowing easycomparison of memory contents at different points in time.

  • 7/28/2019 Capstone Project 2 Final

    12/35

    Page | 12

    CHAPTER 7

    APPENDICES

    7.1. APPENDIXA

    7.1.1. SEMICONDUCTORS:

    S.No. NOTATTION COMPONENT

    1. IC1 AT89C2051 microcontroller

    2. IC2 ULN2003 current buffer

    3. IC3 CD4049 hex inverting buffer

    4. IC4 LM324 quad operational amplifier

    5. IC5 7815, 15V regulator

    6. IC6 7915, -15V regulator

    7. IC7 7805, 5V regulator

    8. T1,T4 BC557 pnp transistor

    9. T5 2N2222 npn transistor

    10. D1, D2 1N4148 switching diode

    11. D3-D6 1N4007 rectifier diode

    12. DIS1-DIS4- LTS 542 common-anode, 7-segment display

    Table 1: Semiconductor Components

    7.1.2. RESISTORS (all -watt, 5% carbon):

    S.No. Notation Rating

    1. R1, R2 2-mega-ohm

    2. R3 82-kilo-ohm

    3. R4, R7-R10 10-kilo-ohm

    4. R5 33-kilo-ohm

    5. R6 100-kilo-ohm

    6. R11 1-kilo-ohm

    7. R16 220-ohm

    8. RNW1 10-kilo-ohm resistor network

    9. VR1 1-kilo-ohm preset

    Table 2: Resistors

  • 7/28/2019 Capstone Project 2 Final

    13/35

    Page | 13

    7.1.3. CAPACITORS

    S.No. Notation Rating

    1. C1, C2 3.3nF ceramic disk

    2. C7, C10-C12 0.1F ceramic disk

    3. C3 2.2nF ceramic disk

    4. C4 10F, 16V electrolytic

    5. C5, C6 22pF ceramic disk

    6. C8, C9 1000F, 50V electrolytic

    Table 3: Capacitors

    7.1.4. MISCELLANEOUS

    S.No. Notation Compnent

    1. X1 230V AC primary to

    15V-0-15V, 500mA secondary transformer

    2. XTAL 12MHz crystal

    3. S1 Push-to-on switch

    4. S2 On/off switch

    5. TX1 40kHz ultrasonic transmitter

    6. RX1 40kHz ultrasonic receiver

    Table 4: Miscellaneous

    7.1.5. RESISTANCE

    The electrical resistance of a circuit component or device is defined as the ratio of the voltage

    applied to the electric current which flows through it

    http://hyperphysics.phy-astr.gsu.edu/hbase/electric/elevol.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/elecur.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/elecur.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/elevol.html#c1
  • 7/28/2019 Capstone Project 2 Final

    14/35

    Page | 14

    If the resistance is constant over a considerable range of voltage, then Ohm's law, I = V/R,

    can be used to predict the behavior of the material. Although the definition above involves

    DC current and voltage, the same definition holds for the AC application of resistors.

    Whether or not a material obeys Ohm's law, its resistance can be described in terms of its

    bulk resistivity. The resistivity, and thus the resistance, is temperature dependent. Oversizable ranges of temperature, this temperature dependence can be predicted from a

    temperature coefficient of resistance.

    7.1.6. RESISTIVITY AND CONDUCTIVITY

    The electrical resistance of a wire would be expected to be greater for a longer wire, less for a

    wire of larger cross sectional area, and would be expected to depend upon the material out of

    which the wire is made. Experimentally, the dependence upon these properties is a

    straightforward one for a wide range of conditions, and the resistance of a wire can be

    expressed as

    The factor in the resistance which takes into account the nature of the material is the

    resistivity. Although it is temperature dependent, it can be used at a given temperature to

    calculate the resistance of a wire of given geometry.

    The inverse of resistivity is called conductivity. There are contexts where the use of

    conductivity is more convenient.

    Electrical conductivity = = 1/

    7.1.7. RESISTOR COMBINATIONS

    The combination rules for any number ofresistors in series or parallel can be derived with the

    use ofOhm's Law, the voltage law, and the current law.

    http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/acres.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c2http://hyperphysics.phy-astr.gsu.edu/hbase/electric/restmp.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c2http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c3http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c3http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c2http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/restmp.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c2http://hyperphysics.phy-astr.gsu.edu/hbase/electric/acres.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/ohmlaw.html#c1
  • 7/28/2019 Capstone Project 2 Final

    15/35

    Page | 15

    7.1.8. RESISTIVITY CALCULATION

    The electrical resistance of a wire would be expected to be greater for a longer wire, less for a

    wire of larger cross sectional area, and would be expected to depend upon the material out of

    which the wire is made (resistivity). Experimentally, the dependence upon these properties is

    a straightforward one for a wide range of conditions, and the resistance of a wire can be

    expressed as

    Resistance = resistivity x length/area

    7.2. APPENDIX-B

    7.2.1. CAPACITOR

    A capacitor consists of two electrodes or plates, each of which stores an opposite charge.

    These two plates are conductive and are separated by an insulatorordielectric. The charge is

    stored at the surface of the plates, at the boundary with the dielectric. Because each plate

    stores an equal but opposite charge, the totalcharge in the capacitor is always zero.

    http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c2http://var%20cal%3Drcal%28%29/http://var%20cal%3Drhocal%28%29/http://var%20cal%3Dlcal%28%29/http://var%20cal%3Dacal%28%29/http://en.wikipedia.org/wiki/Electrodehttp://en.wikipedia.org/wiki/Insulatorhttp://en.wikipedia.org/wiki/Dielectrichttp://en.wikipedia.org/wiki/Dielectrichttp://en.wikipedia.org/wiki/Dielectrichttp://en.wikipedia.org/wiki/Insulatorhttp://en.wikipedia.org/wiki/Electrodehttp://var%20cal%3Dacal%28%29/http://var%20cal%3Dlcal%28%29/http://var%20cal%3Drhocal%28%29/http://var%20cal%3Drcal%28%29/http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c2http://hyperphysics.phy-astr.gsu.edu/hbase/electric/resis.html#c1
  • 7/28/2019 Capstone Project 2 Final

    16/35

    Page | 16

    Figure 7: Capacitor charge formation

    When electric charge accumulates on the plates, an electric field is created in the region

    between the plates that is proportional to the amount of accumulated charge. This electric

    field creates a potential difference V= Edbetween the plates of this simple parallel-plate

    capacitor.

    Figure 8: Capacitor Charge formation 2

    The electrons in the molecules move or rotate the molecule toward the positively charged left

    plate. This process creates an opposing electric field that partially annuls the field created by

    the plates. (The air gap is shown for clarity; in a real capacitor, the dielectric is in direct

    contact with the plates.)

    Capacitance

    The capacitor's capacitance (C) is a measure of the amount ofcharge (Q) stored on each plate

    for a given potential difference orvoltage (V) which appears between the plates:

    http://en.wikipedia.org/wiki/Electric_fieldhttp://en.wikipedia.org/wiki/Capacitancehttp://en.wikipedia.org/wiki/Electric_chargehttp://en.wikipedia.org/wiki/Potential_differencehttp://en.wikipedia.org/wiki/Potential_differencehttp://en.wikipedia.org/wiki/Electric_chargehttp://en.wikipedia.org/wiki/Capacitancehttp://en.wikipedia.org/wiki/Image:Dielectric.pnghttp://en.wikipedia.org/wiki/Electric_fieldhttp://en.wikipedia.org/wiki/Image:Capacitor.png
  • 7/28/2019 Capstone Project 2 Final

    17/35

    Page | 17

    In SI units, a capacitor has a capacitance of one farad when one coulomb of charge causes a

    potential difference of one volt across the plates. Since the farad is a very large unit, values of

    capacitors are usually expressed in microfarads (F), nanofarads (nF) or picofarads (pF).

    The capacitance is proportional to the surface area of the conducting plate and inversely

    proportional to the distance between the plates. It is also proportional to thepermittivity ofthe dielectric (that is, non-conducting) substance that separates the plates.

    Stored energy

    As opposite charges accumulate on the plates of a capacitor due to the separation of charge, a

    voltage develops across the capacitor owing to the electric field of these charges. Ever

    increasing work must be done against this ever increasing electric field as more charge is

    separated. The energy (measured in joules, in SI) stored in a capacitor is equal to the amount

    of work required to establish the voltage across the capacitor, and therefore the electric field.

    The energy stored is given by:

    where V is the voltage across the capacitor.

    7.2.2. IN ELECTRIC CIRCUITS

    Circuits with DC sources

    Electrons cannot directly pass across the dielectric from one plate of the capacitor to the

    other. When there is a current through a capacitor, electrons accumulate on one plate and

    electrons are removed from the other plate. This process is commonly called 'charging' the

    capacitor even though the capacitor is at all times electrically neutral. In fact, the currentthrough the capacitor results in the separation rather than the accumulation of electric charge.

    This separation of charge causes an electric field to develop between the plates of the

    capacitor giving rise to voltage across the plates. This voltage V is directly proportional to the

    amount of charge separated Q. But Q is just the time integral of the current I through the

    capacitor. This is expressed mathematically as:

    http://en.wikipedia.org/wiki/SIhttp://en.wikipedia.org/wiki/Faradhttp://en.wikipedia.org/wiki/Coulombhttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Permittivityhttp://en.wikipedia.org/wiki/Dielectrichttp://en.wikipedia.org/wiki/Electrical_conductionhttp://en.wikipedia.org/wiki/Energyhttp://en.wikipedia.org/wiki/Joulehttp://en.wikipedia.org/wiki/SIhttp://en.wikipedia.org/wiki/SIhttp://en.wikipedia.org/wiki/Joulehttp://en.wikipedia.org/wiki/Energyhttp://en.wikipedia.org/wiki/Electrical_conductionhttp://en.wikipedia.org/wiki/Dielectrichttp://en.wikipedia.org/wiki/Permittivityhttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Coulombhttp://en.wikipedia.org/wiki/Faradhttp://en.wikipedia.org/wiki/SI
  • 7/28/2019 Capstone Project 2 Final

    18/35

    Page | 18

    Where I is the current flowing in the conventional direction, measured in amperes dV/dt is

    the time derivative of voltage, measured in volts / second. C is the capacitance in farads .For

    circuits with a constant (DC) voltage source, the voltage across the capacitor cannot exceed

    the voltage of the source. Thus, an equilibrium is reached where the voltage across the

    capacitor is constant and the current through the capacitor is zero. For this reason, it is

    commonly said that capacitors block DC current.

    Series or parallel arrangements

    Capacitors in aparallel configuration each have the same potential difference (voltage). To

    find their total equivalent capacitance (Ceq):

    The current through capacitors in series stays the same, but the voltage across each capacitor

    can be different. The sum of the potential differences (voltage) is equal to the total voltage.

    To find their total capacitance:

    One possible reason to connect capacitors in series is to increase the overall voltage rating. In

    practice, a very large resistor might be connected across each capacitor to divide the total

    voltage appropriately for the individual ratings.

    Capacitor/inductor duality

    In mathematical terms, the ideal capacitor can be considered as an inverse of the ideal

    inductor, because the voltage-current equations of the two devices can be transformed into

    one another by exchanging the voltage and current terms. Just as two or more inductors can

    be magnetically coupled to make a transformer, two or more charged conductors can be

    electrostatically coupled to make a capacitor. The mutual capacitance of two conductors is

    defined as the current that flows in one when the voltage across the other changes by unitvoltage in unit time.

    http://en.wikipedia.org/wiki/Amperehttp://en.wikipedia.org/wiki/Derivativehttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Secondhttp://en.wikipedia.org/wiki/Series_and_parallel_circuitshttp://en.wikipedia.org/wiki/Series_and_parallel_circuitshttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Series_and_parallel_circuitshttp://en.wikipedia.org/wiki/Image:Capacitorsparallel.pnghttp://en.wikipedia.org/wiki/Series_and_parallel_circuitshttp://en.wikipedia.org/wiki/Secondhttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Derivativehttp://en.wikipedia.org/wiki/Ampere
  • 7/28/2019 Capstone Project 2 Final

    19/35

    Page | 19

    Capacitor symbols

    7.3.APPENDIX-C

    7.3.1. DATASHEET -IC 89C2051

    7.3.1.1 FEATURES

    Compatible with MCS-51 Products 2 Kbytes of Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles 2.7 V to 6 V Operating Range Fully Static Operation: 0 Hz to 24 MHz Two-Level Program Memory Lock 128 x 8-Bit Internal RAM 15 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources Programmable Serial UART Channel Direct LED Drive Outputs On-Chip Analog Comparator Low Power Idle and Power Down Modes

  • 7/28/2019 Capstone Project 2 Final

    20/35

    Page | 20

    7.3.1.2. DESCRIPTION

    The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with 2

    Kbytes of Flash programmable and erasable read only memory (PEROM). The device is

    manufactured using Atmels high density nonvolatile memory technology and is compatible

    with the industry standard MCS-51 instruction set and pinout. By combining a versatile 8-bit

    CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a powerful microcomputer

    which provides a highly flexible and cost effective solution to many embedded control

    applications.

    The AT89C2051 provides the following standard features: 2 Kbytes of Flash, 128 bytes of

    RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a

    full duplex serial port, a precision analog comparator, on-chip oscillator and clock circuitry.

    In addition, the AT89C2051 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 contents

    but freezes the oscillator disabling all other chip functions until the next hardware reset.

    7.3.1.3. PIN CONFIGURATION

    Figure 9: IC 89C2051 Pinout Diagram

  • 7/28/2019 Capstone Project 2 Final

    21/35

    Page | 21

    7.3.1.4. BLOCK DIAGRAM

    Figure 10: IC 89C2051 Block Diagram

  • 7/28/2019 Capstone Project 2 Final

    22/35

    Page | 22

    7.3.1.5. PIN DESCRIPTION

    VCC

    Supply voltage.

    GND

    Ground.

    PORT 1

    Port 1 is an 8-bit bidirectional I/O port. Port pins P1.2 to P1.7 provide internal pullups. P1.0

    and P1.1 require external pullups. P1.0 and P1.1 also serve as the positive input (AIN0) and

    the negative input (AIN1), respectively, of the on-chip precision analog comparator. The Port

    1 output buffers can sink 20 mA and can drive LED displays directly. When 1s are written to

    Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7 are used as inputs and are

    externally pulled low, they will source current (IIL) because of the internal pullups. Port 1

    also receives code data during Flash programming and program verification.

    PORT 3

    Port 3 pins P3.0 to P3.5, P3.7 are seven bidirectional I/O pins with internal pullups. P3.6 is

    hard-wired as an input to the output of the on-chip comparator and is not accessible as a

    general purpose I/O pin. The Port 3 output buffers can sink 20 mA. 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.

    Table 5: Port 3 Functions

  • 7/28/2019 Capstone Project 2 Final

    23/35

    Page | 23

    RST

    Reset input. All I/O pins are reset to 1s as soon as RST goes Hig h. Holding the RST pin high

    for two machine cycles while the oscillator is running resets the device. Each machine cycle

    takes 12 oscillator or clock cycles.

    XTAL1

    Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

    XTAL2

    Output from the inverting oscillator amplifier.

    7.3.1.6. 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 1. 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 2. There areno 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-flops, but minimum and maximum voltage

    high and low time specifications must be observed. Notes: C1, C2 = 30 pF, 10 pF for

    Crystals= 40 pF, 10 pF for Ceramic Resonators

    (a) (b)

    Figure11: (a) Oscillator Connections, (b) External Clock Drive Configuration

  • 7/28/2019 Capstone Project 2 Final

    24/35

    Page | 24

    7.3.1.7. PROGRAM MEMORY LOCK BITS

    On the chip are two lock bits which can be left unprogrammed (U) or can be programmed (P)

    to obtain the additional features listed in the table:

    Table 6: Program Memory Lock Bits

    7.3.1.8. IDLE MODE

    In idle mode, the CPU puts itself to sleep while all the on-chip 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 anyenabled interrupt or by a hardware reset. P1.0 and P1.1 should be set to 0 if no external pull

    ups are used, or set to 1 if external pullups are used. 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.

    7.3.1.9. POWER DOWN MODE

    In the power down mode the oscillator is stopped, and the instruction that invokes power

    down is the last instruction executed. The on-chip RAM and Special Function Registers

    retain their values until the power down mode is terminated. The only exit from power down

    is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The

  • 7/28/2019 Capstone Project 2 Final

    25/35

    Page | 25

    reset should not be activated before VCC is restored to its normal operating level and must be

    held active long enough to allow the oscillator to restart and stabilize. P1.0 and P1.1 should

    be set to 0 if no external pullups are used, or set to 1 if external pullups are used.

    7.3.1.10. PROGRAMMING THE FLASH

    The AT89C2051 is shipped with the 2 Kbytes of on-chip PEROM code memory array in the

    erased state (i.e., contents = FFH) and ready to be programmed. The code memory array is

    programmed one byte at a time. Once the array isprogrammed, to re-program any non-blank

    byte, the entire memory array needs to be erased electrically.

    7.3.1.11. INTERNAL ADDRESS COUNTER

    The AT89C2051 contains an internal PEROM address counter which is always reset to 000H

    on the rising edge of RST and is advanced by applying a positive going pulse to pin XTAL1.

    7.3.1.12. PROGRAMMING ALGORITHM:

    To program the AT89C2051, the following sequence is recommended.

    1. Power-up sequence: Apply power between VCC and GND pins Set RST and XTAL1 to

    GND With all other pins floating, wait for greater than 10 milliseconds

    2. Set pin RST to H Set pin P3.2 to H

    3. Apply the appropriate combination of H or L logic levels to pins P3.3, P3.4, P3.5, P3.7

    to select one of the programming operations shown in the PEROM Programming Modes

    table. To Program and Verify the Array:

    4. Apply data for Code byte at location 000H to P1.0 to P1.7.

    6. Pulse P3.2 once to program a byte in the PEROM array or the lock bits. The byte-write

    cycle is self-timed and typically takes 1.2 ms.

    7. To verify the programmed data, lower RST from 12V to logic H level and set pins P3.3

    to P3.7 to the appropriate levels. Output data can be read at the port P1 pins.

    8. To program a byte at the next address location, pulse XTAL1 pin once to advance the

    internal address counter. Apply new data to the port P1 pins.

    9. Repeat steps 5 through 8, changing data and advancing the address counter for the entire 2

    Kbytes array or until the end of the object file is reached.

    10. Power-off sequence: set XTAL1 to L set RST to L Float all other I/O pins Turn Vcc

    power off.

  • 7/28/2019 Capstone Project 2 Final

    26/35

    Page | 26

    7.3.1.13. DATA POLLING

    The AT89C2051 features Data Polling to indicate the end of a write cycle. During a write

    cycle, an attempted read of the last byte written will result in the complement of the written

    data on P1.7. Once the write cycle has been completed, true data is valid on all outputs, and

    the next cycle may begin. Data Polling may begin any time after a write cycle has been

    initiated.

    7.3.1.14. READY/BUSY

    The Progress of byte programming can also be monitored by the RDY/BSY output signal.

    Pin P3.1 is pulled low after P3.2 goes High during programming to indicate BUSY. P3.1 is

    pulled High again when programming is done to indicate READY.

    7.3.1.15. PROGRAM VERIFY

    If lock bits LB1 and LB2 have not been programmed code data can be read back via the data

    lines for verification:

    1. Reset the internal address counter to 000H by bringing RST from L to H.

    2. Apply the appropriate control signals for Read Code data and read the output data at theport P1 pins.

    3. Pulse pin XTAL1 once to advance the internal address counter.

    4. Read the next code data byte at the port P1 pins.

    5. Repeat steps 3 and 4 until the entire array is read.

    The lock bits cannot be verified directly. Verification of the lock bits is achieved by

    observing that their features are enabled.

    7.3.1.16. CHIP ERASE

    The entire PEROM array (2 Kbytes) and the two Lock Bits are erased electrically by using

    the proper combination of control signals and by holding P3.2 low for 10 ms. The code array

    is written with all "1"s in the Chip Erase operatio and must be executed before any non-blank

    memory byte can be re-programmed.

  • 7/28/2019 Capstone Project 2 Final

    27/35

    Page | 27

    7.3.1.17. READING THE SIGNATURE BYTES

    The signature bytes are read by the same procedure as a normal verification of locations

    000H, 001H, and 002H, except that P3.5 and P3.7 must be pulled to a logic low. The values

    returned are as follows.(000H) = 1EH indicates manufactured by Atmel (001H) = 21H

    indicates 89C2051

    7.3.1.18. PROGRAMMING INTERFACE

    Every code byte in the Flash array can be written and the entire array can be erased by using

    the appropriate combination of control signals. The write operation cycle is self-timed and

    once initiated, will automatically time itself to completion.All major programming vendors

    offer worldwide support for theAtmel microcontroller series.

    7.3.1.19. FLASH PROGRAMMING MODES

    Table 7: Flash Programming Modes

  • 7/28/2019 Capstone Project 2 Final

    28/35

    Page | 28

    (a) (b)

    Figure 12: (a) Programming the Flash Memory (b)Verifying the Flash Memory

    Table 8:Flash Programing and Verification

  • 7/28/2019 Capstone Project 2 Final

    29/35

    Page | 29

    7.3.1.20. FLASH PROGRAMMING AND VERIFICATION WAVEFORMS

    Figure 13: Flash Programming and Verification Waveforms

    7.3.1.21. ABSOLUTE MAXIMUM POWER RATING

    Table 9: Absolute Maximum Power Rating

  • 7/28/2019 Capstone Project 2 Final

    30/35

    Page | 30

    7.3.1.22. DC CHARACTERSTICS

    Table 9: DC Characterstics

  • 7/28/2019 Capstone Project 2 Final

    31/35

    Page | 31

    7.3.1.23. EXTERNAL CLOCK DRIVE WAVEFORM

    Figure 14: External Clock Drive Waveform

    7.3.1.24. EXTERNAL CLOCK DRIVE

    Table 10: External Clock Drive

  • 7/28/2019 Capstone Project 2 Final

    32/35

    Page | 32

    CHAPTER 8

    CONCLUSION

    The objective of this project is to design and implement an Ultrasonic Obstruction Detection

    and Distance Measurement device. As described in this report a system is developed that can

    detect objects and calculate the distance of the tracked object. With respect to the

    requirements for an ultrasonic range finder the following can be concluded.

    (a) The system is able to detect objects within the sensing range.(b) The system can calculate the distance of the obstruction with

    a. sufficient accuracy.b. This device has the capability to interact with other peripheral ifc. used as a secondary device.d. This can also communicate with PC through its serial port.e. This offers a low cost and efficient solution for non contact typef. distance measurements.

    The Range Finder has numerous applications. It can be used for automatic guided vehicles,

    positioning of robots as well as measuring generic distances, liquid levels in tanks, and the

    depth of snow banks. The device can serve as a motion detector in production lines. The

    ultrasonic detection range relates with size, figure, material and position of the object. The

    bigger the reflector is, the better the reflectance is, and the stronger the reflection signal is.

    The ultrasonic distance measurement is an untouchable detection mode. Compared with else

    detection modes, it does not get much influenced by ray, temperature and colour etc, and it

    has the great capability to adapt to various circumstances and ambient conditions. A restricted

    target angle (it requires a near perpendicular surface) and large beam, which can create poorresolution, seem to be the Range Finders only limitations. Also there is a blind area and

    distance limitation in ultrasonic distance measurement. Despite these drawbacks, we find the

    devices main features to be extremely useful.

  • 7/28/2019 Capstone Project 2 Final

    33/35

    Page | 33

    CHAPTER 9

    APPLICATIONS

    Applications of ultrasonic can be divided into two categories.

    1. Ultrasonics in industry

    2. Ultrasonics in medicine

    Both are big fields in themselves. The concentration would be more on the former one.

    In industry ultrasonic is employed for :-

    (a)Low power applications where in the ultrasonic energy explores a body of materialand is thereby modified.

    (b)High power application where in the ultrasonics energy modifies the body of materialto which it is applied.

    Some of the important low power applications are :-

    1) Flow detection,

    2) Thickness gauging,

    3) Measurement of various physical properties of materials.

    4) Extent of corrosion

    5) Estimation of grain sizes in polycrystalline materials.

    6) Measurement of pressure, concentration temperature, viscosity and flow rates.

    7) leak detection

    8) Variable delay lines for computer applications and imaging,

    9) Liquid level control

  • 7/28/2019 Capstone Project 2 Final

    34/35

    Page | 34

    CHAPTER 10

    BIBLOGRAPHY

    1. Electronics for you - September 1998.

    2. www.electronicsforu.com.

    3. www.atmel.com/atmel/acrobat/doc0368.pdf.

    4. Kenneth J. Ayala, The 8051 Microcontroller Architecture, Programming & Applications,

    West Publishing Company, College & School Division, 1996.

    5. Muhammad Ali Mazidi, Janice Gillispie Mazidi, The 8051 Microcontroller & Embedded

    Systems, Pearson Education.

    6. David A. Bell, Electronic Devices and Circuits, Oxford University Press, 2008.

    7. Sensors & Transducers Journal, Vol. 95, Issue 8, August 2008, pp.49-57

    8. Alan Andrews, ABCs ofUltrasonic, Arthur Barker Limited, London, 1961.

    http://www.atmel.com/atmel/acrobat/doc0368.pdfhttp://www.atmel.com/atmel/acrobat/doc0368.pdf
  • 7/28/2019 Capstone Project 2 Final

    35/35

    BIODATA

    SUDEEP PARMARF inal year student (8th semester)

    Department of Electronics & communication

    Lovely Professional University

    Phagwara, (Punjab).

    Contact: +918126258452 , [email protected]

    NANDAM MANOHAR

    F inal year student (8th semester)

    Department of Electronics & communication

    Lovely Professional University

    Phagwara, (Punjab).

    Contact: +919041332599 , [email protected]

    BIKASH KUMAR SINGH

    F inal year student (8th semester)

    Department of Electronics & communication

    Lovely Professional University

    Phagwara, (Punjab).

    Contact: +919653228622 , [email protected]