Tkool Electronics

I.IntroductionDCmotorsarewidelyusedinvariousfieldsduetotheirgoodspeedregulationperformance,largestartingtorqueandstrongoverloadcapacity.Inrecentyears,thestructureandcontrolmethodsofDCmotorshaveundergonegreatchanges.Withcomputersenteringthecontrolfieldandthecontinuousemergenceofnewpowerelectronicpowercomponents,PWM(pulsewidthmodulation)speedregulationhasbecomeanewwayofDCmotorspeedregulation.Andwiththeadvantagesofhighswitchingfrequency,stablelow-speedoperation,excellentdynamicperformance,andhighefficiency,itiswidelyusedinDCmotorspeedregulation.Therefore,thispaperproposesthedesignofaDCmotorPWMcontrolsystembasedon80C196KCandL298N.CatalogI.IntroductionII.PrincipleofPWMSpeedControlSystemIII.ControlSystemHardwareDesign3.1IntroductiontoPowerIntegratedCircuitL298N3.2DCMotorControlSystemHardwareCircuit3.3Anti-interferenceandElectromagneticCompatibilityDesignIV.ControlSystemSoftwareRealizationV.ConclusionFAQOrdering&QuantityII.PrincipleofPWMSpeedControlSystemPWM,orpulsewidthmodulation,referstotheuseoftheswitchingcharacteristicsofhigh-powertransistorstomodulateafixedvoltageDCpowersupply,whichisturnedonandoffatafixedfrequency,andthelengthoftheonandofftimeinacycleischangedasneeded.BychangingthedutycycleofthevoltageonthearmatureoftheDCservomotor,theaveragevoltageischangedtocontrolthespeedofthemotor.Therefore,itisoftencalledaswitchdrivedevice.TheschematicdiagramofPWMcontrolisshowninFigure1.Figure1PWMcontrolschematicdiagramThereareusuallytwowaystochangethedutycycle:PWMandPFM(pulsefrequencymodulation).PWMisbychangingthewidthoftheon-pulse,whichiscommonlyreferredtoasthefixedfrequencywidthmodulationmethod.PFMmeansthattheon-pulsewidthisconstantandthedutycycleischangedbychangingtheswitchingfrequency.Becausewhenitencountersmechanicalresonanceataparticularfrequency,itoftenresultsinsystemvibrationandhowling.Therefore,inthecontrolofDCmotors,thePWMcontrolmethodismainlyused.III.ControlSystemHardwareDesignTheDCmotorspeedcontrolsystembasedon80C196KCandL298Niscomposedofthesmallestsingle-chipmicrocomputersystem,R/Dconverter,PWMpoweramplifiercircuit,A/DandD/Aconversioncircuit,andreceivingcommandinterfacecircuit.Theminimumsystemofthesingle-chipmicrocomputeradoptsthe16-bitsingle-chip80C196KCexternalexpansioninterfacecircuit,whichismainlyusedtorealizethefunctionsofdataacquisitionandPWMsignalgeneration.TheblockdiagramofthespeedcontrolsystemisshowninFigure2.Figure2BlockdiagramofPWMspeedcontrolsystem3.1IntroductiontoPowerIntegratedCircuitL298NInordertoimprovesystemefficiencyandreducepowerconsumption,thepoweramplifierdrivecircuitadoptstheintegratedcircuitL298NbasedonthebipolarH-bridgepulsewidthmodulationmethod.L298Nisahigh-performancepulse-widthmodulationpoweramplifierproducedbySGS,whichhasthecharacteristicsofsmallsizeandstrongdrivingability.ItcontainstwoH-bridgehigh-voltageandhigh-currentbridgedrivers,whichcanrealizethefull-bridgedriveofthemotorwithasinglechip,whichcandrivemotorsbelow46Vand2A.TheinternalstructureofL298NisshownasinFigure3.Figure3L298Ninternalstructureblockdiagram3.2DCMotorControlSystemHardwareCircuitL298NcandrivetwoDCmotors,becausethespeedcontrolsystemisasingle-axisstructure,inordertomakefulluseoftheloadcapacityofthepoweramplifiercircuit,sothatthesystemstartsatthemaximumaccelerationandbrakesatthemaximumacceleration,inthedesign,theinputterminalandtheoutputterminalareconnectedinparalleltocontroltheDCmotor.Thesingle-chip80C196KCgivesaPWMsignalaccordingtothecalculationresultsofthepositionloopandthespeedloop.ThePWMsignalisdirectlyoutputtotheIN1(IN3)terminal,andthePWMsignalisinvertedandoutputtoIN2(IN4)through7406.WhenthedutycycleofthePWManalogsignalis50%,thepositiveandnegativevoltagesatbothendsofthemotorareappliedforthesametime.Themotorisinastateoftremoratthisposition,thatis,inthepowerlubricationstate.Whenthedutycycleisgreaterthan50%,thesignalvoltageOUTAisgreaterthanOUTB,andthemotorrotatesforward,otherwisereverse.Therefore,theoutputpolarityofeachlinkmustbestraightenedouttoformnegativefeedbackandcompleteclosed-loopcontrol.RelyingonchangingthePWMdutycycletocontrolthemotorspeedcanalsochangethemotorrotationdirection,thecontrolmethodissimpleandreliable.Inaddition,becausethemotorisofelectriccoiltype,reverseelectromotiveforcewillbeformedwhenthemotorhasanemergencystopandsuddencommutation.ToensurethenormaloperationoftheL298Ndrivechip,twopairsofcontinuationsareaddedbetweentheoutputterminalsOUTA,OUTBandtheDCmotor.TheflowdiodeshuntsthecurrenttothepositiveorgroundterminalofthepowersupplytopreventbackelectromotiveforcefromdamagingtheL298N.3.3Anti-interferenceandElectromagneticCompatibilityDesignWhenthemotorisdriven,therapidon-offofthepowermainswitchingelementleadstoalargerateofchangeofpowercurrentandvoltage,whichnotonlyaffectsthedrivecircuitbutalsoentersthecontrolcircuitthroughthepowersupplyandground.Inaddition,whenthemotorstartsandbrakes,thetransientvoltageisgeneratedatthesuddenchangeoftheload,itsamplitudewillbehigherthanthepowersupplyvoltage,andtheleadingedgeissteep,thefrequencybandisverywide,anditentersthecontrolcircuitthroughtheDCpowersupply.Therefore,anti-interferenceandelectromagneticcompatibilitydesignisalsoveryimportant.Thesystemhasadoptedmeasuressuchascurrentsmoothing,deburringandshielding.Currentsmoothing:BecausetheinstantaneousenergyofthePWMswitchisrelativelylarge,theRCfilterisusedattheoutputofthePWMpoweramplifiertofilter.Byselectingtheappropriateresistanceandcapacitancevalues,high-frequencyharmonicsareeffectivelysuppressedandthepeakvoltageofthePWMpoweramplifierisabsorbed.Therebyreducingtheinterference;Deburring:Thesystemincreasesthefiltercapacitoronthepowersupplyside,andusesonelargeandonesmallcapacitorinparallel.Thelargecapacitorisresponsibleforthedecoupling,filtering,andsmoothingoflow-frequencyalternatingsignals,andthesmallcapacitoreliminatesmid-andhigh-frequencyparasiticscouplinginthecircuitnetwork,whicheffectivelyreducesspikesandburrs;Shielding:Themotordrivecableadoptsdouble-shieldedcables,andthewiringshouldbeseparatedfromothercablesasmuchaspossible.Figure4DrivehardwarecircuitdiagramIV.ControlsystemsoftwarerealizationThecontrolsystemadoptsthespeed-positionclosed-loopcombinationmethod,takingthepositioncontrolmethodasanexampletointroducetherealizationmethodofthesoftware.ThepositioncontrolisbasedontheclassicPIcontrolalgorithm,andtheproportionalandintegralparametersaresimplifieddesign,andthesegmentedPIcontrolisintroduced.,Thatis,thecalculatederrorisdividedintosections,anddifferentproportionalandintegralparametersparticipateintheadjustmentwithintheerrorrangeofeachsection,whichensuresthesmootherandmorestableoperationofthesystem.ThederivationandsimplificationprocessofPIformulaisasfollows:ThespecificsoftwareimplementationflowchartisshowninFigure5.Thatis,afterreceivingagivenanglecommand,firstcalculatethedifferencebetweenthesampledpositioninformationandthegivenangle,andthendividethedifferenceintonequalparts,andeachsegmentcorrespondstoasetofparametersKp1andki1participateinmediationcontrol,calculatetheoutputofPIcontrolandthenconvertitintothecorrespondingPWMnumericaloutput.Figure5ThespecificsoftwareimplementationflowchartV.ConclusionThisarticlesumsupthedesignschemeoftheDCmotorPWMcontrolsystembasedon80C196KCandL298N.Thesingle-chipmicrocomputergeneratesPWMsignaltothepowerintegratedcircuitL298N.TheclassicPIsegmentcontrolisusedtocontrolthemotor.Ithasthecharacteristicsofsimplecircuitandconvenientcontrol.Theoperatingtestresultsshowthatthesystemworksstablyandreliably,meetstherequirementsofthespeedregulationfunction,andhasbeensuccessfullyappliedtomanyairborneproducts.FAQWhatisl298n?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Whatistheuseofl298n?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoesl298ncontrolDCmotorspeed?1.IfyousendaHIGHsignaltotheenable1pin,motorAisreadytobecontrolledandatthemaximumspeed;2.IfyousendaLOWsignaltotheenable1pin,motorAturnsoff;3.IfyousendaPWMsignal,youcancontrolthespeedofthemotor.Themotorspeedisproportionaltothedutycycle.Whatisl298nmotordrivermodule?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Howdoesl298nmotordriverwork?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoiuseal298motordriverwithArduino?Startbyconnectingpowersupplytothemotors.InourexperimentweareusingDCGearboxMotors(alsoknownasTTmotors)thatareusuallyfoundintwo-wheel-driverobots.Theyareratedfor3to12V.So,wewillconnectexternal12VpowersupplytotheVCCterminal.WhatisthefunctionofHbridge?AnH-bridgeisanelectroniccircuitthatswitchesthepolarityofavoltageappliedtoaload.ThesecircuitsareoftenusedinroboticsandotherapplicationstoallowDCmotorstorunforwardsorbackwards.Whatisthedifferencebetweenl293dandl298n?L293isquadruplehalf-HdriverwhileL298isdualfull-Hdriver,i.e,inL293allfourinput-outputlinesareindependentwhileinL298,ahalfHdrivercannotbeusedindependently,onlyfullHdriverhastobeused....Hence,heatsinkisprovidedinL298.

ARRAY4

I.IntroductionDCmotorsarewidelyusedinvariousfieldsduetotheirgoodspeedregulationperformance,largestartingtorqueandstrongoverloadcapacity.Inrecentyears,thestructureandcontrolmethodsofDCmotorshaveundergonegreatchanges.Withcomputersenteringthecontrolfieldandthecontinuousemergenceofnewpowerelectronicpowercomponents,PWM(pulsewidthmodulation)speedregulationhasbecomeanewwayofDCmotorspeedregulation.Andwiththeadvantagesofhighswitchingfrequency,stablelow-speedoperation,excellentdynamicperformance,andhighefficiency,itiswidelyusedinDCmotorspeedregulation.Therefore,thispaperproposesthedesignofaDCmotorPWMcontrolsystembasedon80C196KCandL298N.CatalogI.IntroductionII.PrincipleofPWMSpeedControlSystemIII.ControlSystemHardwareDesign3.1IntroductiontoPowerIntegratedCircuitL298N3.2DCMotorControlSystemHardwareCircuit3.3Anti-interferenceandElectromagneticCompatibilityDesignIV.ControlSystemSoftwareRealizationV.ConclusionFAQOrdering&QuantityII.PrincipleofPWMSpeedControlSystemPWM,orpulsewidthmodulation,referstotheuseoftheswitchingcharacteristicsofhigh-powertransistorstomodulateafixedvoltageDCpowersupply,whichisturnedonandoffatafixedfrequency,andthelengthoftheonandofftimeinacycleischangedasneeded.BychangingthedutycycleofthevoltageonthearmatureoftheDCservomotor,theaveragevoltageischangedtocontrolthespeedofthemotor.Therefore,itisoftencalledaswitchdrivedevice.TheschematicdiagramofPWMcontrolisshowninFigure1.Figure1PWMcontrolschematicdiagramThereareusuallytwowaystochangethedutycycle:PWMandPFM(pulsefrequencymodulation).PWMisbychangingthewidthoftheon-pulse,whichiscommonlyreferredtoasthefixedfrequencywidthmodulationmethod.PFMmeansthattheon-pulsewidthisconstantandthedutycycleischangedbychangingtheswitchingfrequency.Becausewhenitencountersmechanicalresonanceataparticularfrequency,itoftenresultsinsystemvibrationandhowling.Therefore,inthecontrolofDCmotors,thePWMcontrolmethodismainlyused.III.ControlSystemHardwareDesignTheDCmotorspeedcontrolsystembasedon80C196KCandL298Niscomposedofthesmallestsingle-chipmicrocomputersystem,R/Dconverter,PWMpoweramplifiercircuit,A/DandD/Aconversioncircuit,andreceivingcommandinterfacecircuit.Theminimumsystemofthesingle-chipmicrocomputeradoptsthe16-bitsingle-chip80C196KCexternalexpansioninterfacecircuit,whichismainlyusedtorealizethefunctionsofdataacquisitionandPWMsignalgeneration.TheblockdiagramofthespeedcontrolsystemisshowninFigure2.Figure2BlockdiagramofPWMspeedcontrolsystem3.1IntroductiontoPowerIntegratedCircuitL298NInordertoimprovesystemefficiencyandreducepowerconsumption,thepoweramplifierdrivecircuitadoptstheintegratedcircuitL298NbasedonthebipolarH-bridgepulsewidthmodulationmethod.L298Nisahigh-performancepulse-widthmodulationpoweramplifierproducedbySGS,whichhasthecharacteristicsofsmallsizeandstrongdrivingability.ItcontainstwoH-bridgehigh-voltageandhigh-currentbridgedrivers,whichcanrealizethefull-bridgedriveofthemotorwithasinglechip,whichcandrivemotorsbelow46Vand2A.TheinternalstructureofL298NisshownasinFigure3.Figure3L298Ninternalstructureblockdiagram3.2DCMotorControlSystemHardwareCircuitL298NcandrivetwoDCmotors,becausethespeedcontrolsystemisasingle-axisstructure,inordertomakefulluseoftheloadcapacityofthepoweramplifiercircuit,sothatthesystemstartsatthemaximumaccelerationandbrakesatthemaximumacceleration,inthedesign,theinputterminalandtheoutputterminalareconnectedinparalleltocontroltheDCmotor.Thesingle-chip80C196KCgivesaPWMsignalaccordingtothecalculationresultsofthepositionloopandthespeedloop.ThePWMsignalisdirectlyoutputtotheIN1(IN3)terminal,andthePWMsignalisinvertedandoutputtoIN2(IN4)through7406.WhenthedutycycleofthePWManalogsignalis50%,thepositiveandnegativevoltagesatbothendsofthemotorareappliedforthesametime.Themotorisinastateoftremoratthisposition,thatis,inthepowerlubricationstate.Whenthedutycycleisgreaterthan50%,thesignalvoltageOUTAisgreaterthanOUTB,andthemotorrotatesforward,otherwisereverse.Therefore,theoutputpolarityofeachlinkmustbestraightenedouttoformnegativefeedbackandcompleteclosed-loopcontrol.RelyingonchangingthePWMdutycycletocontrolthemotorspeedcanalsochangethemotorrotationdirection,thecontrolmethodissimpleandreliable.Inaddition,becausethemotorisofelectriccoiltype,reverseelectromotiveforcewillbeformedwhenthemotorhasanemergencystopandsuddencommutation.ToensurethenormaloperationoftheL298Ndrivechip,twopairsofcontinuationsareaddedbetweentheoutputterminalsOUTA,OUTBandtheDCmotor.TheflowdiodeshuntsthecurrenttothepositiveorgroundterminalofthepowersupplytopreventbackelectromotiveforcefromdamagingtheL298N.3.3Anti-interferenceandElectromagneticCompatibilityDesignWhenthemotorisdriven,therapidon-offofthepowermainswitchingelementleadstoalargerateofchangeofpowercurrentandvoltage,whichnotonlyaffectsthedrivecircuitbutalsoentersthecontrolcircuitthroughthepowersupplyandground.Inaddition,whenthemotorstartsandbrakes,thetransientvoltageisgeneratedatthesuddenchangeoftheload,itsamplitudewillbehigherthanthepowersupplyvoltage,andtheleadingedgeissteep,thefrequencybandisverywide,anditentersthecontrolcircuitthroughtheDCpowersupply.Therefore,anti-interferenceandelectromagneticcompatibilitydesignisalsoveryimportant.Thesystemhasadoptedmeasuressuchascurrentsmoothing,deburringandshielding.Currentsmoothing:BecausetheinstantaneousenergyofthePWMswitchisrelativelylarge,theRCfilterisusedattheoutputofthePWMpoweramplifiertofilter.Byselectingtheappropriateresistanceandcapacitancevalues,high-frequencyharmonicsareeffectivelysuppressedandthepeakvoltageofthePWMpoweramplifierisabsorbed.Therebyreducingtheinterference;Deburring:Thesystemincreasesthefiltercapacitoronthepowersupplyside,andusesonelargeandonesmallcapacitorinparallel.Thelargecapacitorisresponsibleforthedecoupling,filtering,andsmoothingoflow-frequencyalternatingsignals,andthesmallcapacitoreliminatesmid-andhigh-frequencyparasiticscouplinginthecircuitnetwork,whicheffectivelyreducesspikesandburrs;Shielding:Themotordrivecableadoptsdouble-shieldedcables,andthewiringshouldbeseparatedfromothercablesasmuchaspossible.Figure4DrivehardwarecircuitdiagramIV.ControlsystemsoftwarerealizationThecontrolsystemadoptsthespeed-positionclosed-loopcombinationmethod,takingthepositioncontrolmethodasanexampletointroducetherealizationmethodofthesoftware.ThepositioncontrolisbasedontheclassicPIcontrolalgorithm,andtheproportionalandintegralparametersaresimplifieddesign,andthesegmentedPIcontrolisintroduced.,Thatis,thecalculatederrorisdividedintosections,anddifferentproportionalandintegralparametersparticipateintheadjustmentwithintheerrorrangeofeachsection,whichensuresthesmootherandmorestableoperationofthesystem.ThederivationandsimplificationprocessofPIformulaisasfollows:ThespecificsoftwareimplementationflowchartisshowninFigure5.Thatis,afterreceivingagivenanglecommand,firstcalculatethedifferencebetweenthesampledpositioninformationandthegivenangle,andthendividethedifferenceintonequalparts,andeachsegmentcorrespondstoasetofparametersKp1andki1participateinmediationcontrol,calculatetheoutputofPIcontrolandthenconvertitintothecorrespondingPWMnumericaloutput.Figure5ThespecificsoftwareimplementationflowchartV.ConclusionThisarticlesumsupthedesignschemeoftheDCmotorPWMcontrolsystembasedon80C196KCandL298N.Thesingle-chipmicrocomputergeneratesPWMsignaltothepowerintegratedcircuitL298N.TheclassicPIsegmentcontrolisusedtocontrolthemotor.Ithasthecharacteristicsofsimplecircuitandconvenientcontrol.Theoperatingtestresultsshowthatthesystemworksstablyandreliably,meetstherequirementsofthespeedregulationfunction,andhasbeensuccessfullyappliedtomanyairborneproducts.FAQWhatisl298n?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Whatistheuseofl298n?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoesl298ncontrolDCmotorspeed?1.IfyousendaHIGHsignaltotheenable1pin,motorAisreadytobecontrolledandatthemaximumspeed;2.IfyousendaLOWsignaltotheenable1pin,motorAturnsoff;3.IfyousendaPWMsignal,youcancontrolthespeedofthemotor.Themotorspeedisproportionaltothedutycycle.Whatisl298nmotordrivermodule?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Howdoesl298nmotordriverwork?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoiuseal298motordriverwithArduino?Startbyconnectingpowersupplytothemotors.InourexperimentweareusingDCGearboxMotors(alsoknownasTTmotors)thatareusuallyfoundintwo-wheel-driverobots.Theyareratedfor3to12V.So,wewillconnectexternal12VpowersupplytotheVCCterminal.WhatisthefunctionofHbridge?AnH-bridgeisanelectroniccircuitthatswitchesthepolarityofavoltageappliedtoaload.ThesecircuitsareoftenusedinroboticsandotherapplicationstoallowDCmotorstorunforwardsorbackwards.Whatisthedifferencebetweenl293dandl298n?L293isquadruplehalf-HdriverwhileL298isdualfull-Hdriver,i.e,inL293allfourinput-outputlinesareindependentwhileinL298,ahalfHdrivercannotbeusedindependently,onlyfullHdriverhastobeused....Hence,heatsinkisprovidedinL298.

