Design of PWM Controller in a MCS51 Compatible MCUWord文件下载.docx
《Design of PWM Controller in a MCS51 Compatible MCUWord文件下载.docx》由会员分享,可在线阅读,更多相关《Design of PWM Controller in a MCS51 Compatible MCUWord文件下载.docx(11页珍藏版)》请在冰点文库上搜索。
Abstract:
Inthispaper,wewilltalksomethingaboutPWMtechnology.PWMtechnologyisakindofvoltageregulationmethodbycontrollingtheswitchfrequencyofDCpowerwithfixedvoltagetomodifythetwo-endvoltageofload.Thistechnologycanbeusedforavarietyofapplicationsincludingmotorcontrol,temperaturecontrolandpressurecontrolandsoon.Thistechniquewillbewidelyusedinmotorcontrol.
Keywords:
PWMtechnology;
frequency;
motorcontrol
Introduction
PWMtechnologyisakindofvoltageregulationmethodbycontrollingtheswitchfrequencyofDCpowerwithfixedvoltagetomodifythetwo-endvoltageofload.Thistechnologycanbeusedforavarietyofapplicationsincludingmotorcontrol,temperaturecontrolandpressurecontrolandsoon.InthemotorcontrolsystemshownasFig.1,throughadjustingthedutycycleofpowerswitch,thespeedofmotorcanbecontrolled.AsshowninFig.2,underthecontrolofPWMsignal,theaverageofvoltagethatcontrolsthespeedofmotorchangeswithDuty-cycle(D=t1/TinthisFigure),thusthemotorspeedcanbeincreasedwhenmotorpowerturnon,decreasedwhenpowerturnoff.
Fig.1:
TheRelationshipbetweenVoltageofArmatureandFig.2ArchitectureofPWMModule
Therefore,themotorspeedcanbecontrolledwithregularlyadjustingthetimeofturn-onandturn-off.Therearethreemethodscouldachievetheadjustmentofdutycycle:
(1)Adjustfrequencywithfixedpulse-width.
(2)Adjustbothfrequencyandpulse-width.(3)Adjustpulse-widthwithfixedfrequency.
Generally,therearefourmethodstogeneratethePWMsignalsasthefollowing:
(1)Generatedbythedevicecomposedofseparatelogiccomponents.Thismethodistheoriginalmethodwhichnowhasbeendiscarded.
(2)Generatedbysoftware.ThismethodneedCPUtocontinuouslyoperateinstructionstocontrolI/OpinsforgeneratingPWMoutputsignals,sothatCPUcannotdoanythingother.Therefore,themethodalsohasbeendiscardedgradually.(3)GeneratedbyASIC.TheASICmakesadecreaseofCPUburdenandsteadyworkgenerallyhasseveralfunctionssuchasover-currentprotection,dead-timeadjustmentandsoon.Thenthemethodhasbeenwidelyusedinmanykindsofoccasionnow.(4)GeneratedbyPWMfunctionmoduleofMCU.ThroughembeddingPWMfunctionmoduleinMCUandinitializingthefunction,PWMpinsofMCUcanalsoautomaticallygeneratePWMoutsignalswithoutCPUcontrollingonlywhenneedtochangeduty-cycle.Itisthemethodthatwillbeimplementedinthispaper.
Inthispaper,weproposeaPWMmoduleembeddedina8052microcontroller.ThePWMmodulecansupportPWMpulsesignalsbyinitializingthecontrolregisterandduty-cycleregisterwiththreemethodsjustmentionedabovetoadjustthedutycycleandseveraloperationmodestoaddflexibilityforuser.
ThefollowingsectionexplainsthearchitectureofthePWMmoduleandthearchitecturesofbasicfunctionalblocks.Section3describestwooperationmodes.Experimentalandsimulationresultsverifyingpropersystemoperationarealsoshowninthatsection.Dependingonmodeofoperation,thePWMmodulecreatesoneormorepulse-widthmodulatedsignals,whosedutyratioscanbeindependentlyadjusted.
ImplementationofPWMmoduleinMCU
OverviewofthePWMmodule
AblockdiagramofPWMmoduleisshowninFig.3.Itisclearlyfromthediagramthatthewholemoduleiscomposedoftwosections:
PWMsignalgeneratoranddead-timegeneratorwithchannelselectlogic.ThePWMfunctioncanbestartedbytheuserthroughimplementingsomeinstructionsforinitializingthePWMmodule.Inparticular,thefollowingpowerandmotioncontrolapplicationsaresupported:
•DCMotor
•UninterruptablelPowerSupply(UPS)
·
ThePWMmodulealsohasthefollowingfeatures:
•TwoPWMsignaloutputswithcomplementaryorindependentoperation
•Hardwaredead-timegeneratorsforcomplementarymode
•DutycycleupdatesareconfigurabletobeimmediatedorsynchronizedtothePWM
Fig.3ArchitectureofPWMModule
Detailsofthearchitecture
PMWgenerator
Thearchitectureofthe2-outputPWMgeneratorshowninFig.4isbasedona16-bitresolutioncounterwhichcreatesapulse-widthmodulatedsignal.Thesystemissynthesizedbyasystemclocksignalwhosefrequencycanbedividedby4timesor12timesthroughsettingthevalueofT3MforPWM0orT4MforPWM1inthespecialregisterPWMCONasshowninFig.4.ToPWM0generator,theclockto16-bitcounterwillbepre-dividedby4timesbydefaultwhenT3Missettozero.Andtheclockwillbedividedby12timeswhenT3Missetto1.ThisisalsotrueforPWM1.TheotherbitsinPWMCONareexplainedindetailinTable1.
Fig.4BitMappingofPWMCON
Table1:
TheBitDefinitioninPWMCON
Channel-selectlogic
ThefollowFig.5showsthechannel-selectlogicwhichisusefulinComplementaryMode.Fromthisdiagram,itiscleartoknowthatsignalCPandCPWMcontrolthesourceofPWMHandPWML.Andthedetailsaboutthetwocontrolsignalswillbediscussedinthesection3,andthearchitectureofdead-timegeneratorwillalsobediscussedinsection5forthecontinuityofComplementaryMode.
Fig.5DiagramofChannel-selectLogic
OperationModeandSimulationResults
Thedesignhastwooperationmodes:
IndependentModeandComplimentaryMode.BysettingthecorrespondingbitCPWMinregisterPWMCONshowninFig.6usercanselectoneofthetwooperationmodes.WhenCPWMissettozero,PWMmodulewillworkinIndependentMode,whereas,PWMmodulewillworkinComplimentaryMode.Inthefollowingofthissection,thetwooperationmodewillbeexplainedrespectivelyindetailandthesimulationresultsofthePWMmodulefromtheSynoposysVCSEDAplatformwhichverifythedesignwillalsobeshown.
IndependentPWMOutputMode
AnIndependentPWMOutputmodeisusefulfordrivingloadssuchastheoneshowninFigure6.AparticularPWMoutputisintheIndependentOutputmodewhenthecorrespondingCPbitinthePWMCONregisterissettozero.Inthiscase,two-channelPWMoutputsareindependentofeachother.ThesignalonpinPWM0/PWMHisfromPWM0generator,andthesignalonpinPWM1/PWMLisfromPWM0generator.Theseparatecaseisachievedbythechannel-selectlogicshowninFig.6.ThePWMI/Opinsaresettoindependentmodebydefaultuponadvicereset.Thedead-timegeneratorisdisabledintheIndependentmode.ThesimulationresultisshowninFigure6asthefollowingFig.6Tr4andtr3arerunbitstoPWM0andPWM1,respectively.Actually,fromthisdiagram,PinP1[5]/P1[4]ofMCUisusedforPWMH/PWMLornormalI/O,alternatively.
Fig6theWaveformofPWMOutputsinIndependentMode
ComplementaryPWMOutputMode
TheComplementaryOutputmodeisusedtodriveinverterloadssimilartotheoneshowninFigure7.ThisinvertertopologyistypicalforDCapplications.InComplementaryOutputMode,thepairofPWMoutputscannotbeactivesimultaneously.ThePWMchannelandoutputpinpairareinternallyconfiguredthroughchannel-selectlogicasshowninFigure7.Adead-timemaybeoptionallyinsertedduringdeviceswitchingwherebothoutputsareinactiveforashortperiod.
Fig7:
TypicalLoadforComplementaryPWMOutputs
TheComplementarymodeisselectedforPWMI/OpinpairbysettingtheappropriateCPWMbitinPWMCON.Inthiscase,PSELisineffect.PWMHandPWMLwillcomefromPWM0generatorwhenPSELissettozero,whenthesignalsfromPWM1generatorisuseless,whereasPWMHandPWMLwillcomefromPWM1generatorwhenPSELissetto1,whenthesignalsfromPWM0generatorisuseless.IntheprocessofproducingthePWMoutputsinComplementaryMode,thedead-timewillbeinsertedtobediscussedinthefollowingsection.
Dead-timeControl
Dead-timegenerationisautomaticallyenabledwhenPWMI/OpinpairisoperatingintheComplementaryOutputmode.Becausethepoweroutputdevicescannotswitchinstantaneously,someamountoftimemustbeprovidedbetweentheturn-offeventofonePWMoutputinacomplementarypairandtheturn-oneventoftheothertransistor.The2-outputPWMmodulehasoneprogrammabledead-timewith8-bitregister.ThecomplementaryoutputpairforthePWMmodulehasan8-bitdowncounterthatisusedtoproducethedead-timeinsertion.AsshowninFigure8,thedeadtimeunithasarisingandfallingedgedetectorconnectedtoPWMsignalfromoneofPWMgenerator.ThedeadtimesisloadedintothetimeronthedetectedPWMedgeevent.Dependingonwhethertheedgeisrisingorfalling,oneofthetransitionsonthecomplementaryoutputsisdelayeduntilthetimercountsdowntozero.AtimingdiagramindicatingthedeadtimeinsertionforthepairofPWMoutputsisshowninFigure8a.
Fig8aDead-timeUnitBlockDiagram
Fig.8btheWaveformsofPWMOutputsinComplementaryMode
TheAT89S52isalow-power,high-performanceCMOS8-bitmicrocontrollerwith8Kbytesofin-systemprogrammableFlashmemory.ThedeviceismanufacturedusingAtmel’shigh-densitynonvolatilememorytechnologyandiscompatiblewiththeindus-try-standard80C51instructionsetandpinout.Theon-chipFlashallowstheprogrammemorytobereprogrammedin-systemorbyaconventionalnonvolatilememorypro-grammer.Bycombiningaversatile8-bitCPUwithin-systemprogrammableFlashonamonolithicchip,theAtmelAT89S52isapowerfulmicrocontrollerwhichprovidesahighly-flexibleandcost-effectivesolutiontomanyembeddedcontrolapplications.TheAT89S52providesthefollowingstandardfeatures:
8KbytesofFlash,256bytesofRAM,32I/Olines,Watchdogt