Tkool Electronics

IDescriptionThisblogintroducesatemperatureacquisitionandalarmsystembasedonAT89S52microcontrollerandDS18B20temperaturesensor.Here,wehavedescribedthefollowingindetail:schemedesign,componentselection,hardwarestructureandsoftwaredesign,etc.CatalogIDescriptionIIIntroduction2.1Introductiontotemperaturemeasurementsystem2.2IntroductiontoDS18B202.3DS18B20TemperaturemeasurementsystemIIISystemschemestructuredesignIVSelectionofmaincomponents4.1Processor4.2DigitaltemperaturesensorDS18B20VSystemhardwaredesign5.1Powermodule5.2Temperatureacquisitionmodule5.3Displaymodule5.4Alarmmodule5.5ButtonmoduleVISystemsoftwaredesign6.1Instructions6.2Initializationsequence6.3Buswritetiming6.4Busreadtiming6.5TemperatureacquisitionprogramVIIExperimentaltestVIIIConclusionFAQOrdering&QuantityIIIntroduction2.1IntroductiontotemperaturemeasurementsystemTemperaturemeasurementsystemsarewidelyusedinthefollowingfields:grainstorage;medicalcare;transportation;smarthomesandgreenhouses;powertelecommunicationsystems;Moreover,thesystemwithanalarmfunctioncanalsoreducetheriskoftemperatureaccidents.Atpresent,thetemperaturevaluescollectedbythetemperaturemeasuringdevicearestillmainlyanalogsignals.However,themicroprocessorcanonlyprocessdigitalsignals,andA/Dconversionisrequiredfirst.Thismakesthedevicestructurecomplexandlowprecision.However,theemergenceofdigitaltemperaturesensorscansolvethisproblem.2.2IntroductiontoDS18B20ThenewdigitaltemperaturesensorrepresentedbyDS18B20integratestemperatureacquisitionandA/Dconversiondirectlyoutputsdigitalsignalsandhasasimpleinterfacecircuitwiththesingle-chipmicrocomputer.DS18B20hasthefeaturesofasinglebus,smallsize,highresolution,stronganti-interference,etc.Ithasapplicationsinthemeasurementofhighwaysubgradetemperaturefieldandbearingtemperaturedetectioninfrozensoilareas.Moreover,thesensorhasaunique64-bitserialnumber,andmultipledevicescanbeconnectedtoasinglesignallinetoachievelong-distance,multi-pointdistributedtemperaturemeasurement.2.3DS18B20TemperaturemeasurementsystemThisbloguses51single-chipmicrocomputersastheprocessingcore,usesDS18B20toformatemperaturemeasurementmodule,plusabuttonmodule,adisplaymodule,andanalarmmodule,etc.,todesignadigitaltemperaturecollectionalarmsystemsuitableformultipleoccasions.Itisdesignedtorealizemultiplefunctionsofsynchronouscollection,display,alarm,andcontrolofspecifiedtemperature.ThetemperaturemeasurementalarmsystemhaspassedthesimulationtestofthePROTUSsimulationplatformandsuccessfullyverifieditsfunctionwiththecircuitboard.Thedevicerunsstably,withagoodtemperaturemeasurementeffectandsmallerror.IIISystemschemestructuredesignThesystemincludesthefollowingparts:ThecoreAT89S52microcontrolleranditsperipheralcircuits;Temperaturemeasurementmodule(DS18B20digitaltemperaturesensor);Powermodule;Displaymodule(drivecircuit,multi-digitLEDdigitaltube);Buttonmodule;Alarmmodule(buzzer;LEDlight-emittingdiode).WecantakealookatdetailsshowninFigure1.Figure1.BlockDiagramoftemperaturemeasurementsystemWhenweusetheDS18B20intelligenttemperaturesensor,itoutputsdigitalsignalswithoutprocessingandconversion.AslongasthereadandwriteasequenceofDS18B20isstrictlyfollowed,thereal-timetemperaturecanbeaccuratelyread.Eventhoughthesystemhashighprecisionandrelativelycomplicatedprocedures,thecircuitissimpleandsmall,whichisconducivetotheintelligentizationandlightweightofthesystem.WithmultipleDS18B20sconnectedtoasinglebus,themicrocomputercancommunicatewithmultipleDS18B20swithonlyonedataline.Inthisway,itcanalsomeettherequirementsofmulti-pointtemperaturemeasurement.IVSelectionofmaincomponents4.1ProcessorThesystemprocessorusesanAT89S52single-chipmicrocomputer.AT89S52isahigh-performance,low-power8-bitCMOSmicroprocessorfromAt-mel.Its8KsystemprogrammableFLASHmemorymakesitsdownloadcircuitsimpleandcanrealizeonlineprogramminginserialandparallelmode.Thereare316-bittimer/countersinsidetheAT89S52chip,1full-duplexserialport,4I/Oports,and256bytesRAM,whichisconvenientforprogramdebugging.4.2DigitaltemperaturesensorDS18B20TheDS18B20temperaturesensorisaone-linesmartdigitaltemperaturesensorproducedbyDALLASSemiconductor.Inaddition,DS18B20isalsotheworldsfirsttemperaturesensorsupportingasingle-wirebusinterface.Ithasthecharacteristicsoflongtransmissiondistance,smallsize,andsimpleinterface.TheDS18B20ismainlycomposedofthefollowingcomponents:Temperaturesensor,configurationregister;64-bitROM;HighandlowalarmtriggersTHandTL.Amongthem,lithographyROMisthekeytorealizingmulti-pointtemperaturemeasurement.Afterthetemperaturemeasurementisconverted,itisoutputintheformof16-bitsign-extendedtwoscomplementandstoredintheDS18B2028-bitRAMs.VSystemhardwaredesignThehardwarecircuitofthesystemismainlycomposedofthefollowing5modules:Temperaturemeasurementmodule,powersupplymodule,displaymodule,alarmmoduleandbuttonmodule.TheoverallcircuitschematicdiagramisshownasinFig.2.AT89S52single-chipmicrocomputerisconnectedtoa11.0592MHzcrystaloscillatorcircuittoprovideanexternalclock,andtheresetterminalRESETisconnectedtothewatchdogcircuittoformaminimalsingle-chipsystem.Thesystemcanachievethefollowingfunctions:DS18B20collectstemperature,andthemicrocontrollerisresponsibleforthecommunicationandcontrolofthesensor;Thedisplaymoduledisplaystheprocessedtemperaturevalueinrealtime;Thealarmmodulemonitorsthetemperaturerange.Whenthetemperatureexceedstheupperandlowerlimits,LEDdiodesandbuzzersareusedtogeneratealarmsignalstoreminduserstotakemeasures;Thebuttonmodulesetsthealarmvalueasrequiredtoimprovethepracticality.5.1PowermoduleThecircuituses+5Vworkingvoltagetosupplypowerforthesingle-chip,acquisition,andalarmcircuits.Inaddition,anindependentpowermoduleneedstobeaddedduringhardwareproduction.5.2TemperatureacquisitionmoduleDS18B20utilizesthecharacteristicofasinglebusline,connectsthetemperatureoutputendDQandP0.3mouththrougha4.7kpull-upresistor.Thesingle-chipmicrocomputerinitializesthesensorandcompletesthetemperaturecollectionthroughthewire.TheGNDofthesensorisgrounded,andVDDcanbepoweredbyadatalineoranexternalpowersupply.Inordertoimprovetheanti-interferenceability,thisdesignusesanexternalpowersupplymode.Figure2.Hardwarecircuitstructure5.3DisplaymoduleInordertosavethehardwareinterface,adynamicscanningdisplayschemeisadopted.Dynamicscanningisacyclicshiftmethodthatusesthepersistenceofthehumaneyetoachievetheeffectofcontinuousdisplay.Thisdesignusesa6-digit8-segmentcommoncathodedigitaltubewithadecimalpointtodisplaythetemperaturevalue.Amongthem,thefirstdigitisthepositiveandnegativesigndigit,thesecond,third,fourth,andfifthdigitsrespectivelydisplaythehundreds,tens,onesanddecimalplacesofthetemperature,andthelastdigitdisplaysthetemperatureunit℃.TheP2portofthesingle-chipmicrocomputer(P2.0~P2.7total8bitscorrespondingto8fields)isconnectedwiththesegmentselectioncommonsignallineofthenixietubethroughthedriverchip74LS245.P3.0~P3.5ofP3portareconnectedwiththebitselectionsignallineofthedigitaltubetorealizebitselectioncontrol.5.4AlarmmoduleInordertoincreasethesafetyfactor,thealarmcircuitadoptsanalarmmethodwithsoundandlightdoubleguarantee.Thisincludesabuzzerand2LEDsofdifferentcolors.Thecollectedtemperatureisconstantlycomparedwiththesettemperaturethreshold:Whenthetemperatureishigherthantheupperlimitthreshold,thebuzzerofportP3.7sendsoutahigh-frequencyalarmsignal,andtheredLEDlightofportP0.6islitatthesametimetogivehightemperaturealarm.Whenthetemperatureislowerthanthelowerlimitthreshold,thebuzzersendsoutalow-frequencyalarmsignal,andatthesametimelightsuptheblueLEDlightofportP0.7togivealow-temperaturealarm.5.5ButtonmoduleWecanrealizehuman-computerinteractionthroughbuttons,adjustthetemperaturethreshold,andmakethesystemsuitableformoreoccasions.Thismoduleiscomposedoftwoparts,onepartisthecontrolbutton(K1~K4),theotherpartistheindicatorlight,whichoccupiestheportP1.0~P1.5ofthesingle-chipmicrocomputer.Fordetails,wecanseeFigure3below.WhenK1ispressed,theredlightison,indicatingthattheupperlimitsettingstateisentered,andthetemperatureisadjustedthroughthebuttonsK2(+)andK3(-).Atthesametime,thedisplaymoduledisplaysthetemperaturevaluesettingsynchronously.Aftertheadjustmentiscompleted,pressK1againtoexit.Thelowerlimittemperaturevalueadjustment(K4)processisconsistentwiththeupperlimit.VISystemsoftwaredesignTheDS18B20hardwarecircuitissimple,andrelativelycomplicatedsoftwaredesignmustbeusedtoprovidereasonablelogictimingtoensurereliableandaccuratework.DS18B20mainlyincludes3kindsofoperations:initialization,busread,andbuswrite.Thesethreeoperationsmuststrictlyfollowthetimingrequirements.Inthefollowing,wewillconductanin-depthanalysisofthesethreeaspects.6.1InstructionsAccordingtothecommunicationprotocolofDS18B20,thesensormustusetheROMinstructionandmemoryRAMinstructionprovidedbyittooperate.Andthesetwokindsofinstructionsappearintheprograminthehexadecimalformof8bitwordlength.CommonlyusedcodesandspecificmeaningsareshowninTable1andTable2.Eachtemperatureconversiongenerallygoesthroughthreesteps:resetoperation,sendROMcommand,sendRAMcommand,andthenreadthetemperature.6.2InitializationsequenceInitializationisoneofthebasicoperationsatthebottomoftheDS18B20,whichisequivalenttoestablishingacommunicationbridgebetweenthemicrocontrollerandthesensortoprepareforthesubsequentoperations.TheinitializationpulseincludestheresetpulsesentbytheCPUandtheresponsepulsesentbythesensor.TheinitializationpulsesequenceisshowninFigure3.Figure3.DS18B20initializationsequenceThehostfirstsendsoutaresetpulse(low-levelsignal)of480-960sandthenreleasesthebustoenterthereceivingmode(RX).WhenDS18B20detectstherisingedgewhenthebusisreleased,itwaitsfor15-60s,andthensendsoutalow-levelresponsepulsewithadelayof60-240s.Atthistime,theDQofthesensorissetto1,andthehostisalsosetto1,andtheinitializationprocessiscompleted.Atthistime,thesensorisinastatewhereitcanbereadandwritten6.3BuswritetimingWritingdatatoDS18B20isthebasicoperationofsendinginstructionsanddata.Therightshiftoperationisusedtorealizebit-by-bitwritingwithlowbitinfrontandhighbitinback.Itmainlyincludestwotimings:writing0andwriting1.Thewritesequencestartswhenthehostpullsdownthebusformorethan1s,andsendsthesignaltobesenttotheDQwithin15s,waitingforthesensortosampleit,andthesensorcompletesthedatacollectionwithin45s.Duringdatacollection,ifthebusishigh,writelogic1;otherwise,writelogic0.ItcanbeseenfromthewritesequenceinFigure4thatonewritecyclerequiresatleast60s,andtheremustbeanintervalgreaterthan1sbetweentwowritecycles.Figure4.WritetimesequenceofDS18B206.4BuswritetimingWritingdatatoDS18B20isthebasicoperationofsendinginstructionsanddata.Therightshiftoperationisusedtorealizebit-by-bitwritingwithlowbitinfrontandhighbitinback.Itmainlyincludestwotimings:writing0andwriting1.Thewritesequencestartswhenthehostpullsdownthebusformorethan1s,andsendsthesignaltobesenttotheDQwithin15s,waitingforthesensortosampleit,andthesensorcompletesthedatacollectionwithin45s.Duringdatacollection,ifthebusishigh,writelogic1;otherwise,writelogic0.ItcanbeseenfromthewritesequenceinFigure4thatonewritecyclerequiresatleast60s,andtheremustbeanintervalgreaterthan1sbetweentwowritecycles.Figure5.ReadtimesequenceofDS18B206.5TemperatureacquisitionprogramTakethetemperatureacquisitionprogramasanexampletobrieflyexplainthesourcecode:VoidConvert_18B20(Void){RST_18B20();WR_18B20(0xcc);WR_18B20(0x44);}IntRead_18B20(Void){RST_18B20();WR_18B20(0xcc);WR_18B20(0xbe);Temp_8[0]=RD_18B20;Temp_8[1]=RD_18B20;return(Temp_8);}VIIExperimentaltestThetesttemperaturevalueisshowninTable3.Thesystemerrorislessthan0.5,andthetestresultsshowthatthesystemhashighaccuracyandstrongpracticability.VIIIConclusionThisarticledesignsatemperatureacquisitionalarmsystembasedonAT89S52single-chipmicrocomputerandDS18B20digitaltemperaturesensor,anddetailsthesoftwareandhardwaredesign.Thedesignhastheadvantagesofsimplestructure,highprecisionandgoodstability,andissuitableforthefollowingfields:granary,electricmachineroom,bearing,airconditioner,refrigerator,industryandagriculture,etc.TheDS18B20singlebusandmulti-pointtemperaturemeasurementfeaturestrengthensitsscalabilityandhasabroadmarketprospect.FAQWhatisDS18B20temperaturesensor?TheDS18B20isa1-wireprogrammabletemperaturesensorfrommaximintegrated.Itiswidelyusedtomeasuretemperatureinhardenvironmentslikeinchemicalsolutions,minesorsoiletc.Theconstrictionofthesensorisruggedandalsocanbepurchasedwithawaterproofoptionmakingthemountingprocesseasy.HowdoestheDS18B20work?Itworksontheprincipleofdirectconversionoftemperatureintoadigitalvalue.IsDS18B20athermistor?Athermistorisathermalresistor-aresistorthatchangesitsresistancewithtemperature....Thermistorshavesomebenefitsoverotherkindsoftemperaturesensorssuchasanalogoutputchips(LM35/TMP36)ordigitaltemperaturesensorchips(DS18B20)orthermocouples.HowaccurateisDS18B20?TheDS18B20readswithanaccuracyof0.5Cfrom-10Cto+85Cand2Caccuracyfrom-55Cto+125C.Whatisds1820?TheDS18B20isonetypeoftemperaturesensoranditsupplies9-bitto12-bitreadingsoftemperature....Thecommunicationofthissensorcanbedonethroughaone-wirebusprotocolwhichusesonedatalinetocommunicatewithaninnermicroprocessor.HowdoIconnectmyDS18B20tomyRaspberryPi?OnceyouveconnectedtheDS18B20,powerupyourPiandlogin,thenfollowthesestepstoenabletheOne-Wireinterface:1.Atthecommandprompt,entersudonano/boot/config.txt,thenaddthistothebottomofthefile:2.dtoverlay=w1-gpio.3.ExitNano,andrebootthePiwithsudoreboot.WhatistheworkingprincipleofDS18B20?TheDS18B20DigitalThermometerprovides9to12-bit(configurable)temperaturereadingswhichindicatethetemperatureofthedevice.Itcommunicatesovera1-Wirebusthatbydefinitionrequiresonlyonedataline(andground)forcommunicationwithacentralmicroprocessor.Inadditionitcanderivepowerdirectlyfromthedataline(parasitepower),eliminatingtheneedforanexternalpowersupply.ThecorefunctionalityoftheDS18B20isitsdirect-to-digitaltemperaturesensor.Theresolutionofthetemperaturesensorisuser-configurableto9,10,11,or12bits,correspondingtoincrementsof0.5C,0.25C,0.125C,and0.0625C,respectively.Thedefaultresolutionatpower-upis12-bit.WheretouseDS18B20Sensor?TheDS18B20isa1-wireprogrammableTemperaturesensorfrommaximintegrated.Itiswidelyusedtomeasuretemperatureinhardenvironmentslikeinchemicalsolutions,minesorsoiletc.Theconstrictionofthesensorisruggedandalsocanbepurchasedwithawaterproofoptionmakingthemountingprocesseasy.Itcanmeasureawiderangeoftemperaturefrom-55Cto+125withadecentaccuracyof5C.EachsensorhasauniqueaddressandrequiresonlyonepinoftheMCUtotransferdatasoitaverygoodchoiceformeasuringtemperatureatmultiplepointswithoutcompromisingmuchofyourdigitalpinsonthemicrocontroller.HowconnectDS18B20toArduino?FirstplugthesensoronthebreadboardtheconnectitspinstotheArduinousingthejumpersinthefollowingorder:pin1toGND;pin2toanydigitalpin(pin2inourcase);pin3to+5Vor+3.3V,attheendputthepull-upresistor.OnanATMega328P,whyisaDS18B20temperaturesensorreturningincorrecttemperaturevalues?Severalpossibilities:1.Ifitisjustreadingalittlehigh,itmightbecausedbyselfheating.Addaheatsinkand/ormakemeasurementslessfrequently.2.Especiallyifthevaluesarereallywhacky,itmightbecodewitherrorsormis-wiring.Useapublishedsketchtocheckoperation.3.TheDS18B20mightbedefective.Tryanother.4.Itsaccurateto0.5C.Areyouexpectingittobemoreaccurate(likedowntotheLSBofthereadvalue)?

HOT316

whichareclearlyexplainedinthebelowBuyingGuide.

MW300

youhavetoknowwhatwouldbethenextstepiftherobotdogfailstoworkoranyofitsfunctionalityfailsafterpurchasi

IPD80R1K4CEATMA1-Infeline

5mmjackandismultisystemcompatible.

DS0026

Becauseofitsrapidcoolingrate.

VS-HFA90FA120-VISHAY

ItismeasuredintheunitsSamplespersecond.

TZMC3V6-GS08-VISHAY

Solarpanelskitscomeindifferentsizeandcostvariants.

L6599DTR-ST

Butthatresearchisverycomplicatedandtimeconsumingfactor.

TICC2530

itcomeswiththetrustofapple.

VJ0805Y473KXACW1BC-VISHAY

Forstoragethetemperatureshouldbebetween-65degreecentigradeto+150centigrade.

78L12

8ftLEDStrip1*RemoteControlReceiver1*44KeyRemoteControl1*AC/DCAdapter1*Usermanual.

Powered By Tkool Electronics

Copyright Your WebSite.sitemap