I.IntroductionDCmotorsarewidelyusedinvariousfieldsduetotheirgoodspeedregulationperformance,largestartingtorqueandstrongoverloadcapacity.Inrecentyears,thestructureandcontrolmethodsofDCmotorshaveundergonegreatchanges.Withcomputersenteringthecontrolfieldandthecontinuousemergenceofnewpowerelectronicpowercomponents,PWM(pulsewidthmodulation)speedregulationhasbecomeanewwayofDCmotorspeedregulation.Andwiththeadvantagesofhighswitchingfrequency,stablelow-speedoperation,excellentdynamicperformance,andhighefficiency,itiswidelyusedinDCmotorspeedregulation.Therefore,thispaperproposesthedesignofaDCmotorPWMcontrolsystembasedon80C196KCandL298N.CatalogI.IntroductionII.PrincipleofPWMSpeedControlSystemIII.ControlSystemHardwareDesign3.1IntroductiontoPowerIntegratedCircuitL298N3.2DCMotorControlSystemHardwareCircuit3.3Anti-interferenceandElectromagneticCompatibilityDesignIV.ControlSystemSoftwareRealizationV.ConclusionFAQOrdering&QuantityII.PrincipleofPWMSpeedControlSystemPWM,orpulsewidthmodulation,referstotheuseoftheswitchingcharacteristicsofhigh-powertransistorstomodulateafixedvoltageDCpowersupply,whichisturnedonandoffatafixedfrequency,andthelengthoftheonandofftimeinacycleischangedasneeded.BychangingthedutycycleofthevoltageonthearmatureoftheDCservomotor,theaveragevoltageischangedtocontrolthespeedofthemotor.Therefore,itisoftencalledaswitchdrivedevice.TheschematicdiagramofPWMcontrolisshowninFigure1.Figure1PWMcontrolschematicdiagramThereareusuallytwowaystochangethedutycycle:PWMandPFM(pulsefrequencymodulation).PWMisbychangingthewidthoftheon-pulse,whichiscommonlyreferredtoasthefixedfrequencywidthmodulationmethod.PFMmeansthattheon-pulsewidthisconstantandthedutycycleischangedbychangingtheswitchingfrequency.Becausewhenitencountersmechanicalresonanceataparticularfrequency,itoftenresultsinsystemvibrationandhowling.Therefore,inthecontrolofDCmotors,thePWMcontrolmethodismainlyused.III.ControlSystemHardwareDesignTheDCmotorspeedcontrolsystembasedon80C196KCandL298Niscomposedofthesmallestsingle-chipmicrocomputersystem,R/Dconverter,PWMpoweramplifiercircuit,A/DandD/Aconversioncircuit,andreceivingcommandinterfacecircuit.Theminimumsystemofthesingle-chipmicrocomputeradoptsthe16-bitsingle-chip80C196KCexternalexpansioninterfacecircuit,whichismainlyusedtorealizethefunctionsofdataacquisitionandPWMsignalgeneration.TheblockdiagramofthespeedcontrolsystemisshowninFigure2.Figure2BlockdiagramofPWMspeedcontrolsystem3.1IntroductiontoPowerIntegratedCircuitL298NInordertoimprovesystemefficiencyandreducepowerconsumption,thepoweramplifierdrivecircuitadoptstheintegratedcircuitL298NbasedonthebipolarH-bridgepulsewidthmodulationmethod.L298Nisahigh-performancepulse-widthmodulationpoweramplifierproducedbySGS,whichhasthecharacteristicsofsmallsizeandstrongdrivingability.ItcontainstwoH-bridgehigh-voltageandhigh-currentbridgedrivers,whichcanrealizethefull-bridgedriveofthemotorwithasinglechip,whichcandrivemotorsbelow46Vand2A.TheinternalstructureofL298NisshownasinFigure3.Figure3L298Ninternalstructureblockdiagram3.2DCMotorControlSystemHardwareCircuitL298NcandrivetwoDCmotors,becausethespeedcontrolsystemisasingle-axisstructure,inordertomakefulluseoftheloadcapacityofthepoweramplifiercircuit,sothatthesystemstartsatthemaximumaccelerationandbrakesatthemaximumacceleration,inthedesign,theinputterminalandtheoutputterminalareconnectedinparalleltocontroltheDCmotor.Thesingle-chip80C196KCgivesaPWMsignalaccordingtothecalculationresultsofthepositionloopandthespeedloop.ThePWMsignalisdirectlyoutputtotheIN1(IN3)terminal,andthePWMsignalisinvertedandoutputtoIN2(IN4)through7406.WhenthedutycycleofthePWManalogsignalis50%,thepositiveandnegativevoltagesatbothendsofthemotorareappliedforthesametime.Themotorisinastateoftremoratthisposition,thatis,inthepowerlubricationstate.Whenthedutycycleisgreaterthan50%,thesignalvoltageOUTAisgreaterthanOUTB,andthemotorrotatesforward,otherwisereverse.Therefore,theoutputpolarityofeachlinkmustbestraightenedouttoformnegativefeedbackandcompleteclosed-loopcontrol.RelyingonchangingthePWMdutycycletocontrolthemotorspeedcanalsochangethemotorrotationdirection,thecontrolmethodissimpleandreliable.Inaddition,becausethemotorisofelectriccoiltype,reverseelectromotiveforcewillbeformedwhenthemotorhasanemergencystopandsuddencommutation.ToensurethenormaloperationoftheL298Ndrivechip,twopairsofcontinuationsareaddedbetweentheoutputterminalsOUTA,OUTBandtheDCmotor.TheflowdiodeshuntsthecurrenttothepositiveorgroundterminalofthepowersupplytopreventbackelectromotiveforcefromdamagingtheL298N.3.3Anti-interferenceandElectromagneticCompatibilityDesignWhenthemotorisdriven,therapidon-offofthepowermainswitchingelementleadstoalargerateofchangeofpowercurrentandvoltage,whichnotonlyaffectsthedrivecircuitbutalsoentersthecontrolcircuitthroughthepowersupplyandground.Inaddition,whenthemotorstartsandbrakes,thetransientvoltageisgeneratedatthesuddenchangeoftheload,itsamplitudewillbehigherthanthepowersupplyvoltage,andtheleadingedgeissteep,thefrequencybandisverywide,anditentersthecontrolcircuitthroughtheDCpowersupply.Therefore,anti-interferenceandelectromagneticcompatibilitydesignisalsoveryimportant.Thesystemhasadoptedmeasuressuchascurrentsmoothing,deburringandshielding.Currentsmoothing:BecausetheinstantaneousenergyofthePWMswitchisrelativelylarge,theRCfilterisusedattheoutputofthePWMpoweramplifiertofilter.Byselectingtheappropriateresistanceandcapacitancevalues,high-frequencyharmonicsareeffectivelysuppressedandthepeakvoltageofthePWMpoweramplifierisabsorbed.Therebyreducingtheinterference;Deburring:Thesystemincreasesthefiltercapacitoronthepowersupplyside,andusesonelargeandonesmallcapacitorinparallel.Thelargecapacitorisresponsibleforthedecoupling,filtering,andsmoothingoflow-frequencyalternatingsignals,andthesmallcapacitoreliminatesmid-andhigh-frequencyparasiticscouplinginthecircuitnetwork,whicheffectivelyreducesspikesandburrs;Shielding:Themotordrivecableadoptsdouble-shieldedcables,andthewiringshouldbeseparatedfromothercablesasmuchaspossible.Figure4DrivehardwarecircuitdiagramIV.ControlsystemsoftwarerealizationThecontrolsystemadoptsthespeed-positionclosed-loopcombinationmethod,takingthepositioncontrolmethodasanexampletointroducetherealizationmethodofthesoftware.ThepositioncontrolisbasedontheclassicPIcontrolalgorithm,andtheproportionalandintegralparametersaresimplifieddesign,andthesegmentedPIcontrolisintroduced.,Thatis,thecalculatederrorisdividedintosections,anddifferentproportionalandintegralparametersparticipateintheadjustmentwithintheerrorrangeofeachsection,whichensuresthesmootherandmorestableoperationofthesystem.ThederivationandsimplificationprocessofPIformulaisasfollows:ThespecificsoftwareimplementationflowchartisshowninFigure5.Thatis,afterreceivingagivenanglecommand,firstcalculatethedifferencebetweenthesampledpositioninformationandthegivenangle,andthendividethedifferenceintonequalparts,andeachsegmentcorrespondstoasetofparametersKp1andki1participateinmediationcontrol,calculatetheoutputofPIcontrolandthenconvertitintothecorrespondingPWMnumericaloutput.Figure5ThespecificsoftwareimplementationflowchartV.ConclusionThisarticlesumsupthedesignschemeoftheDCmotorPWMcontrolsystembasedon80C196KCandL298N.Thesingle-chipmicrocomputergeneratesPWMsignaltothepowerintegratedcircuitL298N.TheclassicPIsegmentcontrolisusedtocontrolthemotor.Ithasthecharacteristicsofsimplecircuitandconvenientcontrol.Theoperatingtestresultsshowthatthesystemworksstablyandreliably,meetstherequirementsofthespeedregulationfunction,andhasbeensuccessfullyappliedtomanyairborneproducts.FAQWhatisl298n?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Whatistheuseofl298n?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoesl298ncontrolDCmotorspeed?1.IfyousendaHIGHsignaltotheenable1pin,motorAisreadytobecontrolledandatthemaximumspeed;2.IfyousendaLOWsignaltotheenable1pin,motorAturnsoff;3.IfyousendaPWMsignal,youcancontrolthespeedofthemotor.Themotorspeedisproportionaltothedutycycle.Whatisl298nmotordrivermodule?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Howdoesl298nmotordriverwork?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoiuseal298motordriverwithArduino?Startbyconnectingpowersupplytothemotors.InourexperimentweareusingDCGearboxMotors(alsoknownasTTmotors)thatareusuallyfoundintwo-wheel-driverobots.Theyareratedfor3to12V.So,wewillconnectexternal12VpowersupplytotheVCCterminal.WhatisthefunctionofHbridge?AnH-bridgeisanelectroniccircuitthatswitchesthepolarityofavoltageappliedtoaload.ThesecircuitsareoftenusedinroboticsandotherapplicationstoallowDCmotorstorunforwardsorbackwards.Whatisthedifferencebetweenl293dandl298n?L293isquadruplehalf-HdriverwhileL298isdualfull-Hdriver,i.e,inL293allfourinput-outputlinesareindependentwhileinL298,ahalfHdrivercannotbeusedindependently,onlyfullHdriverhastobeused....Hence,heatsinkisprovidedinL298.IDescriptionDS18B20isawidelyuseddigitaltemperaturesensor,anditsoutputisadigitalsignal.DS18B20hasthecharacteristicsofsmallsize,lowhardwareoverhead,stronganti-interferenceabilityandhighprecision.TheDS18B20digitaltemperaturesensoriseasytowireandcanbeusedinmanyoccasionsafterbeingpackaged.Suchaspipe,thread,magnetadsorption,stainlesssteelpackageandsoon.ThisArduinoforbeginnerstutorialwillteachyouhowtoreadtheDS18B201-wiretemperaturesensor.CatalogIDescriptionIIIntroductiontoDS18B202.1DS18B20BasicInformation2.2DS18B20Features2.3DS18B20StructureIIIIntroductiontoComponents3.1Memory3.264-bitLithographyROM3.3ConnectionofExternalPowerSupply3.4ConfigurationRegister3.5TemperatureReadingIVDS18B20WorkingPrincipleVConclusionFAQOrdering&QuantityIIIntroductiontoDS18B202.1DS18B20BasicInformationDS18B20isanimprovedintelligenttemperaturesensornewlylaunchedbyAmericanDALLASSemiconductorafterDS1820.Comparedwiththetraditionalthermistor,DS18B20candirectlyreadthemeasuredtemperatureandcanrealizethe9-12-digitdigitalvaluereadingmodethroughsimpleprogrammingaccordingtoactualrequirements.Itcanalsocomplete9-bitand12-bitdigitalquantitiesin93.75msand750ms,respectively.Moreover,theinformationreadfromtheDS18B20ortheinformationwrittenintotheDS18B20onlyneedsoneportline(single-wireinterface)toreadandwrite,andthetemperatureconversionpowercomesfromthedatabus.ThebusitselfcanalsosupplypowertotheconnectedDS18B20withouttheneedforanadditionalpowersupply.Therefore,theuseofDS18B20canmakethesystemstructuresimplerandmorereliable.DS18B20hasgreatlyimprovedcomparedwithDS1820intermsoftemperaturemeasurementaccuracy,conversiontime,transmissiondistance,andresolution.Itbringsmoreconvenientuseandmoresatisfyingeffectstousers.2.2DS18B20FeaturesUnique1-WireInterfaceRequiresOnlyOnePortPinforCommunicationReduceComponentCountwithIntegratedTemperatureSensorandEEPROMMeasuresTemperaturesfrom-55Cto+125C(-67Fto+257F)0.5CAccuracyfrom-10Cto+85CProgrammableResolutionfrom9Bitsto12BitsNoExternalComponentsRequiredParasiticPowerModeRequiresOnly2PinsforOperation(DQandGND)SimplifiesDistributedTemperature-SensingApplicationswithMultidropCapabilityEachDeviceHasaUnique64-BitSerialCodeStoredinOn-BoardROMFlexibleUser-DefinableNonvolatile(NV)AlarmSettingswithAlarmSearchCommandIdentifiesDeviceswithTemperaturesOutsideProgrammedLimitsAvailablein8-PinSO(150mils),8-PinSOP,and3-PinTO-92Packages2.3DS18B20StructureTheexternalstructureofDS18B20isshowninthefigure1.Amongthem:VDDisthepowerinputterminal;DQisthedigitalsignalinput/outputterminal;GNDisthepowerground.Figure1.DS18B20ExternalStructureTheinternalstructureofDS18B20mainlyincludes4parts:64-bitlithographyROM;Temperaturesensor;Non-volatiletemperaturealarmtriggersTHandTL;Configurationregister.Figure2.DS18B20ExternalStructureInthe64-bitROM,themanufacturerhasa64-bitserialnumberburnedbythemanufacturerbeforetheproductleavesthefactory.TheserialnumbercanberegardedastheaddressserialcodeofDS18B20,usedtodistinguisheachDS18B20.Soastobetterrealizethemulti-pointmeasurementoffieldtemperature.IIIIntroductiontoComponents3.1MemoryThememoryofDS18B20includeshigh-speedscratchpadRAMandelectricallyerasableRAM.TheelectricallyerasableRAMalsoincludestemperaturetriggersTHandTL,andaconfigurationregister.Thememorycancompletelydeterminethecommunicationoftheone-lineport,andthenumberiswrittenintotheregisterwiththecommandofwritingtheregister.Thenyoucanusethereadregistercommandtoconfirmthesenumbers.Afterconfirmation,youcanusethecopyregistercommandtotransferthesenumberstotheelectricallyerasableRAM.Whenthenumberintheregisterismodified,thisprocesscanensuretheintegrityofthenumber.ThescratchpadRAMiscomposedof8bytesofmemory.Theninthbytecanbereadwiththereadregistercommand.Thisbyteistocheckthepreviouseightbytes.3.264-bitLithographyROMFor64-bitlithographyROM:Thefirst8bitsaretheowncodeofDS18B20Thenext48bitsareconsecutivedigitalcodesThelast8bitsaretheCRCcheckofthefirst56bits.The64-bitlithographyROMalsoincludes5ROMfunctioncommands:readROM,matchROM,skipROM,searchROMandalarmsearch.3.3ConnectionofExternalPowerSupplyDS18B20canuseexternalpowerVDDorinternalparasiticpower.WhentheVDDportisconnectedtoavoltageof3.0V-5.5V,anexternalpowersupplyisused.AninternalparasiticpowersupplyisusedwhentheVDDportisgrounded.Inaddition,whetheritisaninternalparasiticpowersupplyoranexternalpowersupply,theI/Oportlineshouldbeconnectedtoapull-upresistorofabout5K.3.4ConfigurationRegisterTheconfigurationregisteristoconfiguredifferentdigitstodeterminethetemperatureanddigitalconversion.ItcanbeknownthatR1andR0arethedeterminingbitsoftemperature.DifferentcombinationsofR1andR0canbeconfiguredas9-digit,10-digit,11-digit,and12-digittemperaturedisplay.Inthisway,theconversiontimecorrespondingtodifferenttemperatureconversionpositionscanbeknown.Theresolutionsofthefourconfigurationsare0.5C,0.25C,0.125Cand0.0625C,respectively,andareconfiguredto12bitsatthefactory.3.5TemperatureReadingDS18B20isconfiguredas12bitsatthefactory,and16bitsarereadwhenreadingtemperature.Thefirst5bitsaresignbits.Whenthefirst5digitsare1,thetemperaturereadisanegativenumber;whenthecurrent5digitsare0,thetemperaturereadisapositivenumber.Themethodofreadingwhenthetemperatureispositiveis:justconvertthehexadecimalnumbertodecimal.Whenthetemperatureisnegative,thereadingmethodis:invertthehexadecimalnumber,thenadd1onthisbasis,andthenconverttodecimal.Example:0550H=+85degrees,FC90H=-55degrees.IVDS18B20WorkingPrincipleThereadandwritesequenceandtemperaturemeasurementprincipleofDS18B20arethesameasDS1820.Onlythenumberofdigitsofthetemperaturevalueobtainedvarieswiththeresolution.Andthedelaytimeduringtemperatureconversionisreducedfrom2sto750ms.ThetemperaturemeasurementprincipleofDS18B20isshowninFigure3.Figure3.DS18B20TemperatureMeasurementPrincipleDiagramTheoscillationfrequencyofthecrystaloscillatorwithlowtemperaturecoefficientinthepictureislittleaffectedbytemperature.Itisusedtogenerateafixedfrequencypulsesignalandsendittothesubtractioncounter1.Thehightemperaturecoefficientcrystaloscillatorchangesitsoscillationfrequencysignificantlywithtemperaturechanges.Atthesametime,thegeneratedsignalisusedasthepulseinputofthesubtractioncounter2.Thefigurealsoimpliesacountinggate.Whenthecountinggateisopened,DS18B20countstheclockpulsesgeneratedbythelowtemperaturecoefficientoscillatortocompletethetemperaturemeasurement.Theopeningtimeofthecountinggateisdeterminedbythehightemperaturecoefficientoscillator.Beforeeachmeasurement,firstputthebasecorrespondingto-55℃intothesubtractioncounter1andthetemperatureregisterrespectively.Thesubtractioncounter1andthetemperatureregisterarepresettoabasevaluecorrespondingto-55℃.Thesubtractioncounter1subtractsthepulsesignalgeneratedbythelowtemperaturecoefficientcrystaloscillator.Whenthepresetvalueofthesubtractioncounter1isreducedto0,thevalueofthetemperatureregisterwillincreaseby1,thepresetofthesubtractioncounter1willbereloaded,andthesubtractioncounter1willrestartcountingthepulsesignalsgeneratedbythelowtemperaturecoefficientcrystaloscillator.Thisloopuntilthesubtractioncounter2countsto0,stoptheaccumulationofthetemperatureregistervalue.Thevalueinthetemperatureregisteristhemeasuredtemperatureatthistime.Figure4.DS18B20Theslopeaccumulatorisusedtocompensateandcorrectthenonlinearityinthetemperaturemeasurementprocess,anditsoutputisusedtocorrectthepresetvalueofthesubtractioncounter.Aslongasthecountinggateisnotclosed,repeattheaboveprocessuntilthetemperatureregistervaluereachesthemeasuredtemperaturevalue.ThisisthetemperaturemeasurementprincipleofDS18B20.Inaddition,becausetheDS18B20single-wirecommunicationfunctioniscompletedintimesharing,ithasastrictconceptoftimeslots.Therefore,thereadandwritetimingisveryimportant.VariousoperationsofthesystemtoDS18B20mustbecarriedoutaccordingtotheagreement.Theoperatingprotocolis:initializeDS18B20(sendresetpulse)sendROMfunctioncommandsendmemoryoperationcommandprocessdata.ThetimingdiagramofvariousoperationsisthesameasthatofDS1820.VConclusionInconclusion,thisblogsummarizesthefollowing3aspectsofDS1820:Features,structureandworkingprinciple.DS1820mainlychangesitsappearanceaccordingtodifferentapplications.ThepackagedDS18B20canbeusedinvariousnon-limitingtemperatureapplications.Includingcabletrenchtemperaturemeasurement,blastfurnacewatercirculationtemperaturemeasurement,boilertemperaturemeasurement,machineroomtemperaturemeasurement,agriculturalgreenhousetemperaturemeasurement,cleanroomtemperaturemeasurement,ammunitionstoragetemperaturemeasurement,etc.Inaddition,DS1820isabrasion-resistantandimpact-resistant,smallinsize,easytouse,anddiverseinpackaging,suitablefordigitaltemperaturemeasurementandcontrolofvariousnarrowspaceequipment.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)?

