Tkool Electronics

IDescriptionFirst,thisblogwillintroducethe1wiredigitaltemperaturesensorDS18B20.Wemainlyintroduceitsstructure,characteristicsandworkingprinciplehere.Second,wewillintroduceatemperaturemeasurementsystembasedonDS18B20andAT89S52microcontroller.Herewemainlyintroduceitshardwarestructureandassembler.Third,therewillbepartofthesourceprogramthatisdetailedanalyed.Finally,theblogalsoexplainshowitperformstemperaturemeasurementintheagriculturalfield.Thetemperaturemeasuringdevicehasaseriesofadvantages.Suchas:highdisplayaccuracy,lowprice,simplestructure,convenientexpansionandwideapplication.DS18B20TemperatureSensorTutorialCatalogIDescriptionIIIntroductionIIIDS18B20Overview3.1DS18B20Advantages3.2DS18B20Features3.3DS18B20InternalStructureIVDS18B20MCUTemperatureMeasurementDevice4.1CompositionofSystemHardware4.2DesignofInterfaceVSoftwareDesignVIApplicationinAgriculturalProduction6.1TemperatureofMildew6.2TemperatureofAgriculturalProducts6.3TemperatureDetectioninGreenhouses6.4TemperatureofSoilVIIConclusionFAQOrdering&QuantityIIIntroductionWhatistemperature?Whataretherolesoftemperature?Temperatureisaphysicalquantitythatcharacterizesthedegreeofcoolingofanobject,anditisalsoabasicenvironmentalparameter.Inagro-industrialproductionanddailylife,themeasurementandcontroloftemperaturealwaysoccupyanextremelyimportantposition.Atpresent,atypicaltemperaturemeasurementandcontrolsystemconsistsofthefollowingparts:Analogtemperaturesensor;A/Dconversioncircuit;MCU.However,theanalogsignaloutputbytheanalogtemperaturesensorhastobeconverted.Itcaninterfacewithmicroprocessorssuchassingle-chipmicrocomputersonlyafterobtainingdigitalsignalsthroughtheA/Dconversionlink.Therefore,thehardwarecircuitstructureiscomplicatedandthecostishigh.ButDS18B20canhelpsolvethisproblem.Thenew1wiredigitaltemperaturesensorrepresentedbyDS18B20integratestemperaturemeasurementandA/Dconversion,anddirectlyoutputsdigitalquantities.Thestructureoftheinterfacecircuitwiththesingle-chipmicrocomputerissimple,anditiswidelyusedintheoccasionswithlongdistanceandmanynodes.Therefore,DS18B20hasstrongpromotionandapplicationvalue.IIIDS18B20Overview3.1DS18B20AdvantagesDS18B20type1wireintelligenttemperaturesensorproducedbyDALLASSemiconductorCompany.Itbelongstoanewgenerationofintelligenttemperaturesensorsadaptedtomicroprocessors.Comparedwiththetraditionalthermistor,ithasthefollowingadvantages:Itcandirectlyreadthemeasuredtemperature;Thereadingmodeof9-12digitscanberealizedthroughsimpleprogrammingaccordingtoactualrequirements;Itcanalsocomplete9-bitand12-bitdigitalquantitieswithin93.75msand750ms,respectively,withamaximumresolutionof0.0625C;ToreadorwritetheinformationofDS18B20,onlyoneportline(1wireinterface)isrequiredtoreadandwrite.3.2DS18B20FeaturesUnique1-WireInterfaceRequiresOnlyOnePortPinforCommunicationReduceComponentCountwithIntegratedTemperatureSensorandEEPROMMeasuresTemperaturesfrom-55Cto+125C(-67Fto+257F)0.5CAccuracyfrom-10Cto+85CProgrammableResolutionfrom9Bitsto12BitsNoExternalComponentsRequiredParasiticPowerModeRequiresOnly2PinsforOperation(DQandGND)SimplifiesDistributedTemperature-SensingApplicationswithMultidropCapabilityEachDeviceHasaUnique64-BitSerialCodeStoredinOn-BoardROMFlexibleUser-DefinableNonvolatile(NV)AlarmSettingswithAlarmSearchCommandIdentifiesDeviceswithTemperaturesOutsideProgrammedLimitsAvailablein8-PinSO(150mils),8-PinSOP,and3-PinTO-92Packages3.3DS18B20InternalStructureDS18B20adopts3-pinPR-35packageor8-pinSOICpackage.ItsDS18B20externalshapeandpindiagramareshowninFigure1.TheDS18B20internalstructureblockdiagramisshownasinFigure2.Thestructureof64-bitflashROMisshowninFigure3.Figure1.DS18B20PinoutFigure2.DS18B20InternalStructureFigure3.64bFlashROMStructureIVDS18B20MCUTemperatureMeasurementDevice4.1CompositionofSystemHardwareTheDS18B20single-chipmicrocomputerintelligenttemperaturemeasurementdeviceismainlycomposedofDS18B20temperaturesensor,AT89S52,displaymoduleandpowermodule,asshowninFigure4.Themaintechnicalindicatorsoftheproductare:MeasuringRange(℃):-55.0~+125.0MeasurementAccuracy(℃):0.1ResponseTime(s):1.5Figure4.SystemStructureDiagramThesystemusesDS18B20asatemperaturesensor.Theone-chipcomputerAT89S52ofATMELCompanyservesastheprocessor.Temperaturedisplayandlight-emittingdiodeastemperaturecontroloutputunit.Thewholesystemstrivestohaveasimplestructureandperfectfunctions.Theworkingprincipleofthesystemisasfollows:AfterDS18B20carriesonthefieldtemperaturemeasurement,themeasureddataissenttotheP3.5portofAT89S52.Thetemperaturevalueisdisplayedafterbeingprocessedbythemicrocontroller.Then,thistemperaturevalueiscomparedwiththeupperlimitofthesetalarmtemperature.Ifitishigherthanthesetupperlimit,theyellowLEDlightsup.ThemaincircuitdiagramofthesystemisshownasinFig.5.Figure5.DS18B20TemperatuerMeasurementDevice4.2DesignofInterfaceThereare2waystoconnectDS18B20tothehardwareofthemicrocontroller:Vccisconnectedtoexternalpowersupply,GNDisgrounded,andI/OisconnectedtotheI/Olineofthemicrocontroller;Useparasiticpowersupply,UDDandGNDaregroundedatthistime,andI/OisconnectedtoMCUI/O.Regardlessofthe1stor2ndpowersupplymode,theI/Olinemustbeconnectedtoapull-upresistorofabout4.7k.Figure6showsatypicalconnectionbetweenDS18B20andamicroprocessor.InFigure6(a),DS18B20adoptsparasiticpowersupply,anditsVDDandGNGterminalsarebothgrounded;InFigure6(b),theDS18B20usesanexternalpowersupply,anditsVDDterminalusesa3~5.5Vpowersupply.ThissystemadoptsthewiringmodeshowninFigure6(b),thatis,theworkingmodeofexternalpowersupply.TheactualconnectionpictureofthesystemisshowninFigure6.Figure6.PhysicalDiagramofSystemConnectionVSoftwareDesignItisworthnotingthatDS18B20hasveryhighrequirementsontwoaspects:timingandelectricalparameters.Therefore,theworkflowofthemainCPUaccessingtheDS18B20throughthesingle-businterfacemustfollowastrictoperatingsequence:first,initializetheDS18B20;second,sendROMcommands;andthen,sendfunctioncommands.Wecantakealookatthefollowingpartofthesourceprogramisasfollows:ORG0000HAJMPMAIN;StatementofMCUmemoryallocation!TEMPER_LEQU29H;usedtosavethelower8bitsofthereadtemperatureTEMPER_HEQU28H;usedtosavetheupper8bitsofthereadtemperatureFLAG1EQU38H;WhethertheDS18B20flagisdetectedPNFLAGEQU68H;DatapositiveandnegativeflagA_BITEQU20H;thesingledigitofthedigitaltubestoresthememorylocationB_BITEQU21H;ThetendigitsofthedigitaltubestorethememorylocationC_BITEQU22H;ThedecimalplacesofthedigitaltubestorethememorylocationT_INTEGEREQU26H;TheintegerpartafterFORMAT,whichintegratestwobytesoftemperatureintoonebyteT_DFEQU27H;ThedecimalfractionafterFORMAT,thedecimalfractionofnibbletemperature(therearelowfourdigits)MAIN:LCALLGET_TEMPER;CallthetemperaturereadingsubroutineLCALLT_FORMAT;Formattheread2bytetemperatureLCALLALARM;callthealarmsubroutineLCALLDISPLAY;callthedigitaltubedisplaysubroutineLCALLD1S;testafteradelayof0.5secondsAJMPMAIN;thisistheDS18B20resetinitializationsubroutineINIT_1820:SETBP3.5NOPCLRP3.5;thehostsendsoutaresetlowpulsewithadelayof537microsecondsMOVR1,#2TSR1:MOVR0,#250DJNZR0,$DJNZR1,TSR1SETBP3.5;thenpullupthedatalineNOPNOPNOPMOVR0,#25HTSR2:JNBP3.5,TSR3;waitingforDS18B20responseDJNZR0,TSR2;delayLJMPTSR4TSR3:SETBFLAG1;SettheflagbittoindicatethatDS1820existsLJMPTSR5TSR4:CLRFLAG1;cleartheflagbit,indicatingthatDS1820doesnotexistLJMPTSR7TSR5:MOVR0,#120TSR6:DJNZR0,TSR6;timingrequiresaperiodofdelayTSR7:SETBP3.5RET;readthetemperaturevalueafterconversionGET_TEMPER:;SETBP3.5LCALLINIT_1820;firstresetDS18B20JBFLAG1,TSS2RET;DeterminewhetherDS1820exists?IfDS18B20doesnotexistThenreturnTSS2:MOVA,#0CCH;skipROMmatchingLCALLWRITE_1820MOVA,#44H;IssuetemperatureconversioncommandLCALLWRITE_1820LCALLDISPLAYLCALLINIT_1820;resetbeforereadingtemperatureMOVA,#0CCH;SkipROMmatchingLCALLWRITE_1820MOVA,#0BEH;IssuereadtemperaturecommandLCALLWRITE_1820LCALLREAD_18200;savethereadtemperaturedatato28H/29HRET;WriteDS18B20subroutine(withspecifictimingrequirements)WRITE_1820:MOVR2,#8;atotalof8bitsofdata;CLRCWR1:CLRP3.5MOVR3,#6DJNZR3,$RRCAMOVP3.5,CMOVR3,#23DJNZR3,$SETBP3.5NOPDJNZR2,WR1SETBP3.5RET;readtheprogramofDS18B20,readtwobytesoftemperaturedatafromDS18B20READ_18200:MOV36H,#2;SetthehighandlowtemperatureReadfromDS18B20MOVR1,#29H;thelowbitisstoredin29H(TEMPER_L),thehighbitDeposit28H(TEMPER_H)RE00:MOVR2,#8;Thereare8bitsofdataRE01:;CLRCSETBP3.5NOPNOPCLRP3.5NOPNOPNOPSETBP3.5MOVR3,#9RE10:DJNZR3,RE10MOVC,P3.5MOVR3,#23RE20:DJNZR3,RE20RRCADJNZR2,RE01MOV@R1,ADECR1DJNZ36H,RE00RET;-----Integratethetwo-bytetemperaturereadout(pleaserefertotheinformationaboutthe2-bytetemperatureformatreadoutbyDS18B20)----------T_FORMAT:;AlarmsubroutineALARM:;DisplaysubroutineDISPLAY:;1MSdelay(calculatedby12MHZ)D1MS:MOVR7,#250llmm:nopnopDJNZR7,llmmRET;1MSdelay(calculatedby12MHZ)D1S:MovR6,#4LOOP2:movR5,#125;------------250LOOP1:LCALLD1mSDJNZR5,LOOP1DJNZR6,LOOP2RET;7-segmentdigitaltube0-9digitcommonanodedisplaycodeNUMTAB:DB0C0H,0f9H,0a4H,0b0H,99H,92H,82H,0f8H,80H,90H,0ffHXIAOSHU:DB00H,01H,01H,02H,03H,03H,04H,04H,05H,06H,06H,07H,08H,08H,09H,09HENDVIApplicationinAgriculturalProductionThistemperaturemeasurementsystemcandirectlyoutputdigitalquantities.Inaddition,ithasthecharacteristicsofsimplestructure,convenientuseandlowprice.Therefore,itcanbewidelyusedinagriculturalproduction.6.1TemperatureofMildewModerngrainwarehousescanusethissystemtomonitorthetemperatureofhundredsofpoints.Inthisway,youcaneasilygraspthetemperaturechangesatvariouspointsatdifferenttimes,increasestoragecapacity,andeffectivelyreducetheoccurrenceofmildew.6.2TemperatureofAgriculturalProductsAtpresent,low-temperaturerefrigerationmeasuresarewidelyadoptedforthepreservationoffruitsandvegetables.Thesystemcanbeinstalledinthetemperaturemeasurementpositionoftherefrigeratorcompartment.Inthisway,thetemperaturevaluecanbeconvenientlyobservedatanytimetocheckwhethertheoptimalpreservationtemperatureisreached.6.3TemperatureDetectioninGreenhousesThesystemisusedinplasticgreenhousesforgreenhousevegetablecultivationandflowerproduction.Inthisway,automatictemperaturedisplaycanberealized,andlaborandtimefortemperaturemeasurementcanbesaved.6.4TemperatureofSoilIntheprocessofplantingcropswithstrictrequirementsonsoiltemperature,thesystemcantestthechangesinsoiltemperatureasneededtofacilitatethegraspofaccuratetemperaturevalues.VIIConclusionThesingle-chiptemperaturemeasurementsystemtakesfulladvantageofthesimplicityofthehardwarestructureofDS18B20andAT89S52,using8-segmentdigitaltubedisplay,lowpriceandwideapplication.Accordingtoactualneeds,wecanalsouseLCDasadisplaydeviceorformadistributedtemperaturemeasurementandcontrolsystem.Althoughthedesigniseasytoexpand,italsohasitsshortcomings.Thesimplicityofthehardwarestructurecomesattheexpenseofsoftware.Therefore,specialattentionshouldbepaidtotheworkingsequencerequirementsofDS18B20duringprogramming.Inshort,thesystemcanbewidelyusedintemperaturemeasurementinagriculturalproduction.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)?

