單片機-溫度控制系統(tǒng)-外文翻譯-外文文獻-英文文獻-中英翻譯_第1頁
單片機-溫度控制系統(tǒng)-外文翻譯-外文文獻-英文文獻-中英翻譯_第2頁
單片機-溫度控制系統(tǒng)-外文翻譯-外文文獻-英文文獻-中英翻譯_第3頁
單片機-溫度控制系統(tǒng)-外文翻譯-外文文獻-英文文獻-中英翻譯_第4頁
單片機-溫度控制系統(tǒng)-外文翻譯-外文文獻-英文文獻-中英翻譯_第5頁
已閱讀5頁,還剩27頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

DesignoftheTemperatureControlSystemBasedonAT89C51ABSTRACTTheprincipleandfunctionsofthetemperaturecontrolsystembasedonmicrocontrollerAT89C51arestudied,andthetemperaturemeasurementunitconsistsofthe1-WirebusdigitaltemperaturesensorDS18B20.Thesystemcanbeexpectedtodetectthepresettemperature,displaytimeandsavemonitoringdata.Analarmwillbegivenbysystemifthetemperatureexceedstheupperandlowerlimitvalueofthetemperaturewhichcanbesetdiscretionarilyandthenautomaticcontrolisachieved,thusthetemperatureisachievedmonitoringintelligentlywithinacertainrange.Basingonprincipleofthesystem,itiseasytomakeavarietyofothernon-linearcontrolsystemssolongasthesoftwaredesignisreasonablychanged.Thesystemhasbeenprovedtobeaccurate,reliableandsatisfiedthroughfieldpractice.KEYWORDS:AT89C51;microcontroller;DS18B20;temperature1INTRODUCTIONTemperatureisaveryimportantparameterinhumanlife.Inthemodernsociety,temperaturecontrol(TC)isnotonlyusedinindustrialproduction,butalsowidelyusedinotherfields.Withtheimprovementofthelifequality,wecanfindtheTCapplianceinhotels,factoriesandhomeaswell.AndthetrendthatTCwillbetterservethewholesociety,soitisofgreatsignificancetomeasureandcontrolthetemperature.BasedontheAT89C51andtemperaturesensorDS18B20,thissystemcontrolstheconditiontemperatureintelligently.Thetemperaturecanbesetdiscretionarilywithinacertainrange.ThesystemcanshowthetimeonLCD,andsavemonitoringdata;andautomaticallycontrolthetemperaturewhentheconditiontemperatureexceedstheupperandlowerlimitvalue.Bydoingsoitistokeepthetemperatureunchanged.Thesystemisofhighanti-jamming,highcontrolprecisionandflexibledesign;italsofitstheruggedenvironment.Itismainlyusedinpeople'slifetoimprovethequalityoftheworkandlife.Itisalsoversatile,sothatitcanbeconvenienttoextendtheuseofthesystem.Sothedesignisofprofoundimportance.Thegeneraldesign,hardwaredesignandsoftwaredesignofthesystemarecovered.1.1IntroductionThe8-bitAT89C51CHMOSmicrocontrollersaredesignedtohandlehigh-speedcalculationsandfastinput/outputoperations.MCS51microcontrollersaretypicallyusedforhigh-speedeventcontrolsystems.Commercialapplicationsincludemodems,motor-controlsystems,printers,photocopiers,airconditionercontrolsystems,diskdrives,andmedicalinstruments.TheautomotiveindustryuseMCS51microcontrollersinengine-controlsystems,airbags,suspensionsystems,andantilockbrakingsystems(ABS).TheAT89C51isespeciallywellsuitedtoapplicationsthatbenefitfromitsprocessingspeedandenhancedon-chipperipheralfunctionsset,suchasautomotivepower-traincontrol,vehicledynamicsuspension,antilockbraking,andstabilitycontrolapplications.Becauseofthesecriticalapplications,themarketrequiresareliablecost-effectivecontrollerwithalowinterruptlatencyresponse,abilitytoservicethehighnumberoftimeandeventdrivenintegratedperipheralsneededinrealtimeapplications,andaCPUwithaboveaverageprocessingpowerinasinglepackage.Thefinancialandlegalriskofhavingdevicesthatoperateunpredictablyisveryhigh.Onceinthemarket,particularlyinmissioncriticalapplicationssuchasanautopilotoranti-lockbrakingsystem,mistakesarefinanciallyprohibitive.Redesigncostscanrunashighasa$500K,muchmoreifthefixmeans2backannotatingitacrossaproductfamilythatsharethesamecoreand/orperipheraldesignflaw.Inaddition,fieldreplacementsofcomponentsisextremelyexpensive,asthedevicesaretypicallysealedinmoduleswithatotalvalueseveraltimesthatofthecomponent.Tomitigatetheseproblems,itisessentialthatcomprehensivetestingofthecontrollersbecarriedoutatboththecomponentlevelandsystemlevelunderworstcaseenvironmentalandvoltageconditions.Thiscompleteandthoroughvalidationnecessitatesnotonlyawell-definedprocessbutalsoaproperenvironmentandtoolstofacilitateandexecutethemissionsuccessfully.IntelChandlerPlatformEngineeringgroupprovidespostsiliconsystemvalidation(SV)ofvariousmicro-controllersandprocessors.Thesystemvalidationprocesscanbebrokenintothreemajorparts.Thetypeofthedeviceanditsapplicationrequirementsdeterminewhichtypesoftestingareperformedonthedevice.1.2TheAT89C51providesthefollowingstandardfeatures4KbytesofFlash,128bytesofRAM,32I/Olines,two16-bittimer/counters,afivevectortwo-levelinterruptarchitecture,afulldupleser-ialport,on-chiposcillatorandclockcircuitry.Inaddition,theAT89C51isdesignedwithstaticlogicforoperationdowntozerofrequencyandsupportstwosoftwareselectablepowersavingmodes.TheIdleModestopstheCPUwhileallowingtheRAM,timer/counters,serialportandinterruptsys-temtocontinuefunctioning.ThePower-downModesavestheRAMcontentsbutfreezestheoscil–latordisablingallotherchipfunctionsuntilthenexthardwarereset.1.3PinDescriptionVCCSupplyvoltage.GNDGround.Port0:Port0isan8-bitopen-drainbi-directionalI/Oport.Asanoutputport,eachpincansinkeightTTLinputs.When1sarewrittentoport0pins,thepinscanbeusedashighimpedanceinputs.Port0mayalsobeconfiguredtobethemultiplexedloworderaddress/databusduringaccessestoexternalprogramanddatamemory.InthismodeP0hasinternalpullups.Port0alsoreceivesthecodebytesduringFlashprogramming,andoutputsthecodebytesduringprogramverification.Externalpullupsarerequiredduringprogramverification.Port1:Port1isan8-bitbi-directionalI/Oportwithinternalpullups.ThePort1outputbufferscansink/so-urcefourTTLinputs.When1sarewrittentoPort1pinstheyarepulledhighbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port1pinsthatareexternallybeingpulledlowwillsourcecurrent(IIL)becauseoftheinternalpullups.Port1alsoreceivesthelow-orderaddressbytesduringFlashprogrammingandverification.Port2:Port2isan8-bitbi-directionalI/Oportwithinternalpullups.ThePort2outputbufferscansink/sourcefourTTLinputs.When1sarewrittentoPort2pinstheyarepulledhighbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port2pinsthatareexternallybeingpulledlowwillsourcecurrent(IIL)becauseoftheinternalpullups.Port2emitsthehigh-orderaddressbyteduringfetchesfromexternalprogrammemoryandduringaccessestoPort2pinsthatareexternallybeingpulledlowwillsourcecurrent(IIL)becauseoftheinternalpullups.Port2emitsthehigh-orderaddressbyteduringfetchesfromexternalprogrammemoryandduringaccessestoexternaldatamemorythatuse16-bitaddresses(MOVX@DPTR).Inthisapplication,itusesstronginternalpull-upswhenemitting1s.Duringaccessestoexternaldatamemorythatuse8-bitaddresses(MOVX@RI),Port2emitsthecontentsoftheP2SpecialFunctionRegister.Port2alsoreceivesthehigh-orderaddressbitsandsomecontrolsignalsdurinFlashprogrammingandverification.Port3:Port3isan8-bitbi-directionalI/Oportwithinternalpullups.ThePort3outputbufferscansink/sou-rcefourTTLinputs.When1sarewrittentoPort3pinstheyarepulledhighbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port3pinsthatareexternallybeingpulledlowwillsourcecurrent(IIL)becauseofthepullups.Port3alsoservesthefunctionsofvariousspecialfeaturesoftheAT89C51aslistedbelow:RST:Resetinput.Ahighonthispinfortwomachinecycleswhiletheoscillatorisrunningresetsthedevice.ALE/PROG:AddressLatchEnableoutputpulseforlatchingthelowbyteoftheaddressduringaccessestoexternalmemory.Thispinisalsotheprogrampulseinput(PROG)duringFlashprogramming.InnormaloperationALEisemittedataconstantrateof1/6theoscillatorfrequency,andmaybeusedforexternaltimingorclockingpurposes.Note,however,thatoneALEpulseisskippedduri-ngeachaccesstoexternalDataMemory.Ifdesired,ALEoperationcanbedisabledbysettingbit0ofSFRlocation8EH.Withthebitset,ALEisactiveonlyduringaMOVXorMOVCinstruction.Otherwise,thepinisweaklypulledhigh.SettingtheALE-disablebithasnoeffectifthemicrocontrollerisinexternalexecutionmode.PSEN:ProgramStoreEnableisthereadstrobetoexternalprogrammemory.WhentheAT89C51isexecutingcodefromexternalprogrammemory,PSENisactivatedtwiceeachmachinecycle,exceptthattwoPSENactivationsareskippedduringeachaccesstoexternaldatamemory.EA/VPP:ExternalAccessEnable.EAmustbestrappedtoGNDinordertoenablethedevicetofetchcodefromexternalprogrammemorylocationsstartingat0000HuptoFFFFH.Note,however,thatiflockbit1isprogrammed,EAwillbeinternallylatchedonreset.EAshouldbestrappedtoVCCforinternalprogramexecutions.Thispinalsreceivesthe12-voltprogrammingenablevoltage(VPP)duringFlashprogramming,forpartsthatrequire12-voltVPP.XTAL1:Inputtotheinvertingoscillatoramplifierandinputtotheinternalclockoperatingcircuit.XTAL2:Outputfromtheinvertingoscillatoramplifier.OscillatorCharacteristicsXTAL1andXTAL2aretheinputandoutput,respectively,ofaninvertingamplifierwhichcanbeconfiguredforuseasanon-chiposcillator,asshowninFigure1.Eitheraquartzcrystalorceramicresonatormaybeused.Todrivethedevicefromanexternalclocksource,XTAL2shouldbeleftunconnectedwhileXTAL1isdrivenasshowninFigure2.Therearenorequirementsonthedutycycleoftheexternalclocksignal,sincetheinputtotheinternalclockingcircuitryisthroughadivide-by-twoflip-flop,butminimumandmaximumvoltagehighandlowtimespecificationsmustbeobserved.IdleModeInidlemode,theCPUputsitselftosleepwhilealltheonchipperipheralsremainactive.Themodeisinvokedbysoftware.Thecontentoftheon-chipRAMandallthespecialfunctionsregistersremainunchangedduringthismode.Theidlemodecanbeterminatedbyanyenabledinterruptorbyahardwarereset.Itshouldbenotedthatwhenidleisterminatedbyahardwarereset,thedevicenormallyresumesprogramexecution,fromwhereitleftoff,uptotwomachinecyclesbeforetheinternalresetalgorithmtakescontrol.On-chiphardwareinhibitsaccesstointernalRAMinthisevent,butaccesstotheportpinsisnotinhibited.ToeliminatethepossibilityofanunexpectedwritetoaportpinwhenIdleisterminatedbyreset,theinstructionfollowingtheonethatinvokesIdleshouldnotbeonethatwritestoaportpinortoexternalmemory.Power-downModeInthepower-downmode,theoscillatorisstopped,andtheinstructionthatinvokespower-downisthelastinstructionexecuted.Theon-chipRAMandSpecialFunctionRegistersretaintheirvaluesuntilthepower-downmodeisterminated.Theonlyexitfrompower-downisahardwarereset.ResetredefinestheSFRSbutdoesnotchangetheon-chipRAM.TheresetshouldnotbeactivatedbeforeVCCisrestoredtoitsnormaloperatinglevelandmustbeheldactivelongenoughtoallowtheoscillatortorestartandstabilize.TheAT89C51codememoryarrayisprogrammedbyte-bybyteineitherprogrammingmode.Toprogramanynonblankbyteintheon-chipFlashMemory,theentirememorymustbeerasedusingtheChipEraseMode.2ProgrammingAlgorithmBeforeprogrammingtheAT89C51,theaddress,dataandcontrolsignalsshouldbesetupaccordingtotheFlashprogrammingmodetableandFigure3andFigure4.ToprogramtheAT89C51,takethefollowingsteps.1.Inputthedesiredmemorylocationontheaddresslines.2.Inputtheappropriatedatabyteonthedatalines.3.Activatethecorrectcombinationofcontrolsignals.4.RaiseEA/VPPto12Vforthehigh-voltageprogrammingmode.5.PulseALE/PROGoncetoprogramabyteintheFlasharrayorthelockbits.Thebyte-writecycleisself-timedandtypicallytakesnomorethan1.5ms.Repeatsteps1through5,changingtheaddressanddatafortheentirearrayoruntiltheendoftheobjectfileisreached.DataPolling:TheAT89C51featuresDataPollingtoindicatetheendofawritecycle.Duringawritecycle,anattemptedreadofthelastbytewrittenwillresultinthecomplementofthewrittendatumonPO.7.Oncethewritecyclehasbeencompleted,truedataarevalidonalloutputs,andthenextcyclemaybegin.DataPollingmaybeginanytimeafterawritecyclehasbeeninitiated.2.1Ready/Busy:TheprogressofbyteprogrammingcanalsobemonitoredbytheRDY/BSYoutputsignal.P3.4ispulledlowafterALEgoeshighduringprogrammingtoindicateBUSY.P3.4ispulledhighagainwhenprogrammingisdonetoindicateREADY.ProgramVerify:IflockbitsLB1andLB2havenotbeenprogrammed,theprogrammedcodedatacanbereadbackviatheaddressanddatalinesforverification.Thelockbitscannotbeverifieddirectly.Verificationofthelockbitsisachievedbyobservingthattheirfeaturesareenabled.2.2ChipErase:TheentireFlasharrayiserasedelectricallybyusingthepropercombinationofcontrolsignalsandbyholdingALE/PROGlowfor10ms.Thecodearrayiswrittenwithall“1”s.Thechiperaseoperationmustbeexecutedbeforethecodememorycanbere-programmed.2.3ReadingtheSignatureBytes:Thesignaturebytesarereadbythesameprocedureasanormalverificationoflocations030H,031H,and032H,exceptthatP3.6andP3.7mustbepulledtoalogiclow.Thevaluesreturnedareasfollows.(030H)=1EHindicatesmanufacturedbyAtmel(031H)=51Hindicates89C51(032H)=FFHindicates12Vprogramming(032H)=05Hindicates5Vprogramming2.4ProgrammingInterfaceEverycodebyteintheFlasharraycanbewrittenandtheentirearraycanbeerasedbyusingtheappropriatecombinationofcontrolsignals.Thewriteoperationcycleisselftimedandonceinitiated,willautomaticallytimeitselftocompletion.Amicrocomputerinterfaceconvertsinformationbetweentwoforms.Outsidethemicrocomputertheinformationhandledbyanelectronicsystemexistsasaphysicalsignal,butwithintheprogram,itisrepresentednumerically.Thefunctionofanyinterfacecanbebrokendownintoanumberofoperationswhichmodifythedatainsomeway,sothattheprocessofconversionbetweentheexternalandinternalformsiscarriedoutinanumberofsteps.Ananalog-to-digitalconverter(ADC)isusedtoconvertacontinuouslyvariablesignaltoacorrespondingdigitalformwhichcantakeanyoneofafixednumberofpossiblebinaryvalues.Iftheoutputofthetransducerdoesnotvarycontinuously,noADCisnecessary.Inthiscasethesignalconditioningsectionmustconverttheincomingsignaltoaformwhichcanbeconnecteddirectlytothenextpartoftheinterface,theinput/outputsectionofthemicrocomputeritself.Outputinterfacestakeasimilarform,theobviousdifferencebeingthatheretheflowofinformationisintheoppositedirection;itispassedfromtheprogramtotheoutsideworld.Inthiscasetheprogrammaycallanoutputsubroutinewhichsupervisestheoperationoftheinterfaceandperformsthescalingnumberswhichmaybeneededfordigital-to-analogconverter(DAC).Thissubroutinepassesinformationinturntoanoutputdevicewhichproducesacorrespondingelectricalsignal,whichcouldbeconvertedintoanalogformusingaDAC.Finallythesignalisconditioned(usuallyamplified)toaformsuitableforoperatinganactuator.Thesignalsusedwithinmicrocomputercircuitsarealmostalwaystoosmalltobeconnecteddirectlytotheoutsideworld”andsomekindofinterfacemustbeusedtotranslatethemtoamoreappropriateform.Thedesignofsectionofinterfacecircuitsisoneofthemostimportanttasksfacingtheengineerwishingtoapplymicrocomputers.Wehaveseenthatinmicrocomputersinformationisrepresentedasdiscretepatternsofbits;thisdigitalformismostusefulwhenthemicrocomputeristobeconnectedtoequipmentwhichcanonlybeswitchedonoroff,whereeachbitmightrepresentthestateofaswitchoractuator.Tosolvereal-worldproblems,amicrocontrollermusthavemorethanjustaCPU,aprogram,andadatamemory.Inaddition,itmustcontainhardwareallowingtheCPUtoaccessinformationfromtheoutsideworld.OncetheCPUgathersinformationandprocessesthedata,itmustalsobeabletoeffectchangeonsomeportionoftheoutsideworld.Thesehardwaredevices,calledperipherals,aretheCPU’swindowtotheoutside.ThemostbasicformofperipheralavailableonmicrocontrollersisthegeneralpurposeI70port.EachoftheI/Opinscanbeusedaseitheraninputoranoutput.Thefunctionofeachpinisdeterminedbysettingorclearingcorrespondingbitsinacorrespondingdatadirectionregisterduringtheinitializationstageofaprogram.EachoutputpinmaybedriventoeitheralogiconeoralogiczerobyusingCPUinstructionstopinmaybeviewed(orread.)bytheCPUusingprograminstructions.SometypeofserialunitisincludedonmicrocontrollerstoallowtheCPUtocommunicatebit-seriallywithexternaldevices.Usingabitserialformatinsteadofbit-parallelformatrequiresfewerI/Opinstoperformthecommunicationfunction,whichmakesitlessexpensive,butslower.Serialtransmissionsareperformedeithersynchronouslyorasynchronously.3SYSTEMGENERALDESIGNThehardwareblockdiagramoftheTCisshowninFig.1.Thesystemhardwareincludesthemicrocontroller,temperaturedetectioncircuit,keyboardcontrolcircuit,clockcircuit,Display,alarm,drivecircuitandexternalRAM.BasedontheAT89C51,theDS18B20willtransferthetemperaturesignaldetectedtodigitalsignal.Andthesignalissenttothemicrocontrollerforprocessing.AtlastthetemperaturevalueisshowedontheLCD12232F.Thesestepsareusedtoachievethetemperaturedetection.UsingthekeyboardinterfacechipHD7279tosetthetemperaturevalue,usingthemicrocontrollertokeepacertaintemperature,andusingtheLCDtoshowthepresetvalueforcontrollingthetemperature.Inaddition,theclockchipDS1302isusedtoshowtimeandtheexternalRAM6264isusedtosavethemonitoringdata.Analarmwillbegivenbybuzzerintimeifthetemperatureexceedstheupperandlowerlimitvalueofthetemperature.3.1HARDWAREDESIGNA.MicrocontrollerTheAT89C51isalow-power,high-performanceCMOS8-bitmicrocontrollerwith4Kbytesofin-systemprogrammableFlashmemory.ThedeviceismanufacturedusingAtmel’shigh-densitynonvolatilememorytechnologyandiscompatiblewiththeindustry-standard80C51instructionsetandpinout.Theon-chipFlashallowstheprogrammemorytobereprogrammedin-systemorbyaconventionalnonvolatilememoryprogrammer.Bycombiningaversatile8-bitCPUwithin-systemprogrammableFlashonamonolithicchip,theAtmelAT89C51isapowerfulmicrocontrollerwhichprovidesahighly-flexibleandcost-effectivesolutiontomanyembeddedcontrolapplications.MinimumsystemofthemicrocontrollerisshowninFig.2.Inordertosavemonitoringdata,the6264isusedasanexternalRAM.ItisastaticRAMchip,low-powerwith8Kbytesmemory.B.TemperatureDetectionCircuitThetemperaturesensoristhekeypartinthesystem.TheDallasDS18B20isused,whichsupportsthe1-Wirebusinterface,andtheON-BOARDPatentedisusedinternally.Allthesensorpartsandtheconvertingcircuitareintegratedinintegratedcircuitlikeatransistor[1].Itsmeasurerangeis-55℃~125℃,andtheprecisionbetween-10℃~85℃is±0.5℃[2,3].ThetemperaturecollectedbytheDS18B20istransmittedinthe1-Wirebusway,andthishighlyraisesthesystemanti-jammingandmakesitfitinsitutemperaturemeasurementoftheruggedenvironment[4].TherearetwopowersupplywaysfortheDS18B20.Thefirstisexternalpowersupply:thefirstpinoftheDS18B20isconnectedtotheground;thesecondpinservesassignalwireandthethirdisconnectedtothepower.Thesecondwayisparasitepowersupply[5].Astheparasitepowersupplywillleadtothecomplexityofthehardwarecircuit,thedifficultyofthesoftwarecontrolandtheperformancedegradationofthechip,etc.ButtheDS18B20(s)canbeconnectedtotheI/Oportofthemicrocontrollerintheexternalpowersupplywayanditismorepopular.ThereforetheexternalpowersupplyisusedandthesecondpinisconnectedtothepinP1.3oftheAT89S51.Actually,iftherearemultipointtobedetected,theDS18B20(s)canbeconnectedtothe1-Wirebus.Butwhenthenumberisover8,thereisaconcerntothedrivingandthemorecomplexsoftwaredesignaswellasthelengthofthe1-Wirebus.Normallyitisnomorethan50m.Toachievedistantcontrol,thesystemcanbedesignedintoawirelessonetobreakthelengthlimitofthe1-Wirebus[6].C.LCDCircuitTheLCD12232Fisused,whichcanbeusedtoshowcharacters,temperaturevalueandtime,andsupplyafriendlydisplayinterface.The12232FisaLCDwith8192128×32pixelsChinesecharacterdatabaseand12816×8pixelsASCIIcharactersetgraphics.Itmainlyconsistsofrowdrive/columndriveand128×32fulllatticeLCDwiththefunctionofdisplayinggraphicsaswellas7.5×2Chinesecharacters.ItisinaparallelorserialmodetoconnecttoexternalCPU[7].Inordertoeconomizethehardwareresource,the12232FshouldbeconnectedtotheAT89S51inserialmodewithonly4outputportsused.TheLCDgrayscalecanbechangedbyadjustingthevariableresistorconnectedthepinVlcdoftheLCD.CLKisusedtotransmitserialcommunicationclock.SIDisusedtotransmitserialdata.CSisusedtoenablecontroltheLCD.L+isusedtocontroltheLCDbacklightpower.D.ClockCircuitTheDallasDS18B20isused,whichisahighperformance,low-powerandreal-timeclockchipwithRAM.TheDS18B20servesinthesystemwithcalendarclockandisusedtomonitorthetime.ThetimedataisreadandprocessedbytheAT89C51andthendisplayedbytheLCD.Alsothetimecanbeadjustedbythekeyboard.TheDS18B20crystaloscillatorissetat32768Hz,andtherecommendedcompensationcapacitanceis6pF.Theoscillatorfrequencyislower,soitmightbepossiblenottoconnectthecapacitor,andthiswouldnotmakeabigdifferencetothetimeprecision.Thebackuppowersupplycanbeconnectedtoa3.6Vrechargeablebattery.E.KeyboardControlCircuitThekeyboardinterfaceinthesystemisdrivenbytheHD7279Awhichhasa+5Vsinglepowersupplyandwhichisconnectedtothekeyboardanddisplaywithoutusinganyactive-device.Accordingtothebasicrequirementsandfunctionsofthesystem,only6buttonsareneeded.Thesystem'sfunctionsaresetbytheAT89C51receivingtheentereddata.Inordertosavetheexternalresistor,the1×6keyboardisused,andthekeyboardcodesaredefinedas:07H,0FH,17H,1FH,27H,2FH.Theordercanbereadoutbyreadingthecodeinstruction.HD7279AisconnectedtotheAT89S51inserialmodeandonly4portsareneed.AsshowninFig.6,DIG0~DIG5andDParerespectivelythecolumnlinesandrowlineportsofthesixkeyswhichachievekeyboardmonitoring,decodingandkeycodesidentification.F.AlarmCircuitInordertosimplifythecircuitandconvenientdebugging,a5Vautomaticbuzzerisusedinthealarmcircuit[8].Andthismakethesoftwareprogrammingsimplified.AsshowninFig.7,itiscontrolledbythePNPtransistor9012whosebaseisconnectedtothepinP2.5oftheAT89C51.Whenthetemperatureexceedstheupperandlowerlimitvalue,theP2.5outputlowlevelwhichmakesthetransistorbeonandthenanalarmisgivenbythebuzzer.G.DriveCircuitAstepmotorisusedasthedrivedevicetocontrolthetemperature.Thefour-phaseandeight-beatpulsedistributionmodeisusedtodrivemotorandthesimpledelayprogramisusedtohandlethetimeintervalbetweenthepulsestoobtaindifferentrotationalspeed.Therearetwooutputstatesforthestepmotor.One:whenthetemperatureisovertheuppervalue,themotorrotatesreversely(tolowthetemperature),whilewhenlowerthanthelowerlimitvalue,themotorrotatesnormally(toraisethetemperature);besidesnotequalsthepresetvalue.Two:whenthetemperatureisatsomewherebetweenthetwoendsandequalsthepresetvalue,themotorstops.Thesestepsareusedtoachievethetemperaturecontrol.Inaddition,themotorspeedcanalsobeadjustedbyrelativebuttons.AsshowninFig.8,thecodedataisinputthroughportsA11~A8(beP2.3~P2.0)oftheAT89C51andinvertedoutputbytheinverter74LS04.Finallyitisamplifiedbythepoweramplifier2803Atopowerthemotor.3.2SOFTWAREDESIGNAccordingtothegeneraldesignrequirementandhardwarecircuitprincipleofthesystem,aswellastheimprovementoftheprogramreadability,transferabilityandtheconvenientdebugging,thesoftwaredesignismodularized.Thesystemflowmainlyincludesthefollowing8steps:POST(Power-onself-test),systeminitiation,temperaturedetection,alarmhandling,temperaturecontrol,clockchipDS18B20operation,LCDandkeyboardoperation.ThemainprogramflowisshowninFig.9.Givealittleanalysistotheabove8tasks,itiseasytofindoutthatthelastfivetasksrequiretherealtimeoperation.Buttothetemperaturedetectionitcanbeachievedwithtimer0timing1second,thatistosaytemperaturedetectionoccurspersecond.Thesysteminitiationincludesglobalvariabledefinition,RAMinitiation,specialfunctionregisterinitiationandperipheralequipmentinitiation.GlobalvariabledefinitionmainlyfinishestheinterfacedefinitionofexternalinterfacechipconnectedtotheAT89C51,andspecialdefinitionofsomememoryunits.RAMinitiationmainlyreferstoRAMprocessing.Forexamplewhenthesystemiselectrifiedthetimecodewillbestoredintheinternalunitaddressorthescintillationflagwillbecleared.Thespecialfunctionregisterinitiationincludesloadingtheinitialvalueoftimerandopeningtheinterrupt.Forexample,whenthesystemiselectrifiedthetimerisinitialized.Theperipheralequipmentinitiationreferstosettheinitialvalueofperipheralequipment.Forexample,whenthesystemiselectrified,theLCDshouldbeinitialized,thestart-updisplayshouldbecalled,thetemperatureconversioncommandshouldbeissuedfirstlyandtheclock

溫馨提示

  • 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)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論