Sie sind auf Seite 1von 22

EE401

PROJECT#2

ULTRASONICDISTANCEMETER
GROUP1B

PROJECTREPORT

MEMBERS

MetehanDilaver 2004502023 AdilPalabyk 2004502051 H.AnlAbay 2001502073


SPRING2009

CONTENTS
INTRODUCTION AIMOFPROJECT 3 4 4

8051MICROCONTROLLER PINCONNECTIONOF8051 UsageofEA

4 4 4 5

UsageofPSENandALE RAMROMConnection UsageofRESETPin OscillatorPin

6 6 6 7 11 12 13 13

ConstitutionofPort3

REALIZATIONOFTHEPROJECT SPECIFICATIONSOFSRF04 BEAMPATTERN TIMINGDIAGRAM

CALCULATINGTHEDISTANCE

WORKINGPRINCIPLESOFPROJECT TROUBLESHOOTING CONCLUSION REFERENCES


14 20 21 22

INTRODUCTION
Measuringthedistanceisaneedofhumanbeingalwaysbecauseofmanyreasons. Knowing distance of any object is so important in lots of categories. In nowadays world, cars,planes,robots,rocketsetc.areneedtomeasureorsensethedistanceoftheobjects thatareneartothem.Inadditionthat,inastronomy,army,securityworks,researchworks aswater,petrolormine;distancemeasuringisveryimportantsubjectforefficientworking, andsuccess. Distance measuring is done with many ways. For example with sound, light, laser, infrared,radionavigationetc.Innowadaysworld,withthehelpofdevelopingtechnology, measuringdistanceisgettingsoeasywiththesensors. Mostofthedistancemeasuringsystemshavebecomesocommonandsoeasytouse inthedailylifeofhumans.Forexample,toparkacar,tosearchanythingundertheland,to haveasafetravellingforairplanes,...etc.andlotsofusingareasaresocommon. In the project that is explained in this report is about measuring distance and its calledUltrasonicDistanceMeterbecauseofusingtheultrasonicsensorsinourprojectfor thispurpose. Ultrasonicprincipleisbasedonhighfrequencysoundwavesthathumanearcannot hear.Thereasonsofusingthishighfrequencywavesarecanbesaidasbelow: Thesewavesradiateextremelysmoothandlinear Energyofthesewavesareinhighlevel Thesewavescanbeeasilyreflectedfromhardplanes Themeasureofthedistanceisdonesimplylikethat:, Firstlyultrasonicwavesaresentandthenwaituntilreflectedsignalhascome.After that,thetimeiscalculatedbetweensentandreceivedsignal.Finally,timeandthevelocity ofthesoundmultipliedeachother,sothehalfoftheresultshowsthedistanceoftheobject.

AIMOFTHEPROJECT
Inthisproject,thesubjectthatwewanttorealizeistosetupanultrasonicdistance meter with using a AT89c52 type microcontroller. For this purpose, it is needed to have a maindesign,toconnectallelementsrightly,towritetheprogramcodesformicrocontroller, to simulate it in order to check whether it works rightly or not, to supply the necessary elementsforourrealdesign,andfinallytosetupwholeprojectandrunningit. Inadditionthat,intheprojectdesignitsplannedtoshowthemeasureresultonan LCDdisplayaftermeasuringthedistanceofobject. Simplytheaimoftheprojectisdesigningandrunninganultrasonicdistancemeter whichshowstheresultonLCDscreen.

8051MICROCONTROLLER
8051basedmicrocontrollerstypicallyincludeoneortwoUarts,twoorthreetimers,128or256bytes ofinternaldataRAM(16bytesofwhicharebitaddressable),upto128bytesofIO,512bytesto64 kBofinternalprogrammemory,andsometimesaquantityofextendeddataRAM(ERAM)locatedin theexternaldataspace.Theoriginal8051coreranat12clockcyclespermachinecycle,withmost instructionsexecutinginoneortwomachinecycles.Witha12MHzclockfrequency,the8051could thus execute 1 million onecycle instructions per second or 500,000 twocycle instructions per second.Enhanced8051coresarenowcommonlyusedwhichrunatsix,four,two,orevenoneclock permachine cycle,andhaveclock frequenciesofupto100MHz,and arethuscapableofaneven greaternumberofinstructionspersecond.