ARRAY4

IDescriptionInthisblog,wewillintroduceamultifunctionalelectronicthermometer.Thiskindofthermometercannotonlyaccuratelyandconvenientlymeasurebodytemperatureandfoodtemperature,butalsocanbeusedtomeasureindoorandoutdoortemperature,refrigeratortemperature,etc.Inaddition,italsohasmultiplefunctionssuchastemperaturemeasurementtiming,temperaturememory,soundprompt,backlightdisplay,andautomaticshutdown.Moreover,ithasthecharacteristicsofaccuratemeasurement,simpleoperation,portabilityandlowprice.Therefore,itcanbewidelyusedinhospitalsandhomesasageneraltemperaturemeasuringinstrument.Intermsofitsworkingprinciple,thethermometerusesthedigitaltemperaturesensorDS18B20todetecttemperatureandtransmitsthedigitaltemperaturesignaltothesingle-chipmicrocomputer.Thetemperaturevalueandmeasurementtimecalculatedandcorrectedbythesingle-chipmicrocomputeraredisplayedinrealtimebytheliquidcrystaldisplay.AtutorialonhowtousetheDallasMaxim1-WireDS18B20digitaltemperaturesensorwiththeArduino.CatalogIDescriptionIIDS18B20IntroductionIIIHardwareCircuit3.1PowerCircuit3.2DigitalTemperatureSensorandCalibration3.3MCUCircuit3.4LCDDisplay3.5AudioCircuitIVSoftwareDesignVConclusionFAQOrdering&QuantityIIDS18B20IntroductionDS18B20isasingle-wiredigitaltemperaturesensorproducedbyDALLAS.Itintegratestemperaturesensing,signalconversion,A/Dconversionandheatingfunctionsintoonechip,andbelongstoanewgenerationofintelligentdigitaltemperaturesensorswithmicroprocessors.DS18B20hasatotalof3pins,(respectivelydigitalsignalinput/output,ground,powersupply),usingTO-92small-volumepackaging.DS18B20MainSpecifications:Thetemperaturemeasurementrangeis-55℃~+125℃;Programmableto9to12bitA/Dconversionaccuracy;Thetemperaturemeasurementresolutioncanreach0.0625℃,andtheerroris0.5℃;Theworkingpowersupplycanbeintroducedattheremoteend(3-wireworkingmode)orgeneratedbyparasiticpowersupply(2-wireworkingmode);Themeasuredtemperatureisseriallyoutputwithasign-extended16-bitdigitalquantity;Eachsensorhasaunique64-bitserialnumber,whichisstoredintheROMofthesensor;Thesensoralsohastwotemperatureupperandlowerlimitstorageunits.IIIHardwareCircuitThemultifunctionalelectronicthermometerismainlycomposedofthefollowingparts:PowercircuitDigitaltemperaturesensorSinglechipcomputerLCDMonitorAudiocircuit...ItshardwarecircuitschematicdiagramisshownasinFig.1.Figure1.HardwareCircuit(rightclicktoviewbigpicture)3.1PowerCircuitU1isthemicropowerconsumptionstep-downDC/DCconverterLT3470introducedbyLinearTechnology.Here,U1convertsthe9Vdrybatteryvoltageinto5VDCvoltagetopowertheentirecircuit.So,howtostartandshutdownautomatically?WeonlyneedtopressthestartbuttonS2.Afterstarting,pin1(SHDN)ofU1getsahighlevel,pin5ofU1outputsa5VstableDCvoltage,andthethermometerstartstoworkatthistime.Then,the14-pin(P1.2)oftheone-chipcomputeroutputsahighlevelthroughD2tokeepthe1pinofU1high.When6minutesareup,the14-pinofthesingle-chipmicrocomputeroutputsalowlevel,andthe1pinofU1becomesalowlevel,andthecircuitautomaticallypowersdown.3.2DigitalTemperatureSensorandCalibrationThedigitaltemperaturesensorDS18B20isusedasatemperaturemeasuringprobetocollecttemperaturesignals.Andthedigitizedtemperaturesignalisinputthroughthe19-pin(P1.7)ofthemicrocontroller.DS18B20adopts2-wireworkingmode,andtheworkingpowerisgeneratedbyparasiticpower.Forexample,usethisthermometertomeasurethetemperatureofababy.Wecanfixthetemperatureprobeonaspecialbandageandtieittothearm.Sothatthesensorislocatedunderthearmpit.Inthisway,itcanbeavoidedthatthetemperaturemeasuringprobeisdetachedfromthetestsite.Duetoinfantactivitiesorcryingwhenmeasuringthebodytemperatureoftheinfant,andthemeasurementisconvenient.Foranotherexample,thetemperatureprobecanalsomeasureindoorandoutdoortemperature,refrigeratortemperature,etc.Thespecialprobeformeasuringfoodtemperatureadoptsnon-toxicstrawandnon-toxicsilicagelpackage,whichiseasytoclean.SinceDS18B20isintherangeof-10℃~85℃,itsmeasurementerroris0.5℃.Inordertoaccuratelymeasurebodytemperature,thisblogusesaself-madeconstanttemperaturewaterbathsystemtodeterminethetemperaturecurveofeachsensor.WecancalibratetheDS18B20accordingtothetemperaturecurvetomakethemeasurementerrorwithintherangeof25℃~50℃be0.1℃.3.2.1ConstantTemperatureWaterBathSystemTheconstanttemperaturewaterbathsystemconsistsofthefollowingthreeparts:anelectriccookerwithheatpreservation,acylindricalcopperbodywithgoodheatconduction,andanautomatictemperaturecontroller.Weneedtomake50roundholeswithadiameterof5mmandaheightof30mmonacylindricalcopperbodywithadiameterof120mmandaheightof80mm.Inthisway,thetemperaturesensorcanbefixedandthetemperatureofallthesensorsinthecopperbodycanbekeptconsistent.Putthecylindricalcopperbodyintotheelectriccooker,andadddistilledwatertosubmergethecopperbody.3.2.2DS18B20ActualTemperatureCurveMeasurementInsertmultipleencapsulatedsensorstobetested(nomorethan49)intothesmallholesofthecopperbodyoftheconstanttemperaturewaterbath;Insertthehigh-precisiondigitalthermometerintothesmallholeofthecopperbodytoaccuratelymeasurethecurrenttemperature;Thewiresofallsensorsareledoutthroughtheuppercoverholeoftheelectriccookerandconnectedtotheuppercomputer.Covertheelectriccookerwithheatpreservationmaterial;Turnonthepower,changethetemperaturesettingoftheautomaticthermostat,andcontrolthetemperatureoftheconstanttemperaturewaterbath;Monitorthetemperaturevalueofthedigitalthermometer.Wheneverthespecifiedtemperaturevalueisreached,starttheuppercomputertemperaturemeasurementprogramandsimultaneouslymeasurethecurrenttemperatureofallthesensorstobetested;From25℃~60℃,measure1setofdataevery5℃,andautomaticallygeneratetheactualtemperaturecurveofeachsensor.3.2.3CorrectionofDS18B20Byanalyzingthemeasuredtemperaturecurveofthesensor,wecanfindthatwithintherangeof25℃~50℃,theerroris-0.1℃~-0.3℃.Inthedesignofthisblog,thecurrenttemperaturevalueofDS18B20plus0.2℃isusedastheactualmeasuredtemperature,sothatthemeasurementerrorintherangeof25℃~50℃isreducedto0.1℃.3.3MCUCircuitThemicrocontroller(U2)isthecorecomponentofthethermometer.Ithasthefollowingfunctions:Temperaturesignalreading,processingcalculation,correctionTemperaturemeasurementtimingTemperaturememorySoundprompt,Automaticshutdown...ThisdesignadoptsAT89C2051single-chipmicrocomputerproducedbyAmericanATMELcompany.Itisabuilt-inflashmemorymicrocontrollerthatisfullycompatiblewiththeMCS-51series,withonly20pins.Itisthemostcompact,smallest,andcheapestFlashROMmicrocontrollerintheAT89C51series.Providesthefollowingstandardfunctions:An8-bitCPU;2kBflashmemory;128bytesRAM;Two16-bittimers;Acomplete8-bitbidirectionalI/Oport;5interruptsources.Afterstartingthethermometer,themicrocontrollerstartsaninternaltimertorecordthetemperaturemeasurementtime.ItalsoreadsthedigitaltemperaturesignalsentbyDS18B20,processesandcorrectsittoobtainthereal-timetemperaturevalue.ThetemperaturevalueandtemperaturemeasurementtimearesenttotheLCDdisplayviaserialcommunicationviapin1(P3.0)andpin2(P3.1);Whenthetemperaturemeasurementtimereaches5minutes,thecurrenttemperaturevalueisautomaticallyregistered,andpin11outputsalowleveltocontroltheaudiocircuittogiveasoundprompt;Whenthetemperaturemeasurementtimereaches6minutes,thesingle-chip14pinoutputslowlevel,andthethermometerisautomaticallypoweredoff.3.4LCDDisplayThisblogusesa3andahalfliquidcrystaldisplay(LCD)todisplaytemperatureandtemperaturemeasurementtime.Thedisplayhasthefollowingcharacteristics:Useglassencapsulation;Thereare5pinsintotal;SerialcommunicationWith3andahalfdisplayareaand℃unitdisplay;Functionwithbacklight;Thepowersupplyvoltagerangeis2V~5V.Thisdesignusesthemaindisplayareatoindicatethetemperature,andthesub-displayareatoindicatethetemperaturemeasurementtime.3.5AudioCircuitTheaudiocircuitconsistsofthefollowingparts:TransistorQ2(9015)resistanceR12;CapacitanceC12;BuzzerB1;Whenthepin11ofthesingle-chipmicrocomputeroutputslowlevel,thetransistorQ2issaturatedandturnedon,andthebuzzergeneratesanaudibleprompt.IVSoftwareDesignTheprogramiswrittenin89C51seriesClanguageanddebuggedonthesingle-chipsimulationsystem.TheprogramflowchartisshowninFigure2.Figure2.BlockDiagramofMainProgramAfterpower-onreset,initializetheDS18B20,inputandoutputports,timers,etc.ReadthetemperaturevalueofthelastmeasurementandstoragefromthelowertemperaturelimitstorageunitofDS18B20anddisplayitfor3seconds.StarttheinternaltimerT0ofthemicrocontrollertorecordthetemperaturemeasurementtime.Obtainthetemperaturevalueandcorrecttheerror.AccordingtothecommunicationprotocolofDS18B20,thetemperaturesignalisreadfromthesensor,thesignisdistinguished,andthetemperaturevalueisobtainedaftercalculationandprocessing.Then,add0.2Ctothetemperaturevalueastheactualtemperature,andcorrectthemeasurementerrorwithintherangeof25Cto50Cto0.1C.Displayoftemperature.Accordingtothecommunicationprotocoloftheliquidcrystaldisplay,thetemperaturevalueandtemperaturemeasurementtimearesenttothedisplayfordisplay.Themaindisplayareaindicatesthetemperature,andthesecondarydisplayareaindicatesthetemperaturemeasurementtime.Whenthetemperaturemeasurementtimereaches5minutes,the11-pinofthesingle-chipmicrocomputeroutputsalow-levelcontrolaudiocircuittoemitapromptsound,andthecurrenttemperatureissenttothelowertemperaturestorageunitofDS18B20forregistration,andsenttothesecondarydisplayareafordisplay.Whenthetemperaturemeasurementtimereaches6minutes,the14-pinofthesingle-chipmicrocomputeroutputslowlevel,andthethermometerautomaticallypowersdown.VConclusionComparedwithtraditionalthermometers,theDS18B20Multi-functionElectronicThermometerdesignedinthisbloghasmanyadvantages.Thelatterovercomesthedifficultyofreadingmercurythermometersandiseasytobebrokenandpollutetheenvironment.Atthesametime,comparedwithsimpleelectronicthermometers,multifunctionalelectronicthermometersalsoovercometheshortcomingsofpoormeasurementaccuracy.Becauseofitscompletefunctions,stableperformance,smallsize,lightweight,lowpowerconsumption,andlowprice,itcanbeusedasageneraltemperaturemeasuringinstrumentandwidelyusedinhospitalsandhomes.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)?DescriptionDS18B20isatemperaturesensorofMaxim.Thesingle-chipmicrocomputercancommunicatewithDS18B20through1-Wireprotocolandfinallyreadthetemperature.Thehardwareinterfaceofthe1-Wirebusisverysimple,justconnectthedatapinofDS18B20toanIOportofthemicrocontroller.ThisVideoIntroducesDS18B20withDatasheetCatalogDescriptionDocumentandMediaDS18B20PinoutParametersAdvantageFeaturesApplicationsDS18B20CircuitSchematicDS18B20TemperatureSensorDataDS18B20BlockDiagramHowtousetheDS18B20SensorWheretouseDS18B20SensorProductManufacturerFAQOrdering&QuantityDocumentandMediaComponentDatasheetDS18B20DatasheetDS18B20PinoutPinNameFunctionSOSOPTO-921,2,6,7,82,3,5,6,7-N.C.NoConnection383VDDOptionalVDD.VDDmustbegroundedforoperationinparasitepowermode.412DQDataInput/Output.Open-drain1-Wireinterfacepin.Alsoprovidespowertothedevicewhenusedinparasitepowermode(seethePoweringtheDS18B20section.)541GNDGroundParametersAccuracy(C)0.5ChannelsOneInterface1-WireMultiDroppableYesOper.Temp.(C)-55to+125Package/PinsSOIC(N)/8,TO92/3,UMAX/8ParasitePwr.YesPartNumberDS18B20SensorTypeLocalTemp.Resolution(bits)9,10,11,12Temp.Thresh.Programmable(NV)AdvantageTheDS18B20digitalthermometerprovides9-bitto12-bitCelsiustemperaturemeasurementsandhasanalarmfunctionwithnonvolatileuser-programmableupperandlowertriggerpoints.TheDS18B20communicatesovera1-Wirebusthatbydefinitionrequiresonlyonedataline(andground)forcommunicationwithacentralmicroprocessor.Inaddition,theDS18B20canderivepowerdirectlyfromthedataline(parasitepower),eliminatingtheneedforanexternalpowersupply.EachDS18B20hasaunique64-bitserialcode,whichallowsmultipleDS18B20stofunctiononthesame1-Wirebus.Thus,itissimpletouseonemicroprocessortocontrolmanyDS18B20sdistributedoveralargearea.ApplicationsthatcanbenefitfromthisfeatureincludeHVACenvironmentalcontrols,temperaturemonitoringsystemsinsidebuildings,equipment,ormachinery,andprocessmonitoringandcontrolsystems.FeaturesUnique1-WireInterfaceRequiresOnlyOnePortPinforCommunicationReduceComponentCountwithIntegratedTemperatureSensorandEEPROMMeasuresTemperaturesfrom-55Cto+125C(-67Fto+257F)0.5CAccuracyfrom-10Cto+85CProgrammableResolutionfrom9Bitsto12BitsNoExternalComponentsRequiredParasiticPowerModeRequiresOnly2PinsforOperation(DQandGND)SimplifiesDistributedTemperature-SensingApplicationswithMultidropCapabilityEachDeviceHasaUnique64-BitSerialCodeStoredinOn-BoardROMFlexibleUser-DefinableNonvolatile(NV)AlarmSettingswithAlarmSearchCommandIdentifiesDeviceswithTemperaturesOutsideProgrammedLimitsAvailablein8-PinSO(150mils),8-PinSOP,and3-PinTO-92PackagesApplicationsConsumerProductsIndustrialSystemsThermallySensitiveSystemsThermometersThermostaticControlsDS18B20CircuitSchematicDS18B20TemperatureSensorDataDS18B20canachievethehighest12-bittemperaturestoragevaluethroughprogramming.Thetemperaturestoragevalueisstoredintheregisterinacomplementformat.Thereare2bytesintotal,LSBisthelowbyteandMSBisthehighbyte.Amongthem,MSbisthehighbitofthebyte,andLSbisthelowbitofthebyte.Forbinarynumbers,themeaningofthetemperaturerepresentedbyeachofthemisexpressed.Amongthem,Srepresentsthesignbit,andthelower11bitsareallpowersof2,whichareusedtorepresentthefinaltemperature.ThetemperaturemeasurementrangeofDS18B20isfrom-55degreesto+125degrees.Themanifestationoftemperaturedatahaspositiveandnegativetemperatures.Eachnumberintheregisterisdistributedlikethescaleofacaliper.Thelowestbitofthebinarynumberchanges1,whichrepresentsthemappingrelationshipofatemperaturechangeof0.0625degrees.Whenthetemperatureis0℃,thecorrespondinghexadecimalnumberis0x0000.Whenthetemperatureis125℃,thecorrespondinghexadecimalnumberis0x07D0.Whenthetemperatureisminus55℃,thecorrespondinghexadecimalnumberis0xFC90.Conversely,whenthenumberis0x0001,thetemperatureis0.0625℃.DS18B20BlockDiagramHowtousetheDS18B20SensorThesensorworkswiththemethodof1-Wirecommunication.Itrequiresonlythedatapinconnectedtothemicrocontrollerwithapullupresistorandtheothertwopinsareusedforpowerasshownbelow.Thepull-upresistorisusedtokeepthelineinhighstatewhenthebusisnotinuse.Thetemperaturevaluemeasuredbythesensorwillbestoredina2-byteregisterinsidethesensor.Thisdatacanbereadbytheusingthe1-wiremethodbysendinginasequenceofdata.Therearetwotypesofcommandsthataretobesenttoreadthevalues,oneisaROMcommandandtheotherisfunctioncommand.TheaddressvalueofeachROMmemoryalongwiththesequenceisgiveninthedatasheetbelow.Youhavetoreadthroughittounderstandhowtocommunicatewiththesensor.IfyouareplanningtointerfaceitwithArduino,thenyouneednotworryaboutallthese.Youcandevelopthereadilyavailablelibraryandusethein-builtfunctionstoaccessthedata.WheretouseDS18B20SensorTheDS18B20isa1-wireprogrammableTemperaturesensorfrommaximintegrated.Itiswidelyusedtomeasuretemperatureinhardenvironmentslikeinchemicalsolutions,minesorsoiletc.Theconstrictionofthesensorisruggedandalsocanbepurchasedwithawaterproofoptionmakingthemountingprocesseasy.Itcanmeasureawiderangeoftemperaturefrom-55Cto+125withadecentaccuracyof5C.EachsensorhasauniqueaddressandrequiresonlyonepinoftheMCUtotransferdatasoitaverygoodchoiceformeasuringtemperatureatmultiplepointswithoutcompromisingmuchofyourdigitalpinsonthemicrocontroller.ProductManufacturerMaximIntegratedprovideseaseofdesign,andspeedstimetomarket,throughanalogintegration.ThecompanysanalogICsofferextrafeaturesandfunctionalitycarefullydesignedtostreamlinecircuitandsimplifydesign.LooktoMaximforsolutionsforconsumerelectronics,personalcomputersandperipherals,mobiledevices,wirelessandfibercommunications,testequipment,instrumentation,videodisplays,andautomotiveapplications.Maximsanalogandmixed-signalsolutionsincludedataconverters,interfacecircuits,power,RFwirelesscircuits,clocksandoscillators,microcontrollers(MCUs),operationalamplifiers(opamps),andsensors.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)?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)?