1N4148W-E3-08-VISHAY

IDescriptionDoyouknowtheDCregulatedpowersupply?DCregulatedpowersupplyiswidelyusedinindustrialproduct

293D686X9010B2TE3-VISHAY

I.IntroductiontoGalvanometerThegalvanometerisanimportanttestinginstrument.Itisahigh-sensitivitymecha

BAR9002ELE6327XTMA-Infeline

IDescriptionIndailylife,calendarclocksareusedinvariousplaces.Suchasshoppingmalls,supermarkets,office

VS-ST230S12P0V-VISHAY

IntroductionTheLM741seriesaregeneral-purposeoperationalamplifiers.Itisintendedforawiderangeofanalogu

VS-25RIA80-VISHAY

IntroductionLM2596seriesisa3.0Astep-downswitchingregulatorchipproducedbyTexasInstruments(TI).Itconta

40L15CTPBF-VISHAY

IDescriptionSometimes,ifyoucanusetheinexpensiveLM386anduseittomakeastereopoweramplifier,theeffectsho

IRFR1N60ATRPBF-VISHAY

LM3914isamonolithicicthatsensesanalogvoltagelevelsanddrives10LEDs,providingalinearanalogdisplay.Asin

IPA60R180P7SXKSA1-Infeline

IDescriptionThisblogintroducesthepoweramplifierwithNE5532andLM1875Tasthecorecomponents.Thepowerampli

ILBB0603ER102V-VISHAY

ADC0804DescriptionTherearemultiplekindsofAnalogtoDigitalConverters(ADC)whichareusedtoconvertthesigna

VS-VSKT250-16PBF-VISHAY

FAQWhatisl293d?L293DICisadualH-bridgemotordriverIC.OneH-bridgeiscapabletodriveadcmotorinbidirectiona

Powered By Tkool Electronics

Copyright Your WebSite.sitemap