PINCONNECTIONOF8051
USAGEOFEA TheEAinputsignalonpin31isgenerallytiedhigh(+5V)orlow(ground).IfItshigh,the8051,8052 executesprogramsfrominternalROMwhenexecutinginthelower4K/8Kofmemory.IfItslow programsexecutefromexternalmemoryonly.(PSENpulseslowaccordingly).

USAGEOFPSENANDALE PSENisacontrolsignalthatenablesexternalprogram(code)memory.Itsusuallyconnectedtothe EPROMsoutputenable(OE)pintopermitreadingofprogrambytes. ThePSENsignalpulseslowduringthefetchstageofaninstruction.Thebinarycodesofaprogram (opcodes)arereadfromEPROM.Travelacrossthedatabusandarelatchedintothe8051s instructionregisterfordecoding.WhenexecutingaprogramfrominternalROM,PSENremainsinthe inactive(high)state. TheALEoutputsignalonpin30willbefamiliartoanyonewhohasworkedwithIntels80858088and 8086microprocessors.The8051similarlyusesALEfordemultiplexingtheaddressanddatabus. WhenPORT0isusedinitsalternatemodeasthedatabusandthelowbyteoftheaddressbusALE isthesignalthatlatchestheaddressintoanexternalregisterduringthefirsthalfofamemorycycle. Thisdone,ThePORT0linesarethenavailablefordatainputoroutputduringthesecondhalfofthe memorycycle,whenthedatatransfertakesplace. RAMROMCONNECTIONS

Inourprojectdesign,externalRAMandexternalROMareusedandtheirconnectionsare doneassimilarinthefigureabove.Here,theconnectionsoftheseelementswillbeexplained.Firstly weneedtouseaLATCHtostopcrossingtheaddressanddatainformationofP0.WhenALEisactive, theaddressinfoissenttotheaddresspinsofEPROM.AlsoP2pinsareusedfortheaddressinfoas welltotheaddresspinsofEPROM. WhileALEisinactive,thattimethedataisreadfromtheEPROM.Thisdatareadingisdone withthesignalofPSEN.WhiledataisreadingfromEPROM,PSENisactive.

USAGEOFRESETPIN TheRSTinputonpin9isthemasterresetforthe8051.Whenthissignalisbroughthigh,foratleast twomachinecyclesthe8051internalregistersareloadedwithappropriatevaluesforanorderly systemstartup.

OSCILLATORPINS 8051has2oscillatorpinscalledXTAL1andXTAL2.Aresonancecircuitisconnectedtothese2input pinstocreateasupplyfortheoscillatorsthatinsideoftheIC.Generallyacrystaland2capacitorsis enoughforthatcircuit.Aconnectedresonancecircuitthatisalsousedinourdesignisseeninthe figurebelow.Here,nomatterthevalueofthecapacitors.Theycanbechosenbetween2747pF.

CONSTITUTIONOFPORT3 ItsclearlyseentheexplanationofthePORT3pinsinthetablebelow.Here,intheusageof MAX232,theT1INpinisconnectedtothePORT3.0(serialportdata),theR1OUTpinofMAX232is connectedtothePORT3.1 6

REALIZATIONOFTHEPROJECT
Torealizetheproject,firstly,allthenecessaryresearchesaredoneandinformation aresuppliedthatarerelatedtodesign,programandelementsthatareused. Afterresearchstudiesamainboarddesignisrequired.ForthatpurposeaPCBdesign isdone.PCBisdesignedassuitableastouse8051microcontroller,PIO,externalRAMand ROM,ADC,latch,logicgatesetc.Todesigntheproject,ISISandARESprogramsareused. FirstlysimpledesignofmainboardisdrawnonISISprogramandafterthatitiscreatedon ARES program. In the figures below, its seen the design and PCB schematics in Proteus program.

Figure1a:DesignedschematicofPCBonProteusISIS
7

Figure1b:3DPCBschematicinARES Hereinthefigureabove,theARESmodificationofPCBisseeninthe3dimensions.In thisARESprogrambeforeprintingthePCBItspossibletoseehowwillthePCBbe,Itstop andsideviews,connections,andelements. InthenextpagefigurestherealizedPCBboardsareseen.

Figure2a:RealizedPCB

Figure2b:RealizedPCB
9