ARRAY4

IDescriptionThisblogintroducesandanalyzes4simpleandeasy74LS00NandGatecircuitdiagrams.Itsincluding:SquareWaveGeneratorCircuit,PulseGeneratorCircuit,LEDLightCircuit.Andintheend,wewillanalyzethecircuitthatturnsthetimerintoacountdowntimerindetail.ThisVideoisAnIntroductionof7400LogicDevicesCatalogIDescriptionIISquareWaveGeneratorCircuitIIIPulseGeneratorCircuitIVLEDLightCircuitVTurnTimerintoCountdownTimer5.1SchemeDesign5.2ImplementationofSchemeDesignOrdering&QuantityIISquareWaveGeneratorCircuitLetstakealookatthefigurebelow.Itsasquarewavegeneratorcircuit.Thiscircuitcontainsa74LS00NandGateintegratedcircuit.Figure1.SquareWaveGeneratorCircuitDiagramAmongthiscircuitdiagram:NANDgates1,2andexternalRCtimeconstantcomponentsformanoscillatorcircuitNANDgate3isabufferoutputstage.AslongasthecapacityofCischanged,squarewaveoutputsofdifferentfrequenciescanbeobtained.IIIPulseGeneratorCircuitFigure2.PulseSignalGeneratorCircuitDiagramThecircuitdiagramisshowninFigure2anditsasimplepulsesignalgeneratorcircuit.ThesignalgeneratormainlyusestwoTTLintegratedcircuits(74LS00and74LS221).Sowhychoosethesetwocircuits?Thatisbecause,thesetwocircuitscanbeusedtogenerateapulsesignalof=4s.Besides,itusesfewercomponentsandisconvenientfordebuggingandmaintenance.IVLEDLightCircuitThiscircuitismadewithNE555,74LS00,74LS154,74LS193andLEDlights,andtheproductionprocessisverysimple.Whenweturnonthepower,hereishowitworksis:WhentheoutputQ0ofthe74LS154decoderislow,the74LS193isapositivecounter.Atthistime,theLEDsareindividuallylitfromD1...D16;WhentheoutputQ15ofthe74LS154decoderislow,the74LS193isacountdowncounter.Atthistime,theLEDsareindividuallylitfromD16...D1.Figure3.LEDLightCircuitDiagramFromtheabovewecanseethat:theLEDlightsturnonfromD1toD16,andthenbacktoD1fromD16,andsoon.VTurnTimerintoCountdownTimerGenerally,therearetwodesignideasforturningatimerintoacountdowntimer:First,changethecountingchipinthetimer;Second,resetthefunctionofthechip.Besides,thereisactuallyanotherwaytoachievethisgoal:Byappliyingthe74LS00and74LS20chipstoreversetheresultsonthedisplay,soastoachievethepurposeofcountingdown.5.1SchemeDesignTheresultdisplayedbyeachdigitofthetimerisanincrementalvalue,suchas0.1.2.3.4.5.6.7.8.9.Yet,thecountdowntimerdisplaysadecreasingvalue,suchas9.8.7.6.5.4.3.2.1.0.Aslongasthedisplayresultconversioniscompletedwithasuitablelogiccircuit,thetimercanbeturnedintoacountdowntimer.Atfirst,weneedtofindthelogicalrelationshipbetweenthetimerdisplayresultandthecountdowntimerdisplayresult.Table1belowliststheBCDcodescorrespondingtoeachdisplayresultofthetimerandcountdowntimer.Fromthistable,youcaneasilyfindtheBCDcodesofthetimerandcountdowntimer:ThelowestbitQ1andY1areopposite;WhileQ2andY2arethesame;RelationshipbetweenQ3andY3:Y3ofthecountdowntimeristheexclusiveORoftimerQ3andQ2;RelationshipbetweenQ4andY4:TheY4bitofthecountdowntimeristheoppositevalueoftheORofQ4,Q3,andQ2ofthetimer,whichisalsoequaltothenon-re-ANDofQ4,Q3,andQ2.Table1.CorrespondingBCDCodeDisplayedby(Down)TimerTheabovelogicalexpressionis:Therefore,aslongasyouchooseacircuitthatcancompletetheabovelogicconversionrelationship,youcanrealizethedesignfromatimertoacountdowntimer.Thefigure?showsatwo-digittimercircuit.Afteraddingtheaboveconversioncircuit,itbecomesthefigure3showsthecountdowncircuit.Figure4.TimerCircuitDisplaying2DigitsFigure5.CountdownCircuitDiagram5.2ImplementationofSchemeDesignTwokindsofchips74LS00and74LS20areuesdhere.Theformerarefourtwo-inputNANDgates,whichareusedtocompletetheconversionofY1andgeneratethenegationofQ4,Q3,andQ2.Thelatteraretwofour-inputNANDgates,whichareusedtoobtainY4fromthenon-reANDofQ4,Q3,andQ2.Insummary,wecanfollowthelogicalrelationshipasfollows:ThelogicdiagramisshowninFigure6.Figure6.LogicDiagramKnowingthattheXORgateoperationcanbecompleted,theY3conversioncanbecompleted.Theconnectioncircuitdiagramoftheabove-mentionedY4,Y3,Y1conversionspecificphysicalobjectsisshowninFigure7.Figure7.Y4,Y3,Y1ConversionSpecificPhysicalConnectionDiagramFigure8showstheactualpictureofthecountdowntimer.Figure8.CountdownTimerSofar,thetimerhasbecomeacountdowntimer.Throughthisdesignmethod,thereisnoneedtochangetheoriginalcountercircuit,isitparticularlytrouble-free?I.IntroductionTDA7294isaveryinnovativeDMOShigh-powerintegratedamplifiercircuitlaunchedbythefamousEuropeanSGS-THOMSONSTMicroelectronicstomainlandChinainthe1990s.Itsweepsawaytheraw,cold,andhardtonesofthepreviouslinearintegratedpoweramplifiersandthickfilmintegration,andiswidelyusedintheHI-FIfield:suchashometheater,activespeakers,etc.Thedesignofthischipfocusesontone,andhastheadvantagesofbipolarsignalprocessingcircuitandpowerMOS.Ithasthecharacteristicsofhighvoltageresistance,lownoise,lowdistortion,andveryaffinityforreplayingsound;andhasasilentstandbyfunction,short-circuitcurrentandoverheatprotectionfunctionstomakeitsperformancemoreperfect.ThisarticlewillintroduceseveralpoweramplifiercircuitdesignsbasedonTDA7294.CatalogI.IntroductionII.OCLCircuitIII.BTLCircuitIV.ConstantCurrentPowerAmplifierV.Hi-FiIntegratedPowerAmplifierVI.ActiveSubwooferAmplifierAddsStandbyFunctionVII.HighFidelityPowerAmplifierVIII.ClassABPowerAmplifierIX.Two-channelPowerAmplifierX.100WPowerAmplifierCircuitOrdering&QuantityII.OCLCircuitTheOCLcircuitdiagramisshowninFigure1.Thiscircuitisadual-channel70WpoweramplifiercomposedoftwoTDA7294.Therearefewexternalcomponentsandsimplecircuit.Whenthepowersupplyvoltageis35V,70Wcontinuousoutputpowercanbeobtainedonan8ohmload.Itisverysuitableforplaybackinanenvironmentbelow30squaremeters.Ifthespeakerimpedanceislessthan8ohms,thepowersupplyvoltageshouldbereducedaccordingly.Figure1OCLCircuitDiagramIII.BTLCircuitTheBTLcircuitisshowninFigure2.ItusestwoTDA7294bridgestoformaBTLpoweramplifiercircuit.Theoutputpowercanreachmorethan150W.Itissuitableforplacesthatrequirehighpowersuchasdancehalls.4TDA7294arerequiredforstereo.Whenthepowersupplyvoltageis25V,acontinuousoutputpowerof150Wcanbeobtainedonan8ohmload.Whenthepowersupplyis35V,acontinuousoutputpowerof180Wcanbeobtainedona16ohmload.WhenuseTDA7294asBTLpoweramplifier,theloadmustnotbelessthan8ohms.Figure2BTLCircuitDiagramIV.ConstantCurrentPowerAmplifierThispoweramplifiercircuitissomewhatdifferentfromtheprevioustwostructures.Itsfeedbackcircuitiscurrentsampling,voltagesummationandnegativefeedback.Thiskindofcircuitstructureistheconstantcurrentpoweramplifierthatpeopleoftensay.Thespecificanalysisofthecircuitwillnotbedetailed,onlythemoreprominentadvantagescomparedwiththetraditionalconstantvoltagepoweramplifierwillbeintroduced.(1)Theoutputcurrentofthepoweramplifierhasnothingtodowiththeloadimpedance.Eveniftheloadisshort-circuited,itwillnotcausetheamplifiertooverheat.(2)Theoutputpowerincreaseswiththeincreaseofloadimpedance.Pushingthespeakerloadwithinacertainpowerreservecanensurethebassstrengthandhighfrequencyresolutionoftheoriginalmusicsignal.(3)Theforceactingonthevoicecoilofthespeakeronlydependsonthecurrent.Theuseoffluid-controlledoscillationtopromotethespeakermustbefasterthanthevoltage-controlledoscillation,sothattheinputandoutputimpedanceofthespeakervibrationsystemcanbeeasilymatched.Theconstantcurrentpoweramplifiercircuitisactuallyacontrolledcurrentsourcecontrolledbytheinputsignalvoltage.Itsinternalfeedbackcircuitiscurrentsampling,voltagesummingnegativefeedback,andithasthecharacteristicsofhighinputandoutputimpedance.Theinputimpedanceishigh,whichisexactlywhatthepreviousstageconstantvoltageamplifiercircuitneeds,whichisbeneficialforthesignalvoltagetobesenttotheinputendofthepoweramplifierwithoutloss.Thehighoutputimpedancecanreducetheshuntoftheinternalresistancetothesignal,whichisconducivetoaddingtheoutputsignalcurrenttotheload.InFigure3,thepowersupplyvoltageisselectedas35V,anditsmagnificationisdeterminedbytheratioofthespeakertoR6.Figure3ConstantcurrentpoweramplifiercircuitdiagramV.Hi-FiIntegratedPowerAmplifierThefamousEuropeanSGS-THOMSONSTMicroelectronicshaslaunchedaHi-Fihigh-powerDMOSintegratedamplifiercircuitTDA7294.ThecircuitisshowninFigure4.Itintegratesthebestdesignofmodernpoweramplifiercircuit,combinestheadvantagesofbipolarsignalprocessingcircuitandpowerMOS,hasthecharacteristicsoflownoiseandlowdistortion;standbyandmutecircuitcompletelyeliminatestheimpactnoisecausedbypoweronandoff,andeliminatesspeakerprotectioncircuitoverheating,short-circuitcurrentprotectionandotherfunctionsmakeitsperformancemoreexcellent.ThisdeviceissuitableforhometheaterandHi-Fiamplifiers.Themainparametersare:VS(powersupplyvoltage)10~40V(maximumvoltagewithoutsignal50V);Io(peakoutputcurrent)10A;Po(RMScontinuousoutputpower)70Wwhenvs=35V8;vs=70Wwhen27V4;(effectivevalueofmusicoutputpower)100WwhenVS=38V8;100WwhenVS=29V4.Figure4Hi-FiIntegratedPowerAmplifierCircuitDiagramTheclosed-loopgainofthecircuitinFigure4is30dB.IncreasingR3canincreasethegain,andviceversa,buttheamplifiergainshouldbe24dB.TheamplifierhasthebestperformancewhenR1=R3.R7,C4andR5+R6,C3determinethestandbyandmutetimeconstants.Thelargerthevalue,thelongerthetime.Whenthecontrolterminalisconnectedtolowpotentialground,itismuteandstandby;whenthecontrolterminalisconnectedtoVS,because(R5+R6)R7,pin⑩risestoahigherpotentialthanpin⑨,andturnstoalowpotentialfirstwhenshuttingdown,whichmakesthestandbyandshutdownprocessesgooninasilentstate,ensuringthattheamplifieristurnedonandoffwithoutnoise.Figure5BTLPoweramplifierfinishedboardForhigh-powerprofessionalapplicationsfiledssuchasdancehalls,youcanchoosetheBTLpoweramplifierfinishedboardshowninFigure5.BothTDA7294areequippedwiththeirownprofessionalradiators.Whenvs=25V8,themaximumcontinuousoutputpowerreaches150W;when35V16,Themaximumcontinuousoutputpowerreaches170W.WeusedTDA7294standardapplicationcircuitandMarantzPM80andYAMAHAA-592tomakealisteningcomparison.Theformerisamid-pricedHi-FimachinewithaClassA,ClassAandBstatusswitch,andthelatterisa439.16dollarsclasswithAc-3inputAVpoweramplifier,audiosourceismusicfaxE60CD,speakerisTannerNo.5.ItturnsoutthatthesoundorientationofTDA7294hasadistinctiveEuropeanstyle,soft,mellow,delicate,andfullofbouncingfeeling.ItissimilartotheMarantzPM-80inClassAandBstatus,butthesoundfieldofPM-80isdeeperwhenworkinginpureClassA.ComparedwithYAMAHAA-592,thedifferenceislarger.ThelowfrequencyofA-592seemstobeslightlyimproved.Itsoundspowerful,butitisharderandthelinesareblurry.TDA7294issweetandnatural,withhigherresolution,reallylikelandscapepaintingdonewithsplashesofinkandfine-brushflowersandbirds(atechniqueofchineseink-painting),eachhasitsinfinitecharm.VI.ActiveSubwooferAmplifierAddsStandbyFunctionThiscircuitisanimprovementontheaudiocircuitusingtheintegratedcircuitTDA7294.ThecircuitdiagramisshowninFigure6.TDA729410pinhasamutefunction.WhentheexternalDCprovideshighlevel,theintegratedblockisintheworkingstate;whenthelowlevelisapplied,theintegratedblockisinthecut-offstate.Atthistime,thecircuitconsumeslittlepowerandIC114pinhasnooutput,thatis,standbyform.Thegeneralcircuitistoprovideahighleveltopin10tomakeitintheconductingstate,infact,thedevelopmentofthispinfunctioncanmeetsomespecialworkrequirements.Thiscircuitisbasedonthistoincreasethestandbyfunctionoftheactivesubwooferpoweramplifier,anditscircuitisreliableandresponsive.Figure6ActivesubwooferamplifieraddsstandbyfunctioncircuitdiagramVII.HighFidelityPowerAmplifierThecircuitisshowninFigure7.ThedrivestageadoptsTDA7294.Theinternaldrivestageandoutputstageofthechipusefieldeffecttubes,whicharepoweredby40V,andtheoutputpowercanreach70W(RL=8;THD=0.005%).Ithasadelicatetoneandanexcellentsenseofhearing.PoweroutputVT1,VT2adoptsShankenhigh-powerpairtube2SA1394,2SC3858.Thecircuitprincipleisasfollows:ThesignalisinputtotheTDA7294non-invertinginputpin③throughC1andR1.R7andR3,C3,C4ofICpin②formanegativefeedbacknetwork,theclosedloopgainofthisamplifierisabout34times.The⑨and⑩pinsarethestandbyandmuteterminalsrespectively.SincetheRCnetworktimeconstantofthe⑩pinislargerthanthatofthe⑨pin,theswitchingmachinesareallperformedundermutesatge,avoidingtheswitchingimpactsound,andC7isabootstrapcapacitor.Figure7High-fidelitypoweramplifierpromotedbyTDA7294Productionpoints:(1)InsulatingmicasheetsshouldbeaddedbetweenthemetalcapandtheheatsinkofTDA7294(themetalcapisconnectedtothepin⑧).(2)Thepowertransformerusesring-shaped300Wdouble20V,four50V/10000Ffiltercapacitors,two50V/100F,andtwo100V/0.1F.Thepowersupplypartshouldbetestedseparately,firstwithoutconnectingthepoweramplifier,measurewhetherthepositiveandnegativeoutputvoltageofthepowersupplyaresymmetrical,theerrorshouldbewithin0.6V.(3)Whentestingthemachine,forsafetyreasons,youshouldfirstusealowervoltagetest(suchas25V)withoutaddingasignal,andmeasuretheDCvoltageoftheoutputterminaltotheground.Normally,itshouldbewithin20mV.(4)R8,R9,R10,D1formthefinalbiascircuit.ThisbiasmakestheoutputtubesVT1andVT2notcutoffduringoperation,sothequiescentcurrentcanbesmall(about5mA).(5)Thepowertubeshouldbestrictlymatched(within3%)andgenuineproductsshouldbeselected.TheoutputresistanceR14isa5Wnon-inductivetype,andtheinductorLisformedbytightlywinding10turnsonR14withadiameterof1.5mmenameledwire.TDA7294uses60mmTimes,85mmTimes,20mm12-slotheatsink,andtheoutputpairtubeneedsaprofessionalheatsink.Thesectionswithhighcurrentontheprintedboardneedtobetin-rolled,whichisextremelybeneficialforthetransparencyandstrengthofthesound.Figure8PoweramplifierPCBpromotedbyTDA7294VIII.ClassABPowerAmplifierTDA7294integratedcircuitcanbeusedasahigh-fidelityaudioclassABpoweramplifier.Itcandrive4ohmor8ohmspeakers,andwhenconnectedtoan8ohmspeaker,itwillprovide50wattsofoutputpowerand0.1%THD.Figure9ClassABpoweramplifiercircuitdiagramYoumustinstallalargeenoughradiatorforTDA7294.Pin10isamuteinput,andpin9providesastandbymode.Muteshouldalwaysoccurwhenselectingstandbymode.TheIChasinternalthermalprotection,whichcausesmutereductionat145C,andtheamplifierentersstandbyat150C.TheTDA7294integratedcircuitheatsinkisinternallyconnectedtothenegativepowerrail.Ifthemoduleisinstalledinagroundedmetalenclosure,thentheICmustbeinsulatedfromtheheatsink.Ifnot,thenegativepowerrailwillbeshortedtoground.IX.Two-channelPowerAmplifierTDA7294high-powerintegratedcircuitICisspeciallydesignedforassemblinghigh-performanceaudioamplifiers.TwoTDA7294piecescanbeusedtomakeapowerfuldual-channelhigh-fidelitypoweramplifier.ThecircuitprincipleisshowninFigure10.TheoverallcircuitiscomposedoftwoTDA7294corecomponents,andtheperipheryincludessomeresistorsandcapacitors.Thecircuitsofthetwochannelsarealmostidenticalindesign.TheyallusethestandardcircuitofficiallyreleasedbyTDA7294,connectedtoanon-invertingamplifiercircuit,withavoltagegainof30.5dB,anoutputpowerofupto70Wperchannel,andadualpowersupplysymmetricalpowersupplyvoltage35V.Amongthem,Cl5andCl6areinputcouplingcapacitors.0.47Fisusedintheoriginalcircuit.Here,ifyouincreaseitto1F,youcanimprovethelow-frequencyresponseofthecircuit.Itisrecommendedtousepolypropylenespecialaudiocapacitors,suchasWIMAsMKT4seriescapacitors,itcangreatlyimprovethesoundresolution.R3andR4areinputresistances,whichdeterminetheinputimpedanceofTDA7294inthein-phaseamplificationstate.Here,22kisrelativelymoderate.Toolargeavaluecanreducetheburdenonthefront-endsignalsource,butitmayaffectthestabilityofTDA7294andmaketheoutputmidpointvoltagedriftincreased,toosmallvaluewillaffecttheresponseabilitytolowfrequency.ThetheoreticalvalueofthefeedbackresistorsR7andR8shouldbeequaltotheinputresistorsR3andR4,whichcanensurethebiascurrentbalanceoftheTDA7294inputdifferentialcircuitandreducesignaldistortion.ThefeedbackgroundresistanceR5,R6cooperateswithR7,R8tosetthecircuitgain.Here,thefeedbackDCblockingcapacitorsCl3andCl4areusedtoformACnegativefeedback,inhibitDCvoltageoutput,andprotectthespeaker.Figure10Two-channelpoweramplifiercircuitdiagramTDA7294hasastartmutefunction,andcooperateswithanexternalcircuittoachieveanon-impactsoundeffectwhenthepoweristurnedonandoff.R9,R1O,R11,Rl2,Cl7,Cl8andVD5,VD6intheschematicdiagramformanexternalmutecontrolcircuit.Delaytheenergizationofpins9and10ofTDA7294toachievethefunctionofsoftstart.Thepowersupplyrectifierfiltercircuitisalsoverysimple.Thefullbridgerectifiercircuitiscomposedof4EuropeanspeedrectifierdiodesVD1-VD4.CapacitorsC1andC2arethemainfiltercapacitors.Large-capacityandhigh-currentaudiofiltercapacitorsarerequired,suchasELNAsFORAUDIOseriesorBHCAerovoxindustrialgradecapacitors.DesignPCBisgenerallyabottleneckinamateurproduction,sothatmanyexcellentschematicdiagramshavenotbeentransformedintofinishedPCBsthatcanbeactuallyassembled.Here,thepopularProtel99sedesignsoftwareisusedtodrawtheprintedcircuitboardagainsttheschematicdiagram10,asshowninFigure11.The2mmthickFR-4board-baseddouble-sidedPCBisused,andthecopperfoilisthickenedto70mm,whichissuitableforhighcurrentpoweramplifiers.ThewholePCBtraceadoptsone-pointgroundingmethod,whicheffectivelyeliminatesgroundwireinterferencenoise.Insomehigh-currenttraces,tinplatingisalsoadoptedtoincreasetheadditionalcurrentcarryingcapacity.Thepowerinputandpoweroutputstructureuseshigh-currentscrewterminalstoensuresufficientover-currentcapabilityanddurabilityofrepeatedwiring.Figure11PrintedcircuitboardX.100WPowerAmplifierCircuitFigure12100WpoweramplifiercircuitdiagramcomposedofTDA7294Figure12isa100WpoweramplifiercomposedofamonolithicaudiopoweramplifierintegratedcircuitTDA7294.TDA7294includespre-opamplifier,finalpoweramplifier,temperatureprotection,shortcircuitprotection,mutecontrolandothercircuits.ThefinalstageadoptsbipolarDMOSpowertransistor,whichhasthecharacteristicsofhighoutputpower,bandwidth,lowdistortion,andgoodversatility.Theintegratedcircuitalsohasperfectanti-overload,anti-shortcircuitandtemperatureprotectioncircuitfunctions.Whenthechiptemperatureistoohigh,itautomaticallycutsofftheaudiosignaltoprotectthechipfromburningThepoweramplifiercircuitcomposedofTDA7294hasthecharacteristicsofsimpleperipheralcircuitandeasyproduction.Thecircuitinputimpedanceis20k,theinputsensitivityis750mV,thevoltagegainis32dB,thepowersupplyvoltagerangeis(25~40)V,andthequiescentcurrentis50mA.Whentheloadimpedanceis8,theoutputpoweris100W;whentheloadimpedanceis4,theoutputpowercanreach180W.Inactualproduction,TDA7294shouldbeequippedwithenoughheatsinks.Thesupportingpowercircuitshouldhavesufficientcapacity.Ifyouneedtoincreasethecircuitvoltagegain,youcanappropriatelychangetheratioofR3toR2,voltagegainA=201g(R3/R2)(dB).However,itisnotadvisabletoone-sidedlypursuethevoltagegainofthisstage.Excessivevoltagegaincaneasilycausecircuitself-excitation.Thesolutionistoincreasethevoltagegainofthepre-stage.

