




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
中英文資料對照外文翻譯英文文獻(xiàn)UltrasonicrangingsystemdesignABSTRACT:Ultrasonicrangingtechnologyhaswideusingworthinmanyfields,suchastheindustriallocale,vehiclenavigationandsonarengineering.Nowithasbeenusedinlevelmeasurement,self-guidedautonomousvehicles,fieldworkrobotsautomotivenavigation,airandunderwatertargetdetection,identification,locationandsoon.Sothereisanimportantpracticingmeaningtolearntherangingtheoryandwaysdeeply.Toimprovetheprecisionoftheultrasonicrangingsysteminhand,satisfytherequestoftheengineeringpersonnelfortherangingprecision,theboundandtheusage,aportableultrasonicrangingsystembasedonthesinglechipprocessorwasdeveloped.Keywords:Ultrasoundr,RangingSystem,SingleChipProcessor1IntroductiveWiththedevelopmentofscienceandtechnology,theimprovementofpeople'sstandardofliving,speedingupthedevelopmentandconstructionofthecity.urbandrainagesystemhavegreatlydevelopedtheirsituationisconstantlyimproving.However,duetohistoricalreasonsmanyunpredictablefactorsinthesynthesisofhertime,thecitydrainagesystem.Inparticulardrainagesystemoftenlagsbehindurbanconstruction.Therefore,thereareoftengoodbuildingexcavationhasbeenbuildingfacilitiestoupgradethedrainagesystemphenomenon.Itbroughttothecitysewage,anditiscleartothecitysewageanddrainageculvertinthesewagetreatmentsystem.comfortisveryimportanttopeople'slives.MobilerobotsdesignedtoclearthedrainageculvertandtheautomaticcontrolsystemFreesewageculvertclearguaranteerobot,therobotisdesignedtocleartheculvertsewagetothecore.ControlSystemisthecorecomponentofthedevelopmentofultrasonicrangefinder.Therefore,itisveryimportanttodesignagoodultrasonicrangefinder.2Aprincipleofultrasonicdistancemeasurement2.1TheprincipleofpiezoelectricultrasonicgeneratorPiezoelectricultrasonicgeneratoristheuseofpiezoelectriccrystalresonatorstowork.Ultrasonicgenerator,theinternalstructureasshown,ithastwopiezoelectricchipandaresonanceplate.Whenit'stwopluspulsesignal,thefrequencyequaltotheintrinsicpiezoelectricoscillationfrequencychip,thechipwillhappenpiezoelectricresonance,andpromotethedevelopmentofplatevibrationresonance,ultrasoundisgenerated.Conversely,ifthetwoarenotinter-electrodevoltage,whentheboardreceivedultrasonicresonance,itwillbeforvibrationsuppressionofpiezoelectricchip,themechanicalenergyisconvertedtoelectricalsignals,thenitbecomestheultrasonicreceiver.Thetraditionalwaytodeterminethemomentoftheecho'sarrivalisbasedonthresholdingthereceivedsignalwithafixedreference.Thethresholdischosenwellabovethenoiselevel,whereasthemomentofarrivalofanechoisdefinedasthefirstmomenttheechosignalsurpassesthatthreshold.Theintensityofanechoreflectingfromanobjectstronglydependsontheobject'snature,sizeanddistancefromthesensor.Further,thetimeintervalfromtheecho'sstartingpointtothemomentwhenitsurpassesthethresholdchangeswiththeintensityoftheecho.Asaconsequence,aconsiderableerrormayoccurEventwoechoeswithdifferentintensitiesarrivingexactlyatthesametimewillsurpassthethresholdatdifferentmoments.Thestrongeronewillsurpassthethresholdearlierthantheweaker,soitwillbeconsideredasbelongingtoanearerobject.2.2TheprincipleofultrasonicdistancemeasurementUltrasonictransmitterinadirectiontolaunchultrasound,inthemomenttolaunchthebeginningoftimeatthesametime,thespreadofultrasoundintheair,obstaclesonhiswaytoreturnimmediately,theultrasonicreflectedwavereceivedbythereceiverimmediatelystoptheclock.Ultrasoundintheairasthepropagationvelocityof340m/s,accordingtothetimerrecordsthetimet,wecancalculatethedistancebetweenthelaunchdistancebarrier(s),thatis:s=340t/23UltrasonicRangingSystemfortheSecondCircuitDesignSystemischaracterizedbysingle-chipmicrocomputertocontroltheuseofultrasonictransmitterandultrasonicreceiversincethelaunchfromtimetotime,single-chipselectionof8751,economic-to-use,andthechiphas4KofROM,tofacilitateprogramming.CircuitschematicdiagramshowninFigure2.Figure1circuitprinciplediagram3.140kHzultrasonicpulsegeneratedwiththelaunchRangingsystemusingtheultrasonicsensorofpiezoelectricceramicsensorsUCM40,itsoperatingvoltageofthepulsesignalis40kHz,whichbythesingle-chipimplementationofthefollowingprocedurestogenerate.puzel:mov14h,#12h;ultrasonicfiringcontinued200mshere:cplp1.0;output40kHzsquarewavenop;nop;nop;djnz14h,here;retRanginginfrontofsingle-chipterminationcircuitP1.0inputport,singlechipimplementationoftheaboveprocedure,theP1.0portina40kHzpulseoutputsignal,afteramplificationtransistorT,thedrivetolaunchthefirstultrasonicUCM40T,issued40kHzultrasonicpulse,andthecontinuedlaunchof200ms.Rangingtherightandtheleftsideofthecircuit,respectively,theninputportP1.1andP1.2,theworkingprincipleandcircuitinfrontofthesamelocation.3.2ReceptionandprocessingofultrasonicUsedtoreceivethefirstlaunchofthefirstpairUCM40R,theultrasonicpulsemodulationsignalintoanalternatingvoltage,theop-ampamplificationIC1AandafterpolarizationIC1BtoIC2.IC2islockedloopwithaudiodecoderchipLM567,internalvoltage-controlledoscillatorcenterfrequencyoff0=1/1.1R8C3,capacitorC4determinetheirtargetbandwidth.R8-conditioninginthelaunchofthecarrierfrequencyontheLM567inputsignalisgreaterthan25mV,theoutputfromthehighjump8feetintoalow-level,asinterruptrequestsignalstothesingle-chipprocessing.Ranginginfrontofsingle-chipterminationcircuitoutputportINT0interruptthehighestpriority,rightorleftlocationoftheoutputcircuitwithoutputgateIC3AaccessINT1portsingle-chip,whilesingle-chipP1.3andP1.4receivedinputIC3A,interruptedbytheprocesstoidentifythesourceofinquirytodealwith,interruptprioritylevelforthefirstleftrightafter.Partofthesourcecodeisasfollows:receive1:pushpswpushaccclrex1;relatedexternalinterrupt1jnbp1.1,right;P1.1pinto0,rangingfromrighttointerruptserviceroutinecircuitjnbp1.2,left;P1.2pinto0,totheleftrangingcircuitinterruptserviceroutinereturn:SETBEX1;openexternalinterrupt1popaccpoppswretiright:...;rightlocationentrancecircuitinterruptserviceroutineAjmpReturnleft:...;leftRangingentrancecircuitinterruptserviceroutineAjmpReturn3.3ThecalculationofultrasonicpropagationtimeWhenyoustartfiringatthesametimestartthesingle-chipcircuitrywithinthetimerT0,theuseoftimercountingfunctionrecordsthetimeandthelaunchofultrasonicreflectedwavereceivedtime.Whenyoureceivetheultrasonicreflectedwave,thereceivercircuitoutputsanegativejumpintheendofINT0orINT1interruptrequestgeneratesasignal,single-chipmicrocomputerinresponsetoexternalinterruptrequest,theimplementationoftheexternalinterruptservicesubroutine,readthetimedifference,calculatingthedistance.Someofitssourcecodeisasfollows:RECEIVE0:PUSHPSWPUSHACCCLREX0;relatedexternalinterrupt0MOVR7,TH0;readthetimevalueMOVR6,TL0CLRCMOVA,R6SUBBA,#0BBH;calculatethetimedifferenceMOV31H,A;storageresultsMOVA,R7SUBBA,#3CHMOV30H,ASETBEX0;openexternalinterrupt0POPACCPOPPSWRETIForaflattarget,adistancemeasurementconsistsoftwophases:acoarsemeasurementand.afinemeasurement:Step1:Transmissionofonepulsetraintoproduceasimpleultrasonicwave.Step2:Changingthegainofbothechoamplifiersaccordingtoequation,untiltheechoisdetected.Step3:Detectionoftheamplitudesandzero-crossingtimesofbothechoes.Step4:Settingthegainsofbothechoamplifierstonormalizetheoutputat,say3volts.Settingtheperiodofthenextpulsesaccordingtothe:periodofechoes.Settingthetimewindowaccordingtothedataofstep2.Step5:Sendingtwopulsetrainstoproduceaninterferedwave.Testingthezero-crossingtimesandamplitudesoftheechoes.Ifphaseinversionoccursintheecho,determinetootherwisecalculatetobyinterpolationusingtheamplitudesnearthetrough.Derivetsubm1andtsubm2.Step6:Calculationofthedistanceyusingequation.4.TheultrasonicrangingsystemsoftwaredesignSoftwareisdividedintotwoparts,themainprogramandinterruptserviceroutine.Completionoftheworkofthemainprogramisinitialized,eachsequenceofultrasonictransmittingandreceivingcontrol.Interruptserviceroutinesfromtimetotimetocompletethreeoftherotationdirectionofultrasoniclaunch,themainexternalinterruptservicesubroutinetoreadthevalueofcompletiontime,distancecalculation,theresultsoftheoutputandsoon.5.ConclusionsRequiredmeasuringrangeof30cm~200cmobjectsinsidetheplanetodoanumberofmeasurementsfoundthatthemaximumerroris0.5cm,andgoodreproducibility.Single-chipdesigncanbeseenontheultrasonicrangingsystemhasahardwarestructureissimple,reliable,smallfeaturessuchasmeasurementerror.Therefore,itcanbeusednotonlyformobilerobotcanbeusedinotherdetectionsystems.Thoughts:Asforwhythereceiverdonothavethetransistoramplifiercircuit,becausethemagnificationwell,integratedamplifier,butalsowithautomaticgaincontrollevel,magnificationto76dB,thecenterfrequencyis38kto40k,isexactlyresonantultrasonicsensorsfrequency中文文獻(xiàn)超聲測距系統(tǒng)設(shè)計摘要:超聲測距技術(shù)在工業(yè)現(xiàn)場、車輛導(dǎo)航、水聲工程等領(lǐng)域都具有廣泛的應(yīng)用價值,目前已應(yīng)用于物位測量、機器人自動導(dǎo)航以及空氣中與水下的目標(biāo)探測、識別、定位等場合。因此,深入研究超聲的測距理論和方法具有重要的實踐意義。為了進(jìn)一步提高測距的精確度,滿足工程人員對測量精度、測距量程和測距儀使用的要求,本文研制了一套基于單片機的便攜式超聲測距系統(tǒng)。關(guān)鍵詞:超聲波,測距儀,單片機前言隨著科技的發(fā)展,人們生活水平的提高,城市發(fā)展建設(shè)加快,城市給排水系統(tǒng)也有較大發(fā)展,其狀況不斷改善。但是,由于歷史原因合成時間住的許多不可預(yù)見因素,城市給排水系統(tǒng),特別是排水系統(tǒng)往往落后于城市建設(shè)。因此,經(jīng)常出現(xiàn)開挖已經(jīng)建設(shè)好的建筑設(shè)施來改造排水系統(tǒng)的現(xiàn)象。城市污水給人們帶來了困擾,因此箱涵的排污疏通對大城市給排水系統(tǒng)污水處理,人們生活舒適顯得非常重要。而設(shè)計研制箱涵排水疏通移動機器人的自動控制系統(tǒng),保證機器人在箱涵中自由排污疏通,是箱涵排污疏通機器人的設(shè)計研制的核心部分。控制系統(tǒng)核心部分就是超聲波測距儀的研制。因此,設(shè)計好的超聲波測距儀就顯得非常重要了。2超聲波測距原理2.1壓電式超聲波發(fā)生器原理壓電式超聲波發(fā)生器實際上是利用壓電晶體的諧振來工作的。超聲波發(fā)生器內(nèi)部結(jié)構(gòu),它有兩個壓電晶片和一個共振板。當(dāng)它的兩極外加脈沖信號,其頻率等于壓電晶片的固有振蕩頻率時,壓電晶片將會發(fā)生共振,并帶動共振板振動,便產(chǎn)生超聲波。反之,如果兩電極間未外加電壓,當(dāng)共振板接收到超聲波時,將壓迫壓電晶片作振動,將機械能轉(zhuǎn)換為電信號,這時它就成為超聲波接收器了。測量脈沖到達(dá)時間的傳統(tǒng)方法是以擁有固定參數(shù)的接收信號開端為基礎(chǔ)的。這個界限恰恰選于噪音水平之上,然而脈沖到達(dá)時間被定義為脈沖信號剛好超過界限的第一時刻。一個物體的脈沖強度很大程度上取決于這個物體的自然屬性尺寸還有它與傳感器的距離。進(jìn)一步說,從脈沖起始點到剛好超過界限之間的時間段隨著脈沖的強度而改變。結(jié)果,一種錯誤便出現(xiàn)了——兩個擁有不同強度的脈沖在不同時間超過界限卻在同一時間到達(dá)。強度較強的脈沖會比強度較弱的脈沖超過界限的時間早點,因此我們會認(rèn)為強度較強的脈沖屬于較近的物體。2.2超聲波測距原理超聲波發(fā)射器向某一方向發(fā)射超聲波,在發(fā)射時刻的同時開始計時,超聲波在空氣中傳播,途中碰到障礙物就立即返回來,超聲波接收器收到反射波就立即停止計時。超聲波在空氣中的傳播速度為340m/s,根據(jù)計時器記錄的時間t,就可以計算出發(fā)射點距障礙物的距離(s),即:s=340t/23超聲波測距系統(tǒng)的電路設(shè)計系統(tǒng)的特點是利用單片機控制超聲波的發(fā)射和對超聲波自發(fā)射至接收往返時間的計時,單片機選用C51,經(jīng)濟易用,且片內(nèi)有4K的ROM,便于編程。電路原理圖如圖1所示。圖1電路原理圖3.140kHz脈沖的產(chǎn)生與超聲波發(fā)射測距系統(tǒng)中的超聲波傳感器采用UCM40的壓電陶瓷傳感器,它的工作電壓是40kHz的脈沖信號,這由單片機執(zhí)行下面程序來產(chǎn)生。puzel:mov14h,#12h;超聲波發(fā)射持續(xù)200mshere:cplp1.0;輸出40kHz方波nop;nop;nop;djnz14h,here;ret前方測距電路的輸入端接單片機P1.0端口,單片機執(zhí)行上面的程序后,在P1.0端口輸出一個40kHz的脈沖信號,經(jīng)過三極管T放大,驅(qū)動超聲波發(fā)射頭UCM40T,發(fā)出40kHz的脈沖超聲波,且持續(xù)發(fā)射200ms。右側(cè)和左側(cè)測距電路的輸入端分別接P1.1和P1.2端口,工作原理與前方測距電路相同。3.2超聲波的接收與處理接收頭采用與發(fā)射頭配對的UCM40R,將超聲波調(diào)制脈沖變?yōu)榻蛔冸妷盒盘枺?jīng)運算放大器IC1A和IC1B兩極放大后加至IC2。IC2是帶有鎖定環(huán)的音頻譯碼集成塊LM567,內(nèi)部的壓控振蕩器的中心頻率f0=1/1.1R8C3,電容C4決定其鎖定帶寬。調(diào)節(jié)R8在發(fā)射的載頻上,則LM567輸入信號大于25mV,輸出端8腳由高電平躍變?yōu)榈碗娖?,作為中斷請求信號,送至單片機處理.前方測距電路的輸出端接單片機INT0端口,中斷優(yōu)先級最高,左、右測距電路的輸出通過與門IC3A的輸出接單片機INT1端口,同時單片機P1.3和P1.4接到IC3A的輸入端,中斷源的識別由程序查詢來處理,中斷優(yōu)先級為先右后左。部分源程序如下:receive1:pushpswpushaccclrex1;關(guān)外部中斷1jnbp1.1,right;P1.1引腳為0,轉(zhuǎn)至右測距電路中斷服務(wù)程序jnbp1.2,left;P1.2引腳為0,轉(zhuǎn)至左測距電路中斷服務(wù)程序return:SETBEX1;開外部中斷1popaccpoppswretiright:...;右測距電路中斷服務(wù)程序入口ajmpreturnleft:...;左測距電路中斷服務(wù)程序入口ajmpreturn3.3計算超聲波傳播時間在啟動發(fā)射電路的同時啟動單片機內(nèi)部的定時器T0,利用定時器的計數(shù)功能記錄超聲波發(fā)射的時間和收到反射波的時間。當(dāng)收到超聲波反射波時,接收電路輸出端產(chǎn)生一個負(fù)跳變,在INT0或INT1端產(chǎn)生一個中斷請求信號,單片機響應(yīng)外部中斷請求,執(zhí)行外部中斷服務(wù)子程序,讀取時間差,計算距離。其部分源程序如下:RECEIVE0:PUSHPSWPUSHACCCLREX0;關(guān)外部中斷0MOVR7,TH0;讀取時間值MOVR6,TL0CLRCMOVA,R6SUBBA,#0BBH;計算時間差MOV31H,A;存儲結(jié)果MOVA,R7SUBBA,#3CHMOV30H,ASETBEX0;開外部中斷0POPACCPOPPSWRETI對于一個平坦的目標(biāo),距離測量包括兩個階段:粗糙的測量和精細(xì)測量。第一步:脈沖的傳送產(chǎn)生一種簡單的超聲波。第二步:根據(jù)公式改變回波放大器的獲得量直到回?fù)鼙粰z測到。第三步:檢測兩種回波的振幅與過零時間。第四步:設(shè)置回波放大器的所得來規(guī)格輸出,假定是3伏。通過脈沖的周期設(shè)置下一個脈沖。根據(jù)第二部的數(shù)據(jù)設(shè)定時間窗。第五步:發(fā)射兩串脈沖產(chǎn)生干擾波。測量過零時間與回波的振幅。如果逆向發(fā)生在回波中,決定要不通過在低氣壓插入振幅。第六步:通過公式計算距離y。4超聲波測距系統(tǒng)的軟件設(shè)計軟件分為兩部分,主程序和中斷服務(wù)程序。主程序完成初始化工作、各路超聲波發(fā)射和接收順序的控制。定時中斷服務(wù)子程序完成三方向超聲波的輪流發(fā)射,外部中斷服務(wù)子程序主要完成時間值的讀取、距離計算、結(jié)果的輸出等工作。5結(jié)論對所要求測量范圍30cm~200cm內(nèi)的平面物體做了多次測量發(fā)現(xiàn),其最大誤差為0.5cm,且重復(fù)性好??梢娀趩纹瑱C設(shè)計的超聲波測距系統(tǒng)具有硬件結(jié)構(gòu)簡單、工作可靠、測量誤差小等特點。因此,它不僅可用于移動機器人,還可用在其它檢測系統(tǒng)中。思考:至于為什么接收不用晶體管做放大電路呢,因為放大倍數(shù)搞不好,集成放大電路,還帶自動電平增益控制,放大倍數(shù)為76dB,中心頻率是38k到40k,剛好是超聲波傳感器的諧振頻率。附錄C系統(tǒng)硬件電路原理圖附錄D超聲波測距雷達(dá)設(shè)計PCB圖附錄E程序源代碼1.主程序以及顯示子程序#include<AT89x51.H> //器件配置文件#include<intrins.h>#defineRXP3_6#defineTXP3_7#defineLCM_RWP2_6//定義LCD引腳#defineLCM_RSP2_5#defineLCM_EP2_7#defineLCM_DataP1#defineKey_DataP3_3//定義Keyboard引腳#defineKey_CLKP3_2#defineBusy0x80//用于檢測LCM狀態(tài)字中的Busy標(biāo)識sbitbeep=P3^4;//sbitbeep=P2^3;//sbitplay=P1^3;voidInit_DS18B20(void);unsignedintReadTemperature(void);voidInit_DS18B201(void);unsignedintReadTemperature1(void);voidLCMInit(void);voidDisplayOneChar(unsignedcharX,unsignedcharY,unsignedcharDData);voidDisplayListChar(unsignedcharX,unsignedcharY,unsignedcharcode*DData);voidDelay5Ms(void);voidDelay400Ms(void);voidDecode(unsignedcharScanCode);voidWriteDataLCM(unsignedcharWDLCM);voidWriteCommandLCM(unsignedcharWCLCM,BuysC);unsignedcharReadDataLCM(void);unsignedcharReadStatusLCM(void);unsignedcharcodemcustudio[]={"==RangeFinder=="};unsignedcharcodeemail[]={"heyaodz@163.com"};unsignedcharcodeCls[]={""};unsignedcharcodeASCII[15]={'0','1','2','3','4','5','6','7','8','9','.','-','M'};staticunsignedcharDisNum=0;//顯示用指針 unsignedinttime=0; unsignedlongS=0; bitflag=0; unsignedchardisbuff[4] ={0,0,0,0,};/********************************************************/voiddelayms(unsignedintms){ unsignedchari=100,j; for(;ms;ms--) { while(--i) { j=10; while(--j); } }}//寫數(shù)據(jù)voidWriteDataLCM(unsignedcharWDLCM){ ReadStatusLCM();//檢測忙 LCM_Data=WDLCM; LCM_RS=1; LCM_RW=0; LCM_E=0;//若晶振速度太高可以在這后加小的延時 LCM_E=0;//延時 LCM_E=1;}//寫指令voidWriteCommandLCM(unsignedcharWCLCM,BuysC)//BuysC為0時忽略忙檢測{ if(BuysC)ReadStatusLCM();//根據(jù)需要檢測忙 LCM_Data=WCLCM; LCM_RS=0; LCM_RW=0; LCM_E=0; LCM_E=0; LCM_E=1; }//讀數(shù)據(jù)unsignedcharReadDataLCM(void){ LCM_RS=1; LCM_RW=1; LCM_E=0; LCM_E=0; LCM_E=1; return(LCM_Data);}//讀狀態(tài)unsignedcharReadStatusLCM(void){ LCM_Data=0xFF; LCM_RS=0; LCM_RW=1; LCM_E=0; LCM_E=0; LCM_E=1; while(LCM_Data&Busy);//檢測忙信號 return(LCM_Data);}voidLCMInit(void)//LCM初始化{ LCM_Data=0; WriteCommandLCM(0x38,0);//三次顯示模式設(shè)置,不檢測忙信號 Delay5Ms(); WriteCommandLCM(0x38,0); Delay5Ms(); WriteCommandLCM(0x38,0); Delay5Ms(); WriteCommandLCM(0x38,1);//顯示模式設(shè)置,開始要求每次檢測忙信號 WriteCommandLCM(0x08,1);//關(guān)閉顯示 WriteCommandLCM(0x01,1);//顯示清屏 WriteCommandLCM(0x06,1);//顯示光標(biāo)移動設(shè)置 WriteCommandLCM(0x0F,1);//顯示開及光標(biāo)設(shè)置}//按指定位置顯示一個字符voidDisplayOneChar(unsignedcharX,unsignedcharY,unsignedcharDData){ Y&=0x1; X&=0xF;//限制X不能大于15,Y不能大于1 if(Y)X|=0x40;//當(dāng)要顯示第二行時地址碼+0x40; X|=0x80;//算出指令碼 WriteCommandLCM(X,1);//發(fā)命令字 WriteDataLCM(DData);//發(fā)數(shù)據(jù)}//按指定位置顯示一串字符voidDisplayListChar(unsignedcharX,unsignedcharY,unsignedcharcode*DData){ unsignedcharListLength;ListLength=0; Y&=0x1; X&=0xF;//限制X不能大于15,Y不能大于1 while(DData[ListLength]>0x19)//若到達(dá)字串尾則退出 { if(X<=0xF)//X坐標(biāo)應(yīng)小于0xF { DisplayOneChar(X,Y,DData[ListLength]);//顯示單個字符 ListLength++; X++; } }}//5ms延時voidDelay5Ms(void){ unsignedintTempCyc=5552; while(TempCyc--);}//400ms延時voidDelay400Ms(void){ unsignedcharTempCycA=5; unsignedintTempCycB; while(TempCycA--) { TempCycB=7269; while(TempCycB--); };}/********************************************************/voidConut(void) { time=TH0*256+TL0; TH0=0; TL0=0; S=(time*1.8)/10;//算出來是MM if(S<500) { beep=0; delayms(10); beep=1; delayms(10); //beep=0; //delayms(10); //beep=1; //delayms(1); } else { beep=1; } if((S>=7000)||flag==1)//超出測量范圍顯示“-” { flag=0; DisplayOneChar(0,1,ASCII[11]); DisplayOneChar(1,1,ASCII[10]); //顯示點 DisplayOneChar(2,1,ASCII[11]); DisplayOneChar(3,1,ASCII[11]); DisplayOneChar(4,1,ASCII[11]); DisplayOneChar(5,1,ASCII[12]); //顯示M } else { disbuff[0]=S/1000; disbuff[1]=S/100%10; disbuff[2]=S/10%10; disbuff[3]=S%10; DisplayOneChar(0,1,ASCII[disbuff[0]]); DisplayOneChar(1,1,ASCII[10]); //顯示點 DisplayOneChar(2,1,ASCII[disbuff[1]]); DisplayOneChar(3,1,ASCII[disbuff[2]]); DisplayOneChar(4,1,ASCII[disbuff[3]]); DisplayOneChar(5,1,ASCII[12]); //顯示M } }/********************************************************/voidzd0()interrupt1 //T0中斷用來計數(shù)器溢出,超過測距范圍{flag=1; //中斷溢出標(biāo)志 RX=0;}/********************************************************/voidStartModule() //啟動模塊{ TX=1; //啟動一次模塊 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); TX=0;}voidTimer_Count(void){ TR0=1; //開啟計數(shù) while(RX); //當(dāng)RX為1計數(shù)并等待 TR0=0; //關(guān)閉計數(shù)Conut(); //計算}/*********************************************************/voidmain(void){unsignedintvalA,tempe=0,tempe1=0; unsignedcharTempCyc; //play=0; Delay400Ms();//啟動等待,等LCM講入工作狀態(tài) LCMInit();//LCM初始化// Delay5Ms();//延時片刻(可不要)// DisplayListChar(0,0,mcustudio);// DisplayListChar(0,1,email);// ReadDataLCM();//測試用句無意義 for(TempCyc=0;TempCyc<10;TempCyc++) Delay400Ms();//延時 //DisplayListChar(0,1,Cls); TMOD=0x01; //設(shè)T0為方式1,GATE=1; TH0=0; TL0=0; ET0=1;//允許T0中斷 EA=1; //開啟總中斷 Init_DS18B20(); while(1) { // tempe=ReadTemperature(); //讀溫度 tempe=ReadTemperature(); //讀溫度 WriteCommandLCM(0x80,1); WriteDataLCM('T'); WriteCommandLCM(0x81,1); WriteDataLCM('='); WriteCommandLCM(0x82,1); WriteDataLCM(tempe/100+0x30); WriteCommandLCM(0x83,1); WriteDataLCM(tempe/10-tempe/100*10+0x30); WriteCommandLCM(0x84,1); WriteDataLCM('.'); WriteCommandLCM(0x85,1); WriteDataLCM(tempe-(tempe/100)*100-(tempe/10-tempe/100*10)*10+0x30); WriteCommandLCM(0x86,1); WriteDataLCM('C'); //////////////// tempe1=ReadTemperature1(); //讀溫度 WriteCommandLCM(0x88,1); WriteDataLCM('T'); WriteCommandLCM(0x89,1); WriteDataLCM('='); WriteCommandLCM(0x8a,1); WriteDataLCM(tempe1/100+0x30); WriteCommandLCM(0x8b,1); WriteDataLCM(tempe1/10-tempe1/100*10+0x30); WriteCommandLCM(0x8c,1); WriteDataLCM('.'); WriteCommandLCM(0x8d,1); WriteDataLCM(tempe1-(tempe1/100)*100-(tempe1/10-tempe1/100*10)*10+0x30); WriteCommandLCM(0x8e,1); WriteDataLCM('C'); //delayms(60); delayms(6); RX=1; StartModule();
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 科研課題申報 評審書
- 課題申報書優(yōu)美用語
- 綜合能源服務(wù)課題申報書
- 課題申報書基于兒童立場
- 中學(xué)課題立項申報書
- 輔導(dǎo)員方面課題申報書
- 員工解除勞務(wù)合同范例
- 京東服裝租賃合同范本
- 合作協(xié)議合同范本格式
- 員工曠工辭退合同范本
- 看圖寫話我是乖孩子
- 印萌打印平臺合作協(xié)議VIP
- 作物栽培學(xué)復(fù)習(xí)資料完整版要點
- 油管、套管等規(guī)格對照表
- IEST-RP-CC0053
- 模糊邏輯與模糊推理
- 玉米收割機的設(shè)計(機械CAD圖紙)
- 金屬補償器計算大全
- 國際部SOP手冊2014修改版(2.0版)
- 凈菜配送標(biāo)準(zhǔn)
- 水工環(huán)地質(zhì)調(diào)查技術(shù)標(biāo)準(zhǔn)手冊
評論
0/150
提交評論