Inthefigureinthepreviouspage,itseasilyseentheworkingofthePCB.Whenwe look at the first picture of PCB, we see the led light. And in the second picture Its seen anotherledlight.BecausethatPCBisworkingfromexternalROMwiththehelpofEApinof microcontroller. In the ROM, the program is written to lighting the led one by one. That s whythedifferentledsareseenaslightninginthepictureabove. After finishing design procedure of PCB, Its started to work on the real project. Firstly,withthehelpofresearches,Itsdeterminedwhichelementsaresuitabletouse,as sensors, LCD, and other elements of circuit design. While choosing them, their working conditions,suitabilitywithotherpartsindesign,easytofind,andthecostofthemarecared. AsaresultofthemSRF04typeultrasonicsensors(transmitterandreceiver)aredetermined to use with 89C52 microcontroller. In this project choosing the sensor type was the most importantandnecessarysubject. SRF04 type ultrasonic sensor is has two parts as transmitter and receiver parts. Transmitterparttransmitsthehighfrequencysignaltomediumandreceiverpartgetsthe reflected signal from any object. These ultrasonic sensors work with high frequency that morethanahumanearcanhear. Inthenextpagetheconnectiondiagramandthecircuitofultrasonicsensorsisseen clearly.

Figure3a:Ultrasonicsensordesign

10

Ultrasonicsensorcouplesareconnectedthemselveswithrespecttothediagramof the above. The first sensor is transmitting sensor and it has an input pin to get the PWM. Thisinputisusedforgivinghighfrequencysignal.Thesecondoneisreceiversensorandit hasanoutputpinthatwouldbeconnectedto8051.Thatoutputfromreceiverisconnected tothemicrocontrollertomakeitworkwhenreceivedsignalistakenfromanyobject.

Figure3b:Ultrasonicsensordesign Togetmoreinformationaboutultrasonicsensorsthatisusedinthisproject,inthe tablebelowsomespecificationsforSRF04canbeseen. SPECIFICATION VOLTAGE5VOLTS CURRENT30mATyp.50mAMax FREQUENCY40kHz MAXRANGE3meters MINRANGE3centimeters ECHOPULSEPositiveTTLlevelsignal,proportionaltorange WEIGHT0.4oz SENSITIVITYDetecta3cmdiameterstickat>2m INPUTTRIGGERer10uSecminimum,TTLlevelpulse
11

BeamPattern:

TheSRF04Timingdiagramisshowninthenextpage.Weonlyneedtosupplyashort 10uSpulsetothetriggerinputtostarttheranging.TheSRF04willsendoutan8cycleburst ofultrasoundat40kHzandraiseitsecholinehigh.Itthenlistensforanecho,andassoonas itdetectsoneitlowerstheecholineagain.Theecholineisthereforeapulsewhosewidthis proportionaltothedistancetotheobject.Bytimingthepulseitispossibletocalculatethe rangeininches/centimetersoranythingelse.IfnothingisdetectedthentheSRF04willlower itsecholineanywayafterabout36mS.

12

CalculatingtheDistance
The SRF04 provides an echo pulse proportional to distance. If the width of the pulse is measuredinuS,thendividingby58willgiveyouthedistanceincm,ordividingby148willgivethe distanceininches.uS/58=cmoruS/148=inches.

While choosing the elements for project, the program is determined as well to be writteninCcodesinKeilu_versiontocreatehexfileformicrocontroller.Thewholeprogram isgivenattheendofthisreportclearly.


13

WORKINGPRINCIPLEOFPROJECT
Asasimpleworkingprincipleoftheproject,thediagramcanbedrawnasseeninthe figurebelow. Figure3:Simpleworkingdiagramofproject Intheproject,tomakeabletoworkitrightlyItsnecessarytogiveahighfrequency signaltoultrasonicsensors.Thesignalfrequencythatisusedinprojectisabout40KHz.For thatpurpose,Itsplannedtosetupacircuitthatgivesanoutasa40KHzsquarewavesignal. Thatsignalisgiventoinputofultrasonicsensors. TosetupasquarewaveoscillatorcircuitNE555ICisused.Tocreateasquarewave 555timerICsaresousefulandcommonintegratedcircuitsthatareused.Withthehelpof adjustingresistorsandcapacitorsItseasytohaveacircuitthatgivesoutput40KHzsquare wavesignal.Onthefigure4,ItsseentheoscillatorcircuitandalsoItsoutput,thatissetup withNE555IC.
14

Figure4:40KHzsquarewaveoscillatorcircuit.