ARRAY4

I.DescriptionTDA2030Aisoneofthehigh-fidelityintegratedpoweramplifiers,andmanypoweramplifiercircuitsusethisintegrationmethod.TDA2030isalsoaHI-FIpoweramplifierintegratedblockusedbymanycomputeractivespeakers.Ithassimpleconnectionmethodandaffordableprice.Theratedpoweris14W.Thepowersupplyvoltageis6~18V.Theoutputcurrentislarge,theharmonicdistortionandthecrossoverdistortionaresmall(14V/4ohm,THD=0.5%).Ithasexcellentshortcircuitandoverheatprotectioncircuit.Thefollowingdescribesitsconnectionandapplicationcircuit.CatalogI.DescriptionII.Connection2.1SinglePowerConnection2.2DualPowerConnectionIII.ApplicationCircuit3.1OTLFormPowerAmplifier3.2OCLFormPowerAmplifier3.3BTLFormPowerAmplifier3.440WPowerAmplifierCircuit3.5High-fidelityActiveSpeakerCircuit3.625WBridgeLowFrequencyPowerAmplifierCircuitOrdering&QuantityII.ConnectionItsconnectionmethodisdividedintosinglepowersupplyanddualpowersupply:2.1SinglePowerConnectionFigure1TDA2030singlepowerconnectiondiagram2.2DualPowerConnectionFigure2TDA2030dualpowerconnectiondiagramIII.ApplicationCircuit3.1OTLFormPowerAmplifierOTLformpoweramplifier:singlepowersupply,outputcouplingcapacitor.TheR5(150k)andR4(4.7k)resistorsinthecircuitshowninFigure3determinetheclosed-loopgainoftheamplifier.ThesmallertheR4resistor,thegreaterthegain,buttoolargegaincaneasilycausesignaldistortion.Twodiodesareconnectedbetweenthepowersupplyandtheoutputterminaltopreventtheinductiveloadofthespeakerfromkickingbackandaffectingthesoundquality.ThecapacitorofC3(0.22uF)andtheresistanceofR6(1)areusedtocompensatetheinductiveload(speaker)toeliminateself-excitation.Thecircuitusesa36Vsinglepowersupplyandtheoutputpowerisabout20W.Figure3OTLtypepoweramplifiermadewithTDA2030A3.2OCLFormPowerAmplifierTheformoftheOCLpoweramplifieradoptsdualpowersuppliesandhasnooutputcouplingcapacitor.AsshowninFigure4,sincethelowfrequencyresponseoftheoutputcouplingcapacitorisimproved,itisahigh-fidelitycircuit.Thedualpowersupplyusesatransformerwiththemiddlepointoftheprimarycoilgroundedandtheupperandlowervoltagesaresymmetricalandequal.Afterrectificationandfiltering,a18Vdualpowersupplyisformed,andtheoutputpoweris20W.Figure4OCLtypepoweramplifiermadewithTDA20303.3.BTLFormPowerAmplifierThemainfeatureofBTLis:itiscomposedoftwoidenticalpoweramplifiers,andtheinputsignalsareinversetoeachother.Thein-phaseinputandtheinvertedinputoftheamplifierareactuallyusedtoensurethattheinputsignalsareinversetoeachother.Atthesametime,theamplitudesofthetwoinputsignalsshouldbethesame,sothatthebasicrequirementsoftheBTLcircuitformcanbemet.ThecircuitdiagramisshowninFigure5,whereR7(1k)andR8(33)resistorsdividethesignalandtheattenuationfactorisexactlythesameastheamplificationfactorofU1.TheattenuatedsignalisaddedtotheinvertinginputterminalofU2throughR5.Infact,twoopampscompleteasignalamplification,andtheactualmeasuredoutputlevelis1.5timeshigherthanthatofanintegratedcircuit.Thatis,theoriginaloutputpoweroftheopampis20W,andtheoutputpowerisnowabout50W.However,duetothecharacteristicsoftheBTLcircuit,whenchoosinganintegratedcircuit,usetwooperationalamplifiercircuitswiththesameparametersasmuchaspossibletoadjusttheinputsignalamplitude.Youcanuseanoscilloscopetoobservetheamplitudeofthetwoinputsignalsbyinputtingasinewave.Atthistime,adjustR7tomakethetwoinputsignalsTheamplitudeisthesametoensurethatthenonlinearsymmetrydistortionisminimizedwhileincreasingthepower.Figure5BTLtypepoweramplifiermadewithTDA2030A3.440WPowerAmplifierCircuitFigure6isa40WpoweramplifiercircuitmadebyTDA2030poweramplifierintegratedblockandBD907/908:Figure640WpoweramplifiercircuitmadebyTDA20303.5High-fidelityActiveSpeakerCircuitAhigh-fidelityactivespeakercircuitdesignedwithTDA2030,thecircuitdiagramisshowninFigure7.Usingdualpowersupply,addedhighandlowbassandvolumeadjustment.WhendesigningthePCB,thegroundwireshouldnotpassthroughthecomponentpinsasmuchaspossibletoreduceDCnoise.Figure7Highfidelityactivespeakercircuitdiagram3.625WBridgeLowFrequencyPowerAmplifierCircuitFigure825WbridgelowfrequencypoweramplifiercircuitThecircuitinFigure8usestwoTDA2030sconnectedtoformabridgecircuit,withthesamecircuitstructureandparametersonbothsides.Theintegratedcircuitontherightiscontrolledbytheintegratedcircuitontheleftthrougha22knegativefeedbackresistor,andviceversa.Thediode1N4001isusedtopreventthespeakerinductiveloadfromgeneratingovervoltageanddamagingthedevice.Theamplificationfactorofthecircuitcanbeadjustedbychangingthenegativefeedbackvoltageratiobetweentheoutputterminal(pin4)andtheinvertinginputterminal(pin2).

