spin46sw.com
46sw.com 时间:2021-04-08 阅读:(
)
FreescaleSemiconductor,Inc.
,2006.
Allrightsreserved.
FreescaleSemiconductorApplicationNoteAN3005Rev.
1,05/2006TableofContentsThisapplicationnotedescribesthedesignofa3-phaseBrushlessDC(BLDC)motordrivebasedonFreescale'sPowerPCMPC5554microcontroller.
TheapplicationdesigntakesadvantageoftheEnhancedTimeProcessingUnit(eTPU)module,whichisusedasamotorcontrolco-processor.
TheeTPUcompletelyhandlesthemotorcontrolprocessing(excludingcommutationprocessing),eliminatingthemicroprocessoroverheadforotherduties.
BLDCmotorsareverypopularinawidearrayofapplications.
ComparedtoaDCmotor,theBLDCmotorusesanelectriccommutator,replacingthemechanicalcommutatorandmakingitmorereliablethantheDCmotor.
InBLDCmotors,rotormagnetsgeneratetherotor'smagneticflux,allowingBLDCmotorstoachievehigherefficiency.
Therefore,BLDCmotorsmaybeusedinhigh-endwhitegoods(refrigerators,washingmachines,dishwashers,etc.
),high-endpumps,fans,andotherappliancesthatrequirehighreliabilityandefficiency.
Theconceptoftheapplicationistocreateaspeed-closedloopBLDCdriverusingaHallpositionsensor.
ItservesasanexampleofaBLDCmotorcontrolsystemdesign1PowerPCMPC5554andeTPUAdvantagesandFeatures22TargetMotorTheory.
43SystemConcept.
124SoftwareDesign235ImplementationNotes416MicroprocessorUsage457SummaryandConclusions468References47BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554CoversMPC5554andalleTPU-EquippedDevicesby:MilanBrejl&MichalPrinc&PavelSustekSystemApplicationEngineersRoznovCzechSystemCenterBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1PowerPCMPC5554andeTPUAdvantagesandFeaturesFreescaleSemiconductor2usingaFreescalemicroprocessorwiththeeTPU.
ItalsoillustratestheusageofdedicatedmotorcontroleTPUfunctionsthatareincludedintheDCmotorcontroleTPUfunctionset.
Thisapplicationnotealsoincludesbasicmotortheory,systemdesignconcept,hardwareimplementation,andmicroprocessorandeTPUsoftwaredesign,includingtheFreeMASTERvisualizationtool.
Figure1.
UsingtheMPC5554DEMO,33395EvaluationMotorBoard,andMCGBLDCMotor1PowerPCMPC5554andeTPUAdvantagesandFeatures1.
1PowerPCMPC5554MicrocontrollerTheMPC5554microcontrollerisafamilyofnextgenerationpowertrainmicrocontrollersbasedonthePowerPCBookEarchitecture.
Featuringtwo32channelseTPUengines,32Kbytesofcache,64KbytesofinternalSRAM,2MbytesofinternalFlashmemory,a64-channeleDMAcontroller,3FlexCANmodules,3UARTsandfourDSPImodules,theMPC5554familyhasbeendesignedforapplicationsthatrequirecomplex,real-timecontrol.
PowerPCMPC5554andeTPUAdvantagesandFeaturesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor3This32-bitdeviceisbasedonthePowerPCoperatingatacorefrequencyupto132MHz.
On-chipmodulesinclude:High-performance32-bitPowerPCBookE-compliantcoreMemorymanagementunit(MMU)with24-entryfullyassociativetranslationlook-asidebuffer(TLB)2MBofembeddedFlashmemorywithErrorCorrectionCoding(ECC)64KBon-chipL2staticRAMwithECC32KBofcachethatcanbeconfiguredasadditionalRAMnexusIEEE-ISTO5001classmulticoredebugcapabilitiesTwoenhancedtimeprocessorunits(eTPUs)64-channeleDMA(EnhancedDirectMemoryAccess)controllerInterruptcontroller(INTC)capableofhandling286satiable-priorityinterruptsourcesFrequencymodulatedphase-lockedloop(FMPLL)toassistinelectromagneticinterference(EMI)managementEnhancedqueuedanalog-to-digitalconverter(eQADC)Fourdeserialserialperipheralinterface(DSPI)modulesThreecontrollerareanetwork(FlexCAN)modulesTwoenhancedserialcommunicationinterface(eSCI)modulesEighty-eightchannelsoftimedI/OCrossbarswitch(XBAR)EnhancedmodularI/Osystem(eMIOS)Formoreinformation,refertoReference1.
1.
2eTPUModuleTheeTPUisanintelligent,semi-autonomousco-processordesignedfortimingcontrol,I/Ohandling,serialcommunications,motorcontrol,andenginecontrolapplications.
ItoperatesinparallelwiththehostCPU.
TheeTPUprocessesinstructionsandreal-timeinputevents,performsoutputwaveformgeneration,andaccessesshareddatawithoutthehostCPU'sintervention.
Consequently,thehostCPUsetupandservicetimesforeachtimereventareminimizedoreliminated.
TheeTPUontheMPC5554microcontrollerhastwoengineswithupto32timerchannelsforeach.
Inadditionithas16Kbytesofcodememoryand3Kbytesofdatamemorythatstoressoftwaremodulesdownloadedatboottimeandthatcanbemixedandmatchedasrequiredforanyspecificapplication.
TheeTPUprovidesmorespecializedtimerprocessingthanthehostCPUcanachieve.
ThisispartiallyduetotheeTPUimplementation,whichincludesspecificinstructionsforhandlingandprocessingtimeevents.
Inaddition,channelconditionsareavailableforusebytheeTPUprocessor,thuseliminatingmanybranches.
TheeTPUcreatesnohostCPUoverheadforservicingtimingevents.
Formoreinformation,refertoReference8.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1TargetMotorTheoryFreescaleSemiconductor42TargetMotorTheoryAbrushlessDC(BLDC)motorisarotatingelectricmachinewherethestatorisaclassicthree-phasestator,likethatofaninductionmotor,andtherotorhassurface-mountedpermanentmagnets(seeFigure2).
Figure2.
BLDCMotor—CrossSectionInthisrespect,theBLDCmotorisequivalenttoareversedDCcommutatormotor,inwhichthemagnetrotateswhiletheconductorsremainstationary.
IntheDCcommutatormotor,thecurrentpolarityisalteredbythecommutatorandbrushes.
UnlikethebrushlessDCmotor,thepolarityreversalisperformedbypowertransistorsswitchinginsynchronizationwiththerotorposition.
Therefore,BLDCmotorsoftenincorporateeitherinternalorexternalpositionsensorstosensetheactualrotorposition,orthepositioncanbedetectedwithoutsensors.
2.
1DigitalControlofaBLDCMotorTheBLDCmotorisdrivenbyrectangularvoltagestrokescoupledwiththegivenrotorposition(seeFigure3).
Thegeneratedstatorfluxinteractswiththerotorflux,whichisgeneratedbyarotormagnetanddefinesthetorqueandthusthespeedofthemotor.
Thevoltagestrokesmustbeproperlyappliedtotwophasesofthethree-phasewindingsystemsothattheanglebetweenthestatorfluxandtherotorfluxiskeptascloseto90°aspossible,togetthemaximumgeneratedtorque.
Therefore,themotorrequireselectroniccontrolforproperoperation.
StatorStatorwinding(inslots)ShaftRotorAirgapPermanentmagnetsTargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor5Figure3.
VoltageStrokesAppliedtothe3-PhaseBLDCMotorForthecommon3-phaseBLDCmotor,astandard3-phasepowerstageisused(seeFigure4).
Thepowerstageutilizessixpowertransistorsthatoperateineitheranindependentorcomplementarymode.
Inbothmodes,the3-phasepowerstageenergizestwomotorphasesconcurrently.
Thethirdphaseisunpowered(seeFigure3).
Thus,wegetsixpossiblevoltagevectorsthatareappliedtotheBLDCmotorusingaPulseWidthModulation(PWM)technique(seeFigure5).
Therearetwobasictypesofpowertransistorswitchingschemes:independentandcomplementary.
Bothswitchingmodesareabletoworkinbipolarorunipolarmode.
ThepresentedapplicationutilizesthecomplementarybipolarPWMmode.
FormoreinformationaboutPWMtechniques,refertoReference12.
Figure4.
3-PhaseBLDCPowerStage306090120150180210240270300330ElectricalangleVoltagePhaseAPhaseBPhaseC+UDCB-UDCB+UDCB-UDCB+UDCB-UDCBQ1PWM_Q5Q6Q4C1Phase_CPWM_Q1PWM_Q4PWM_Q3Phase_BGNDQ2UDCBPWM_Q2Phase_AQ3PWM_Q6Q5BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1TargetMotorTheoryFreescaleSemiconductor62.
1.
1CommutationCommutationprovidesthecreationofarotationalfield.
Asmentionedearlier,forproperoperationofaBLDCmotor,itisnecessarytokeeptheanglebetweenthestatorandrotorfluxascloseto90°aspossible.
Wegetatotalofsixpossiblestatorfluxvectorswithasix-stepcontrol.
Thestatorfluxvectormustbechangedatspecificrotorpositions,whichareusuallysensedbytheHallsensors.
TheHallsensorsgeneratethreesignalsthatalsoconsistofsixstates.
EachoftheHallsensors'statescorrespondtoacertainstatorfluxvector.
AlloftheHallsensorsstates,withcorrespondingstatorfluxvectors,areillustratedinFigure5.
Figure5.
StatorFluxVectorsatSix-StepControlThenexttwofiguresdepictthecommutationprocess.
TheactualrotorpositioninFigure6correspondstotheHallsensorsstateABC[110](seeFigure5).
PhaseAisconnectedtothepositiveDCbusvoltagebythetransistorQ1;phaseCisconnectedtothegroundbytransistorQ6,andphaseBisunpowered.
Assoonastherotorreachesacertainposition(seeFigure7),theHallsensorsstatechangesitsvaluefromABC[110]toABC[100].
AnewvoltagepatternisselectedandappliedtotheBLDCmotor.
Asshownbelow,whenusingthesix-stepcontroltechnique,itisdifficulttokeeptheanglebetweentherotorfluxandthestatorfluxpreciselyat90°inasix-stepcontroltechnique.
Theactualanglevariesfrom60°to120°.
Thecommutationprocessisrepeatedpereach60electricaldegreesandiscriticaltomaintainitsangular(time)accuracy.
Anydeviationcausestorqueripples,resultinginspeedvariation.
TargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor7Figure6.
SituationRightBeforeCommutation(Counter-ClockwiseMotion)Figure7.
SituationRightAfterCommutation2.
1.
1.
1QuadratureEncoderVersusHallSensorsTheBLDCmotorapplicationusesthequadratureencoderforrotorpositionsensing.
Thequadratureencoderoutputconsistsofthreesignals.
Twophases,AandB,representtherotorposition,andanindexpulsedefinesthezeroposition.
AllquadratureencodersignalsaredepictedinFigure8.
ComparedwithHallsensors,therearesomedifferences,whichaffectthecontrolalgorithm.
Themaindifferenceisthatthequadratureencoderdoesnotgivecommutationmomentandabsoluteposition,asdotheHallsensors.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1TargetMotorTheoryFreescaleSemiconductor8Figure8.
QuadratureEncoderOutputSignalsThedifferencesbetweenthequadratureencoderandHallsensorsaresummarizedinTable1.
Table1.
DifferencesBetweenQuadratureEncoderandHallSensorsThetwocontrolalgorithmsaredescribedlateronwiththequadratureencoder.
Thefirstsolutioniscommonlyusedandperiodicallyscansthequadratureencoder.
ThesecondsolutionusesspecificadvantagesoftheQDeTPUfunctionandtranslatesthequadratureencoderoutputsdirectlyintoHallsensorssignals.
Theseinternalsignalsareusedasaninputforthecommutationalgorithm.
Thisalgorithmisimplementedinthepresentedapplication.
2.
1.
1.
2CommutationwithPeriodicalScanningofQuadratureEncoderThecommutationoftheBLDCmotorisperformedinthesixdefinedmoments.
Sincethequadratureencodergivesthepreciseposition,theoneelectricalrevolutionisdividedintosixsectors(seeFigure9).
Torecognizethecommutationmoment,itisnecessarytoscanquadratureencoderpositionveryquickly.
Thefrequencyofscanningdependsonthemaximalrotorspeed,thenumberofpolepairsandontherequiredprecisionofcommutationmomentdetection.
ThesamescanfrequencyasusedinthePWMissatisfactoryforthecommonapplications.
Inthiscase,therotorpositioncanbescannedinthemomentofaPWMreloadinterrupt.
Thealgorithmtranslatestheactualpositionintotheoneofthesixsectors.
Ifachangeofsectorisdetected,thecommutationisperformed.
Thisalgorithmisnotimplementedinthepresentedapplication!
QuadratureEncoderHallSensors3outputs3outputsDoesnotgiveabsolutepositionGivesabsolutepositionGivesprecisepositionGives6eventsperelectricalrevolutiononerevolutionpositioncountervaluesPhaseAPhaseBIndex1998199901219981999012TargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor9Figure9.
SeparationofOneElectricalRevolutionintoSixCommutationSectorsNOTE:TheFigure9considers500pulsespermechanicalrevolution,bothrisingandfallingedgescounting,twopolepairs(500x4/2=1000pulsesperelectricalrevolution)2.
1.
1.
3DirectConversionofQuadratureEncoderSignalstoaCommutationSectorAdifferentmethodisthedirectconversionofencoderoutputtocommutationsectors.
TheconversionisprovidedbytheeTPU.
Theadvantageofthismethodisthataninterruptratedependsontheactualmotorspeed,whileinthepreviousmethod,thereisaconstantlyhighinterruptrateinordertoscantheactualmotorposition.
Thedirectconversionoperatesinfollowingway:Theelectricalrevolutionisdividedintosixsectors,asinFigure9.
Therotorpositionisscannedbytheshaftencoder,whichhasitsoutputsconnectedtothededicatedeTPUinputpins.
Thequadraturedecoder(QD)eTPUfunctionusesthesepinstodecodethequadratureencodersignalandtoprocesspositioncounting.
Afterrotoralignmenttoknownposition,twocompareparametersoftheQDeTPUfunctionaresettovaluesthatcorrespondtosectorbordersandthepositioncounterissettozero,seeFigure10.
Whenthemotorstartstomove,thepositioncounterstartstocountthepulsesofthequadratureencoder.
Nointerruptisgenerateduntilthepositioncounterreachesoneofthecomparevalues.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1TargetMotorTheoryFreescaleSemiconductor10Figure10.
AlignmentRotorPositionFigure11.
SituationPriortoFirstCompareFollowingAlignmentAssoonasthepositioncounterreachesoneofthecomparevalues,thepositioninterruptiscalledinordertostartthecommutation.
ThepositioninterruptsetsthenewvaluesintothecompareparametersoftheQDeTPUfunctionbasedonthespindirection.
ThenewvaluescorrespondstothenextcommutationsectorinTargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor11clockwiseorcounter-clockwisedirectionaccordingtoactualspindirection.
Thenthecontrolword,whichsavestheactualcommutationsector,isupdatedandthenewvoltagepatternisappliedtothemotor.
Figure12depictsthenewsituationaftercommutation.
Figure12.
SituationFollowingCommutationWecanseethatthepositioninterruptiscalledsixtimesperelectricalrevolution.
NotethatthepositioninterruptiscalledinthesamemomentaswhenweuseHallsensors.
2.
1.
2PositionAlignmentSincethequadratureencoderdoesn'tgivetheabsoluteposition,weneedtoknowtheexactrotorpositionbeforethemotorisstarted.
Onepossibleandveryeasilyimplementedmethodistherotoralignmenttoapredefinedposition.
Themotorispoweredbyadefinedstaticvoltagepatternandtherotoralignstothepredefinedposition.
Thisalignmentisdoneonlyonce,duringtheinitialmotorstartup.
TheFigure10showsthepositionofthealignedrotor.
Afteralignment,thecompareparametersofthepositioncounteraresetto+/-30electricdegreesfromthealignmentposition,inordertopresetthecommutationsector.
Thenextvoltagevectorissettobeorthogonaltothealignmentposition.
Theresultantdirectionofthevoltagevectorisgivenbythepolarityofappliedvoltage.
2.
1.
3SpeedControlCommutationensurestheproperrotorrotationoftheBLDCmotor,whilethemotorspeedonlydependsontheamplitudeoftheappliedvoltage.
TheamplitudeoftheappliedvoltageisadjustedusingthePWMtechnique.
Therequiredspeediscontrolledbyaspeedcontroller,whichisimplementedasaconventionalBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor12Proportional-Integral(PI)controller.
ThedifferencebetweentheactualandrequiredspeedsisinputtothePIcontrollerwhichthen,basedonthisdifference,controlsthedutycycleofthePWMpulseswhichcorrespondtothevoltageamplituderequiredtomaintainthedesiredspeed.
Figure13.
SpeedControllerThespeedcontrollercalculatesthePIalgorithmgivenintheequationbelow:AftertransformingtheequationintoadiscretetimedomainusinganintegralapproximationwiththeBackwardEulermethod,wegetthefollowingequationsforthenumericalPIcontrollercalculation:where:3SystemConcept3.
1SystemOutlineThesystemisdesignedtodrivea3-phaseBLDCmotor.
Theapplicationmeetsthefollowingperformancespecifications:e(k)=Inputerrorinstepkw(k)=Desiredvalueinstepkm(k)=Measuredvalueinstepku(k)=Controlleroutputinstepkup(k)=ProportionaloutputportioninstepkuI(k)=IntegraloutputportioninstepkuI(k-1)=Integraloutputportioninstepk-1TI=IntegraltimeconstantT=SamplingtimeKc=ControllergainSpeedControllerPWMGeneratorωdesiredPWMOutputDutyCycleωactualωerrorPowerStage-ΣCommutationHallSensorsut()Kcet()1TI-----eτ()τd0t∫+=uk()uPk()uIk()+=uPk()Kcek()=uIk()uIk1–()Kc+TTI-----ek()=SystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor13VoltagecontrolofaBLDCmotorusingquadratureencoderHEDS-5640A06TargetedatPowerPCMPC5554DEMOEvaluationBoard(MPC554DEMO),InterfaceBoardwithUNI-3,33395EvaluationMotorBoard,andMCGBLDCmotor(IB23810)Controltechniqueincorporates:—VoltageBLDCmotorcontrolwithspeed-closedloop—Bothdirectionsofrotation—4-quadrantoperation—Startfromanymotorpositionwithoutrotoralignment—Minimumspeedof10RPM—Maximumspeedof1000RPM(limitedbypowersupply)Manualinterface(Start/Stopswitch,Up/Downpushbuttoncontrol,LEDindication)FreeMASTERcontrolinterface(speedset-up,speedloopclose/openchoice)FreeMASTERmonitor—FreeMASTERgraphicalControlPage(requiredspeed,actualmotorspeed,start/stopstatus,faultstatus)—FreeMASTERSpeedControlScope(observesrequired,ramp,andactualspeeds,appliedvoltage)—DetaildescriptionofalleTPUfunctionsusedintheapplication(monitoringofchannelregistersandallfunctionparametersinrealtime)DCBusover-currentfaultprotection3.
2ApplicationDescriptionAstandardsystemconceptischosenforthemotorcontrolfunction(seeFigure14).
Thesystemincorporatesthefollowinghardware:EvaluationBoardMPC5554DEMOInterfaceBoardwithUNI-333395EvaluationMotorBoardMCGBLDCmotor(IB23810)PowerSupply12VDC,2.
7AmpsTheeTPUmodulerunsthemaincontrolalgorithm.
The3-phasePWMoutputsignalsfora3-phaseinverteraregeneratedaccordingtofeedbacksignalsfromquadratureencoderandtheinputvariablevalues,providedbythemicroprocessorCPU.
CommutationofPWMphasesiscontrolledbytheCPU.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor14Figure14.
SystemConceptThesystemprocessingisdistributedbetweentheCPUandtheeTPU,whichbothruninparallel.
TheCPUperformsthefollowingtasks:Periodicallyscanstheuserinterface(ON/OFFswitch,UpandDownbuttons,FreeMASTER).
Basedontheuserinput,ithandlestheapplicationstatemachineandcalculatestherequiredspeeds,whichispassedtotheeTPU.
EnsuresprocessingofpositioninterruptscomingfromeTPUQDchannelsandconsecutivecommutationofPWMphases.
TheinterruptsaregeneratedeachtimetheQDpositioncounterreachesavaluewhichcorrespondstotheborderbetweentwocommutationsectors.
PeriodicallyreadsapplicationdatafromeTPUDATARAMinordertomonitorapplicationvariables.
Intheeventofanovercurrentfault,thePWMoutputsareimmediatelytemporarilydisabledbytheeTPUhardware.
Then,afteraninterruptlatency,theCPUdisablesthePWMoutputspermanentlyanddisplaysthefaultstate.
TheeTPUperformsthefollowingtasks:SixeTPUchannels(PWMC)areusedtogeneratePWMoutputsignals.
ThreeeTPUchannels(QD)areusedtoprocessquadratureencodersignals.
eTPUcontrolsaspeedclosedloop.
TheactualmotorspeediscalculatedbasedontheQDpositioncounterandQDlastedgetimeandcomparedwiththerequiredspeed,providedbytheCPUandpassedthrougharamp.
ThespeedPIcontrolalgorithmprocessestheerrorbetweentherequiredandactualspeed.
ThePIcontrolleroutputispassedtothePWMgeneratorasanewlycorrectedvalueoftheappliedmotorvoltage.
BLDCMotorDriveeTPUenable/disablePWMsignalsrequiredspeedApplicationStateMachineON/OFFswitchstatusdatamonitoringFaultLEDCPUHardware3-PhasePowerStageBLDCmotor912VDC÷ON/OFFDOWNUPUARTFreeMASTERRemoteControlRS232GPIOShaftEncoderSignalsPWMSignalsFaultSignalStatusLEDCommutationProcessingpositioninterruptPWMphasescommutationShaftEncoderEMIOSOver-currentinterruptSystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor15Figure15.
TheApplicationandFreeMASTERScreen3.
2.
1UserInterfaceTheapplicationisinterfacedbythefollowing:ON/OFFswitchontheInterfaceBoardwithUNI-3Up/DownbuttonsontheInterfaceBoardwithUNI-3,orFreeMASTERrunningonaPCconnectedtotheMPC5554DEMOviaanRS232serialcable.
TheON/OFFswitchaffectstheapplicationstateandenablesanddisablesthePWMphases.
Whentheswitchisintheoff-position,novoltageisappliedtothemotorwindings.
WhentheON/OFFswitchisintheon-position,themotorspeedcanbecontrolledeitherbytheUpandDownbuttonsontheInterfaceBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor16Board,orbytheFreeMASTERonthePC.
TheFreeMASTERalsodisplaysacontrolpage,real-timevaluesofapplicationvariables,andtheirtimebehaviourusingscopes.
FreeMASTERsoftwarewasdesignedtoprovideanapplication-debugging,diagnostic,anddemonstrationtoolforthedevelopmentofalgorithmsandapplications.
ItrunsonaPCconnectedtotheMPC5554DEMOviaanRS232serialcable.
AsmallprogramresidentinthemicroprocessorcommunicateswiththeFreeMASTERsoftwaretoreturnstatusinformationtothePCandprocesscontrolinformationfromthePC.
FreeMASTERsoftware,executingonaPC,usespartofMicrosoftInternetExplorerastheuserinterface.
Note,thatFreeMASTERversion1.
2.
31.
1orhigherisrequired.
TheFreeMASTERapplicationcanbedownloadedfromhttp://www.
freescale.
com.
FormoreinformationaboutFreeMASTER,refertoReference7.
3.
3HardwareImplementationandApplicationSetupAspreviouslystated,theapplicationrunsontheMPC5554familyofPowerPCmicroprocessorsusingthefollowing:MPC5554DEMOInterfaceBoardwithUNI-333395EvaluationMotorBoard3-phaseMCGBLDCmotor(IB23810)PowerSupply,12VDC,minimum2.
7AmpsFigure16showstheconnectionoftheseparts.
AllsystempartsaresuppliedbyFreescaleanddocumentedaccordingtoreferences.
3.
3.
1PowerPCMPC5554EvaluationBoard(MPC5554DEMO)ThisboardisnotintendedtobeafullevaluationboardfortheMPC5554,butshowsaminimalsystemforlearningaboutthenewMPC5500familyofproduct.
TheFLASHmemoryplacedontheMPC5554hasthreeaddressspaces.
Lowandmidaddressspacesare256-Kbytesandhighaddressspacesis1.
5Mbyteinsize.
Itgivesatotalmemoryspaceof2Mbytes.
Formoreinformation,refertoReference2.
Table2listsallMPC5554DEMOjumpersettingsusedintheapplication.
SystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor17Figure16.
ConnectionofApplicationPartsTable2.
.
MPC5554DEMOJumperSettings.
JumperSettingCAN_SELSettingCONFIGSWITCHSettingJP1-1JP1-2JP2JP3JP4JP5VRH_ENSRAM_SELVSTBY_SWITCH1-21-21-231-21-231-21-21-23ON123456121212121212123456ONOFFONOFFONOFFBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor183.
3.
2FlashingtheMPC5554DEMOTheeSysFlasherutilitycanbeusedforprogrammingcodeintotheFLASHmemoryontheMPC5554DEMO.
Checkforcorrectsettingofswitchesandjumpers.
Theflashingprocedureisasfollows:1.
RunMetrowerksMPC55xxV1.
5b2andopentheproject.
ChoosetheIntflashtargetandcompiletheapplication.
Afilesimple_eflash.
elf.
S19,whichwillbeloadedintoFLASHmemory,iscreatedintheprojectdirectorybin.
2.
RuntheeSysFlasherapplication.
IntheTargetConfigurationwindowselectthetypeoftheBDMCommunicationasP&EWiggler.
ClickOKtoclosethewindow.
3.
GototheProgramsectionbyclickingthe"ProgramFlash"button(seeFigure17).
SelecttheBinaryImage,setAddressas0x0andcheckthe"Verifyafterprogram"option(seeFigure18).
Pressthe"Program"andselectintflash.
binfile.
Finally,press"Open"buttonatthebottomofthewindowtostartloadingthecodeintotheFLASHmemory.
4.
Ifthecodehasbeenprogrammedcorrectly,removetheBDMinterfaceandpushtheRESETbuttonontheMPC5554Demo.
TheapplicationshouldnowrunfromtheFLASH.
Figure17.
eSysFlasherTargetConfigurationWindowTheeSYSFlasherapplicationcanbedownloadedfromhttp://www.
freescale.
comSystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor19Figure18.
eSysFlasherProgramWindow3.
3.
3InterfaceBoardwithUNI-3ThisboardenablestoconnectthepowerstagewithamotortotheMPC5554DEMOBoardandcanbeusedbysoftwareandhardwaredeveloperstotestprogramsandtools.
ItsupportsalgorithmsthatuseHallsensors,LEMsensors,encoderfeedbackandBack-EMF(electromotiveforce)signalsforsensorscontrol.
InputconnectionsaremadeviaconnectorsonthebottomsideoftheboardandheadersontheMPC5554DEMOBoard.
Outputconnectionsaremadevia40-pinUNI-3connectorandexpansionheaders.
Powerrequirementsaremetbyinputconnectors.
Figure19.
InterfaceBoardwithUNI-3Formoreinformation,refertoReference3.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor203.
3.
4SettingOvercurrentLevelTheover-currentfaultsignalisconnectedtotheeMIOSOutputDisableInputpin(eMIOS10)thatenables,togetherwithapropereTPUconfiguration,handlingthefaultbyeTPUhardware.
ThisconnectionispartoftheMPC5554.
Inordertoenablehandlingthefaultalsobyasoftware,thefaultsignal,availableoneMIOS10pingeneratesinterruptrequesttotheCPUincaseofafault.
Theover-currentlevelissetbythetrimmerR24(I_SEN)ontheInterfaceBoardwithUNI-3(seeFigure20).
Reference3describeswhatvoltagemustthetrimmerdefinefortheover-currentcomparator.
Dothefollowingstepsinordertosetuptheover-currentlevelproperlywithoutmeasuringthevoltage:1.
ConnectallsystempartsaccordingtoFigure16.
2.
Downloadandstarttheapplication.
3.
TurnON/OFFswitchON.
UsingUpandDownbuttonssettherequiredspeedtothemaximum.
4.
AdjusttheR24trimmer.
YoucanfindalevelfromwhichtheredLEDstartstolightandthemotorspeedstartstobelimited.
Setthetrimmerlevelsomewhathigher,sothatthemotorcanrunatthemaximumspeed.
5.
TurntheON/OFFswitchOFF.
6.
TurnON/OFFswitchON.
UsingUpandDownbuttonssettherequiredspeedtothemaximum.
7.
Iftheapplicationgoestothefaultstateduringtheacceleration,adjusttheR24trimmerlevelsomewhathigher,sothatthemotorcangettothemaximumspeed.
theFigure20.
OvercurrentLevelTrimmeronInterfaceBoardwithUNI-3(R24)3.
3.
533395EvaluationMotorBoardThe33395EvaluationMotorBoardisa12-volt,8-amppowerstage,whichissuppliedwitha40-pinribboncable.
IncombinationwiththeMPC5554EVBandInterfaceBoardwithUNI-3,itprovidesanout-of-the-boxsoftwaredevelopmentplatformforsmallbrushlessDCmotors.
Thepowerstageenablessensingavarietyoffeedbacksignalssuitablefordifferentmotorcontroltechniques.
Itmeasuresallthethreephasecurrents,reconstructsDC-buscurrentfromthem,DC-busvoltage,Back-EMFvoltageswithzerocrosssensing.
AlltheanalogsignalsareadaptedtobedirectlysampledbytheA/Dconverter.
ThisSystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor21single-boardpowerstagecontainsananalogbridgegatedriverintegratedcircuitry,sensingandcontrolcircuitry,powerN-MOSFETtransistors,DC-Busbrakechopper,aswellasvariousinterfaceconnectorsforthesupplyandthemotor.
Formoreinformation,refertoReference4.
Figure21.
33395EvaluationMotorBoard3.
3.
6BLDCMotorwithQuadratureEncoderTheenclosedmotorisalow-voltageMCGBLDCmotor(IB23810).
ThemotorcharacteristicsinTable3applytooperationat25°C.
Table3.
MCGBLDCMotor(IB23810)MotorCharacteristicsCharacteristicToleranceUnitsValueMax.
operatingspeedMAX.
R.
P.
M.
5000ContinuoustorqueMAX.
OZ-IN20PeaktorqueMAX.
OZ-IN60BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SystemConceptFreescaleSemiconductor22Figure30depictsthemotortiming.
Formoremotorspecifications,refertoReference5.
QuadratureencoderHEDS-5640A06isattachedtothemotorinordertoscanandencodeshaftmovement.
Thebasicencoderfeaturesareasfollows:ThreechannelquadratureoutputwithindexpulseResolution500countsperrevolutionExternalmountingearsQuickandeasyassemblyNosignaladjustmentrequiredSmallsize-40°Cto100°CoperatingtemperatureTTLcompatibleSingle5VsupplyFormorequadratureencoderspecifications,refertoReference6.
3.
3.
7PowerSupplyThepowersupply12V/2.
7A,isalsousedtopowerthe33395EvaluationMotorBoard.
Theapplicationisscaledforthis12Vpowersupply.
ContinuouscurrentMAX.
AMPS2.
0PeakcurrentMAX.
AMPS5.
9Torquesensitivity±10%OZ-IN/AMPS11.
4BackEMFconstant±10%V/KR.
P.
M.
8.
4D.
C.
resistance±10%OHMS3.
35Inductance±15%mH6.
32RotorinertiaNOM.
OZ-IN-SEC20.
0011WeightNOM.
LBS1.
18Table3.
MCGBLDCMotor(IB23810)MotorCharacteristics(continued)CharacteristicToleranceUnitsValueSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor234SoftwareDesignThissectiondescribesthesoftwaredesignoftheBLDCmotordriveapplication.
ThesystemprocessingisdistributedbetweentheCPUandtheeTPU,whichruninparallel.
TheCPUandeTPUtasksaredescribedintermsofthefollowing:CPU—SoftwareFlowchart—ApplicationStateDiagram—eTPUApplicationAPIeTPU—eTPUBlockDiagram—eTPUTimingTheCPUsoftwareusesseveralready-to-useFreescalesoftwaredrivers.
ThecommunicationbetweenthemicroprocessorandtheFreeMASTERonPCishandledbysoftwareincludedinfmaster.
c/.
hfiles.
TheeTPUmoduleusesthegeneraleTPUutilities,eTPUfunctioninterfaceroutines(eTPUfunctionAPI),andeTPUapplicationinterfaceroutines(eTPUapplicationAPI).
Thegeneralutilities,includedintheetpu_util.
c/.
hfiles,areusedforinitializationofglobaleTPUmoduleandenginesettings.
TheeTPUfunctionAPIroutinesareusedforinitializationoftheeTPUchannelsandinterfacingeacheTPUfunctionduringrun-time.
AneTPUapplicationAPIencapsulatesseveraleTPUfunctionAPIs.
TheuseofaneTPUapplicationAPIeliminatestheneedtoinitializeeacheTPUfunctionseparatelyandtohandlealleTPUfunctioninitializationsettings,andsoensuresthecorrectcooperationofeTPUfunctions.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor24Figure22.
eTPUProjectStructureCPUCodeeTPUFunctionSourceCode,compiledbyByteCraftETPU_Cetpuc.
hetpuc_common.
hCodeGeneratedbyeTPUCompileretpu__auto.
hetpu_set3.
hetpu_.
cetpuc_set3.
cetpu_util.
c/.
hetpu_struct.
hStandardeTPUUtilitiesetpu_.
c/.
heTPUFunctionAPIetpu_app_.
c/.
heTPUApplicationAPI_etpu_gct.
c/.
hUsereTPUInitializationCodeUserApplicationmain.
cInitializationMethods:my_system_etpu_init();my_system_etpu_start();Run-TimeMethodsRun-TimeMethodsAN2940-46SWgeneratedbyeTPUGCTtheonlycodewrittenbytheuserAN2892AN2954-57SWAN2864SWAN2958SWSoftwareLevelSourceCodeFilesOrigineTPUCodeUserwrittencodeFreescalesuppliedcodeGeneratedcodeByteCraftsuppliedcodeSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor254.
1CPUSoftwareFlowchartFigure23.
CPUSoftwareFlowchartAfterreset,theCPUsoftwareinitializesinterruptsandpins.
ThefollowingCPUprocessingisincorporatedintwoperiodictimerinterrupts,oneperiodicaleTPUchannelinterrupt,andtwofaultinterrupts.
4.
1.
1TimerInterruptServiceRoutineThetimerinterruptishandledbythetimer_isrfunction.
Thefollowingactionsareperformedperiodically,intimer_isr:ReadtheON/OFFswitchstatusHandletheapplicationstatemachineTheapplicationstatediagramisdescribedindetailbelow.
ServicetheUpandDownbuttonsandtheStatusLEDbytheApplicationButtonsAndStatusLedfunctionReadthedatastructurethroughtheeTPUapplicationAPIroutinefs_etpu_app_bldcmesl1_get_data(see4.
3).
RESETInitializeinterruptsandpinswaitReadON/OFFswitchstatusHandleapplicationstatemachineServiceUp/DownbuttonsandStatusLEDReadapplicationdatastructureTimer3InterruptHandleovercurrentfaultFaultInterruptFreeMasterDispatcherFreeMasterTimerInterruptFreeMasterRecordereTPUChannelInterruptHandleeTPUglobalexceptioneTPUGlobalExceptionInterruptBasedonDirectionandSectorvaluescommutatePWMphasesSetthenewvaluesintotwocompareparametersofQDeTPUfunctioneTPUPositionInterruptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor264.
1.
2PositionInterruptServiceRoutineTheeTPUpositioninterrupt,whichisraisedbytheQDeTPUfunctionrunningoneTPUchannels1and2,ishandledbytheetpu_ch1_ch2_isrfunction.
Thefs_etpu_app_bldcmesl1_commutateapplicationAPIfunctioniscalledtoensurecommutationsofPWMphases(basedonactualdirectionandpositionofthemotionsystem).
TheinformationabouttheactualdirectionandthestateofpositioncounterisprovidedbytheeTPUQDfunction.
FurtherthisapplicationAPIfunctionsetstheQDeTPUfunctionparameterspc_interrupt1andpc_interrupt2asanewcomparevaluesforQDtoensuregenerationofthenextpositioninterrupt.
4.
1.
3FreeMASTERInterruptServiceRoutineTheFreeMASTERinterruptserviceroutineiscalledfmasterDispatcher.
Thisfunctionisimplementedinfmaster.
c.
4.
1.
4eTPUChannelInterruptServiceRoutineThisinterrupt,whichisraisedeveryPWMperiodbythePWMMDCeTPUfunctionrunningoneTPUchannel7,ishandledbytheetpu_ch7_isrfunction.
ThisfunctioncallsfmasterRecorder,implementedinfmaster.
c,enablingtheconfigurationofapplicationvariabletimecourseswithaPWM-periodtimeresolution.
4.
1.
5FaultInterruptServiceRoutineTheover-currentfaultinterrupt,whichisraisedbyeMIOSinputfunctionrunningoneMIOSchannel10,ishandledbytheemios_isrfunction.
Thefollowingactionsareperformedinordertoswitchthemotoroff:ResettherequiredspeedDisablethegenerationofPWMsignalsSwitchtheFaultLEDonEnterAPP_STATE_MOTOR_FAULTSetFAULT_OVERCURRENT4.
1.
6eTPUGlobalExceptionInterruptServiceRoutineTheglobalexceptioninterruptishandledbytheetpu_globalexception_isrfunction.
Thefollowingsituationscancausethisinterruptassertion:MicrocodeGlobalExceptionisassertedIllegalInstructionFlagisassertedSCMMISCFlagisassertedThefollowingactionsareperformedinordertoswitchthemotoroff:ResettherequiredspeedDisablethegenerationofPWMsignalsSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor27EnterAPP_STATE_GLOBAL_FAULTBasedontheeTPUglobalexceptionsource,setFAULT_MICROCODE_GE,FAULT_ILLEGAL_INSTR,orFAULT_MISC.
4.
2ApplicationStateDiagramTheapplicationstatediagramconsistsofsevenstates(seeFigure24).
Afterreset,theapplicationgoesfirstlytoAPP_STATE_INIT.
WheretheON/OFFswitchisintheOFFposition,theAPP_STATE_STOPfollows,otherwisetheAPP_STATE_MOTOR_FAULTisenteredandtheON/OFFswitchmustbeturnedOFFtogetfromAPP_STATE_MOTOR_FAULTtoAPP_STATE_STOP.
ThenthecyclebetweenAPP_STATE_STOP,APP_STATE_ENABLE,APP_STATE_RUN,andAPP_STATE_DISABLEcanberepeated,dependingontheON/OFFswitchposition.
APP_STATE_ENABLEandAPP_STATE_DISABLEstatesareintroducedinordertoensurethesafetransitionsbetweentheAPP_STATE_STOPandAPP_STATE_RUNstates.
Wheretheover-currentfaultinterruptisraised(seeredlineonFigure24),theAPP_STATE_MOTOR_FAULTisentered.
ThisfaultisclearedbymovingtheON/OFFswitchtotheOFFpositionandthusenteringtheAPP_STATE_STOP.
WheretheeTPUglobalexceptioninterruptisraised(seegraylineonFigure24),theAPP_STATE_GLOBAL_FAULTisentered.
TheglobalfaultisclearedbymovingtheON/OFFswitchtotheOFFpositionandthusenteringtheAPP_STATE_INIT.
Figure24.
ApplicationStateDiagramThefollowingparagraphsdescribetheprocessingineachoftheapplicationstates.
ON/OFFswitchmovedOFFAPP_STATE_ENABLEAPP_STATE_RUNAPP_STATE_MOTOR_FAULTAPP_STATE_DISABLEAPP_STATE_STOPresetAPP_STATE_INITON/OFFswitchmovedOFFON/OFFswitchmovedONAPP_STATE_GLOBAL_FAULTON/OFFswitchmovedOFFover-currentfaultinterruptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor284.
2.
1APP_STATE_INITThisstateispassedthroughonly.
Itisenteredeitherafterareset,oraftertheAPP_STATE_GLOBAL_FAULT.
Thefollowingactionsareperformedinordertoinitialize(re-initialize)theapplication:Callmy_system_etpu_initroutineforeTPUmoduleinitializationGeteTPUfunctionsDATARAMaddressesforFreeMASTERGettheaddressesofchannelconfigurationregistersforFreeMASTERInitializeFreeMASTERCallmy_system_etpu_startroutineforeTPUStart.
Atthispoint,theCPUandtheeTPUruninparallel.
DependingontheON/OFFswitchposition,enterAPP_STATE_STOPorAPP_STATE_MOTOR_FAULT4.
2.
1.
1InitializationandStartofeTPUModuleTheeTPUmoduleisinitializedusingthemy_system_etpu_initfunction.
Later,afterinitializationofallotherperipherals,theeTPUisstartedbymy_system_etpu_start.
ThesefunctionsusethegeneraleTPUutilitiesandeTPUfunctionAPIroutines.
Boththemy_system_etpu_initandmy_system_etpu_startfunctions,includedinbldcmesl1_etpu_gct.
cfile,aregeneratedbytheeTPUGraphicalConfigurationTool.
TheeTPUGraphicalConfigurationToolcanbedownloadedfromhttp://www.
freescale.
com/webapp/sps/site/prod_summary.
jspcode=eTPU.
Formoreinformation,refertoReference11.
Themy_system_etpu_initfunctionfirstconfigurestheeTPUmoduleandmotorsettings.
Someofthesesettingsincludethefollowing:channelfiltermode=three-samplemodechannelfilterclock=etpuclkdiv64Theinputsignals(fromHallsensors)arefilteredbychannelfilters.
Thefiltersettingsguaranteefilteringallnoisepulsesuptoawidthof1usandpasspulsesfromawidthof1.
5us(at128MHzsystemclock).
TCR1source=etpuclkdiv2TCR1prescaler=1TheTCR1internaleTPUclockissettoitsmaximumrateof64MHz(at128MHzsystemclock),correspondingtothe16nsresolutionofgeneratedPWMsignals.
TCR2source=etpuclkdiv8TCR2prescaler=2TheTCR2internaleTPUclockissettoarateof8MHz(at128MHzsystemclock).
TheTCR2clocksettingsareoptimizedformotorspeedcalculationprecision.
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor29Afterconfiguringthemoduleandenginesettings,themy_system_etpu_initfunctioninitializestheeTPUchannels.
Channel1-quadraturedecoder(QD)-phaseAchannelChannel2-quadraturedecoder(QD)-phaseBchannelChannel3-quadraturedecoder(QD)-indexchannelChannel5-speedcontroller(SC)Channel7-PWMmasterforDCmotors(PWMMDC)Channel8-PWMcommuted(PWMC)-phaseA-basechannelChannel10-PWMcommuted(PWMC)-phaseB-basechannelChannel12-PWMcommuted(PWMC)-phaseC-basechannelTheseeTPUchannelsareinitializedbythefs_etpu_app_bldcmesl1_initeTPUapplicationAPIfunction(see4.
3).
Theapplicationsettingsareasfollows:—PWMphases-typeiscommutedcomplementarypairs—PWMfrequency20kHz—PWMdead-time1s—Motorspeedrange1200RPM—Motorspeedminimum10RPM—DC-busvoltage12V—Numberofmotorpolepairs2—Speedcontrollerupdatefrequency500Hz—PIcontrollerparameters:P-gainis0.
5(0x004000*2-15),andI-gainis0.
125(0x001000*2-15).
Thecontrollerparameterswereexperimentallytuned.
—Rampparameters:0.
25storampupfromzerotothemaximumspeed,0.
25storampdownfromthemaximumspeedtozero.
—Numberofquadratureencoderpositioncounterincrementsperonerevolution2000Themy_system_etpu_startfunctionfirstappliesthesettingsforthechannelinterruptenableandchanneloutputdisableoptions,thenenablestheeTPUtimers,sostartingtheeTPU.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor30Figure25.
eTPUConfigurationUsingtheeTPUGraphicalConfigurationTool4.
2.
1.
2InitializationofFreeMASTERCommunicationPriortotheFreeMASTERinitialization,itisnecessarytosetpointerstotheeTPUfunctionsDATARAMbasesandConfigurationRegisterbases.
Basedonthesepointers,whicharereadbyFreeMASTERduringtheinitialization,thelocationsofalleTPUfunctionparametersandConfigurationRegistersaredefined.
ThisisessentialforcorrectFreeMASTERoperation!
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor31FreeMASTERconsistsofsoftwarerunningonaPCandonthemicroprocessor,connectedviaanRS-232serialport.
AsmallprogramresidentinthemicroprocessorcommunicateswiththeFreeMASTERonthePCinordertoreturnstatusinformationtothePC,andprocessescontrolinformationfromthePC.
ThemicroprocessorpartoftheFreeMASTERisinitializedbytwofunctions:iniFmasterUartandfmasterInit.
Bothfunctionsareincludedinfmaster.
c,whichautomaticallyinitializestheUARTdriverandinstallsallnecessaryservices.
4.
2.
2APP_STATE_STOPInthisstate,thePWMsignalsaredisabledandthemotorisoff.
Themotorshaftcanberotatedbyhand,whichenablestheusertoexplorethefunctionalityofthequadraturedecoder(QD)eTPUfunction,towatchvariablesproducedbytheQD,andtoseeQDsignalsinFreeMASTER.
WhentheON/OFFswitchisturnedon,theapplicationgoesthroughAPP_STATE_ENABLEtoAPP_STATE_RUN.
4.
2.
3APP_STATE_ENABLEThisstateispassedthroughonly.
Thefollowingactionsareperformedinordertoswitchthemotordriveon:Resettherequiredspeed.
EnablethegenerationofPWMsignalsbycallingthefs_etpu_app_bldcmesl1_enableapplicationAPIroutine.
Thisroutinealsoperformsthemotoralignment.
IfthePWMphasesweresuccessfullyenabled,theeMIOSchannel10isconfiguredasinput,interruptonfallingedge,andAPP_STATE_RUNisentered.
WherethePWMphaseswerenotsuccessfullyenabled,theapplicationstatedoesnotchange.
4.
2.
4APP_STATE_RUNInthisstate,thePWMsignalsareenabledandthemotorison.
TherequiredmotorspeedcanbesetusingtheUpandDownbuttonsontheInterfaceorbyusingFreeMASTER.
ThelatestvalueisperiodicallywrittentotheeTPU.
WhentheON/OFFswitchisturnedoff,theapplicationgoesthroughAPP_STATE_DISABLEtoAPP_STATE_STOP.
4.
2.
5APP_STATE_DISABLEThisstateispassedthroughonly.
Thefollowingactionsareperformedinordertoswitchthemotordriveoff:ResettherequiredspeedDisablethegenerationofPWMsignalsIfPWMphasesweresuccessfullydisabled,APP_STATE_STOPisentered.
WherePWMphaseswerenotsuccessfullydisabled,theapplicationstateremainsthesame.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor324.
2.
6APP_STATE_MOTOR_FAULTThisstateisenteredaftertheover-currentfaultinterruptserviceroutine.
TheapplicationwaitsuntiltheON/OFFswitchisturnedoff.
ThisclearsthefaultandtheapplicationenterstheAPP_STATE_STOP.
4.
2.
7APP_STATE_GLOBAL_FAULTThisstateisenteredaftertheeTPUglobalexceptioninterruptserviceroutine.
TheapplicationwaitsuntiltheON/OFFswitchisturnedoff.
ThisclearsthefaultandtheapplicationenterstheAPP_STATE_INIT.
4.
3eTPUApplicationAPITheeTPUapplicationAPIencapsulatesseveraleTPUfunctionAPIs.
TheeTPUapplicationAPIincludesCPUmethodswhichenableinitialization,control,andmonitoringofaneTPUapplication.
TheuseofeTPUapplicationAPIfunctionseliminatestheneedtoinitializeandseteacheTPUfunctionseparately,andensurescorrectcooperationoftheeTPUfunctions.
TheeTPUapplicationAPIisdeviceindependentandhandlesonlytheeTPUtasks.
InordertoshortentheeTPUapplicationnames,abbreviatedapplicationnamesareintroduced.
Theabbreviationsinclude:motortype(DCM=DCMotor,BLDCM=BrushlessDCMotor,PMSM=PermanentMagnetSynchronousMotor,ACIM=ACInductionMotor,SRM=SwitchedReluctanceMotor,SM=StepperMotor)sensortype(H=HallSensors,E=ShaftEncoder,R=Resolver,S=Sincos,X=sensorless)controltype(OL=OpenLoop,PL=PositionLoop,SL=SpeedLoop,CL=CurrentLoop,SVC=SpeedVectorControl,TVC=TorqueVectorControl)Basedonthesedefinitions,theBLDCMESL1isanabbreviationfor'BLDCmotorwithquadratureencoderandspeedclosedloop'eTPUmotor-controlapplication.
AsthereareseveralBLDCmotorapplicationswithquadratureencoderandspeedclosedloop,thenumber1denotesthefirstsuchapplicationinorder.
TheBLDCMESL1eTPUapplicationAPIisdescribedinthefollowingparagraphs.
Thereare6basicfunctionsaddedtotheBLDCMESL1applicationAPI.
Theroutinescanbefoundintheetpu_app_bldcmesl1.
c/.
hfiles.
AllBLDCMESL1applicationAPIroutineswillbedescribedinorderandarelistedbelow:InitializationFunction:int32_tfs_etpu_app_bldcmesl1_init(bldcmesl1_instance_t*bldcmesl1_instance,uint8_tPWM_master_channel,uint8_tPWM_phaseA_channel,uint8_tPWM_phaseB_channel,uint8_tPWM_phaseC_channel,uint8_tQD_phaseA_channel,SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor33uint8_tQD_phaseB_channel,uint8_tQD_index_channel,uint8_tSC_channel,uint8_tPWM_phases_type,uint32_tPWM_freq_hz,uint32_tPWM_dead_time_ns,int32_tspeed_range_rpm,int32_tspeed_min_rpm,int32_tdc_bus_voltage_mv,uint8_tpole_pairs,uint32_tSC_freq_hz,int32_tSC_P_gain,int32_tSC_I_gain,uint32_tSC_ramp_time_ms,uint24_tQD_pc_per_rev)4.
3.
1int32_tfs_etpu_app_bldcmesl1_init(.
.
.
)ThisroutineisusedtoinitializetheeTPUchannelsfortheBLDCmotorwithquadratureencoderandspeedclosedloopapplication.
Thisfunctionhasthefollowingparameters:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
Thisstructuremustbedeclaredintheuserapplication.
Wheretherearemoreinstancesoftheapplicationrunningsimultaneously,theremustbeaseparatebldcmesl1_instance_tstructureforeachone.
PWM_master_channel(uint8_t)-ThisisthePWMmasterchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
PWM_phaseA_channel(uint8_t)-ThisisthePWMphaseAchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
Inthecaseofcomplementarysignalgeneration(PWM_phases_type==FS_ETPU_APP_BLDCMESL1_COMPL_PAIRS),thecomplementarychannelisonechannelhigher.
PWM_phaseB_channel(uint8_t)-ThisisthePWMphaseBchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
Inthecaseofcomplementarysignalgeneration(PWM_phases_type==FS_ETPU_APP_BLDCMESL1_COMPL_PAIRS),thecomplementarychannelisonechannelhigher.
PWM_phaseC_channel(uint8_t)-ThisisthePWMphaseCchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
Inthecaseofcomplementarysignalgeneration(PWM_phases_type==FS_ETPU_APP_BLDCMESL1_COMPL_PAIRS),thecomplementarychannelisonechannelhigher.
QD_phaseA_channel(uint8_t)-ThisisthequadraturedecoderphaseAchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
QD_phaseB_channel(uint8_t)-ThisisthequadraturedecoderphaseBchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor34QD_index_channel(uint8_t)-Thisisthequadraturedecoderindexchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
SC_channel(uint8_t)-Thisisthespeedcontrollerchannelnumber.
0-31forETPU_A,and64-95forETPU_B.
PWM_phases_type(uint8_t)-ThisparameterdeterminesthetypeofallPWMphases.
Thisparametershouldbeassignedavalueof:FS_ETPU_APP_BLDCMESL1_SINGLE_CHANNELS,orFS_ETPU_APP_BLDCMESL1_COMPL_PAIRS.
PWM_freq_hz(uint32_t)-ThisisthePWMfrequencyinHz.
PWM_dead_time_ns(uint32_t)-ThisisthePWMdead-timeinns.
speed_range_rpm(int32_t)-Thisisthemaximummotorspeedinrpm.
speed_min_rpm(int32_t)-Thisistheminimum(measurable)motorspeedinrpm.
dc_bus_voltage_mv(int32_t)-ThisistheDC-busvoltageinmV.
pole_pairs(uint8_t)-Thisisthenumberofmotorpole-pairs.
SC_freq_hz(uint32_t)-ThisisthespeedcontrollerupdatefrequencyinHz.
TheassignedvaluemustbeequaltothePWM_freq_hzdividedby1,2,3,4,5,.
.
.
SC_P_gain(fract24_t)-ThisisthespeedcontrollerP-gainin24-bitsignedfractionalformat(9.
15).
0x008000correspondsto1.
00x000001correspondsto0.
0000305(30.
5*10-6)0x7FFFFFcorrespondsto255.
9999695SC_I_gain(fract24_t)-ThisisthespeedcontrollerI-gainin24-bitsignedfractionalformat(9.
15).
0x008000correspondsto1.
00x000001correspondsto0.
0000305(30.
5*10-6)0x7FFFFFcorrespondsto255.
9999695SC_ramp_time_ms(uint32_t)-Thisparameterdefinestherequiredspeedramptimeinms.
Astepchangeoftherequiredspeedfrom0tospeed_range_rpmissloweddownbytheramptotakethedefinedtime.
QD_qd_pc_per_rev(uint24_t)-ThisisthenumberofQDpositioncounterincrementsperonerevolution.
4.
3.
2int32_tfs_etpu_app_bldcmesl1_enable(.
.
.
)ThisroutineisusedtoenablethegenerationofPWMsignals,toalignmotortothestartposition,toinitializeandenablepositioninterruptsfromthequadratureencoderandtostartthespeedcontroller.
Thisfunctionhasthefollowingparameters:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor35configuration(uint8_t)-ThisistherequiredconfigurationoftheSC.
Thisparametershouldbeassignedavalueof:FS_ETPU_APP_BLDCMESL1_SPEED_LOOP_OPENED,orFS_ETPU_APP_BLDCMESL1_SPEED_LOOP_CLOSED.
qd_pc_interrupt1(int32_t)-ThisisthefirstoutoftwoQDpc_interruptparameterstobeset.
QDeTPUfunctiongeneratesthepositioninterrupttotheCPUwhentheQDpositioncounterreachesthisvalue.
Thisisusedforcommutationpurposes.
qd_pc_interrupt2(int32_t)-ThisisthesecondoutoftwoQDpc_interruptparameterstobeset.
QDeTPUfunctiongeneratesthepositioninterrupttotheCPUwhentheQDpositioncounterreachesthisvalue.
Thisisusedforcommutationpurposes.
4.
3.
3int32_tfs_etpu_app_bldcmesl1_disable(bldcmesl1_instance_t*bldcmesl1_instance)ThisroutineisusedtodisablethegenerationofPWMsignalsandstopthespeedcontroller.
Thisfunctionhasthefollowingparameter:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
4.
3.
4voidfs_etpu_app_bldcmesl1_set_speed_required(.
.
.
)Thisroutineisusedtosettherequiredmotorspeed.
Thisfunctionhasthefollowingparameters:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
speed_required_rpm(int32_t)-Thisistherequiredmotorspeedinrpm.
4.
3.
5voidfs_etpu_app_bldcmesl1_commutate(.
.
.
)ThisroutineisusedtocommutatePWMphases.
Thisfunctionhasthefollowingparameters:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
4.
3.
6voidfs_etpu_app_bldcmesl1_get_data(.
.
.
)Thisroutineisusedtogettheapplicationstatedata.
Thisfunctionhasthefollowingparameters:bldcmesl1_instance(bldcmesl1_instance_t*)-Thisisapointertobldcmesl1_instance_tstructure,whichisfilledbyfs_etpu_app_bldcmesl1_init.
bldcmesl1_data(bldcmesl1_data_t*)-Thisisapointertobldcmesl1_data_tstructureofapplicationstatedata,whichisupdated.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor364.
4eTPUBlockDiagramTheeTPUfunctionsusedtodrivetheBLDCmotorwithspeedclosedlooparelocatedinthemotor-controlsetofeTPUfunctions(set3-DCmotors).
TheeTPUfunctionswithinthesetserveasbuildingblocksforvariousmotor-controlapplications.
Thefollowingparagraphsdescribethefunctionalityofeachblock.
Figure26.
BlockDiagramofeTPUProcessing4.
4.
1PWMGenerator(PWMMDC+PWMC)ThegenerationofPWMsignalsformotor-controlapplicationswitheTPUisprovidedbythreeeTPUfunctions:PWM-MasterforDCMotors(PWMMDC)PWM-FullRange(PWMF)PWM-Commuted(PWMC)ThePWMMasterforDCMotors(PWMMDC)functioncalculatesaPWMdutycycleandupdatesthethreePWMphases.
ThephasesmaybedriveneitherbythePWMFullRange(PWMF)function,whichenablesafull(0%to100%)duty-cyclerange,orbythePWMCommuted(PWMC)function,whichenablesswitchingthephaseONandOFF.
ThePWMCfunctionisusedinthedescribedapplication.
ThePWMCfunctiongeneratesthePWMsignals.
ThePWMMDCfunctioncontrolsthreePWMCfunctions,threePWMphases,anddoesnotgenerateanydrivesignal.
ThePWMMDCcanbeexecutedevenonaneTPUchannelnotconnectedtoanoutputpin.
PWMCPWMMDCSCappliedvoltagerequiredspeedMotorInverterCPUeTPUHardwareduty-cyclesFaultfaultinterruptOutputDisableQDQD_IndexShaftEncoderpositiondifference&timedifferencepositioninterruptcommutationEMIOSSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor37Figure27.
FunctionalityofPWMMDC+PWMCFormoredetailsaboutthePWMMDC,PWMF,andPWMCeTPUfunctions,refertoReference12.
4.
4.
2QuadratureDecoder(QD)ThequadraturedecodereTPUfunctionsetisintendedtoprocesssignalsgeneratedbyashaftencoderinamotioncontrolsystems.
Itusestwochannelstodecodeapairofout-of-phaseencodersignalsandtoproducea24-bitbi-directionalpositioncounter,togetherwithdirectioninformation,fortheCPU.
Anadditionalinputchannelscanalsobeprocessed.
Theindexchannelreceivesapulseoneachrevolution.
Basedontheactualdirection,arevolutioncounterisincrementedordecrementedontheindexpulse.
Afurtheradditionalinputchannelcanindicateahomeposition,butitisnotusedinthisapplication.
PWMMDCupdateupdateperiodapplied_voltagePWMCpolarity:active-highORactive-lowvariablePWMperiodscenter-alignedORedge-alignedsinglechannelORcomplementarypairPWMCPWMCupdatenoupdatenoupdatenewinputvaluesnewinputvaluesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor38FormoredetailsabouttheQDeTPUfunction,refertoReference9.
4.
4.
3SpeedController(SC)TheSpeedControllereTPUfunctionisnotintendedtoprocessinputoroutputsignals.
ItspurposeistocontrolanothereTPUfunction'sinputparameter.
TheSCfunctioncanbeexecutedevenonaneTPUchannelnotconnectedtoanoutputpin.
TheSCfunctionincludesageneralPIDcontrolleralgorithm.
Thecontrollercalculatesitsoutputbasedontwoinputs:ameasuredvalue,andarequiredvalue.
Themeasuredvalue(theactualmotorspeed)iscalculatedbasedoninputsprovidedbytheHDfunction.
Therequiredvalueisanoutputofthespeedramp,whoseinputisaSCfunctionparameter,andcanbeprovidedbytheCPUoranothereTPUfunction.
Inthemotor-controleTPUfunctionset,thisfunctionmostlyprovidesthespeedouter-loop.
Figure28.
FunctionalityofSCFormoredetailsabouttheSCeTPUfunction,refertoReference11.
time_differenceQDposition_differencedirectionrevolution_counterQDIndexQDHomeomega_actualomega_rampomega_desiredapplied_voltageSCtimerequested_valuePIcontrollerrampperiodrevolution_periodomega_actualscaling_factorsector_periodSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor394.
5eTPUTimingeTPUprocessingisevent-driven.
Onceaneventservicebegins,itsexecutioncannotbeinterruptedbyanothereventservice.
Theothereventserviceshavetowait,whichcausesaservicerequestlatency.
Themaximumservicerequestlatency,orworstcaselatency(WCL),differsforeacheTPUchannel.
TheWCLisaffectedbythechannelpriorityandactivityonotherchannels.
TheWCLofeachchannelmustbekeptbelowarequiredlimit.
Forexample,theWCLofthePWMCchannelsmustbelowerthanthePWMperiod.
AtheoreticalcalculationofWCLs,foragiveneTPUconfiguration,isnotatrivialtask.
ThemotorcontroleTPUfunctionsintroduceadebuggingfeaturethatenablestheusertocheckchannellatenciesusinganoscilloscope,andeliminatesthenecessityoftheoreticalWCLcalculations.
Asmentionedearlier,someeTPUfunctionsarenotintendedtoprocessanyinputoroutputsignalsfordrivingthemotor.
Thesefunctionsturntheoutputpinhighandlow,sothatthehigh-timeidentifiestheperiodoftimeinwhichthefunctionexecutionisactive.
Anoscilloscopecanbeusedtodeterminehowmuchthechannelactivitypulsevariesintime,whichindicatesthechannelservicelatencyrange.
Forexample,whentheoscilloscopetimebaseissynchronizedwiththePWMperiods,thebehaviorofatestedchannelactivitypulsecanbedescribedbyoneofthefollowingcases:ThepulseisasynchronouswiththePWMperiods.
ThismeansthatthetestedchannelactivityisnotsynchronizedwiththePWMperiods.
ThepulseissynchronouswiththePWMperiodsandstable.
ThismeansthatthetestedchannelactivityissynchronouswiththePWMperiodsandisnotdelayedbyanyservicelatency.
ThepulseissynchronouswiththePWMperiodsbutitspositionvariesintime.
ThismeansthatthetestedchannelactivityissynchronouswiththePWMperiodsandtheservicelatencyvariesinthistimerange.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SoftwareDesignFreescaleSemiconductor40Figure29.
OscilloscopeScreenshotandExplanationofeTPUTimingFigure29explainstheapplicationeTPUtiming.
Theoscilloscopescreen-shotdepictsatypicalsituationdescribedbelow.
AliveviewontheoscilloscopescreenenablestheusertoseethevariationofSCandPWMMDCactivitypulses,whichdeterminesthechannelservicelatencyranges.
InFigure29,signals3(pink)and4(green)arePWMsignalsofonephase.
Itisacomplementarypairofcenter-alignedPWMsignals.
Thebasechannel(3)isofactive-highpolarity,whilethecomplementarychannel(4)isactive-low.
ThePWMphasecommutationisrecognizableonthescreen.
ThePWMperiodis50s,whichcorrespondstoaPWMfrequencyof20kHz.
Signal1(blue)isgeneratedbythespeedcontroller(SC)eTPUfunction.
ItspulsesdeterminetheactivityoftheSC.
ThepulsewidthdeterminesthetimenecessarytocalculatethemotorspeedfromtheQDpositioncounterandQDlastedgetime,calculatetherequiredspeedramp,andapplythePIcontrolleralgorithm.
Thisoutputisthenewvalueofappliedmotorvoltage.
Thiscalculationisperformedperiodicallyata500Hzrate,whichisevery40thPWMperiod.
Signal2(cyan)isgeneratedbythePWMmasterforDCmotors(PWMMDC)eTPUfunction.
ItspulsesdeterminetheactivityofthePWMMDC.
ImmediatelyaftereachSCpulse,averynarrowPWMMDCpulseoccurs.
ThesepulsesdeterminetheservicetimeofanSCrequesttoupdatethenewvalueofappliedmotorvoltage.
Apartfromthesepulses,foreveryPWMperiod,apulsewillappearwhichsignalsaPWMSCactivityPWMMDCupdatesPWMperiodscommutationSCPWMCPWMCPWMMDCImplementationNotesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor41update.
ThePWMupdateactivitypulseiswidewhenanewvalueofappliedmotorvoltagehasbeenprocessed;itisnarrowwhennonewvaluehasbeenprocessedandthePWMduty-cyclesarenotupdated.
Thefs_etpu_pwmmdc_init_3phfunctionparameterupdate_timeenablestheusertoadjustthepositionofthePWMMDCactivitypulserelativetothePWMperiodframe.
Theactivitypulsehasascheduledupdate_timepriortotheendoftheperiodframe,sothattheupdateisfinishedbytheendoftheperiodframe,evenintheworstcaselatency.
Reference12describeshowtosettheupdate_timevalue.
Thedifferencebetweenthevaluesofthefs_etpu_pwmmdc_init_3phfunctionparameterstart_offset,andthefs_etpu_sc_initfunctionparameterstart_offset,determinesthepositionoftheSCactivitypulserelativetothePWMperiodframe.
TheSCactivityprecedesthePWMMDCactivity,sothattheworstcaseSClatencydoesnotaffectthePWMMDClatency.
5ImplementationNotes5.
1ScalingofQuantitiesTheBLDCmotorcontrolalgorithmrunningoneTPUusesa24-bitfractionalrepresentationforallrealquantitiesexcepttime.
The24-bitsignedfractionalformatisrepresentedusing1.
23format(1signbit,23fractionalbits).
Themostnegativenumberthatcanberepresentedis-1.
0,whoseinternalrepresentationis0x800000.
Themostpositivenumberis0x7FFFFFor1.
0-2-23.
Thefollowingequationshowstherelationshipbetweenrealandfractionalrepresentations:where:FractionalValueisafractionalrepresentationoftherealvalue[fract24]RealValueistherealvalueofthequantity[V,A,RPM,etc.
]RealQuantityRangeisthemaximalrangeofthequantity,definedintheapplication[V,RPM,etc.
]5.
1.
1PIControllerParametersThePIcontrollerparametersaresetina32-bitextendedfractionalformat9.
23.
Thisformatenablestheusertosetvaluesintherangeof-256.
0to256.
0-2-23.
Internally,theparametervalueistransformedintooneoftwo24-bitformats,either9.
15,or1.
23,basedonthevalue.
5.
2SpeedCalculationThespeedcontroller(SC)eTPUfunctioncalculatestheangularmotorspeedusingpc_scandlast_edgeparametersoftheQDeTPUfunction.
Thefollowingequationapplies:FractionalValueRealValueRealQuatityRange-=omega_actualposition_differencetime_difference-scaling_factor=BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1ImplementationNotesFreescaleSemiconductor42where:omega_actual[fract24]istheactualangularspeedasafractionofthemaximumspeedrangeposition_difference[int24]isthedifferencebetweentheupdatedvalueofQDpositioncounterandthepreviousvalue,whichwascapturedbySCinthepreviousSCperiod.
Infacttheposition_differenceisreadablefrompc_scparameteroftheQDfunction.
AfterSCreadsthenewupdatedvalueitresetsthispc_scparameterswhichensuresthattheposition_differenceisavailableinthepc_scparameternexttimeSCreadsit.
time_difference[int24]isthedifferencebetweentheupdatedvalueofQDlast_edgeandthepreviousvalue,whichwascapturedbySCinthepreviousSCperiodscaling_factorispre-calculatedusingthefollowingequation:where:etpu_tcr_freq[Hz]isafrequencyoftheinternaleTPUtimer(TCR1orTCR2)usedomega_max[RPM]isamaximalspeedrangepc_per_revisanumberofQDpositioncounterincrementsperonerevolutionTheinternaleTPUtimer(TCR1orTCR2)frequencymustbesetsothatthecalculationofomega_actualbothfitsintothe24-bitsarithmeticanditsresolutionissufficient.
5.
3DefinitionofCommutationTablesThePWMphasesarecommutedbyCPUoneachpositioninterruptgeneratedbyoneoftwoQDchannels.
Thisisactuallydonebyapplyingtwocommutationcommands.
Thefirstcommandturnsaphaseoff,andthesecondturnsanotherphaseon.
Suchpairsofcommutationcommandsmustbedefinedforeachsectorbordercrossing,oneachphase,andforbothmotordirections.
Thecommutationcommandisa32-bitwordthatconsistsofthefollowing8-bitparts.
ChannelnumberofthePWMphasebasechannelNewbasechannelcommutationstate.
Itcanbe:—ON_ACTIVE_HIGH—ON_ACTIVE_LOW—OFF_LOW—OFF_HIGHNewcomplementarychannelcommutationstate.
Itcanbe:—ON_ACTIVE_HIGH—ON_ACTIVE_LOW—OFF_LOW—OFF_HIGHscaling_factor30256etpu_tcr_freqomega_maxpc_per_rev=ImplementationNotesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor43Newphaseoptions:—DUTY_POS—DUTY_NEG.
Forafulldescriptionofallcommutationcommandoptions,refertoReference10.
Figure30depictstheMCGBLDCmotor(IB23810)motortimingdiagram.
Thefollowingexampledescribeshowtodefineseveralofthecommutationcommandsbasedonthistimingdiagram:Forincrementaldirection,readthemotortimingdiagramfromrighttoleft.
QDpositioninterrupt,whichindicatescrossingborderbetweensectors3and1,comesat120electricaldegrees(reddottedline).
ThePWMphaseBisturnedoff,withthepininlowstate,andphaseCon,withactive-highpolarityonthebasechannelandactive-lowpolarityonthecomplementarychannel,onthispositioninterrupt.
Furthermore,thePWMphaseBoptionissettonotchangethecalculatedduty-cyclevalue(negativedutycycle),andthephaseCoptionissettopositiveduty-cyclevalue,whichgeneratesapositivevoltage.
So,thecommutationcommandsassociatedwiththesector1inanincrementalmotordirectionaredefined,usingpredefinedmacros,asfollows:((FS_ETPU_PWMMDC_DUTY_NEG<<24)+(FS_ETPU_PWMMDC_OFF_LOW<<16)+(FS_ETPU_PWMMDC_OFF_LOW<<8)+APP_BLDCMESL10_PWM_PHASEB_BASE_CHANNEL)((FS_ETPU_PWMMDC_DUTY_POS<<24)+(FS_ETPU_PWMMDC_ON_ACTIVE_LOW<<16)+(FS_ETPU_PWMMDC_ON_ACTIVE_HIGH<<8)+APP_BLDCMESL10_PWM_PHASEC_BASE_CHANNEL)BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1ImplementationNotesFreescaleSemiconductor44Figure30.
MCGBLDCMotor(IB23810)TimingDiagramFordecrementaldirection,readthemotortimingdiagramfromlefttoright.
QDpositioninterrupt,whichindicatescrossingborderbetweensectors2and6,comesat240electricaldegrees(bluedottedline).
ThePWMphaseAisturnedoffandphaseConduringthispositioninterrupt.
ThePWMphaseCoptionissettonegatetheduty-cycleinordertogeneratenegativephasevoltage.
So,thecommutationcommandsassociatedwiththesector6inadecrementalmotordirectionaredefined,usingpredefinedmacros,asfollows:((FS_ETPU_PWMMDC_DUTY_NEG<<24)+(FS_ETPU_PWMMDC_OFF_LOW<<16)+(FS_ETPU_PWMMDC_OFF_LOW<<8)+APP_BLDCMESL10_PWM_PHASEA_BASE_CHANNEL)((FS_ETPU_PWMMDC_DUTY_POS<<24)+(FS_ETPU_PWMMDC_ON_ACTIVE_LOW<<16)+MicroprocessorUsageBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor45(FS_ETPU_PWMMDC_ON_ACTIVE_HIGH<<8)+APP_BLDCMESL10_PWM_PHASEC_BASE_CHANNEL)Thiswayallcommutationcommandscanbedefined.
6MicroprocessorUsageTable4showshowmuchmemoryisneededtoruntheapplication.
TheeTPUmoduleusageintermsoftimeloadcanbeeasilydeterminedbasedonthefollowingfacts:AccordingtoReference12,themaximumeTPUloadproducedbyPWMgenerationis946eTPUcyclesperonePWMperiod.
ThePWMfrequencyissetto20kHz,thusthePWMperiodis3750eTPUcycles(eTPUmoduleclockis64MHz,halfofthe128MHzCPUclock).
AccordingtoReference11,thespeedcontrollercalculationtakes324eTPUcycles.
Thecalculationisperformedevery40thPWMperiod.
AccordingtoReference9,thecontributionofQDfunctiontotheoveralleTPUtimeloadcanbecalculated.
Itdependsonthenumberofshaftencoderpulses(500)andthemotorspeed(maximum1000rpm).
ThemaximumeTPUbusytimeperoneencoderpulseis732eTPUcycles.
ThevaluesofeTPUloadbyeachofthefunctionsareinfluencedbycompilerefficiency.
Theabovenumbersaregivenforguidanceonlyandaresubjecttochange.
Foruptodateinformation,refertotheinformationprovidedinthelatestreleaseavailablefromFreescale.
ThepeakoftheeTPUtimeloadoccurswhenboththespeedcontrollercalculationandaQDsignaltransitionareprocessedwithinonePWMperiod.
Thispeakvaluemustbekeptbelow100%,whichensuresthatallprocessingfitsintothePWMperiod,noservicelatencyislongerthanthePWMperiod,andthusthegeneratedPWMsignalsarenotaffected.
Table4.
MemoryUsageinBytesMemoryAvailableUsedFLASH2M33124RAM64K3432eTPUcodeRAM16K6120eTPUdataRAM3K288BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1SummaryandConclusionsFreescaleSemiconductor46Table5showstheeTPUmoduletimeloadinseveraltypicalsituations.
Formoreinformation,refertoReference13.
7SummaryandConclusionsThisapplicationnoteprovidestheuserwithadescriptionofthedemoapplicationBLDCmotorwithquadratureencoderandspeedclosedloop.
TheapplicationalsodemonstratesusageoftheeTPUmoduleonthePowerPCMPC5554,whichresultsinaCPUindependentmotordrive.
Lastly,thedemoapplicationistargetedattheMPC5554familyofdevices,butitcouldbeeasilyreusedwithanydevicethathasaneTPU.
Table5.
eTPUTimeLoadSituationAverageTimeLoad[%]PeakTimeLoadWithinPWMPeriod[%]MotorSpeed300RPM(120commutationspersecond)25.
542.
0MotorSpeed10000RPM(4000commutationspersecond)33.
642.
0ReferencesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMPC5554,Rev.
1FreescaleSemiconductor478ReferencesTable6.
References1.
MPC5554ReferenceManual,MPC5554RM2.
MPC5554DEMOUser'sManual,MPC5554DEMOEVBUM3.
InterfaceBoardwithUNI-3User'sManual4.
33395EvaluationMotorBoardDesignerReferenceManualDRM33395/D5.
MCG'sMotorsweb:http://www.
mcg-net.
com6.
QuadratureEncoderHEDS-5640A06distributor'sweb:http://www.
agilent.
com/semiconductors7.
FreeMASTERwebpage,http://www.
freescale.
com,searchkeyword"FreeMASTER"8.
EnhancedTimeProcessingUnitReferenceManual,ETPURM9.
"UsingtheQuadratureDecoder(QD)eTPUFunction,"AN284210.
"UsingtheHallDecoder(HD)eTPUFunction,"AN284111.
"UsingtheSpeedController(SC)eTPUFunction,"AN284312.
"UsingtheDCMotorControlPWMeTPUFunctions,"AN248013.
"UsingtheDCMotorControleTPUFunctionSet(set3),"AN295814.
eTPUGraphicalConfigurationTool,http://www.
freescale.
com,searchkeyword"ETPUGCT"15.
DSP56F80xMCPWMModuleinMotorControlApplications,AN192716.
"3-PhaseBLDCMotorControlwithQuadratureEncoderusingDSP56F80x,"AN1915/DHowtoReachUs:HomePage:www.
freescale.
comE-mail:support@freescale.
comUSA/EuropeorLocationsNotListed:FreescaleSemiconductorTechnicalInformationCenter,CH3701300N.
AlmaSchoolRoadChandler,Arizona85224+1-800-521-6274or+1-480-768-2130support@freescale.
comEurope,MiddleEast,andAfrica:FreescaleHalbleiterDeutschlandGmbHTechnicalInformationCenterSchatzbogen781829Muenchen,Germany+441296380456(English)+46852200080(English)+498992103559(German)+33169354848(French)support@freescale.
comJapan:FreescaleSemiconductorJapanLtd.
HeadquartersARCOTower15F1-8-1,Shimo-Meguro,Meguro-ku,Tokyo153-0064,Japan0120191014or+81354379125support.
japan@freescale.
comAsia/Pacific:FreescaleSemiconductorHongKongLtd.
TechnicalInformationCenter2DaiKingStreetTaiPoIndustrialEstateTaiPo,N.
T.
,HongKong+80026668080support.
asia@freescale.
comForLiteratureRequestsOnly:FreescaleSemiconductorLiteratureDistributionCenterP.
O.
Box5405Denver,Colorado802171-800-441-2447or303-675-2140Fax:303-675-2150LDCForFreescaleSemiconductor@hibbertgroup.
comInformationinthisdocumentisprovidedsolelytoenablesystemandsoftwareimplementerstouseFreescaleSemiconductorproducts.
Therearenoexpressorimpliedcopyrightlicensesgrantedhereundertodesignorfabricateanyintegratedcircuitsorintegratedcircuitsbasedontheinformationinthisdocument.
FreescaleSemiconductorreservestherighttomakechangeswithoutfurthernoticetoanyproductsherein.
FreescaleSemiconductormakesnowarranty,representationorguaranteeregardingthesuitabilityofitsproductsforanyparticularpurpose,nordoesFreescaleSemiconductorassumeanyliabilityarisingoutoftheapplicationoruseofanyproductorcircuit,andspecificallydisclaimsanyandallliability,includingwithoutlimitationconsequentialorincidentaldamages.
"Typical"parametersthatmaybeprovidedinFreescaleSemiconductordatasheetsand/orspecificationscananddovaryindifferentapplicationsandactualperformancemayvaryovertime.
Alloperatingparameters,including"Typicals",mustbevalidatedforeachcustomerapplicationbycustomer'stechnicalexperts.
FreescaleSemiconductordoesnotconveyanylicenseunderitspatentrightsnortherightsofothers.
FreescaleSemiconductorproductsarenotdesigned,intended,orauthorizedforuseascomponentsinsystemsintendedforsurgicalimplantintothebody,orotherapplicationsintendedtosupportorsustainlife,orforanyotherapplicationinwhichthefailureoftheFreescaleSemiconductorproductcouldcreateasituationwherepersonalinjuryordeathmayoccur.
ShouldBuyerpurchaseoruseFreescaleSemiconductorproductsforanysuchunintendedorunauthorizedapplication,BuyershallindemnifyandholdFreescaleSemiconductoranditsofficers,employees,subsidiaries,affiliates,anddistributorsharmlessagainstallclaims,costs,damages,andexpenses,andreasonableattorneyfeesarisingoutof,directlyorindirectly,anyclaimofpersonalinjuryordeathassociatedwithsuchunintendedorunauthorizeduse,evenifsuchclaimallegesthatFreescaleSemiconductorwasnegligentregardingthedesignormanufactureofthepart.
FreescaleandtheFreescalelogoaretrademarksofFreescaleSemiconductor,Inc.
Allotherproductorservicenamesarethepropertyoftheirrespectiveowners.
FreescaleSemiconductor,Inc.
2004.
Allrightsreserved.
AN3005Rev.
105/2006
提速啦的来历提速啦是 网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑 由赣州王成璟网络科技有限公司旗下赣州提速啦网络科技有限公司运营 投资1000万人民币 在美国Cera 香港CTG 香港Cera 国内 杭州 宿迁 浙江 赣州 南昌 大连 辽宁 扬州 等地区建立数据中心 正规持有IDC ISP CDN 云牌照 公司。公司购买产品支持3天内退款 超过3天步退款政策。提速啦的市场定位提速啦主...
我们先普及一下常识吧,每年9月的第一个星期一是美国劳工节。于是,有一些服务商会基于这些节日推出吸引用户的促销活动,比如RackNerd有推出四款洛杉矶和犹他州独立服务器,1G带宽、5个独立IP地址,可以配置Windows和Linux系统,如果有需要独立服务器的可以看看。第一、劳工节促销套餐这里有提供2个套餐。两个方案是选择犹他州的,有2个方案是可以选择洛杉矶机房的。CPU内存SSD硬盘配置流量价格...
LOCVPS怎么样?LOCVPS是一家成立于2011年的稳定老牌国人商家,目前提供中国香港、韩国、美国、日本、新加坡、德国、荷兰等区域VPS服务器,所有机房Ping延迟低,国内速度优秀,非常适合建站和远程办公,所有机房Ping延迟低,国内速度优秀,非常适合做站。XEN架构产品的特点是小带宽无限流量、不超售!KVM架构是目前比较流行的虚拟化技术,大带宽,生态发展比较全面!所有大家可以根据自己业务需求...
46sw.com为你推荐
编程小学生惊库克小学生学编程好吗?小度商城小度分期靠谱吗?老虎数码虎打个数字www.7788dy.com回家的诱惑 哪个网站更新的最快啊javmoo.comjavbus上不去.怎么办sesehu.com68lolita com是真的吗广告法新修订的《广告法》有哪些内容yinrentangWeichentang正品怎么样,谁知道?www.cn12365.org全国公民身份证号码查询服务中心(http://www.nciic.com.cn/)这个网站怎么查不了啊?关键词分析关键词分析的考虑思路是怎样的,哪个数据是最重要的
cn域名 怎样注册域名 网游服务器租用 vps侦探 荷兰vps cn域名备案 域名停靠一青草视频 budgetvm bluevm themeforest 68.168.16.150 suspended eq2 panel1 国外在线代理 100x100头像 双拼域名 空间论坛 南通服务器 中国网通测速 更多