Theoutputofthiscircuitisgiventosensorsinputsothatitcanmakeradiationto mediumthesesignals. Whenthishighfrequencysignalgiventoinputofsensors,thetransmittersensor startstoradiateitandifthesesignalsreflectedfromantobject,thereceiversensorgets reflectedsignalsanditgivesasinusoidaloutputvoltage.Withthehelpofthisoutputvoltage sensorscandetectifthereisanyobjectornotinfrontofthem. Whenthereceivergetsreflectedsignalfromanyobject,assaid,itgivesanoutput sinusoidalvoltage,buttheseoutputvoltageisinsolittlelevel.Itsabout0.10.3Volt. Becauseoflittleamount,theseoutputvoltageisnotsuitabletouseformicrocontroller.To makeabletousethissignalwithmicrocontroller,Itsnecessarytoamplifythislowvoltage outputsignalwiththehelpofanamplifiercircuit. TosetupanamplifiercircuitanopampICisusedfortheproject.Forthispurpose LM358opampICcanbeused.Inourproject,LM358typeopampICisusedforamplifier circuit.Inthenextpage,theopampamplifiercircuitcanbeseeninthefigure5clearly.

15

Asseeninthefigureabovetheopampamplifiercircuitissetupandaninput sinusoidalsignalisgiveninsolittleamountofvoltagesjustinmilivolts.Intheleft oscilloscopescreeninputsinusoidalandasresultofamplifier,theamplifiedsinusoidalis seen.Inputsinusoidalvoltageamountishere50milivolts,andamplifiedsignalisinamount ofabout8Volt.Thatmeansouramplifieramplifiesthesignalfor50times. Here,inthefigure,twoopampisused.Firstopampisusedtoamplifytheinput sinusoidalvoltage,andsecondoneisusedascomparator.Whenthatcomparatorgetsthe amplifiedsignal,itgivesanoutputas+5Volt(supplyvoltage)forpositivecycle,anditgives0 Voltfornegativecyclesoftheamplifiedsignal.Thecomparatoroutputisseeninthesecond oscilloscopescreenabove. Thereasonofusingcomparatorinthedesignis,toget+5Vand0Vexactly.Because thesevoltagelevelsaresuitabletousefor8051microcontroller.Whenthereceiversensor getsanyreflectedsignalfromanobject,itwillgiveanoutputinlittlevoltage,itsamplified andintheoutputofthecomparatorasquarewavewillbesuppliedtosayamessageto 8051asreflectedsignalreceived. Figure5:Opampamplifieranditsoutput

16

Thesimpledesignofourprojectconsistof8051microcontroller,Itssensorinput, anditsLCDoutputports.Asseeninthefiguresbelow,theconnectionofsensors,LCDand startbuttonaredone. Figure6a:Completeddesignofprojectinsimulationprogram

Figure6b:Completeddesignofprojectinsimulationprogram
17

Torunthesimulationofdesign,Itsnecessarytopressthestartbutton.Whenthat buttonispressed,NE555oscillatorcircuitstartstosend40KHzsquarewavetotheinputof transmittersensor.Thatsquarewaveistakenfrom3rdpinofNE555IC,sothispinis connectedtosensorinput.Also,atthesametimewhenthatbuttonpressed,amessage signalissentto8051microcontrollertosaysignaltransmissionstarted.So,whenthis messageissent,8051startstorunitstimeruntilreflectedsignalreachesreceiversensor.In additionthat,untilreflectedsignalreach,microcontrollershowsawritingonLCDdisplayas Noobjectfound.Becausethereisnoreflectedsignalreached. Insimulationprogram,thereisnosensorfigure,soItsplannedtomakethedesign behaveassensorworkingwiththehelpofsensorbutton.Whenthatbuttonispressed,a messagesignalissenttomicrocontrollertosayreflectedsignalreceived.When microcontrollergetsthismessage,itstopsthetimerrunning,calculatesthedistanceofthe objectwithrespecttothesavedtimeintimer,andshowstheresultontheLCDdisplay screenintermofcm. Inthenextpage,Itsclearlyseenthecompletedprojectdesignashardwareand softwareaswell.Whentherealdesignisrun,theresultcanbeseenontheLCDasseenin thefiguresbelowandinthenextpage. In the figure7, completed hardware design of project is seen. Ultrasonic transmitter and receiver sensors, the oscillator circuit that connected to sensors, 8051 microcontroller, LCD display and amplifiercircuitarecompletedandreadyto work. Figure7:Completedhardwaredesign