IDescriptionThisblogintroducesthepoweramplifierwithNE5532andLM1875Tasthecorecomponents.Thepoweramplifierwearediscussinghereisahigh-fidelitytwo-channelstereosubwooferpoweramplifier.Here,wewilldiscussitsmethodsandprocedures,schematicdesign,assemblyanddebugging,andspeakerproduction.Hopethisblogcanprovideagoodreferenceforbeginners.Figure1.LM1875CatalogIDescriptionIILM1875TandNE5532Overview2.1PowerAmplifierLM1875T2.2Pre-amplificationComponentNE5532IIICompositionofPowerSupplyIVAssemblyandDebuggingSpeaker4.1ElectricalInspection4.2BoxProductionVIntheEndOrdering&QuantityIILM1875TandNE5532OverviewFirst,weintroducethecorecomponentsthatwewilluse.Andthen,thebasiccharacteristicsofthesecomponents.Audiopoweramplifierisgenerallycomposedofthefollowingthreeparts:powersupply,pre-amplifierandpost-amplifier.Here,wewillusehigh-efficiencyHI-FIpowerintegratedchipLM1875Tasthecoreoriginal.LM1875Tadoptsapositiveandnegative15Vdualpowersupply,theleft,andrightchannelsworkinOCLmode,andthebassworksinBTLmode.AsfarasthecharacteristicsofLM1875Tareconcerned,ithasthecharacteristicsofgoodsoundquality,goodfrequencyresponse,lowcostandrelativelysimplecircuit.Inaddition,thepre-amplifierpartusestheNE5532integratedoperationalamplifier.2.1PowerAmplifierLM1875TLM1875Thasexcellentperformance.Manyluxury-lookingactivespeakers,mid-rangepoweramplifiers,andsubwoofersonthemarketuseLM1875T.ThepoweramplifiercircuitcomposedofLM1875Tchiphasthefollowingcharacteristics:Theoutputpowerislarge,themaximumpowercanreachabout20W;Thestaticcurrentissmall,theloadcapacityisstrong,andthedynamiccurrentislarge,whichcandrive4~8speakers;Thecircuitissimple,easytomanufactureandlowcost;Withaninternalprotectioncircuit,itisahigh-fidelitypoweramplifiercomponentwithstableperformance.Theblogdesignofthisarticleisadual-channelstereosubwooferpoweramplifier,butLM1875Tisamono-channelpoweramplifierintegratedcircuit,sothedual-channelOCLworkingmodeusesoneLM1875Tforeachchannel.SincethebassworksinBTLmode,wehavetousetwopieces.LM1875Thas5pins.Theyarepositivepowersupply,negativepowersupply,positiveinput,reverseinput,andoutput.ThecircuitisshowninFigure2.Figure2.LM1875Circuit2.2Pre-amplificationComponentNE5532Beforethepoweramplifiercircuit,itisgenerallynecessarytoaddapreamplifier.Thepurposeofthisistoamplifythevoltageofvariousinputweakelectricalsignals.Inordertoensurethattheoutputelectricalsignalhashighfidelity,thepre-amplifierisNE5532.NE5532isahigh-performance,low-noise,dualoperationalamplifierintegratedcircuit.Comparedwithmanystandardopamps,NE5532hasbettersoundperformance,excellentoutputdrivecapability,relativelyhighsmallsignalbandwidth,andlargepowersupplyvoltagerange.Therefore,itisverysuitableforhigh-qualityandprofessionalaudioequipment,instruments,controlcircuitsandtelephonechannelamplifiers.Whenusedforaudioamplification,thetoneiswarmandhighfidelity.ThefunctionalblockdiagramofNE5532isshownasinFig.3.Figure3.NE5532FunctionalBlockDiagramIIICompositionofPowerSupplyLM1875Tadoptsapositiveandnegative15Vdualpowersupply.TheoperatingvoltageofNE5532isalso15V.Weneedtostepdownthemainspowerto15Vthroughastep-downtransformer,thenrectifyitthroughtherectifierbridgeKBL406,filteritthroughalargecapacitor,anddirectlysupplyittothepoweramplifier.Inthisway,largeroutputpowerisobtained.After7815and7915,theregulatedoutput15VisusedasthepowersupplyofthepreamplifierNE5532.ThecompositionofthepowersupplyisshowninFigure4.Figure4.PowerCircuitFigure5.PowerAmplifierCircuitBoardIVAssemblyandDebuggingSpeakerWhenstartingthecircuitinstallation,firstcheckthecircuitboardagainstthecircuitdiagram.Forexample,checkwhetherthemaincomponentsareinstalledcorrectly,andwhetherthesolderjointshavemissingsolderingorfalsesoldering.Thenturnonthepowertodebugthecircuit,andmakespeakersafterthedebuggingiscompleted.TheactualproductionisshowninFigure6.Figure6.PhysicalShootingPic4.1ElectricalInspectionUseanACsignalgeneratortoaddatinysinusoidalsignaltothesignalinput.Then,usetheoscilloscopetomeasurethethreeoutputsignalsofthepoweramplifierboard.Atthistime,observewhetherthesinemeetstherequirementsandwhethertheparametersinthetestarerelativelystable.Then,connecttwofull-rangespeakerstotheleftandrightchannels,andconnectawoofertothebassoutputport.Atthistime,addthesongsignaltocarefullycheckwhetherthethreespeakersareworkingproperlyandthesoundisgood.Iftheabovestepsarewellexpressed,thenproceedtothenextstep.4.2BoxProductionThekeytomakingspeakersistheselection,sizeandothersteps.Intheexperiment,weusedthelaminatesinthelaboratoryforsplicingandassembly.First,drawasketch.Thepaintingisdividedonthreedifferentsubstrates,andthenmadeintotwopartsrespectively.Afterdrilling,polishing,splicingandbonding,thecompletedcircuitpartsareinstalledintheirrespectiveparts.Then,wedividetheentirepoweramplifierintothreeparts.Twosatellitespeakers,aswellasawooferandpoweramplifierboard.Thesethreepartstogetherformacomplete2.1subwooferpoweramplifier.Here,thereisaplacethatneedsspecialattention.Whenmakingthebasspartofthecabinet,theimpactofvibrationshouldbefullyconsidered.Therefore,wehavetodesigndampingcomponents.VIntheEndAftertheinstallationisnormal,connectthemusicsignalsourceandlistentothemusiceffect.Thesoundreproducedbythiscircuithasastrongsenseofhierarchy,aclearsenseoforientation,andanobvioussenseofspaceanddistance.Inaddition,thesoundimageorientationisclear,thewidthisoutstanding,andthesounddynamicrangeislarge,givingpeoplearealfeeling.I.IntroductionAsweallknow,theionnitridingprocessrequiresrelativelyhighcontrolofthepressureinsidethefurnace,sothispaperdesignsagasflowcontrollerbasedontheL298NchipdrivenDCmotorcontrol,whichcanbeusedtocontrolthegasflowofthereactor.Soletsfirstunderstandtheionnitridingtheory.CatalogI.IntroductionII.IonNitridingTheoryIII.SystemFlowandPressureMeasurementandControlBlockDiagramIV.L298NChipIntroductionV.ControllerPrincipleVI.ConclusionFAQOrdering&QuantityII.IonNitridingTheoryNitridingisachemicalheattreatmentmethodtostrengthenthemetalsurface.Itistoplacemetalpartsinanactivenitrogenmedium,andatacertaintemperatureandholdingtime,thenitrogenelementcanpenetrateintothemetalsurface,therebychangingthechemicalcompositionofthemetallayertomakeithavehighwearresistance,fatiguestrength,corrosionresistanceandburnresistance,etc.,soitiswidelyusedinindustry.Ionnitridingiscarriedoutinalow-temperatureplasma.Thelow-pressuregasisionizedundertheactionofanelectricfieldtoproducehigh-energyionsandhigh-energyneutralatoms.Thesehigh-energyparticlescanimprovethestructureoftheinfiltrationlayer,promotethechemicalreactionprocess,andacceleratethenitridinglayerformation.Ionnitridingiscarriedoutinglowdischarge.Intheprocessofionnitriding,thepressurecontrolaccuracyofthefurnaceisrelativelyhigh,andthecontroldeviationreachesseveraltensofPa.AccordingtoPaschensLaw:Amongthem:Pisthegaspressure;Disthedistancebetweenparallelplateelectrodes;Visthecathodesecondaryelectronemissioncoefficient;BisStolevsconstant;Aisaconstant.Takingthederivativeofformula(1),thebreakdownvoltageexpression(2)canbeobtained:Itcanbeseenfromformula(2)thatthebreakdownvoltageVisrelatedtothegaspressureandd,andingeneralexperiments,disfixed,soionnitridingisextremelyimportantforpressurecontrol.III.SystemFlowandPressureMeasurementandControlBlockDiagramTheflowmetercontrolsthegasflowattheinlet.Whentheinletandexhaustflowsarebalanced,thefurnacepressureremainsstable.Duetotheinternalinfluenceoffurnacegasleakageandotherinterferencefactors,theinternalpressureofthefurnacefluctuatesupanddown,andthesystemdeviatesfromtheequilibriumstate,whichaffectstheplasmaprocessinseverecases.WeuseanordinaryDCmotortodrivetheDCmotorthroughtheL298N,andthemotordrivestheconetorotatethroughthereductionlever.Whentheconeisscrewedin,thegaspumpedoutperunittimeisreduced;whenitisscrewedout,thegaspumpedoutincreases,sothatthepressureinsidethefurnaceisstabilizedattherequiredvalue.Thechangeoffurnacepressureismeasuredbythepressuresensorandpassedthroughthetransmitter,whichsendsthegasflowcontrollertothefeedbackvoltage.Theelectricvacuumbutterflyvalveusedforthesuctionportisexpensive,asshowninFigure1.Figure1BlockdiagramofsystemflowandpressuremeasurementandcontrolIV.L298NChipIntroductionL298NcanacceptstandardTTLlogiclevelsignalVSS,andVSScanbeconnectedto4.5~7Vvoltage.4pinVSisconnectedtothepowersupplyvoltage,andtheVSvoltagerangeVIHis+2.5~46V.Theoutputcurrentcanreach2.5A,whichcandriveinductiveloads.Theemittersofpin1andpin15areseparatelyledouttoconnectthecurrentsamplingresistortoformacurrentsensingsignal.L298candrivetwomotors,OUT1,OUT2andOUT3,OUT4canbeconnectedtoeachmotor,thisexperimentaldevicewechoosetodriveonemotor.Pins5,7,10and12areconnectedtotheinputcontrolleveltocontroltheforwardandreverserotationofthemotor.EnAandEnBareconnectedtothecontrolpotentialenergyendtocontrolthestallingofthemotor.Figure2istheL298Nfunctionallogicdiagram,Table1istheL298Ninternalfuntionalmodule.Figure2L298NfunctionallogicdiagramEnAIn1In2OperativeCondition0Stop110Rotatingforward101Inversion111Brake100StopTable1L298NinternalfunctionalmoduleThefunctionalmoduleofIn3andIn4isthesameasTable1.ItcanbeseenfromTable1thatwhenEnAislowlevel,theinputlevelhasaneffectonmotorcontrol.WhenEnAishighlevel,whenEnAishigh,theinputlevelisonehighandonelow,andthemotorrotatesforwardorreverse.Iftheyarebothlowlevel,themotorwillstop,andiftheyarebothhighlevel,themotorwillbrake.V.ControllerPrincipleFigure3istheschematicdiagramofthecontroller,composedof3dashedblockdiagrams:Figure3TheschematicdiagramofthecontrollerThefollowingarethefunctionsofthe3dashedblockdiagrams:(1)Thedashedblockdiagram1controlstheforwardandreverserotationofthemotor,U1AandU2Aarecomparators,andVIcomesfromthevoltageofthefurnacepressuresensor.WhenVIVRBF1,U1Aoutputshighlevel,U2Aoutputhighlevelturnsintolowlevelthroughinverter,andthemotorrotatesforward.Similarly,whenVIVRBF1,themotorreverses.Theforwardandreverserotationofthemotorcancontroltheflowofgasextractedbytheairextractor,therebychangingthepressureinsidethefurnace.(2)Inthedashedblockdiagram2,twocomparatorsU3AandU4Aformadual-limitcomparator.WhenVBVIVA,itoutputslowlevel,andwhenVIVA,VIVB,itoutputshighlevel.VA,VBaretheupperandlowerlimitsofthevoltageconvertedbythefurnacepressuretransducer,thatis,thecontrolrangeofthereactionfurnacepressure.Accordingtoprocessrequirements,wecanspecifythevaluesofVAandVBbyourselves,aslongasthefurnacepressureiswithintherangedeterminedbyVAandVB,themotorstops(notethatVB<VRBF1<VA,ifitisnotinthisrange,thesystemisunstable).(3)Thedashedblockdiagram3isalongdelaycircuit.U5Aisacomparator,Rs1isthesamplingresistor,VRBF2isthemotorovercurrentvoltage.ThevoltageonRs1isgreaterthanVREF2,themotorisovercurrent,andU5Aoutputslowlevel.Itcanbeseenfromtheabovethatblock1controlstheforwardandreverserotationofthemotor,andblock2controlsthesizeoftherippleofthefurnacepressure.Whenthefurnacepressureistoosmallortoolarge,themotorturnstoafixedpositionatbothendstostop,accordingtothesteady-stateoperatingequationoftheDCmotor:Amongthem:Фisthemagneticfluxofeachpoleofthemotor;Ceistheelectromotiveforceconstant;Nisthenumberofmotorrevolutions;Iaisthearmaturecurrent;Raisthearmatureloopresistance.WhenthenumberofrevolutionsofthemotorNis0,thecurrentofthemotorincreasessharply,andthemotorwillburnoutifthetimeistoolong.Butwhenthemotorstarts,thecurrentinthecoilinthemotoralsoincreasessharply,sowemustseparatethesetwostates.Thelongdelaycircuitcandistinguishthesetwostates.Theworkingprincipleofthelong-delaycircuit:WhentheRs1overcurrentU5Ageneratesanegativepulseandisdifferentiated,thepulsetriggerspin2of555,thecircuitisset,andpin3outputshighlevel.Becausethedischargeterminal7pinisopen,C1,R5andU6Aformedasanintegration,thenstartworking,thechargingvoltageonthecapacitorC1riseslinearly,andtheintegrationconstantofthedelayoperationalamplifieris100R5C1.WhenthechargingvoltageonC1,thatis,thevoltageonpin6exceeds2/3VCC,the555circuitresetsandoutputsalowlevel.Themotorgenerallystart-upinlessthan0.8s,andtheC1chargingtimeisgenerally0.8~1s.TheoutputlevelofU5AisORedwiththeoutputlevelofpin3of555viaU7.IftheoutputlowlevelofU5AislongerthanthechargingtimeofC1,U7outputslowlevelafterC1ischarged.TheANDgateU8inputstothe6pinENAterminalofL298N.Themotorstops.IftheoutputlevelofU5AislessthanthechargingtimeofC1,pin6willnotactandthemotorwillstartnormally.Thelongdelaycircuitabsorbsthemotorstart-upovercurrentvoltagewaveform,sothatthemotorstartsnormally.VI.ConclusionThisarticlesummarizesthedesignschemeforthepressurecontrolofionnitridingbasedontheL298Nchip.Ithasbeenprovedthattheuseofthiscontrollertocontrolthegasflowcanreduceproductioncosts,increasethesystemcostperformance,andimprovethecontroldynamicperformanceandstabilityoftheentiresystemcontrol.FAQWhatisl298n?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Whatistheuseofl298n?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoesl298ncontrolDCmotorspeed?1.IfyousendaHIGHsignaltotheenable1pin,motorAisreadytobecontrolledandatthemaximumspeed;2.IfyousendaLOWsignaltotheenable1pin,motorAturnsoff;3.IfyousendaPWMsignal,youcancontrolthespeedofthemotor.Themotorspeedisproportionaltothedutycycle.Whatisl298nmotordrivermodule?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Howdoesl298nmotordriverwork?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoiuseal298motordriverwithArduino?Startbyconnectingpowersupplytothemotors.InourexperimentweareusingDCGearboxMotors(alsoknownasTTmotors)thatareusuallyfoundintwo-wheel-driverobots.Theyareratedfor3to12V.So,wewillconnectexternal12VpowersupplytotheVCCterminal.WhatisthefunctionofHbridge?AnH-bridgeisanelectroniccircuitthatswitchesthepolarityofavoltageappliedtoaload.ThesecircuitsareoftenusedinroboticsandotherapplicationstoallowDCmotorstorunforwardsorbackwards.Whatisthedifferencebetweenl293dandl298n?L293isquadruplehalf-HdriverwhileL298isdualfull-Hdriver,i.e,inL293allfourinput-outputlinesareindependentwhileinL298,ahalfHdrivercannotbeusedindependently,onlyfullHdriverhastobeused....Hence,heatsinkisprovidedinL298.

