A Project Report on Ultrasonic RANGE FINDER Using Micrcontroller ATmel 89C2051



Comments



Description

ULTRASONIC RANGE FINDERA PROJECT REPORT Submitted by NISHIT CHITTORA in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING in ELECTRONICS AND COMMUNICATION ENGINEERING GEETANJALI INSTITUE OF TECHNICAL STUDIES, UDAIPUR RAJASTHAN TECHNICAL UNIVERSITY MAY 2011 GEETANJALI INSTITUTE OF TECHNICAL STUDIES, DABOK, UDAIPUR, RAJASTHAN, INDIA (Affiliated to Rajasthan Technical University, Kota, Rajasthan) CERTIFICATE Certified that this project report “ULTRASONIC RANGE FINDER” is the bonafide work of “NISHIT CHITTORA” who carried out the project work under my supervision. SIGNATURE Mr. Rajeev Mathur HEAD OF THE DEPARTMENT ECE Department GITS, Dabok, Udaipur SIGNATURE Mr. Satish Somani SUPERVISOR Senior lecturer, ECE Department GITS,Dabok, Udaipur ABSTRACT The report details the implementation of distance measurement system using the ultrasonic waves. As the human ear’s audible perception range is 20 Hz to 40 kHz, it is insensitive to ultrasonic waves, and hence the ultrasound waves can be used for applications in industries/vehicles without hindering human activity. They are widely used as range meters and proximity detectors in industries also it can be used in parking assistance system. The distance can be measured using pulse echo and phase measurement method. Here the pulse echo methods used. The measurement unit uses a continuous signal in the transmission frequency range of ultrasonic transducers. The signal is transmitted by an ultrasonic transducer, reflected by an obstacle and received by another transducer where the signal is detected. The time delay of the transmitted and the received signal corresponds to the distance between the system and the obstacle. TABLE OF CONTENTS CHAPTER NO. TITLE ABSTRACT LIST OF FIGURES PAGE NO. iii vi 1. INTRODUCTION 1.1 1.2 1.3 OBJECTIVE ULTRASONIC RANGE FINDER BLOCK DIAGRAM OF ULTRASONIC RANGE FINDER 1.4 1.5 THEORY OF OPERATION ULTRASONIC WAVES 1.5.1 LONGITUDINAL WAVES 1.5.2 TRANSVERSE WAVES 1.6 ULTRASONIC DISTANCE SENSORS 1 2 4 4 5 6 6 7 2 CIRCUIT DESCRIPTION 2.1 POWER SUPPLY 2.2 CONSTRUCTION AND TESTING 8 11 12 3 SOFTWARE 3.1 ASSEMBLY LANGUAGE PROGRAM 3.2 OTHER USES 14 14 20 4 CONCLUSION 4.1 APPLICATION 23 24 APPENDICES APPENDIX-A APPENDIX-B APPENDIX-C APPENDIX-D APPENDIX-E 25 25 27 28 31 36 REFERENCES 49 16. FLASH PROGRAMMING AND VERIFICATION WAVEFORMS EXTERNAL CLOCK DRIVE WAVEFORM 4 5 7 9 11 13 25 25 29 29 35 36 38 38 42 42 43 45 . 3. 5.LIST OF FIGURES 1. 2. 10 11. 4. (A) PROGRAMMING THE FLASH MEMORY (B)VERIFYING THE FLASH MEMORY 15. 12. 7. BLOCK DIAGRAM OF ULTRASONIC RANGE FINDER TRANSMITTING AND RECEIVING WAVES ULTRASONIC TRANSDUCER (TRANSMITTER AND RECEIVER CIRCUIT DIAGRAM OF ULTRASONIC RANGE FINDER POWER SUPPLY CIRCUIT DIAGRAM TRANSMITTED AND RECEIVED PULSES PCB LAYOUT (TOP) PCB LAYOUT (BOTTOM) CAPACITOR CHARGE FORMATION CAPACITOR CHARGE FORMATION 2 IC 89C2051 PINOUT DIAGRAM IC 89C2051 BLOCK DIAGRAM (A) OSCILLATOR CONNECTIONS (B) EXTERNAL CLOCK DRIVE CONFIGURATION 14. 6. 8. 13. 9. 1. saves the no. the device has to rely on the target to reflect the pulse back to itself. 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.1 OBJECTIVE The object of this work is to replace the old traditional range detector. In the pulse echo method. 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. For contact less measurement of distance. The target needs to have a proper orientation that is it needs to be perpendicular to the direction of propagation of the pulses. It saves electric consumption. 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. INTRODUCTION The techniques of distance measurement using ultrasonic in air include continuous wave and pulse echo technique.1. The time taken for the pulse to propagate from transmitter to receiver is proportional to the distance of object. used in several applications. through seven segment display and one microcontroller as well as ultrasonic receiver & transmitter sensors. thus limiting its distance range. . a burst of pulses is sent through the transmission medium and is reflected by an object kept at specified distance. The bulky pressing switch is replaced by the small and one touch tactile switch. of man power. In this project. 2 when seen on a CRO. The material thickness decides the resonant frequency when mounted and excited by electrodes attached on either side of it. Weak echoes also occur due to the signals being directly received through the side lobes. This circuit calculates the distance based on the speed of sound at 25°C ambient temperature and shows it on a 7segment display. These are ignored as the real echo received . The velocity of sound in the air is around 330 m/s at 0°C and varies with temperature. The medical scanners used for abdomen or heart ultrasound are designed at 2.receiver pair is shown in Ultrasonic generators use piezoelectric materials such as zinc or lead zirconium tartrates or quartz crystal. also a 40 kHz pre-tuned unit.1. It travels to the object in the air and the echo signal is picked up by another ultrasonic transducer unit (receiver). you can measure distance up to 2. which lasts for a period of approximately 0. 2 shows the transmitted burst.5 meters. One way is to use ultrasonic waves at 40 kHz for distance measurement. two 40kHz ultrasonic transducers (one each for transmitter and receiver).2 ULTRASONIC RANGE FINDER There are several ways to measure distance without contact. Using it. operational amplifier iM324I inverter Ca4M4VI four T-segment displays I five transistors and some discreet components. you excite the ultrasonic transmitter unit with a 40kHz pulse burst and expect an echo from the object whose distance you want to measure. The received signal. a 40kHz transducer is used for measurement in the air medium. Fig.5 ms. The ultrasonic transmitter. which is very weak is amplified several times in the receiver circuit and appears somewhat as shown in Fig. 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. fn this circuit. the required components are AT89C2051 microcontroller. For this particular application. current buffer ULN2003.R Mez. That is why we should have a level control.alone would give the correct distance. Using velocity of 333 m/s. Of course.5 and will need a higher pulse excitation voltage or a better transducer. It reads when the echo arrives. . 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). Here the microcontroller is used to generate 40 kHz sound pulses. it finds the time taken in microseconds for to-and-fro travel of sound waves. the signal gets weaker if the target is farther than 2. Under control of a host microcontroller (trigger pulse).1.3 BLOCK DIAGRAM OF ULTRASONIC RANGE FINDER Figure 1 : Block Diagram of Ultrasonic Range Finder 1. .4 THEORY OF OPERATION The Ping sensor detects objects by emitting a short ultrasonic burst and then "listening" for the echo. This burst travels through the air at about 1130 feet per second. Thus while passing through a particular medium these signals get attenuated. The PING sensor provides an output pulse to the host that will terminate when the echo is detected. hits an object and then bounces back to the sensor. Figure 2: Transmitting and Receiving Waves 1. 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. hence the width of this pulse corresponds to the distance to the target. Vibrations above this frequency are termed as ultrasonic. Time dependent control of sensitivity is used to compensate the distance dependency of the echo .the sensor emits a short 40 kHz (ultrasonic) burst. Ultrasonic signals are affected by the properties of the medium.5 ULTRASONIC WAVES Sound waves with frequency range from 20 Hz to 20 KHz are responsive to the human ear. They do so by evaluating the echo of a transmitted pulse with concern to its travel time. By considering whether the echo has been received within a time window. whether car parking places are occupied. These types of waves are referred as L –waves. Since these can travel in solid. A variety of ultrasonic presence sensors with different operation frequencies are designed for different distance range and different resolution.amplitude.e. Ultrasonic waves are generally used two types which are given as :1. interference can be suppressed and relevant objects are monitored more reliably. Ultrasonic distance meters are used for the measurement of the filling level in containers or the height of material on conveyor belts. which holds the average echo amplitude constant. Such sensors are employed in the automation of industrial processes as well as in traffic control systems. . for example to monitor. while different reflection properties are compensated by an automatic gain control. Echo amplitude therefore has very little influence on the accuracy of the distance measurement provided the signal to noise ratio is not very low. 1. a time interval.1 LONGITUDINAL WAVES Longitudinal waves exist when the motion of the particle and the medium is parallel to the direction of propagation of the waves. liquid and gases.5. These waves can be easily detected.5. which can be preset by the user. the distance range is given in which the sensor responds to the presence of an object. i.2 TRANSVERSE 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. Using this technique. The task for the ultrasonic sensors is not merely to detect ultrasound. This is done by ultrasonic transducers. which transform an electrical signal into an ultrasonic wave and vice versa. To achieve this performance.1994). Figure 3: Ultrasonic Transducer (Transmitter and Receiver) 2.6 ULTRASONIC DISTANCE SENSORS Ultrasonic sonar sensors actively transmit acoustic waves and receive them later. Furthermore. Algorithms based on models for the ultrasonic signal propagation and the interaction between the physical or chemical variables of interest are employed (munich. The ultrasound signal carries the information about the variables to be measured.1. . demodulated and evaluated by dedicated hardware. Ultrasonic sensors can be embedded into a control system that accesses additional sensors. as intelligent sensors they have to extract the information carried by the ultrasonic signals efficiently and with high accuracy. the signals are processed. combines information of the different sensors. techniques of a sensor specific signal evaluation are being applied. handles the bus protocols and initiates actions. The echo signal received by the receiver sensor after reflection is very weak. This inverted output is fed to another set of three inverters (N4. Pin 13 is the other pin of the . Inverting buffer CD4049 drives the ultrasonic sensor used as the transmitter. The third stage is a precision rectifier amplifier with a gain of 10.01μF capacitor for coupling. If you use the ubiquitous 0. The first stage (A1) is a buffer with unity gain. CIRCUIT DESCRIPTION Figure 4 shows the circuit of the microcontroller based distance meter. Thus the transmitter power is increased for increasing the range. there will be 2-mega-ohm resistor for feedback. The positive going pulse is applied to one of the terminals of the ultrasonic sensor and the same pulse after 180-degree phase shift is applied to another terminal.6V. Three inverters (N1. It is amplified by quad operational amplifier LM324. even for signal voltage of less than 0. which steps-up the transmitter output to 60V (peak-to.3nF (small-value) capacitor. unlike a simple diode. which is an analogue comparator.3. N2 and N3) are connected in parallel to increase the transmitted power. If you want to increase the range up to 5 meters. The rectifier functions. use a ferrite-core step-up pulse transformer. The received signal is directly fed to the non-inverting input (pin 3) of A1 and coupled to the second stage by a 3. Outputs of both sets of parallel inverters are applied as a push pull drive to the ultrasonic transmitter. N5 and N6).peak). The output is filtered to accept 40 kHz frequencies and fed to pin 12 of microcontroller AT89C2051. The 40kHz pulse bursts from the microcontroller are amplified by transistor T5. . Figure 4: Circuit Diagram of Ultrasonic Range Finder Comparator used for level adjustment using preset VR1.7 through P1. These pins are pulled up with a 10-kiloohm resistor network RNW1. They drive all the segments of the 7-segment display with the help of inverting buffer IC2.3 of the microcontroller are connected to the base of transistors T1 through T4 to provide the supply to displays DIS1 through DIS4.0 of . Port-1 pins P1.2. The two units are fixed by cello tape on to a cardboard. respectively. and port-3 pin P3. Pin P3. Port-3 pins P3. Microcontroller AT89C2051 is at the heart of the circuit. So you have to space the transmitter and receiver units about 5 cm apart. with the analogue circuit at one end.7 are connected to input pins through 1 to 7of IC2 (IC ULN2003). Even this low side-lobe signal is directly picked up by the receiver unit.0 through P3. 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. The ultrasonic transducer outputs a beam of sound waves. respectively. filtered by capacitors C8 and C9 and then regulated by ICs 7815 (IC5). respectively. A 12MHz crystal is used to generate the basic clock frequency for the microcontroller. 2. The 230V AC mains is stepped down by transformer X1 to deliver the secondary output of 15V-0-15V.6 low when it goes above the level of voltage set on pin 13. Capacitors C10 through C12 bypass the ripples present in the regulated power supply. Regulators 7815.1 POWER SUPPLY Figure shows the circuit of the power supply. transistors T2 through T4 provide anode currents to the other three 7segment displays. The echo signal will make port-3 pin 3. . 500 mA.microcontroller IC1 goes low to drive transistor T1 into saturation. 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. -15V and+5V regulated supply. Thus the display appears to be continuous. This status is sensed by the microcontroller as programmed. Segment data and displayenable pulse for the display are refreshed every 5 ms. 7915 and 7805 provide +15V. while the power on reset signal for the microcontroller is derived from the combination of capacitor C4 and resistor R8. The comparator is inbuilt in microcontroller AT89C2051. When port-3 pin P3. we know that the echo signal has arrived. Resistor R16 connected to pin 5 of DIS2 enables the decimal point. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D3 through D6. Using switch S1 you can manually reset the microcontroller. even though the individual LEDs used in it light up one by one. 7915 (IC6)and 7805 (IC7). which provides supply to the common. Similarly.anode pin (either pin 3 or 8) of display DIS1.6 goes high. Microcontroller IC1 provides the segment data and displayenable signal simultaneously in time-division multiplexed mode for displaying a particular number on the 7-segment display unit. ’ pin 8 will pulse at 40kHz bursts. place an A4-size plastic sheet in front of the ultrasonic transducers and observe the echo signal. Give this signal to channel 1 of the oscilloscope. 7. After switching on the power supply and microcontroller automatically getting reset upon power-’on. Adjust the time base to 2 ms per division and set it to trigger mode instead of normal mode. This can be seen using an oscilloscope. 6 and its component layout in Fig. single-side PCB for the microcontroller-based distance meter is shown in Fig. Give the received signal to channel 2 of the oscilloscope. Assemble the PCB and put the programmed microcontroller into the socket.2 CONSTRUCTION AND TESTING An actual-size. It will . Adjust the potentiometer on the oscilloscope labeled ‘level’ such that the trace starts with the burst and appears steady as shown.Figure 5: Power Supply Circuit Diagram 2. Connect the transmitter and receiver ultrasonic units either by a twisted pair of wire or by a shielded cable to the board. Then. 6 goes high. .appear as shown.2V at pin 13. When the echo signal goes above the level of reference voltage set on pin 13. port-3 pin P3. a waiting time is given to avoid direct echoes for about 20 μs. it will make P3. Then the signal is awaited.5 ms is started by making pin 8 high and low alternately for 12. The laser pointer is fixed such that it is axial to the transducers. Software The software is \ written in Assembly language and assembled using 8051 cross-assembler. it is displayed for half a second before proceeding to another measurement.6 (jump not bit) instruction.5 microseconds so that the pulse frequency is 40 kHz. Other uses Simply by changing this program. It is well commented and easy to understand. If the echo comes within this time. the display appears continuous and flicker-free. If the echo does not arrive even after 48 milliseconds. Channel 2 is connected to pin 12. Thus. This will enable detection of weak echoes also.6 low. while the timer runs counting time in microseconds. the arrival of echo is sensed by the program using jnb p3. the timer reads and the 16-bit number is divided by twice the velocity and converted into decimal format as a 4-digit number. The negative inverting terminal (pin 13) is connected to a preset reference. which is the positive non-inverting terminal of AT89C2051’s comparator. When the echo arrives.1V0. The pulse train for 0. After 25 such pulses have passed. It can also be used with suitable additional software as a burglar alarm unit for homes or offices. the same unit can be made to detect moving objects (such as cars racing on the street) and find their range and speed. The two transducers can be fixed to a thick cardboard with two wires leading to the circuit—two 40cm long shielded cables will do. Adjust the preset such that the voltage is 0. the waiting loop is broken and the pulse train sequence is started once again. port-3 pin P3. The pulse train for 0. the waiting loop is broken and the pulse train sequence is started once again. After 25 such pulses have passed.5 microseconds so that the pulse frequency is 40 kHz.Figure 6: Transmitted and Received Pulses 3. while the timer runs counting time in microseconds. When the echo arrives.5 ms is started by making pin 8 high and low alternately for 12. If the echo does not arrive even after 48 milliseconds.6 goes high. SOFTWARE The software is written in Assembly language and assembled using 8051 crossassembler. Then the signal is awaited. If the echo comes within this . It is well commented and easy to understand. the timer reads and the 16-bit number is divided by twice the velocity and converted into decimal format as a 4-digit number. a waiting time is given to avoid direct echoes for about 20 μs. //TIMER 0 INTERRUPT VECTOR. up and down .53 ms // (343m/s*.35/2 mm/us = 1/6 mm/us . //TIMR-0 TO MODE 1 //TIMER REG.time. ORG 30H MOV SP.6ms .. MOV P3. 3. Thus. it is displayed for half a second before proceeding to another measurement. /*timer low reg. MOV TL0.1 ASSEMBLY LANGUAGE PROGRAM PROGRAM LISTING: $mod51 ORG 0H AJMP 30H ORG 0BH . //Timer 0 Interrupt //service routine address //set stack pointer //set all port 3 bits high //to enables inputs also //set port 1 to all zeros //expect bits 0. is also so. MOV P1. pulse: setb p3. GIVES //64ms BEG: MOV TH0.1 //TIMER 1 .35mx65=22.#60H .5ms=17cm) //generates 40KHz . we have to stop transmitting for a time of about .$ clr p3.#25 .0 IS SET TO 0.5m b. so we stop for this amount of time and expect an echo. after 100 times. MOV TMOD. mov r1.1 s .350m/s gives 0.#0FFH . 1mm per 3 micros .#03 . #0 .35 mm/us. up and down 10 meters say! . total cycle time is 64.#01100001B .4 //25 pulses 26 us =. velocity of sound in air is 350 m/s .#0H .4 .*/ mov r2.35 m/ms. AJMP TIMER0ISR .#5 djnz r1.MODE 2COUNTER. the display appears continuous and flicker-free. #6 call UDIV16 . mov 40h.#0c0h.#10 djnz r2.r0 mov 41h.16 bit/16bit unsigned divide . MOV 41h. alters acc. /*check_echo:*/ jnb p3. pulse . mov r6.#0 .TH0 mov r0. mov r2.output r3.dptr*/ UDIV16: mov r7.r0 =dividend X .r0 .output r1. div_loop: clr C .#5 djnz r1. setb tr0 .th0 cjne a.check_echo . MOV 40h. mov B. mov a.#0 .r2 = remainder .input r1. rlc a mov r0.flags. djnz r2.TL0 .r4-47.#0 mov r2.40h mov r1.r0 =quotient q of x/y .a //clear partial remainder //set loop count //clear carry flag //shift the highest bit of dividend into .input r3.#25 disp: call disp1 .$ .#16 .r2 =divisor Y . //wait for 13 us //20pulses //start timer //wait 20 us //check timeout //read timer count //divide by 6 //show the value on LED //so many times for a visible time limit //upto 4 metres /*subroutine UDIV16 . djnz 50h.disp . jmp beg checktimeout: mov a.r1 mov 50h.$ .41h mov r3.mov r1. jmp beg.6. r6 mov r0.r7 most significant digit*R2 = LSByte*/ MOV R3.R6. This routine is for 16 bit Hex to BCD conversion.a ret //the lowest bit of partial remainder //get rem.R3 DIV AB MOV R4.#00D MOV R4.r1 rlc a mov r1.#00D MOV R5. .a . R7.mov a.#10 . mov r3.B MOV R5.a mov a. MOV B.r6 .A . saved before the //last subtraction.B .R5.a mov a. /*.r7 rlc a mov r7.R3(up to 64K ) Hex2BCD: . rlc a mov r6.r7 .R4.R6.R4.R2 DIV AB MOV R3.#10D MOV A.r6 mov r2. mov a.r1=high byte .a mov a.a mov a.R5. R7.Accepts a 16 bit binary number in R1.16 Bit Hex to BCD Conversion for 8051 Microcontroller .#00D MOV R6.#00D MOV B.#00D MOV R7.R2 and returns 5 digit BCD in . CHECK FOR HIGH /*content of 18 to 1B memory locations are output on LEDs.CJNE R1.#0H.#10 DIV AB MOV R5.#6 ADD A.#00D.R4 MOV B.HIGH_BYTE MOV B.R6 CONTINUE: MOV R6.R5 MOV B. //HIGH_BYTE .R3 MOV B.ADD_IT SJMP CONTINUE ADD_IT: ADD A.A ENDD: ret DISP1: REFRESH: .#5 ADD A.#10 DIV AB MOV R4.41h mov r2.R6 DIV AB MOV R6.A DJNZ R1.40h . only numbers 0 to 9 and A to F are valid data in these locations*/ mov r1.#2 ADD A.B ADD A.#10 DIV AB MOV R3.B ADD A. BYTE SJMP ENDD HIGH_BYTE: MOV A.B CJNE R6.B MOV R7. #10D MOV A. check_echo .output r1.flags.40h mov r1. mov r6.r3 .41h mov r3. mov 40h.#16 .a //clear partial remainder //set loop count //clear carry flag //shift the highest bit of dividend into . jmp beg . div_loop: clr C .r2 =divisor Y .r1 mov 50h.#10 djnz r2.CALL HEX2BCD MOV 18H.r0 .#0c0h.r4 . MOV 40h. jmp beg checktimeout: mov a.r0 =dividend X . mov a.TL0 .16 bit/16bit unsigned divide .output r3.r5 mov r2.input r3.subroutine UDIV16 // least significant digit //next significant digit //wait 20 us //check timeout //read timer count //divide by 6 // show the value on LED //so many times for a visible time limit //upto 4 metres /*.#25 disp: call disp1 .#0 .r0 mov 41h. alters acc.$ .r2 = remainder .input r1.disp . mov B.dptr*/ UDIV16: mov r7.TH0 mov r0.th0 cjne a.#6 call UDIV16 . check_echo: jnb p3.r0 =quotient q of x/y . MOV 1AH. MOV 19H.6.r4-47.#0 .#0 mov r2. MOV 41h. djnz 50h. rlc a mov r0. dph mov r6.r4 rlc a mov r4.r3 mov dph.a djnz B. PQ2: CALL SEGDISP //the lowest bit of partial remainder //update partial remainder if borrow //update parital reminder //put qt. mov r7. mov r7.r7 rlc a mov r7.#8 .r1 //most significant digit (max:9999) //1b. div_1: mov a.r1 rlc a mov r1.mov a.a mov a.3_ 0 made low one by one starts //with 18 //decimal pt.#1bh .on 3rd digit from left (2 nd //fromright) .r7 subb a.#2 .1a. rlc a mov r6.a .18.div_loop mov a.holds values for 4 digits // pin p3.a mov a.R6 .a mov a.r2 mov dpl. refresh1: MOV R0. in r0.a cpl C jnc div_1 .r6 .a mov a. mov a.r5 mov r1.19.r4 MOV 1BH.r5 rlc a mov r5. MOV R4.a mov a.dpl .r6 clr C subb a. a jnc pQ2 PV3: RET SEGDISP: mov dptr. S1: MOV A.c rrc a .R4 .#0FH MOVC A.deC R0 mov a. //SEGMENT_PORT MOV A.c .A . //11111110-1 mov p3. //output to drive transistors for digit lighting rrc a . mov p3. /*WE WANT TO USE PORT 1 BITS 0 AND 1 FOR INPUT ANLOG . //11111011-1 mov p3.R5 .2.@A+dptr segcode: MOV R5.#03H . //we use p3. //11110111 rrc a . //dec pt is D0 bit that is wired to p3.#ledcode MOV A. cpl c .1.7 for the segment ‘a’ of display RRC A .A ORL A.3. //1111111-0 yes low makes //leftmost //digit show ms digit mov p3.5 rrc a mov p3. so retain them high*/ S3: MOV P1.r4 rrc a mov r4.0. //get digit code from r4 00001000 cpl a .c rrc a . //11111101-1 mov p3. //so get that bit D0into carry .7.5.c S5: .c .@R0 ANL A.c . //segment ‘a. 0CH. 72H.#0ffH . 0BCH. . 0B6H. //extinguish the digit after that time MOV P3. 9EH. //let it burn for some time MOV A.S4: ACALL DELAY1 . 0FAH DB 0EH. #0ffH N: NOP DJNZ R1. the same unit can be made to detect moving objects (such as cars racing on the street) and find their range and speed. 0FEH. //to prevent shadow s6: RET ledcode: DB 7EH. 0F6H. 0CEH. 0CCH. It can also be used with suitable additional software as a burglar alarm unit for homes or offices. 0DAH.2 OTHER USES Simply by changing this program. N RET END 3. 0EEH.A . //these is code for //the numbers 0 to 9 and A to F DELAY1: MOV R1. 0F8H. 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. This offers a low cost and efficient solution for non contact type . This can also communicate with PC through its serial port.4. The system can calculate the distance of the obstruction with sufficient accuracy. This device has the capability to interact with other peripheral if used as a secondary device. • • • • • The system is able to detect objects within the sensing range.CONCLUSION The objective of this project is to design and implement an Ultrasonic Obstruction Detection and Distance Measurement device. the better the reflectance is. The device can serve as a motion detector in production lines. b) High power application where in the ultrasonics energy modifies the body of material to which it is applied. figure. It can be used for automatic guided vehicles. which can create poor resolution. The Range Finder has numerous applications. The ultrasonic distance measurement is an untouchable detection mode. temperature and colour etc. it does not get much influenced by ray. and the depth of snow banks. material and position of the object. and the stronger the reflection signal is. Compared with else detection modes. seem to be the Range Finder’s only limitations. Despite these drawbacks. Ultrasonics in medicine Both are big fields in themselves. 4. positioning of robots as well as measuring generic distances. Some of the important low power applications are :1) Flow detection.distance measurements. In industry ultrasonic is employed for :a) Low power applications where in the ultrasonic energy explores a body of material and is thereby modified. A restricted target angle (it requires a near perpendicular surface) and large beam. Also there is a blind area and distance limitation in ultrasonic distance measurement. liquid levels in tanks. The concentration would be more on the former one. . and it has the great capability to adapt to various circumstances and ambient conditions. 1. Ultrasonics in industry 2.1 APPLICATIONS Applications of ultrasonic can be divided into two categories. we find the device’s main features to be extremely useful. The ultrasonic detection range relates with size. The bigger the reflector is. 6) Measurement of pressure. concentration temperature. 3) Measurement of various physical properties of materials. viscosity and flow rates. 4) Extent of corrosion 5) Estimation of grain sizes in polycrystalline materials. 9) Liquid level control .2) Thickness gauging. 7) leak detection 8) Variable delay lines for computer applications and imaging. 3nF ceramic disk 0. 10. 1. 4. 7-segment display Table 1: Semiconductor Components RESISTORS (all ¼-watt. 6. NOTATTION IC1 IC2 IC3 IC4 IC5 IC6 IC7 T1. 5. 1. C2 C7. 11. 3. 2.No. ±5% carbon): S.1μF ceramic disk . 9. 6. 7. 9. 8. -15V regulator 7805.No. 7. 10. D2 D3-D6 DIS1-DIS4. 4. Notation R1. 5. C10-C12 Rating 3.No. R2 R3 R4. 15V regulator 7915.2-kilo-ohm 220-ohm 10-kilo-ohm resistor network 1-kilo-ohm preset Table 2: Resistors CAPACITORS S. R7-R10 R5 R6 R11 R12-R15 R16 RNW1 VR1 Rating 2-mega-ohm 82-kilo-ohm 10-kilo-ohm 33-kilo-ohm 100-kilo-ohm 1-kilo-ohm 1. 3. 5V regulator BC557 pnp transistor 2N2222 npn transistor 1N4148 switching diode 1N4007 rectifier diode common-anode. 2. 1. 12.LTS 542 COMPONENT AT89C2051 microcontroller ULN2003 current buffer CD4049 hex inverting buffer LM324 quad operational amplifier 7815.T4 T5 D1. 8.APPENDIX –A SEMICONDUCTORS: S. 2. Notation C1. 50V electrolytic Table 3: Capacitors MISCELLANEOUS S. 1. 6. Notation X1 Compnent 230V AC primary to 15V-0-15V.No. C6 C8. 5. 6. 500mA secondary 2. 3. 5. 16V electrolytic 22pF ceramic disk 1000μF. 4. XTAL S1 S2 TX1 RX1 transformer 12MHz crystal Push-to-on switch On/off switch 40kHz ultrasonic transmitter 40kHz ultrasonic receiver Table 4: Miscellaneous APPENDIX-B PCB LAYOUT DESIGN .2nF ceramic disk 10μF. 4.3. C3 C4 C5. C9 2. C RESISTANCE .Figure 7: PCB layout (Top) Figure 8: PCB layout (Bottom) APPENDIX. then Ohm's law. and the resistance of a wire can be expressed as . its resistance can be described in terms of its bulk resistivity. \ RESISTIVITY AND CONDUCTIVITY The electrical resistance of a wire would be expected to be greater for a longer wire.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: If the resistance is constant over a considerable range of voltage. the same definition holds for the AC application of resistors. less for a wire of larger cross sectional area. Whether or not a material obeys Ohm's law. Over sizable ranges of temperature. is temperature dependent. and thus the resistance. The resistivity. I = V/R. can be used to predict the behavior of the material. Experimentally. the dependence upon these properties is a straightforward one for a wide range of conditions. this temperature dependence can be predicted from a temperature coefficient of resistance. Although the definition above involves DC current and voltage. and would be expected to depend upon the material out of which the wire is made. RESISTIVITY CALCULATION The electrical resistance of a wire would be expected to be greater for a longer wire. and the resistance of a wire can be expressed as . The inverse of resistivity is called conductivity. and would be expected to depend upon the material out of which the wire is made (resistivity).The factor in the resistance which takes into account the nature of the material is the resistivity. Electrical conductivity = σ = 1/ρ RESISTOR COMBINATIONS The combination rules for any number of resistors in series or parallel can be derived with the use of Ohm's Law. the dependence upon these properties is a straightforward one for a wide range of conditions. the voltage law. less for a wire of larger cross sectional area. Experimentally. Although it is temperature dependent. There are contexts where the use of conductivity is more convenient. and the current law. it can be used at a given temperature to calculate the resistance of a wire of given geometry. Resistance = resistivity x length/area . Figure 9: Capacitor charge formation When electric charge accumulates on the plates. each of which stores an opposite charge. The charge is stored at the surface of the plates. Figure 10: Capacitor Charge formation 2 . the total charge in the capacitor is always zero. Because each plate stores an equal but opposite charge. at the boundary with the dielectric. This electric field creates a potential difference V = E·d between the plates of this simple parallel-plate capacitor. an electric field is created in the region between the plates that is proportional to the amount of accumulated charge. These two plates are conductive and are separated by an insulator or dielectric.APPENDIX-D CAPACITOR A capacitor consists of two electrodes or plates. This process creates an opposing electric field that partially annuls the field created by the plates. The energy (measured in joules. It is also proportional to the permittivity of the dielectric (that is. in a real capacitor. The energy stored is given by: .The electrons in the molecules move or rotate the molecule toward the positively charged left plate. in SI) stored in a capacitor is equal to the amount of work required to establish the voltage across the capacitor.) Capacitance The capacitor's capacitance (C) is a measure of the amount of charge (Q) stored on each plate for a given potential difference or voltage (V) which appears between the plates: In SI units. Since the farad is a very large unit. Ever increasing work must be done against this ever increasing electric field as more charge is separated. values of capacitors are usually expressed in microfarads (µF). (The air gap is shown for clarity. and therefore the electric field. a capacitor has a capacitance of one farad when one coulomb of charge causes a potential difference of one volt across the plates. nanofarads (nF) or picofarads (pF). Stored energy As opposite charges accumulate on the plates of a capacitor due to the separation of charge. non-conducting) substance that separates the plates. The capacitance is proportional to the surface area of the conducting plate and inversely proportional to the distance between the plates. a voltage develops across the capacitor owing to the electric field of these charges. the dielectric is in direct contact with the plates. an equilibrium is reached where the voltage across the capacitor is constant and the current . C is the capacitance in farads For circuits with a constant (DC) voltage source. This process is commonly called 'charging' the capacitor even though the capacitor is at all times electrically neutral.where V is the voltage across the capacitor. the current through the capacitor results in the separation rather than the accumulation of electric charge. But Q is just the time integral of the current I through the capacitor. measured in amperes dV/dt is the time derivative of voltage. This is expressed mathematically as: where I is the current flowing in the conventional direction. the voltage across the capacitor cannot exceed the voltage of the source. This voltage V is directly proportional to the amount of charge separated Q. In fact. 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. Thus. electrons accumulate on one plate and electrons are removed from the other plate. This separation of charge causes an electric field to develop between the plates of the capacitor giving rise to voltage across the plates. measured in volts / second. To find their total capacitance: One possible reason to connect capacitors in series is to increase the overall voltage rating. The mutual capacitance of two conductors is defined as the current . a very large resistor might be connected across each capacitor to divide the total voltage appropriately for the individual ratings. because the voltage-current equations of the two devices can be transformed into one another by exchanging the voltage and current terms. but the voltage across each capacitor can be different. Just as two or more inductors can be magnetically coupled to make a transformer. the ideal capacitor can be considered as an inverse of the ideal inductor. two or more charged conductors can be electrostatically coupled to make a capacitor. it is commonly said that capacitors block DC current. In practice. To find their total equivalent capacitance (Ceq): The current through capacitors in series stays the same. For this reason. Capacitor/inductor duality In mathematical terms. Series or parallel arrangements Capacitors in a parallel configuration each have the same potential difference (voltage). The sum of the potential differences (voltage) is equal to the total voltage.through the capacitor is zero. that flows in one when the voltage across the other changes by unit voltage in unit time. Capacitor symbols APPENDIX-E DATASHEET -IC 89C2051 . a five vector two-level interrupt architecture. 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. on-chip oscillator and clock circuitry. a full duplex serial port. two 16-bit timer/counters.FEATURES • Compatible with MCS-51 Products • 2 Kbytes of Reprogrammable Flash Memory Endurance: 1.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 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 . In addition. The device is manufactured using Atmel’s high density nonvolatile memory technology and is compatible with the industry standard MCS-51 instruction set and pinout.000 Write/Erase Cycles • 2. 15 I/O lines. 128 bytes of RAM. a precision analog comparator. By combining a versatile 8-bit CPU with Flash on a monolithic chip. PIN CONFIGURATION Figure 11: IC 89C2051 Pinout Diagram . serial port and interrupt system to continue functioning. The Idle Mode stops the CPU while allowing the RAM. The Power Down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset. timer/counters.AT89C2051 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Port 1 output buffers can sink 20 mA and can drive LED displays directly.2 to P1. When 1s are written to Port 1 pins.BLOCK DIAGRAM Figure 12: IC 89C2051 Block Diagram Pin Description VCC Supply voltage.0 and P1. GND Ground.2 to P1. When pins P1. P1. respectively.7 provide internal pullups. P1.1 require external pullups.0 and P1. of the onchip precision analog comparator. Port pins P1. they can be used as inputs.1 also serve as the positive input (AIN0) and the negative input (AIN1).7 are used as inputs and are externally . PORT 1 Port 1 is an 8-bit bidirectional I/O port. pulled low. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. All I/O pins are reset to 1s as soon as RST goes Hig h. PORT 3 Port 3 pins P3. 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. . RST Reset input. P3. they will source current (IIL) because of the internal pullups.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. P3. Port 1 also receives code data during Flash programming and program verification.7 are seven bidirectional I/O pins with internal pullups. Port 3 also serves the functions of various special features of the AT89C2051 as listed below: Table 5: Port 3 Functions Port 3 also receives some control signals for Flash programming and programming verification.0 to P3. As inputs. The Port 3 output buffers can sink 20 mA. Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.5. since the input to the internal clocking circuitry is through a divide by. of an inverting amplifier which can be configured for use as an on-chip oscillator. as shown in Figure 1. C2 = 30 pF. To drive the device from an external clock source. but minimum and maximum voltage high and low time specifications must be observed.OSCILLATOR CHARACTERISTICS XTAL1 and XTAL2 are the input and output.two flip-flops. XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2. Notes: C1. respectively. 10 pF for Ceramic Resonators (a) (b) Figure13: (a) Oscillator Connections. (b) External Clock Drive Configuration 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 . There are no requirements on the duty cycle of the external clock signal. 10 pF for Crystals= 40 pF. Either a quartz crystal or ceramic resonator may be used. the device normally resumes program execution. POWER DOWN MODE In the power down mode the oscillator is stopped. On-chip hardware inhibits access to internal RAM in this event. P1. up to two machine cycles before the internal reset algorithm takes control. . To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset. from where it left off.1 should be set to ’0’ if no external pull ups are used.IDLE MODE In idle mode. The only exit from power down is a hardware reset. the CPU puts itself to sleep while all the on-chip peripherals remain active. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. The mode is invoked by software.0 and P1. the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. It should be noted that when idle is terminated by a hardware reset. The idle mode can be terminated by any enabled interrupt or by a hardware reset. and the instruction that invokes power down is the last instruction executed. or set to ’1’ if external pullups are used. or set to ’1’ if external pullups are used. but access to the port pins is not inhibited.0 and P1. Reset redefines the SFRs but does not change the on-chip RAM.1 should be set to ’0’ if no external pullups are used. The 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. 5. 5. contents = FFH) and ready to be programmed. to re-program any non-blank byte. Power-up sequence: Apply power between VCC and GND pins Set RST and XTAL1 to GND With all other pins floating.2 to ’H’ 3. 1. wait for greater than 10 milliseconds 2. The code memory array is programmed one byte at a time. P3. P3. the following sequence is recommended. the entire memory array needs to be erased electrically.PROGRAMMING THE FLASH The AT89C2051 is shipped with the 2 Kbytes of on-chip PEROM code memory array in the erased state (i.4. To Program and Verify the Array: 4..7 to select one of the programming operations shown in the PEROM Programming Modes table.0 to P1. Raise RST to 12V to enable programming. Apply the appropriate combination of ’H’ or ’L’ logic levels to pins P3.e. P3.7. PROGRAMMING ALGORITHM: To program the AT89C2051. 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.3. Apply data for Code byte at location 000H to P1. Set pin RST to ’H’ Set pin P3. . Once the array isprogrammed. and the next cycle may begin. Apply new data to the port P1 pins. pulse XTAL1 pin once to advance the internal address counter. Power-off sequence: set XTAL1 to ’L’ set RST to ’L’ Float all other I/O pins Turn Vcc power off DATA POLLING: The AT89C2051 features Data Polling to indicate the end of a write cycle.2 once to program a byte in the PEROM array or the lock bits. an attempted read of the last byte written will result in the complement of the written data on P1. The byte-write cycle is self-timed and typically takes 1. true data is valid on all outputs. READY/BUSY: The Progress of byte programming can also be monitored by the RDY/BSY output signal.1 is pulled High again when programming is done to indicate READY. Pin P3. 8. Once the write cycle has been completed. P3. During a write cycle. changing data and advancing the address counter for the entire 2 Kbytes array or until the end of the object file is reached.7 to the appropriate levels. PROGRAM VERIFY: If lock bits LB1 and LB2 have not been programmed code data can be read back via the data lines for verification: . 7.6.2 goes High during programming to indicate BUSY. Repeat steps 5 through 8. 10. Output data can be read at the port P1 pins. lower RST from 12V to logic ’H’ level and set pins P3. To verify the programmed data.3 to P3. 9. To program a byte at the next address location.2 ms. Data Polling may begin any time after a write cycle has been initiated.1 is pulled low after P3. Pulse P3.7. Repeat steps 3 and 4 until the entire array is read. Reset the internal address counter to 000H by bringing RST from ’L’ to ’H’. except that P3. Read the next code data byte at the port P1 pins. The write operation cycle is self-timed and once initiated. The lock bits cannot be verified directly. will automatically time itself to completion. 3.5 and P3.1. . and 002H. 4. Apply the appropriate control signals for Read Code data and read the output data at the port P1 pins.All major programming vendors offer worldwide support for the Atmel microcontroller series. 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.7 must be pulled to a logic low. 5.(000H) = 1EH indicates manufactured by Atmel (001H) = 21H indicates 89C2051 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. READING THE SIGNATURE BYTES: The signature bytes are read by the same procedure as a normal verification of locations 000H. Pulse pin XTAL1 once to advance the internal address counter. 2. 001H.2 low for 10 ms. Verification of the lock bits is achieved by observing that their features are enabled. 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. The values returned are as follows. FLASH PROGRAMMING MODES Table 7: Flash Programming Modes (a) (b) Figure 14: (a) Programming the Flash Memory (b)Verifying the Flash Memory . Table 8:Flash Programing and Verification FLASH PROGRAMMING AND VERIFICATION WAVEFORMS Figure 15: Flash Programming and Verification Waveforms . ABSOLUTE MAXIMUM POWER RATING Table 8: Absolute Maximum Power Rating DC CHARACTERSTICS Table 9: DC Characterstics . EXTERNAL CLOCK DRIVE WAVEFORM Figure 16: External Clock Drive Waveform EXTERNAL CLOCK DRIVE Table 9: External Clock Drive . 95. College & School Division. The 8051 Microcontroller Architecture. Issue 8. Gadre. ABC’s of Ultrasonic. www. West Publishing Company. 2008. Bell. Programming and Customizing the AVR Controller. Janice Gillispie Mazidi. Electronic Devices and Circuits. 6) 7) 8) 9) 10) 11) Muhammad Ali Mazidi.September 1998. pp. Pearson Education.electronicsforu. Sensors & Transducers Journal. OE. Dhananjay V. 1961. Programming & Applications.pdf Kenneth J.com/doc/7370615/Ultrasonic-Distance-Meter www. Mattiat. Oxford University Press. Vol. . Arthur Barker Limited.scribd. David A. The 8051 Microcontroller & Embedded Systems. The Ultrasonic Transducers Materials. 1996.com www. 49-57 Alan Andrews. London.com/atmel/acrobat/doc0368.REFERENCES 1) 2) 3) 4) 5) Electronics for you . Ayala. August 2008.atmel.
Copyright © 2024 DOKUMEN.SITE Inc.