18

When the start button is pressed high frequency oscillator starts sending signal to sensors. And until received signal reachtoreceiversensor,ontheLCDdisplay a message is seen as Cisim Bulunamadi means no object found. Its seen clearly in theFigure8. Figure8:LCDdisplayafterstartbutton pressed When the received signal reach to the receiver sensor, that time 8051 microcontroller calculates the distance of theobjectandshowstheresultontheLCD displayintermsofcmvalueasseeninthe Figure9. Figure9:LCDdisplayafterreceivedsignalreached

19

TROUBLESHOOTING
While working on project, many difficulties and problems occurred. The most importantproblemwasdeterminingthesuitablesensortypewithourmicrocontroller.After long and deep researches, SR type ultrasonic transmitter and receiver couple sensors are chosensuitableelementforourproject.

Another problem occurred in the programming of the microcontroller. Because of wrong or missing headers or punctuation marks, program gives errors. To overcome this problemwehavegottheerrorlistandithelpedusfindtheerrorseasilyandfaster. Inadditionthatmostofdifficultiesareoccurredwhilewewereworkingonhardware. FirstlywhilesolderingthePCBelements,someshortcircuitoccurredandPCBisunableto work.Toovercomethisproblem,alltheelementscheckedonebyoneandtheirconnections arecheckedaswellifthereisanyshortcircuitoropencircuittoo.Becauseofcontrollingall thePCBdeeply,therewasabigtimelossandtiredfullstruggleforallofus.Becausewhile time passing and unless problem couldnt be solved that is a demoralizating and demotivating situation. But eventually, all the problem solved and PCB work without any problem. Beside them another big problem was lived while setting up amplifier circuit. In amplifiercircuit,opampICsareused.Butchoosingthemissoimportant.Becauseoperating frequency of opamp is important parameter to choose them. By ignoring that parameter mostofouramplifiercircuitsdidntworkproperly.Forthatproblem,bysearchingdifferent typeamplifiercircuitdesign,wefoundanamplifiercircuitthatissetupLM358opampand wedecidedtosetupsimilaramplifiercircuitaswell.

20

CONCLUSION
Ultrasonicdistancemeterprojectwasveryusefulapplicationforusbecauseofusing severalelements,hardwaredesign,connectingthem,andprogrammingmicrocontrolleras software.Thisprojecthastaughtushowarealprojectcanberealized,todevelopour programmingability,andhardwaredesign. Bythehelpofthisprojectwork,ourabilityofsettingupcircuit,connectingelements, soldering,andhandpracticearedevelopedandsothatwegotagoodtrustofourselvesto successsomethinginreal. Inadditiontothat,thisprojectworkisasastartofanexperimentforourjobthatwe willdoinfuture.Withthehelpofthat,welearnthowtoseethedifficultiesandproblems, howtoovercomeallofthemandsolveallproblemssothattoreachthesuccess. Besideallthem,wehavefoundthepossibilitytorealizearealthing.Itsnotasthe sametodoitbysimulationsonPC.Seeingarealthinganditsrunningmakeusfeelmore positively. Webelievethatwiththecontinuingofsimilarapplicationsproject,ourabilityinmost ofsubjectwillberaiseddaybyday.

21

REFERENCES
Websources
http://www.biltek.tubitak.gov.tr/gelisim/elektronik/dosyalar/diger/ultrasoni k.pdf http://www.8051turk.com/site/ http://hobby_elec.piclist.com/e_srm1_1.htm http://www.quasarelectronics.com/3123atmel89seriesprogrammer.htm http://www.airobotlab.ogu.edu.tr/research_files/kiris2004.pdf

ebooksources
Endstristandard8051AilesiMikrodenetleyiciler&AnalogDevices MicroConverters(ADuC8xx)SelimDilma ExploringCforMicrocontrollersAHandsonApproach(JivanS.Parab, VinodG.Shelake,RajanishK.Kamat,GourishM.Naik) 8051MicrocontrollerARCHITECTURE,PROGRAMMINGand APPLICATIONS(KennethJ.AyalaWesternCarolinaUniversity) PrenticeHallThe8051Microcontroller2ndEdition1995 8051MikrodenetleyiciUygulamalar(zcerit,akroluveBaylm)

22

Das könnte Ihnen auch gefallen