I.IntroductionDCmotorsarewidelyusedinvariousfieldsduetotheirgoodspeedregulationperformance,largestartingtorqueandstrongoverloadcapacity.Inrecentyears,thestructureandcontrolmethodsofDCmotorshaveundergonegreatchanges.Withcomputersenteringthecontrolfieldandthecontinuousemergenceofnewpowerelectronicpowercomponents,PWM(pulsewidthmodulation)speedregulationhasbecomeanewwayofDCmotorspeedregulation.Andwiththeadvantagesofhighswitchingfrequency,stablelow-speedoperation,excellentdynamicperformance,andhighefficiency,itiswidelyusedinDCmotorspeedregulation.Therefore,thispaperproposesthedesignofaDCmotorPWMcontrolsystembasedon80C196KCandL298N.CatalogI.IntroductionII.PrincipleofPWMSpeedControlSystemIII.ControlSystemHardwareDesign3.1IntroductiontoPowerIntegratedCircuitL298N3.2DCMotorControlSystemHardwareCircuit3.3Anti-interferenceandElectromagneticCompatibilityDesignIV.ControlSystemSoftwareRealizationV.ConclusionFAQOrdering&QuantityII.PrincipleofPWMSpeedControlSystemPWM,orpulsewidthmodulation,referstotheuseoftheswitchingcharacteristicsofhigh-powertransistorstomodulateafixedvoltageDCpowersupply,whichisturnedonandoffatafixedfrequency,andthelengthoftheonandofftimeinacycleischangedasneeded.BychangingthedutycycleofthevoltageonthearmatureoftheDCservomotor,theaveragevoltageischangedtocontrolthespeedofthemotor.Therefore,itisoftencalledaswitchdrivedevice.TheschematicdiagramofPWMcontrolisshowninFigure1.Figure1PWMcontrolschematicdiagramThereareusuallytwowaystochangethedutycycle:PWMandPFM(pulsefrequencymodulation).PWMisbychangingthewidthoftheon-pulse,whichiscommonlyreferredtoasthefixedfrequencywidthmodulationmethod.PFMmeansthattheon-pulsewidthisconstantandthedutycycleischangedbychangingtheswitchingfrequency.Becausewhenitencountersmechanicalresonanceataparticularfrequency,itoftenresultsinsystemvibrationandhowling.Therefore,inthecontrolofDCmotors,thePWMcontrolmethodismainlyused.III.ControlSystemHardwareDesignTheDCmotorspeedcontrolsystembasedon80C196KCandL298Niscomposedofthesmallestsingle-chipmicrocomputersystem,R/Dconverter,PWMpoweramplifiercircuit,A/DandD/Aconversioncircuit,andreceivingcommandinterfacecircuit.Theminimumsystemofthesingle-chipmicrocomputeradoptsthe16-bitsingle-chip80C196KCexternalexpansioninterfacecircuit,whichismainlyusedtorealizethefunctionsofdataacquisitionandPWMsignalgeneration.TheblockdiagramofthespeedcontrolsystemisshowninFigure2.Figure2BlockdiagramofPWMspeedcontrolsystem3.1IntroductiontoPowerIntegratedCircuitL298NInordertoimprovesystemefficiencyandreducepowerconsumption,thepoweramplifierdrivecircuitadoptstheintegratedcircuitL298NbasedonthebipolarH-bridgepulsewidthmodulationmethod.L298Nisahigh-performancepulse-widthmodulationpoweramplifierproducedbySGS,whichhasthecharacteristicsofsmallsizeandstrongdrivingability.ItcontainstwoH-bridgehigh-voltageandhigh-currentbridgedrivers,whichcanrealizethefull-bridgedriveofthemotorwithasinglechip,whichcandrivemotorsbelow46Vand2A.TheinternalstructureofL298NisshownasinFigure3.Figure3L298Ninternalstructureblockdiagram3.2DCMotorControlSystemHardwareCircuitL298NcandrivetwoDCmotors,becausethespeedcontrolsystemisasingle-axisstructure,inordertomakefulluseoftheloadcapacityofthepoweramplifiercircuit,sothatthesystemstartsatthemaximumaccelerationandbrakesatthemaximumacceleration,inthedesign,theinputterminalandtheoutputterminalareconnectedinparalleltocontroltheDCmotor.Thesingle-chip80C196KCgivesaPWMsignalaccordingtothecalculationresultsofthepositionloopandthespeedloop.ThePWMsignalisdirectlyoutputtotheIN1(IN3)terminal,andthePWMsignalisinvertedandoutputtoIN2(IN4)through7406.WhenthedutycycleofthePWManalogsignalis50%,thepositiveandnegativevoltagesatbothendsofthemotorareappliedforthesametime.Themotorisinastateoftremoratthisposition,thatis,inthepowerlubricationstate.Whenthedutycycleisgreaterthan50%,thesignalvoltageOUTAisgreaterthanOUTB,andthemotorrotatesforward,otherwisereverse.Therefore,theoutputpolarityofeachlinkmustbestraightenedouttoformnegativefeedbackandcompleteclosed-loopcontrol.RelyingonchangingthePWMdutycycletocontrolthemotorspeedcanalsochangethemotorrotationdirection,thecontrolmethodissimpleandreliable.Inaddition,becausethemotorisofelectriccoiltype,reverseelectromotiveforcewillbeformedwhenthemotorhasanemergencystopandsuddencommutation.ToensurethenormaloperationoftheL298Ndrivechip,twopairsofcontinuationsareaddedbetweentheoutputterminalsOUTA,OUTBandtheDCmotor.TheflowdiodeshuntsthecurrenttothepositiveorgroundterminalofthepowersupplytopreventbackelectromotiveforcefromdamagingtheL298N.3.3Anti-interferenceandElectromagneticCompatibilityDesignWhenthemotorisdriven,therapidon-offofthepowermainswitchingelementleadstoalargerateofchangeofpowercurrentandvoltage,whichnotonlyaffectsthedrivecircuitbutalsoentersthecontrolcircuitthroughthepowersupplyandground.Inaddition,whenthemotorstartsandbrakes,thetransientvoltageisgeneratedatthesuddenchangeoftheload,itsamplitudewillbehigherthanthepowersupplyvoltage,andtheleadingedgeissteep,thefrequencybandisverywide,anditentersthecontrolcircuitthroughtheDCpowersupply.Therefore,anti-interferenceandelectromagneticcompatibilitydesignisalsoveryimportant.Thesystemhasadoptedmeasuressuchascurrentsmoothing,deburringandshielding.Currentsmoothing:BecausetheinstantaneousenergyofthePWMswitchisrelativelylarge,theRCfilterisusedattheoutputofthePWMpoweramplifiertofilter.Byselectingtheappropriateresistanceandcapacitancevalues,high-frequencyharmonicsareeffectivelysuppressedandthepeakvoltageofthePWMpoweramplifierisabsorbed.Therebyreducingtheinterference;Deburring:Thesystemincreasesthefiltercapacitoronthepowersupplyside,andusesonelargeandonesmallcapacitorinparallel.Thelargecapacitorisresponsibleforthedecoupling,filtering,andsmoothingoflow-frequencyalternatingsignals,andthesmallcapacitoreliminatesmid-andhigh-frequencyparasiticscouplinginthecircuitnetwork,whicheffectivelyreducesspikesandburrs;Shielding:Themotordrivecableadoptsdouble-shieldedcables,andthewiringshouldbeseparatedfromothercablesasmuchaspossible.Figure4DrivehardwarecircuitdiagramIV.ControlsystemsoftwarerealizationThecontrolsystemadoptsthespeed-positionclosed-loopcombinationmethod,takingthepositioncontrolmethodasanexampletointroducetherealizationmethodofthesoftware.ThepositioncontrolisbasedontheclassicPIcontrolalgorithm,andtheproportionalandintegralparametersaresimplifieddesign,andthesegmentedPIcontrolisintroduced.,Thatis,thecalculatederrorisdividedintosections,anddifferentproportionalandintegralparametersparticipateintheadjustmentwithintheerrorrangeofeachsection,whichensuresthesmootherandmorestableoperationofthesystem.ThederivationandsimplificationprocessofPIformulaisasfollows:ThespecificsoftwareimplementationflowchartisshowninFigure5.Thatis,afterreceivingagivenanglecommand,firstcalculatethedifferencebetweenthesampledpositioninformationandthegivenangle,andthendividethedifferenceintonequalparts,andeachsegmentcorrespondstoasetofparametersKp1andki1participateinmediationcontrol,calculatetheoutputofPIcontrolandthenconvertitintothecorrespondingPWMnumericaloutput.Figure5ThespecificsoftwareimplementationflowchartV.ConclusionThisarticlesumsupthedesignschemeoftheDCmotorPWMcontrolsystembasedon80C196KCandL298N.Thesingle-chipmicrocomputergeneratesPWMsignaltothepowerintegratedcircuitL298N.TheclassicPIsegmentcontrolisusedtocontrolthemotor.Ithasthecharacteristicsofsimplecircuitandconvenientcontrol.Theoperatingtestresultsshowthatthesystemworksstablyandreliably,meetstherequirementsofthespeedregulationfunction,andhasbeensuccessfullyappliedtomanyairborneproducts.FAQWhatisl298n?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Whatistheuseofl298n?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoesl298ncontrolDCmotorspeed?1.IfyousendaHIGHsignaltotheenable1pin,motorAisreadytobecontrolledandatthemaximumspeed;2.IfyousendaLOWsignaltotheenable1pin,motorAturnsoff;3.IfyousendaPWMsignal,youcancontrolthespeedofthemotor.Themotorspeedisproportionaltothedutycycle.Whatisl298nmotordrivermodule?ThisL298NMotorDriverModuleisahighpowermotordrivermodulefordrivingDCandStepperMotors.ThismoduleconsistsofanL298motordriverICanda78M055Vregulator.L298NModulecancontrolupto4DCmotors,or2DCmotorswithdirectionalandspeedcontrol.Howdoesl298nmotordriverwork?TheL298NisadualH-BridgemotordriverwhichallowsspeedanddirectioncontroloftwoDCmotorsatthesametime.ThemodulecandriveDCmotorsthathavevoltagesbetween5and35V,withapeakcurrentupto2A.Howdoiuseal298motordriverwithArduino?Startbyconnectingpowersupplytothemotors.InourexperimentweareusingDCGearboxMotors(alsoknownasTTmotors)thatareusuallyfoundintwo-wheel-driverobots.Theyareratedfor3to12V.So,wewillconnectexternal12VpowersupplytotheVCCterminal.WhatisthefunctionofHbridge?AnH-bridgeisanelectroniccircuitthatswitchesthepolarityofavoltageappliedtoaload.ThesecircuitsareoftenusedinroboticsandotherapplicationstoallowDCmotorstorunforwardsorbackwards.Whatisthedifferencebetweenl293dandl298n?L293isquadruplehalf-HdriverwhileL298isdualfull-Hdriver,i.e,inL293allfourinput-outputlinesareindependentwhileinL298,ahalfHdrivercannotbeusedindependently,onlyfullHdriverhastobeused....Hence,heatsinkisprovidedinL298.IDescriptionDS18B20isawidelyuseddigitaltemperaturesensor,anditsoutputisadigitalsignal.DS18B20hasthecharacteristicsofsmallsize,lowhardwareoverhead,stronganti-interferenceabilityandhighprecision.TheDS18B20digitaltemperaturesensoriseasytowireandcanbeusedinmanyoccasionsafterbeingpackaged.Suchaspipe,thread,magnetadsorption,stainlesssteelpackageandsoon.ThisArduinoforbeginnerstutorialwillteachyouhowtoreadtheDS18B201-wiretemperaturesensor.CatalogIDescriptionIIIntroductiontoDS18B202.1DS18B20BasicInformation2.2DS18B20Features2.3DS18B20StructureIIIIntroductiontoComponents3.1Memory3.264-bitLithographyROM3.3ConnectionofExternalPowerSupply3.4ConfigurationRegister3.5TemperatureReadingIVDS18B20WorkingPrincipleVConclusionFAQOrdering&QuantityIIIntroductiontoDS18B202.1DS18B20BasicInformationDS18B20isanimprovedintelligenttemperaturesensornewlylaunchedbyAmericanDALLASSemiconductorafterDS1820.Comparedwiththetraditionalthermistor,DS18B20candirectlyreadthemeasuredtemperatureandcanrealizethe9-12-digitdigitalvaluereadingmodethroughsimpleprogrammingaccordingtoactualrequirements.Itcanalsocomplete9-bitand12-bitdigitalquantitiesin93.75msand750ms,respectively.Moreover,theinformationreadfromtheDS18B20ortheinformationwrittenintotheDS18B20onlyneedsoneportline(single-wireinterface)toreadandwrite,andthetemperatureconversionpowercomesfromthedatabus.ThebusitselfcanalsosupplypowertotheconnectedDS18B20withouttheneedforanadditionalpowersupply.Therefore,theuseofDS18B20canmakethesystemstructuresimplerandmorereliable.DS18B20hasgreatlyimprovedcomparedwithDS1820intermsoftemperaturemeasurementaccuracy,conversiontime,transmissiondistance,andresolution.Itbringsmoreconvenientuseandmoresatisfyingeffectstousers.2.2DS18B20FeaturesUnique1-WireInterfaceRequiresOnlyOnePortPinforCommunicationReduceComponentCountwithIntegratedTemperatureSensorandEEPROMMeasuresTemperaturesfrom-55Cto+125C(-67Fto+257F)0.5CAccuracyfrom-10Cto+85CProgrammableResolutionfrom9Bitsto12BitsNoExternalComponentsRequiredParasiticPowerModeRequiresOnly2PinsforOperation(DQandGND)SimplifiesDistributedTemperature-SensingApplicationswithMultidropCapabilityEachDeviceHasaUnique64-BitSerialCodeStoredinOn-BoardROMFlexibleUser-DefinableNonvolatile(NV)AlarmSettingswithAlarmSearchCommandIdentifiesDeviceswithTemperaturesOutsideProgrammedLimitsAvailablein8-PinSO(150mils),8-PinSOP,and3-PinTO-92Packages2.3DS18B20StructureTheexternalstructureofDS18B20isshowninthefigure1.Amongthem:VDDisthepowerinputterminal;DQisthedigitalsignalinput/outputterminal;GNDisthepowerground.Figure1.DS18B20ExternalStructureTheinternalstructureofDS18B20mainlyincludes4parts:64-bitlithographyROM;Temperaturesensor;Non-volatiletemperaturealarmtriggersTHandTL;Configurationregister.Figure2.DS18B20ExternalStructureInthe64-bitROM,themanufacturerhasa64-bitserialnumberburnedbythemanufacturerbeforetheproductleavesthefactory.TheserialnumbercanberegardedastheaddressserialcodeofDS18B20,usedtodistinguisheachDS18B20.Soastobetterrealizethemulti-pointmeasurementoffieldtemperature.IIIIntroductiontoComponents3.1MemoryThememoryofDS18B20includeshigh-speedscratchpadRAMandelectricallyerasableRAM.TheelectricallyerasableRAMalsoincludestemperaturetriggersTHandTL,andaconfigurationregister.Thememorycancompletelydeterminethecommunicationoftheone-lineport,andthenumberiswrittenintotheregisterwiththecommandofwritingtheregister.Thenyoucanusethereadregistercommandtoconfirmthesenumbers.Afterconfirmation,youcanusethecopyregistercommandtotransferthesenumberstotheelectricallyerasableRAM.Whenthenumberintheregisterismodified,thisprocesscanensuretheintegrityofthenumber.ThescratchpadRAMiscomposedof8bytesofmemory.Theninthbytecanbereadwiththereadregistercommand.Thisbyteistocheckthepreviouseightbytes.3.264-bitLithographyROMFor64-bitlithographyROM:Thefirst8bitsaretheowncodeofDS18B20Thenext48bitsareconsecutivedigitalcodesThelast8bitsaretheCRCcheckofthefirst56bits.The64-bitlithographyROMalsoincludes5ROMfunctioncommands:readROM,matchROM,skipROM,searchROMandalarmsearch.3.3ConnectionofExternalPowerSupplyDS18B20canuseexternalpowerVDDorinternalparasiticpower.WhentheVDDportisconnectedtoavoltageof3.0V-5.5V,anexternalpowersupplyisused.AninternalparasiticpowersupplyisusedwhentheVDDportisgrounded.Inaddition,whetheritisaninternalparasiticpowersupplyoranexternalpowersupply,theI/Oportlineshouldbeconnectedtoapull-upresistorofabout5K.3.4ConfigurationRegisterTheconfigurationregisteristoconfiguredifferentdigitstodeterminethetemperatureanddigitalconversion.ItcanbeknownthatR1andR0arethedeterminingbitsoftemperature.DifferentcombinationsofR1andR0canbeconfiguredas9-digit,10-digit,11-digit,and12-digittemperaturedisplay.Inthisway,theconversiontimecorrespondingtodifferenttemperatureconversionpositionscanbeknown.Theresolutionsofthefourconfigurationsare0.5C,0.25C,0.125Cand0.0625C,respectively,andareconfiguredto12bitsatthefactory.3.5TemperatureReadingDS18B20isconfiguredas12bitsatthefactory,and16bitsarereadwhenreadingtemperature.Thefirst5bitsaresignbits.Whenthefirst5digitsare1,thetemperaturereadisanegativenumber;whenthecurrent5digitsare0,thetemperaturereadisapositivenumber.Themethodofreadingwhenthetemperatureispositiveis:justconvertthehexadecimalnumbertodecimal.Whenthetemperatureisnegative,thereadingmethodis:invertthehexadecimalnumber,thenadd1onthisbasis,andthenconverttodecimal.Example:0550H=+85degrees,FC90H=-55degrees.IVDS18B20WorkingPrincipleThereadandwritesequenceandtemperaturemeasurementprincipleofDS18B20arethesameasDS1820.Onlythenumberofdigitsofthetemperaturevalueobtainedvarieswiththeresolution.Andthedelaytimeduringtemperatureconversionisreducedfrom2sto750ms.ThetemperaturemeasurementprincipleofDS18B20isshowninFigure3.Figure3.DS18B20TemperatureMeasurementPrincipleDiagramTheoscillationfrequencyofthecrystaloscillatorwithlowtemperaturecoefficientinthepictureislittleaffectedbytemperature.Itisusedtogenerateafixedfrequencypulsesignalandsendittothesubtractioncounter1.Thehightemperaturecoefficientcrystaloscillatorchangesitsoscillationfrequencysignificantlywithtemperaturechanges.Atthesametime,thegeneratedsignalisusedasthepulseinputofthesubtractioncounter2.Thefigurealsoimpliesacountinggate.Whenthecountinggateisopened,DS18B20countstheclockpulsesgeneratedbythelowtemperaturecoefficientoscillatortocompletethetemperaturemeasurement.Theopeningtimeofthecountinggateisdeterminedbythehightemperaturecoefficientoscillator.Beforeeachmeasurement,firstputthebasecorrespondingto-55℃intothesubtractioncounter1andthetemperatureregisterrespectively.Thesubtractioncounter1andthetemperatureregisterarepresettoabasevaluecorrespondingto-55℃.Thesubtractioncounter1subtractsthepulsesignalgeneratedbythelowtemperaturecoefficientcrystaloscillator.Whenthepresetvalueofthesubtractioncounter1isreducedto0,thevalueofthetemperatureregisterwillincreaseby1,thepresetofthesubtractioncounter1willbereloaded,andthesubtractioncounter1willrestartcountingthepulsesignalsgeneratedbythelowtemperaturecoefficientcrystaloscillator.Thisloopuntilthesubtractioncounter2countsto0,stoptheaccumulationofthetemperatureregistervalue.Thevalueinthetemperatureregisteristhemeasuredtemperatureatthistime.Figure4.DS18B20Theslopeaccumulatorisusedtocompensateandcorrectthenonlinearityinthetemperaturemeasurementprocess,anditsoutputisusedtocorrectthepresetvalueofthesubtractioncounter.Aslongasthecountinggateisnotclosed,repeattheaboveprocessuntilthetemperatureregistervaluereachesthemeasuredtemperaturevalue.ThisisthetemperaturemeasurementprincipleofDS18B20.Inaddition,becausetheDS18B20single-wirecommunicationfunctioniscompletedintimesharing,ithasastrictconceptoftimeslots.Therefore,thereadandwritetimingisveryimportant.VariousoperationsofthesystemtoDS18B20mustbecarriedoutaccordingtotheagreement.Theoperatingprotocolis:initializeDS18B20(sendresetpulse)sendROMfunctioncommandsendmemoryoperationcommandprocessdata.ThetimingdiagramofvariousoperationsisthesameasthatofDS1820.VConclusionInconclusion,thisblogsummarizesthefollowing3aspectsofDS1820:Features,structureandworkingprinciple.DS1820mainlychangesitsappearanceaccordingtodifferentapplications.ThepackagedDS18B20canbeusedinvariousnon-limitingtemperatureapplications.Includingcabletrenchtemperaturemeasurement,blastfurnacewatercirculationtemperaturemeasurement,boilertemperaturemeasurement,machineroomtemperaturemeasurement,agriculturalgreenhousetemperaturemeasurement,cleanroomtemperaturemeasurement,ammunitionstoragetemperaturemeasurement,etc.Inaddition,DS1820isabrasion-resistantandimpact-resistant,smallinsize,easytouse,anddiverseinpackaging,suitablefordigitaltemperaturemeasurementandcontrolofvariousnarrowspaceequipment.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)?

IDescriptionInthisblog,wewillintroduceamultifunctionalelectronicthermometer.Thiskindofthermometercannotonlyaccuratelyandconvenientlymeasurebodytemperatureandfoodtemperature,butalsocanbeusedtomeasureindoorandoutdoortemperature,refrigeratortemperature,etc.Inaddition,italsohasmultiplefunctionssuchastemperaturemeasurementtiming,temperaturememory,soundprompt,backlightdisplay,andautomaticshutdown.Moreover,ithasthecharacteristicsofaccuratemeasurement,simpleoperation,portabilityandlowprice.Therefore,itcanbewidelyusedinhospitalsandhomesasageneraltemperaturemeasuringinstrument.Intermsofitsworkingprinciple,thethermometerusesthedigitaltemperaturesensorDS18B20todetecttemperatureandtransmitsthedigitaltemperaturesignaltothesingle-chipmicrocomputer.Thetemperaturevalueandmeasurementtimecalculatedandcorrectedbythesingle-chipmicrocomputeraredisplayedinrealtimebytheliquidcrystaldisplay.AtutorialonhowtousetheDallasMaxim1-WireDS18B20digitaltemperaturesensorwiththeArduino.CatalogIDescriptionIIDS18B20IntroductionIIIHardwareCircuit3.1PowerCircuit3.2DigitalTemperatureSensorandCalibration3.3MCUCircuit3.4LCDDisplay3.5AudioCircuitIVSoftwareDesignVConclusionFAQOrdering&QuantityIIDS18B20IntroductionDS18B20isasingle-wiredigitaltemperaturesensorproducedbyDALLAS.Itintegratestemperaturesensing,signalconversion,A/Dconversionandheatingfunctionsintoonechip,andbelongstoanewgenerationofintelligentdigitaltemperaturesensorswithmicroprocessors.DS18B20hasatotalof3pins,(respectivelydigitalsignalinput/output,ground,powersupply),usingTO-92small-volumepackaging.DS18B20MainSpecifications:Thetemperaturemeasurementrangeis-55℃~+125℃;Programmableto9to12bitA/Dconversionaccuracy;Thetemperaturemeasurementresolutioncanreach0.0625℃,andtheerroris0.5℃;Theworkingpowersupplycanbeintroducedattheremoteend(3-wireworkingmode)orgeneratedbyparasiticpowersupply(2-wireworkingmode);Themeasuredtemperatureisseriallyoutputwithasign-extended16-bitdigitalquantity;Eachsensorhasaunique64-bitserialnumber,whichisstoredintheROMofthesensor;Thesensoralsohastwotemperatureupperandlowerlimitstorageunits.IIIHardwareCircuitThemultifunctionalelectronicthermometerismainlycomposedofthefollowingparts:PowercircuitDigitaltemperaturesensorSinglechipcomputerLCDMonitorAudiocircuit...ItshardwarecircuitschematicdiagramisshownasinFig.1.Figure1.HardwareCircuit(rightclicktoviewbigpicture)3.1PowerCircuitU1isthemicropowerconsumptionstep-downDC/DCconverterLT3470introducedbyLinearTechnology.Here,U1convertsthe9Vdrybatteryvoltageinto5VDCvoltagetopowertheentirecircuit.So,howtostartandshutdownautomatically?WeonlyneedtopressthestartbuttonS2.Afterstarting,pin1(SHDN)ofU1getsahighlevel,pin5ofU1outputsa5VstableDCvoltage,andthethermometerstartstoworkatthistime.Then,the14-pin(P1.2)oftheone-chipcomputeroutputsahighlevelthroughD2tokeepthe1pinofU1high.When6minutesareup,the14-pinofthesingle-chipmicrocomputeroutputsalowlevel,andthe1pinofU1becomesalowlevel,andthecircuitautomaticallypowersdown.3.2DigitalTemperatureSensorandCalibrationThedigitaltemperaturesensorDS18B20isusedasatemperaturemeasuringprobetocollecttemperaturesignals.Andthedigitizedtemperaturesignalisinputthroughthe19-pin(P1.7)ofthemicrocontroller.DS18B20adopts2-wireworkingmode,andtheworkingpowerisgeneratedbyparasiticpower.Forexample,usethisthermometertomeasurethetemperatureofababy.Wecanfixthetemperatureprobeonaspecialbandageandtieittothearm.Sothatthesensorislocatedunderthearmpit.Inthisway,itcanbeavoidedthatthetemperaturemeasuringprobeisdetachedfromthetestsite.Duetoinfantactivitiesorcryingwhenmeasuringthebodytemperatureoftheinfant,andthemeasurementisconvenient.Foranotherexample,thetemperatureprobecanalsomeasureindoorandoutdoortemperature,refrigeratortemperature,etc.Thespecialprobeformeasuringfoodtemperatureadoptsnon-toxicstrawandnon-toxicsilicagelpackage,whichiseasytoclean.SinceDS18B20isintherangeof-10℃~85℃,itsmeasurementerroris0.5℃.Inordertoaccuratelymeasurebodytemperature,thisblogusesaself-madeconstanttemperaturewaterbathsystemtodeterminethetemperaturecurveofeachsensor.WecancalibratetheDS18B20accordingtothetemperaturecurvetomakethemeasurementerrorwithintherangeof25℃~50℃be0.1℃.3.2.1ConstantTemperatureWaterBathSystemTheconstanttemperaturewaterbathsystemconsistsofthefollowingthreeparts:anelectriccookerwithheatpreservation,acylindricalcopperbodywithgoodheatconduction,andanautomatictemperaturecontroller.Weneedtomake50roundholeswithadiameterof5mmandaheightof30mmonacylindricalcopperbodywithadiameterof120mmandaheightof80mm.Inthisway,thetemperaturesensorcanbefixedandthetemperatureofallthesensorsinthecopperbodycanbekeptconsistent.Putthecylindricalcopperbodyintotheelectriccooker,andadddistilledwatertosubmergethecopperbody.3.2.2DS18B20ActualTemperatureCurveMeasurementInsertmultipleencapsulatedsensorstobetested(nomorethan49)intothesmallholesofthecopperbodyoftheconstanttemperaturewaterbath;Insertthehigh-precisiondigitalthermometerintothesmallholeofthecopperbodytoaccuratelymeasurethecurrenttemperature;Thewiresofallsensorsareledoutthroughtheuppercoverholeoftheelectriccookerandconnectedtotheuppercomputer.Covertheelectriccookerwithheatpreservationmaterial;Turnonthepower,changethetemperaturesettingoftheautomaticthermostat,andcontrolthetemperatureoftheconstanttemperaturewaterbath;Monitorthetemperaturevalueofthedigitalthermometer.Wheneverthespecifiedtemperaturevalueisreached,starttheuppercomputertemperaturemeasurementprogramandsimultaneouslymeasurethecurrenttemperatureofallthesensorstobetested;From25℃~60℃,measure1setofdataevery5℃,andautomaticallygeneratetheactualtemperaturecurveofeachsensor.3.2.3CorrectionofDS18B20Byanalyzingthemeasuredtemperaturecurveofthesensor,wecanfindthatwithintherangeof25℃~50℃,theerroris-0.1℃~-0.3℃.Inthedesignofthisblog,thecurrenttemperaturevalueofDS18B20plus0.2℃isusedastheactualmeasuredtemperature,sothatthemeasurementerrorintherangeof25℃~50℃isreducedto0.1℃.3.3MCUCircuitThemicrocontroller(U2)isthecorecomponentofthethermometer.Ithasthefollowingfunctions:Temperaturesignalreading,processingcalculation,correctionTemperaturemeasurementtimingTemperaturememorySoundprompt,Automaticshutdown...ThisdesignadoptsAT89C2051single-chipmicrocomputerproducedbyAmericanATMELcompany.Itisabuilt-inflashmemorymicrocontrollerthatisfullycompatiblewiththeMCS-51series,withonly20pins.Itisthemostcompact,smallest,andcheapestFlashROMmicrocontrollerintheAT89C51series.Providesthefollowingstandardfunctions:An8-bitCPU;2kBflashmemory;128bytesRAM;Two16-bittimers;Acomplete8-bitbidirectionalI/Oport;5interruptsources.Afterstartingthethermometer,themicrocontrollerstartsaninternaltimertorecordthetemperaturemeasurementtime.ItalsoreadsthedigitaltemperaturesignalsentbyDS18B20,processesandcorrectsittoobtainthereal-timetemperaturevalue.ThetemperaturevalueandtemperaturemeasurementtimearesenttotheLCDdisplayviaserialcommunicationviapin1(P3.0)andpin2(P3.1);Whenthetemperaturemeasurementtimereaches5minutes,thecurrenttemperaturevalueisautomaticallyregistered,andpin11outputsalowleveltocontroltheaudiocircuittogiveasoundprompt;Whenthetemperaturemeasurementtimereaches6minutes,thesingle-chip14pinoutputslowlevel,andthethermometerisautomaticallypoweredoff.3.4LCDDisplayThisblogusesa3andahalfliquidcrystaldisplay(LCD)todisplaytemperatureandtemperaturemeasurementtime.Thedisplayhasthefollowingcharacteristics:Useglassencapsulation;Thereare5pinsintotal;SerialcommunicationWith3andahalfdisplayareaand℃unitdisplay;Functionwithbacklight;Thepowersupplyvoltagerangeis2V~5V.Thisdesignusesthemaindisplayareatoindicatethetemperature,andthesub-displayareatoindicatethetemperaturemeasurementtime.3.5AudioCircuitTheaudiocircuitconsistsofthefollowingparts:TransistorQ2(9015)resistanceR12;CapacitanceC12;BuzzerB1;Whenthepin11ofthesingle-chipmicrocomputeroutputslowlevel,thetransistorQ2issaturatedandturnedon,andthebuzzergeneratesanaudibleprompt.IVSoftwareDesignTheprogramiswrittenin89C51seriesClanguageanddebuggedonthesingle-chipsimulationsystem.TheprogramflowchartisshowninFigure2.Figure2.BlockDiagramofMainProgramAfterpower-onreset,initializetheDS18B20,inputandoutputports,timers,etc.ReadthetemperaturevalueofthelastmeasurementandstoragefromthelowertemperaturelimitstorageunitofDS18B20anddisplayitfor3seconds.StarttheinternaltimerT0ofthemicrocontrollertorecordthetemperaturemeasurementtime.Obtainthetemperaturevalueandcorrecttheerror.AccordingtothecommunicationprotocolofDS18B20,thetemperaturesignalisreadfromthesensor,thesignisdistinguished,andthetemperaturevalueisobtainedaftercalculationandprocessing.Then,add0.2Ctothetemperaturevalueastheactualtemperature,andcorrectthemeasurementerrorwithintherangeof25Cto50Cto0.1C.Displayoftemperature.Accordingtothecommunicationprotocoloftheliquidcrystaldisplay,thetemperaturevalueandtemperaturemeasurementtimearesenttothedisplayfordisplay.Themaindisplayareaindicatesthetemperature,andthesecondarydisplayareaindicatesthetemperaturemeasurementtime.Whenthetemperaturemeasurementtimereaches5minutes,the11-pinofthesingle-chipmicrocomputeroutputsalow-levelcontrolaudiocircuittoemitapromptsound,andthecurrenttemperatureissenttothelowertemperaturestorageunitofDS18B20forregistration,andsenttothesecondarydisplayareafordisplay.Whenthetemperaturemeasurementtimereaches6minutes,the14-pinofthesingle-chipmicrocomputeroutputslowlevel,andthethermometerautomaticallypowersdown.VConclusionComparedwithtraditionalthermometers,theDS18B20Multi-functionElectronicThermometerdesignedinthisbloghasmanyadvantages.Thelatterovercomesthedifficultyofreadingmercurythermometersandiseasytobebrokenandpollutetheenvironment.Atthesametime,comparedwithsimpleelectronicthermometers,multifunctionalelectronicthermometersalsoovercometheshortcomingsofpoormeasurementaccuracy.Becauseofitscompletefunctions,stableperformance,smallsize,lightweight,lowpowerconsumption,andlowprice,itcanbeusedasageneraltemperaturemeasuringinstrumentandwidelyusedinhospitalsandhomes.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)?DescriptionDS18B20isatemperaturesensorofMaxim.Thesingle-chipmicrocomputercancommunicatewithDS18B20through1-Wireprotocolandfinallyreadthetemperature.Thehardwareinterfaceofthe1-Wirebusisverysimple,justconnectthedatapinofDS18B20toanIOportofthemicrocontroller.ThisVideoIntroducesDS18B20withDatasheetCatalogDescriptionDocumentandMediaDS18B20PinoutParametersAdvantageFeaturesApplicationsDS18B20CircuitSchematicDS18B20TemperatureSensorDataDS18B20BlockDiagramHowtousetheDS18B20SensorWheretouseDS18B20SensorProductManufacturerFAQOrdering&QuantityDocumentandMediaComponentDatasheetDS18B20DatasheetDS18B20PinoutPinNameFunctionSOSOPTO-921,2,6,7,82,3,5,6,7-N.C.NoConnection383VDDOptionalVDD.VDDmustbegroundedforoperationinparasitepowermode.412DQDataInput/Output.Open-drain1-Wireinterfacepin.Alsoprovidespowertothedevicewhenusedinparasitepowermode(seethePoweringtheDS18B20section.)541GNDGroundParametersAccuracy(C)0.5ChannelsOneInterface1-WireMultiDroppableYesOper.Temp.(C)-55to+125Package/PinsSOIC(N)/8,TO92/3,UMAX/8ParasitePwr.YesPartNumberDS18B20SensorTypeLocalTemp.Resolution(bits)9,10,11,12Temp.Thresh.Programmable(NV)AdvantageTheDS18B20digitalthermometerprovides9-bitto12-bitCelsiustemperaturemeasurementsandhasanalarmfunctionwithnonvolatileuser-programmableupperandlowertriggerpoints.TheDS18B20communicatesovera1-Wirebusthatbydefinitionrequiresonlyonedataline(andground)forcommunicationwithacentralmicroprocessor.Inaddition,theDS18B20canderivepowerdirectlyfromthedataline(parasitepower),eliminatingtheneedforanexternalpowersupply.EachDS18B20hasaunique64-bitserialcode,whichallowsmultipleDS18B20stofunctiononthesame1-Wirebus.Thus,itissimpletouseonemicroprocessortocontrolmanyDS18B20sdistributedoveralargearea.ApplicationsthatcanbenefitfromthisfeatureincludeHVACenvironmentalcontrols,temperaturemonitoringsystemsinsidebuildings,equipment,ormachinery,andprocessmonitoringandcontrolsystems.FeaturesUnique1-WireInterfaceRequiresOnlyOnePortPinforCommunicationReduceComponentCountwithIntegratedTemperatureSensorandEEPROMMeasuresTemperaturesfrom-55Cto+125C(-67Fto+257F)0.5CAccuracyfrom-10Cto+85CProgrammableResolutionfrom9Bitsto12BitsNoExternalComponentsRequiredParasiticPowerModeRequiresOnly2PinsforOperation(DQandGND)SimplifiesDistributedTemperature-SensingApplicationswithMultidropCapabilityEachDeviceHasaUnique64-BitSerialCodeStoredinOn-BoardROMFlexibleUser-DefinableNonvolatile(NV)AlarmSettingswithAlarmSearchCommandIdentifiesDeviceswithTemperaturesOutsideProgrammedLimitsAvailablein8-PinSO(150mils),8-PinSOP,and3-PinTO-92PackagesApplicationsConsumerProductsIndustrialSystemsThermallySensitiveSystemsThermometersThermostaticControlsDS18B20CircuitSchematicDS18B20TemperatureSensorDataDS18B20canachievethehighest12-bittemperaturestoragevaluethroughprogramming.Thetemperaturestoragevalueisstoredintheregisterinacomplementformat.Thereare2bytesintotal,LSBisthelowbyteandMSBisthehighbyte.Amongthem,MSbisthehighbitofthebyte,andLSbisthelowbitofthebyte.Forbinarynumbers,themeaningofthetemperaturerepresentedbyeachofthemisexpressed.Amongthem,Srepresentsthesignbit,andthelower11bitsareallpowersof2,whichareusedtorepresentthefinaltemperature.ThetemperaturemeasurementrangeofDS18B20isfrom-55degreesto+125degrees.Themanifestationoftemperaturedatahaspositiveandnegativetemperatures.Eachnumberintheregisterisdistributedlikethescaleofacaliper.Thelowestbitofthebinarynumberchanges1,whichrepresentsthemappingrelationshipofatemperaturechangeof0.0625degrees.Whenthetemperatureis0℃,thecorrespondinghexadecimalnumberis0x0000.Whenthetemperatureis125℃,thecorrespondinghexadecimalnumberis0x07D0.Whenthetemperatureisminus55℃,thecorrespondinghexadecimalnumberis0xFC90.Conversely,whenthenumberis0x0001,thetemperatureis0.0625℃.DS18B20BlockDiagramHowtousetheDS18B20SensorThesensorworkswiththemethodof1-Wirecommunication.Itrequiresonlythedatapinconnectedtothemicrocontrollerwithapullupresistorandtheothertwopinsareusedforpowerasshownbelow.Thepull-upresistorisusedtokeepthelineinhighstatewhenthebusisnotinuse.Thetemperaturevaluemeasuredbythesensorwillbestoredina2-byteregisterinsidethesensor.Thisdatacanbereadbytheusingthe1-wiremethodbysendinginasequenceofdata.Therearetwotypesofcommandsthataretobesenttoreadthevalues,oneisaROMcommandandtheotherisfunctioncommand.TheaddressvalueofeachROMmemoryalongwiththesequenceisgiveninthedatasheetbelow.Youhavetoreadthroughittounderstandhowtocommunicatewiththesensor.IfyouareplanningtointerfaceitwithArduino,thenyouneednotworryaboutallthese.Youcandevelopthereadilyavailablelibraryandusethein-builtfunctionstoaccessthedata.WheretouseDS18B20SensorTheDS18B20isa1-wireprogrammableTemperaturesensorfrommaximintegrated.Itiswidelyusedtomeasuretemperatureinhardenvironmentslikeinchemicalsolutions,minesorsoiletc.Theconstrictionofthesensorisruggedandalsocanbepurchasedwithawaterproofoptionmakingthemountingprocesseasy.Itcanmeasureawiderangeoftemperaturefrom-55Cto+125withadecentaccuracyof5C.EachsensorhasauniqueaddressandrequiresonlyonepinoftheMCUtotransferdatasoitaverygoodchoiceformeasuringtemperatureatmultiplepointswithoutcompromisingmuchofyourdigitalpinsonthemicrocontroller.ProductManufacturerMaximIntegratedprovideseaseofdesign,andspeedstimetomarket,throughanalogintegration.ThecompanysanalogICsofferextrafeaturesandfunctionalitycarefullydesignedtostreamlinecircuitandsimplifydesign.LooktoMaximforsolutionsforconsumerelectronics,personalcomputersandperipherals,mobiledevices,wirelessandfibercommunications,testequipment,instrumentation,videodisplays,andautomotiveapplications.Maximsanalogandmixed-signalsolutionsincludedataconverters,interfacecircuits,power,RFwirelesscircuits,clocksandoscillators,microcontrollers(MCUs),operationalamplifiers(opamps),andsensors.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)?

访客,请您发表评论:

Powered By Tkool Electronics

Copyright Your WebSite.sitemap