orthogonal46sw.com
46sw.com 时间:2021-04-08 阅读:(
)
FreescaleSemiconductor,Inc.
,2005.
Allrightsreserved.
FreescaleSemiconductorApplicationNoteAN2957Rev.
0,06/2005TableofContentsThisapplicationnotedescribesthedesignofa3-phasebrushlessDC(BLDC)motordrivebasedonFreescale'sColdFireMCF523xmicroprocessor.
Theapplicationdesigntakesadvantageoftheenhancedtimeprocessingunit(eTPU)module,whichisusedasamotorcontrolco-processor.
TheeTPUhandlesthemotorcontrolprocessing(excludingcommutationprocessing),eliminatingthemicroprocessoroverheadforotherduties.
BLDCmotorsareverypopularinawidearrayofapplications.
ComparedtoaDCmotor,theBLDCmotorusesanelectriccommutator,replacingthemechanicalcommutatorandmakingitmorereliablethantheDCmotor.
InBLDCmotors,rotormagnetsgeneratetherotor'smagneticflux,allowingBLDCmotorstoachievehigherefficiency.
Therefore,BLDCmotorsmaybeusedinhigh-endwhitegoods(refrigerators,washingmachines,dishwashers,etc.
),high-endpumps,fans,andotherappliancesthatrequirehighreliabilityandefficiency.
Theconceptoftheapplicationistocreateaspeed-closedloopBLDCdriverusingaquadratureencoder.
ItservesasanexampleofaBLDCmotorcontrolsystemdesign1ColdFireMCF523xandeTPUAdvantagesandFeatures22TargetMotorTheory.
43SystemConcept.
134SoftwareDesign235ImplementationNotes416MicroprocessorUsage457SummaryandConclusions468References46BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523xCoversMCF523xandalleTPU-equippedDevicesby:MilanBrejl&MichalPrincSystemApplicationEngineersRoznovCzechSystemCenterBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0ColdFireMCF523xandeTPUAdvantagesandFeaturesFreescaleSemiconductor2usingaFreescalemicroprocessorwiththeeTPU.
ItalsoillustratestheusageofdedicatedmotorcontroleTPUfunctionsthatareincludedintheDCmotorcontroleTPUfunctionset.
Thisapplicationnotealsoincludesbasicmotortheory,systemdesignconcept,hardwareimplementation,andmicroprocessorandeTPUsoftwaredesign,includingtheFreeMASTERvisualizationtool.
Figure1.
UsingM523xEVB,33395EvaluationMotorBoard,andMCGBLDCMotor1ColdFireMCF523xandeTPUAdvantagesandFeatures1.
1ColdFireMCF523xMicroprocessorTheMCF523xisafamilyofhighly-integrated,32-bitmicroprocessorsbasedontheV2ColdFirecore.
Itfeaturesa16-or32-channeleTPU,64KbytesofinternalSRAM,a2-bankSDRAMcontroller,four32-bittimerswithDMArequestcapability,a4-channelDMAcontroller,uptotwoCANmodules,threeUARTs,andaqueuedSPI.
TheMCF523xfamilyhasbeendesignedforgeneralpurposeindustrialcontrolapplications.
Itisalsoahigh-performanceupgradeforusersoftheMC68332.
ColdFireMCF523xandeTPUAdvantagesandFeaturesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor3This32-bitdeviceisbasedontheversion2ColdFirereducedinstructionsetcomputer(RISC)core,operatingatacorefrequencyofupto150MHzandabusfrequencyofupto75MHz.
On-chipmodulesincludethefollowing:V2ColdFirecorewithanenhancedmultiply-accumulateunit(EMAC)providing144Dhrystone2.
1MIPS@150MHzeTPUwith16or32channels,6Kbytesofcodememory,and1.
5KbytesofdatamemorywitheTPUdebugsupport64KbytesofinternalSRAMExternalbusspeedofhalftheCPUoperatingfrequency(75MHzbus@150MHzcore)10/100Mbpsbus-masteringEthernetcontroller8Kbytesofconfigurableinstruction/datacacheThreeuniversalasynchronousreceiver/transmitters(UARTs)withDMAsupportControllerareanetwork2.
0B(FlexCANmodule)—OptionalsecondFlexCANmodulemultiplexedwiththethirdUARTInter-integratedcircuit(I2C)buscontrollerQueuedserialperipheralinterface(QSPI)moduleHardwarecryptographyaccelerator(optional)—Randomnumbergenerator—DES/3DES/AESblockcipherengine—MD5/SHA-1/HMACaccelerator4-channel,32-bitdirectmemoryaccess(DMA)controller4-channel,32-bitinputcapture/outputcomparetimerswithoptionalDMAsupport4-channel,16-bitperiodicinterrupttimers(PITs)ProgrammablesoftwarewatchdogtimerInterruptcontrollercapableofhandlingupto126interruptsourcesClockmodulewithphaselockedloop(PLL)Externalbusinterfacemoduleincludinga2-banksynchronousDRAMcontroller32-bit,non-multiplexedbuswithupto8chipselectsignalsthatsupportpage-modeFLASHmemoriesFormoreinformation,refertoReference1.
1.
2eTPUModuleTheeTPUisanintelligent,semi-autonomousco-processordesignedfortimingcontrol,I/Ohandling,serialcommunications,motorcontrol,andenginecontrolapplications.
ItoperatesinparallelwiththehostCPU.
TheeTPUprocessesinstructionsandreal-timeinputevents,performsoutputwaveformgeneration,andaccessesshareddatawithoutthehostCPU'sintervention.
Consequently,thehostCPUsetupandservicetimesforeachtimereventareminimizedoreliminated.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0TargetMotorTheoryFreescaleSemiconductor4TheeTPUhasupto32timerchannels,inadditiontohaving6Kbytesofcodememoryand1.
5Kbytesofdatamemorythatstoresoftwaremodulesdownloadedatboottime,andcanbemixedandmatchedasneededforanyapplication.
TheeTPUprovidesmorespecializedtimerprocessingthanthehostCPUcanachieve.
ThisispartiallyduetotheeTPUimplementation,whichincludesspecificinstructionsforhandlingandprocessingtimeevents.
Inaddition,channelconditionsareavailableforusebytheeTPUprocessor,thuseliminatingmanybranches.
TheeTPUcreatesnohostCPUoverheadforservicingtimingevents.
Formoreinformation,refertoReference7.
2TargetMotorTheoryAbrushlessDC(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,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor5Figure3.
VoltageStrokesAppliedtothe3-PhaseBLDCMotorForthecommon3-phaseBLDCmotor,astandard3-phasepowerstageisused(seeFigure4).
Thepowerstageutilizessixpowertransistorsthatoperateineitheranindependentorcomplementarymode.
Inbothmodes,the3-phasepowerstageenergizestwomotorphasesconcurrently.
Thethirdphaseisunpowered(seeFigure3).
Thus,wegetsixpossiblevoltagevectorsthatareappliedtotheBLDCmotorusingapulsewidthmodulation(PWM)technique(seeFigure5).
Therearetwobasictypesofpowertransistorswitchingschemes:independentandcomplementary.
Bothswitchingmodesareabletoworkinbipolarorunipolarmode.
ThepresentedapplicationutilizesthecomplementarybipolarPWMmode.
FormoreinformationaboutPWMtechniques,refertoReference15.
Figure4.
3-PhaseBLDCPowerStage306090120150180210240270300330ElectricalangleVoltagePhaseAPhaseBPhaseC+UDCB-UDCB+UDCB-UDCB+UDCB-UDCBQ1PWM_Q5Q6Q4C1Phase_CPWM_Q1PWM_Q4PWM_Q3Phase_BGNDQ2UDCBPWM_Q2Phase_AQ3PWM_Q6Q5BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0TargetMotorTheoryFreescaleSemiconductor62.
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,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor7Figure6.
SituationRightBeforeCommutation(Counter-ClockwiseMotion)Figure7.
SituationRightAfterCommutation2.
1.
1.
1QuadratureEncoderVersusHallSensorsTheBLDCmotorapplicationusesthequadratureencoderforrotorpositionsensing.
Thequadratureencoderoutputconsistsofthreesignals.
Twophases,AandB,representtherotorposition,andanindexpulsedefinesthezeroposition.
AllquadratureencodersignalsaredepictedinFigure8.
ComparedwithHallsensors,therearesomedifferences,whichaffectthecontrolalgorithm.
Themaindifferenceisthatthequadratureencoderdoesnotgivecommutationmomentandabsoluteposition,asdotheHallsensors.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0TargetMotorTheoryFreescaleSemiconductor8Figure8.
QuadratureEncoderOutputSignalsThedifferencesbetweenthequadratureencoderandHallsensorsaresummarizedinTable1.
Thetwocontrolalgorithmsaredescribedlateronwiththequadratureencoder.
Thefirstsolutioniscommonlyusedandperiodicallyscansthequadratureencoder.
ThesecondsolutionusesspecificadvantagesoftheQDeTPUfunctionandtranslatesthequadratureencoderoutputsdirectlyintoHallsensorssignals.
Theseinternalsignalsareusedasaninputforthecommutationalgorithm.
Thisalgorithmisimplementedinthepresentedapplication.
2.
1.
1.
2CommutationwithPeriodicalScanningofQuadratureEncoderThecommutationoftheBLDCmotorisperformedinthesixdefinedmoments.
Sincethequadratureencodergivesthepreciseposition,theoneelectricalrevolutionisdividedintosixsectors(seeFigure9).
Torecognizethecommutationmoment,itisnecessarytoscanquadratureencoderpositionveryquickly.
Thefrequencyofscanningdependsonthemaximalrotorspeed,thenumberofpolepairsandontherequiredprecisionofcommutationmomentdetection.
ThesamescanfrequencyasusedinthePWMissatisfactoryforthecommonapplications.
Inthiscase,therotorpositioncanbescannedinthemomentofaPWMreloadinterrupt.
Thealgorithmtranslatestheactualpositionintotheoneofthesixsectors.
Ifachangeofsectorisdetected,thecommutationisperformed.
Thisalgorithmisnotimplementedinthepresentedapplication!
Table1.
DifferencesBetweenQuadratureEncoderandHallSensorsQuadratureEncoderHallSensors3outputs3outputsDoesnotgiveabsolutepositionGivesabsolutepositionGivesprecisepositionGives6eventsperelectricalrevolutiononerevolutionpositioncountervaluesPhaseAPhaseBIndex1998199901219981999012TargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor9Figure9.
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,DrivenbyeTPUonMCF523x,Rev.
0TargetMotorTheoryFreescaleSemiconductor10Figure10.
AlignmentRotorPositionFigure11.
SituationPriortoFirstCompareFollowingAlignmentAssoonasthepositioncounterreachesoneofthecomparevalues,thepositioninterruptiscalledinordertostartthecommutation.
ThepositioninterruptsetsthenewvaluesintothecompareparametersoftheQDeTPUfunctionbasedonthespindirection.
ThenewvaluescorrespondstothenextcommutationsectorinTargetMotorTheoryBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor11clockwiseorcounter-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,whichisimplementedasaconventionalproportional-integral(PI)controller.
ThedifferencebetweentheactualandrequiredspeedsisinputtotheBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0TargetMotorTheoryFreescaleSemiconductor12PIcontrollerwhichthen,basedonthisdifference,controlsthedutycycleofthePWMpulseswhichcorrespondtothevoltageamplituderequiredtomaintainthedesiredspeed.
Figure13.
SpeedControllerThespeedcontrollercalculatesthePIalgorithmgivenintheequationbelow:AftertransformingtheequationintoadiscretetimedomainusinganintegralapproximationwiththeBackwardEulermethod,wegetthefollowingequationsforthenumericalPIcontrollercalculation:where: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,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor133SystemConcept3.
1SystemOutlineThesystemisdesignedtodrivea3-phaseBLDCmotor.
Theapplicationmeetsthefollowingperformancespecifications:VoltagecontrolofaBLDCmotorusingquadratureencoderHEDS-5640A06TargetedatColdFireMCF523xevaluationboard(M523xEVB),33395evaluationmotorboard(powerstage),andMCGBLDCmotor(IB23810)Controltechniqueincorporates:—VoltageBLDCmotorcontrolwithspeed-closedloop—Bothdirectionsofrotation—4-quadrantoperation—Rotoralignmenttothestartposition—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:EvaluationboardM523xEVB33395evaluationmotorboardMCGBLDCmotor(IB23810)Quadratureencoder(HEDS-5640A06)Powersupply9VDC,2.
7AmpsBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SystemConceptFreescaleSemiconductor14TheeTPUmodulerunsthemaincontrolalgorithm.
The3-phasePWMoutputsignalsfora3-phaseinverteraregeneratedaccordingtofeedbacksignalsfromquadratureencoderandtheinputvariablevalues,providedbythemicroprocessorCPU.
CommutationofPWMphasesiscontrolledbytheCPU.
Figure14.
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.
OneeTPUchannel(GPIO)isusedtogenerateaninterrupttotheCPUwhentheover-currentfaultsignalactivates.
BLDCMotorDriveeTPUGPIOenable/disablePWMsignalsrequiredspeedApplicationStateMachineover-currentinterruptON/OFFswitchstatusdatamonitoringFaultLEDCPUHardware3-PhasePowerStageBLDCmotor912VDC÷ON/OFFDOWNUPUARTFreeMASTERRemoteControlRS232GPIOShaftEncoderSignalsPWMSignalsFaultSignalStatusLEDCommutationProcessingpositioninterruptPWMphasescommutationShaftEncoderSystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor15eTPUcontrolsaspeedclosedloop.
TheactualmotorspeediscalculatedbasedontheQDpositioncounterandQDlastedgetimeandcomparedwiththerequiredspeed,providedbytheCPUandpassedthrougharamp.
ThespeedPIcontrolalgorithmprocessestheerrorbetweentherequiredandactualspeed.
ThePIcontrolleroutputispassedtothePWMgeneratorasanewlycorrectedvalueoftheappliedmotorvoltage.
Figure15.
TheApplicationandFreeMASTERScreenBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SystemConceptFreescaleSemiconductor163.
2.
1UserInterfaceTheapplicationisinterfacedbythefollowing:ON/OFFswitchonM523xEVB.
Up/downbuttonsonM523xEVB,orFreeMASTERrunningonaPCconnectedtotheM523xEVBviaanRS232serialcable.
TheON/OFFswitchaffectstheapplicationstateandenablesanddisablesthePWMphases.
Whentheswitchisintheoff-position,novoltageisappliedtothemotorwindings.
WhentheON/OFFswitchisintheon-position,themotorspeedcanbecontrolledeitherbytheupanddownbuttonsontheM523xEVB,orbytheFreeMASTERonthePC.
TheFreeMASTERalsodisplaysacontrolpage,real-timevaluesofapplicationvariables,andtheirtimebehaviorusingscopes.
FreeMASTERsoftwarewasdesignedtoprovideanapplication-debugging,diagnostic,anddemonstrationtoolforthedevelopmentofalgorithmsandapplications.
ItrunsonaPCconnectedtotheM523xEVBviaanRS232serialcable.
AsmallprogramresidentinthemicroprocessorcommunicateswiththeFreeMASTERsoftwaretoreturnstatusinformationtothePCandprocesscontrolinformationfromthePC.
FreeMASTERsoftware,executingonaPC,usespartofMicrosoftInternetExplorerastheuserinterface.
Note,thatFreeMASTERversion1.
2.
31.
1orhigherisrequired.
TheFreeMASTERapplicationcanbedownloadedfromhttp://www.
freescale.
com.
FormoreinformationaboutFreeMASTER,refertoReference6.
3.
3HardwareImplementationandApplicationSetupAspreviouslystated,theapplicationrunsontheMCF523xfamilyofColdFiremicroprocessorsusingthefollowing:M523xEVB33395evaluationmotorboard3-phaseMCGBLDCmotor(IB23810)Powersupply,9-12VDC,minimum2.
7AmpsFigure16showstheconnectionoftheseparts.
AllsystempartsaresuppliedbyFreescaleanddocumentedaccordingtoreferences.
SystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor17Figure16.
ConnectionofApplicationParts3.
3.
1ColdFireMCF523xEvaluationBoard(M523xEVB)TheEVBisintendedtoprovideamechanismforcustomerstoeasilyevaluatetheMCF523xfamilyofColdFiremicroprocessors.
TheheartoftheevaluationboardistheMCF5235;allotherM523xfamilymembershaveasubsetoftheMCF5235featuresandcanthereforebefullyemulatedusingtheMCF5235device.
TheM523xEVBisfittedwithasingle512Kx16page-modeFLASHmemory(U19),givingatotalmemoryspaceof2Mbytes.
Alternatively,afootprintisavailableforupgradingflashtoa512Kx32page-modeFLASHmemory(U35),doublingthememorysizeto4Mbytes.
Formoreinformation,refertoReference2.
Table2listsallM523xEVBjumpersettingsusedintheapplication.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SystemConceptFreescaleSemiconductor183.
3.
2FlashingtheM523xEVBTheCFFlasherutilitycanbeusedforprogrammingcodeintotheFLASHmemoryontheMCF523xEVB.
Checkforcorrectsettingofswitchesandjumpers:SW7-6on,SW7-7off,JP642-3,(JP312-3).
Theflashingprocedureisasfollows:1.
RunMetrowerksCodeWarriorforColdFireandopentheproject.
Choosethesimple_eflashtargetandcompiletheapplication.
Afilesimple_eflash.
elf.
S19,whichwillbeloadedintoFLASHmemory,iscreatedintheprojectdirectorybin.
2.
RuntheCFFlasherapplication,clickonthe"TargetConfig"button.
IntheTargetConfigurationwindowselectthetypeofboardasM523xEVBandtheBDMCommunicationasPE_LPT(seeFigure17).
ClickOKtoclosethewindow.
3.
GototheProgramsectionbyclickingthe"Program"button.
Selectthesimple_eflash.
elf.
S19fileandcheckthe"VerifyafterProgram"option(seeFigure18).
Finally,pressthe"Program"buttonatthebottomofthewindowtostartloadingthecodeintotheFLASHmemory.
4.
Ifthecodehasbeenprogrammedcorrectly,removetheBDMinterfaceandpushtheRESETbuttonontheM523xEVB.
TheapplicationshouldnowrunfromtheFLASH.
TheCFFlasherapplicationcanbedownloadedfromhttp://www.
freescale.
com/coldfire.
Table2.
M523xEVBJumperSettingsJumperSettingJumperSettingJumperSettingJumperSettingJP1JP2JP3JP4JP5JP6JP7JP8JP9121-2121-212-31-2312-31-2312-3JP20JP21JP22JP23JP24JP25JP26JP27JP28JP2912-312-312-312-312-31-231-231-21-21-2JP40JP41JP42JP43JP44JP45JP46JP47JP48JP491-21-21-21-21-21-21-21-21-21-2JP60JP61JP62JP63JP641-21-2121212-3DIP1DIP2DIP3DIP4DIP5DIP6DIP7DIP8DIP9DIP10DIP11DIP12ONONONONONONOFFONONONOFFONJP10JP11JP12JP13JP14JP15JP16JP17JP18JP1912-312-312-312-312-312-312-312-312-312-3JP30JP31JP32JP33JP34JP35JP36JP37JP38JP391-212-31-231-21-21-231-231-21-21-2JP50JP51JP52JP53JP54JP55JP56JP57JP58JP591-231-231-231212121-231-21-21-2SystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor19Figure17.
CFFlasherTargetConfigurationWindowFigure18.
CFFlasherProgramWindow3.
3.
3SettingOvercurrentLevelTheover-currentfaultsignalisconnectedtotheeTPUoutputdisablepin(LETPUODIS)thathandleseTPUhardwarefaults,alongwiththepropereTPUconfiguration.
ThisconnectionispartofM523xEVB1.
Inordertoenablehandlingofthefaultbysoftware,thefaultsignal,availableontheLETPUODISpin,BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SystemConceptFreescaleSemiconductor20mustbeconnectedtoeTPUchannel4,whichrunstheGPIOfunctionandgeneratesaninterruptrequesttotheCPUinthecaseofafault.
Thisconnectionmustbedonemanually.
Connectpin6(LETPUODIS)withpin16(ETPUCH4)ontheeTPUheader(seeFigure19).
Theover-currentlevelissetbytrimmerR41onM523xEVB(seeFigure20).
Reference3describeswhatvoltagethetrimmerdefinesfortheover-currentcomparator.
Followthestepsbelowtosetuptheover-currentlevelproperlywithoutmeasuringthevoltage:1.
ConnectallsystempartsaccordingtoFigure16,connectpin16withpin40ontheeTPUheader.
Nowtheover-currentinterruptisdisabled.
Theover-currentfaultishandledbyhardwareonly.
2.
Downloadandstarttheapplication.
3.
TurntheON/OFFswitchON.
UsingtheUpandDownbuttons,settherequiredspeedtothemaximum.
4.
AdjusttheR41trimmer.
YoucanfindalevelfromwhichtheredLEDstartstolightandthemotorspeedstartstobelimited.
Setthetrimmerlevelsomewhathigher,sothatthemotorcanrunatthemaximumspeed.
5.
TurntheON/OFFswitchOFF.
6.
Connectpin16withpin6ontheeTPUheader.
Nowtheover-currentinterruptisenabled.
Theover-currentfaultishandledbybothhardwareandsoftware.
7.
TurntheON/OFFswitchON.
Usingtheupanddownbuttons,settherequiredspeedtothemaximum.
Iftheapplicationgoestothefaultstateduringtheacceleration,adjusttheR41trimmerlevelsomewhathigher,sothatthemotorcangettothemaximumspeed.
Figure19.
ConnectionBetweenLETPUODISandETPUCH4ontheeTPUHeader1.
WhentheeTPUisconfiguredfor32-channels,LTPUODISisapplicabletochannels0-15.
Whentheethernetisenabled(SW11on),thefunctionofLTPUODISthenchangestochannels0-7andUTPUODISthuscontrolschannels8-15.
ThereforetheUTPUODISmustbetiedtoLTPUODIStoenabletheapplicationtoworkwhenethernetisenabled.
SystemConceptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor21Figure20.
OvercurrentLevelTrimmeronM523xEVB(R41)3.
3.
433395EvaluationMotorBoardThe33395evaluationmotorboardisa12-volt,8-amppowerstage,whichissuppliedwitha40-pinribboncable.
IncombinationwiththeM523xEVB,itprovidesanout-of-the-boxsoftwaredevelopmentplatformforsmallbrushlessDCmotors.
Thepowerstageenablessensingavarietyoffeedbacksignalssuitablefordifferentmotorcontroltechniques.
Itmeasuresallthethreephasecurrents,reconstructstheDC-buscurrentfromthem,theDC-busvoltage,andtheback-EMFvoltageswithzerocrosssensing.
AlltheanalogsignalsareadaptedtobedirectlysampledbytheA/Dconverter.
Thissingle-boardpowerstagecontainsananalogbridgegatedriverintegratedcircuitry,sensingandcontrolcircuitry,powerN-MOSFETtransistors,DC-busbreakchopper,aswellasvariousinterfaceconnectorsforthesupplyandthemotor.
Figure21.
33395EvaluationMotorBoardBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SystemConceptFreescaleSemiconductor22Formoreinformation,refertoReference3.
3.
3.
5BLDCMotorwithQuadratureEncoderTheenclosedmotorisalow-voltageMCGBLDCmotor(IB23810).
ThemotorcharacteristicsinTable3applytooperationat25°C.
Figure31depictsthemotortiming.
Formoremotorspecifications,refertoReference4.
QuadratureencoderHEDS-5640A06isattachedtothemotorinordertoscanandencodeshaftmovement.
Thebasicencoderfeaturesareasfollows:ThreechannelquadratureoutputwithindexpulseResolution500countsperrevolutionExternalmountingearsQuickandeasyassemblyNosignaladjustmentrequiredSmallsize-40°Cto100°CoperatingtemperatureTTLcompatibleSingle5VsupplyFormorequadratureencoderspecifications,refertoReference5.
Table3.
MCGBLDCMotor(IB23810)MotorCharacteristicsCharacteristicToleranceUnitsValueMax.
operatingspeedMAX.
R.
P.
M.
5000ContinuoustorqueMAX.
OZ-IN20PeaktorqueMAX.
OZ-IN60ContinuouscurrentMAX.
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.
18SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor233.
3.
6PowerSupplyThepowersupplysuppliedwiththeM523xEVB,9.
0V/2.
7A,isalsousedtopowerthe33395evaluationmotorboard.
Theapplicationisscaledforthis9Vpowersupply.
Incasea12Vpowersupplyisusedinstead,theapplicationshouldberescaledforthewidervoltageandspeedrange.
4SoftwareDesignThissectiondescribesthesoftwaredesignoftheBLDCmotordriveapplication.
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,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor24Figure22.
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,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor254.
1CPUSoftwareFlowchartFigure23.
CPUSoftwareFlowchartAfterreset,theCPUsoftwareinitializesinterruptsandpins.
ThefollowingCPUprocessingisincorporatedintwoperiodicaltimerinterrupts,oneperiodicaleTPUchannelinterrupt,oneeTPUpositioninterruptandtwofaultinterrupts.
4.
1.
1InitializationofInterruptsandPinsTheinitializationoftimer3,eTPUchannel1,2,4and7interrupts,andtheeTPUglobalexceptioninterrupt,togetherwithinitializationoftheGPIOandLETPUODISpins,isdonebytheInitInterruptsAndPinsfunction.
4.
1.
2Timer3InterruptServiceRoutineThetimer3interruptishandledbythetimer3_isrfunction.
Thefollowingactionsareperformedperiodical,intimer3_isr:ReadtheON/OFFswitchstatusHandletheapplicationstatemachineTheapplicationstatediagramisdescribedindetailbelow.
ServicetheupanddownbuttonsandthestatusLEDbytheApplicationButtonsAndStatusLedfunctionRESETInitializeinterruptsandpinswaitReadON/OFFswitchstatusHandleapplicationstatemachineServiceUp/DownbuttonsandStatusLEDReadapplicationdatastructureTimer3InterruptHandleovercurrentfaultFaultInterruptFreeMasterDispatcherFreeMasterTimerInterruptFreeMasterRecordereTPUChannelInterruptHandleeTPUglobalexceptioneTPUGlobalExceptionInterruptBasedonDirectionandSectorvaluescommutatePWMphasesSetthenewvaluesintotwocompareparametersofQDeTPUfunctioneTPUPositionInterruptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor26ReadthedatastructurethroughtheeTPUapplicationAPIroutinefs_etpu_app_bldcmesl1_get_data(see4.
3).
4.
1.
3PositionInterruptServiceRoutineTheeTPUpositioninterrupt,whichisraisedbytheQDeTPUfunctionrunningoneTPUchannels1and2,ishandledbytheetpu_ch1_ch2_isrfunction.
Thefs_etpu_app_bldcmesl1_commutateapplicationAPIfunctioniscalledtoensurecommutationsofPWMphases(basedonactualdirectionandpositionofthemotionsystem).
TheinformationabouttheactualdirectionandthestateofpositioncounterisprovidedbytheeTPUQDfunction.
FurtherthisapplicationAPIfunctionsetstheQDeTPUfunctionparameterspc_interrupt1andpc_interrupt2asanewcomparevaluesforQDtoensuregenerationofthenextpositioninterrupt.
4.
1.
4FreeMASTERInterruptServiceRoutineTheFreeMASTERinterruptserviceroutineiscalledfmasterDispatcher.
Thisfunctionisimplementedinfmaster.
c.
4.
1.
5eTPUChannelInterruptServiceRoutineThisinterrupt,whichisraisedeveryPWMperiodbythePWMMDCeTPUfunctionrunningoneTPUchannel7,ishandledbytheetpu_ch7_isrfunction.
ThisfunctioncallsfmasterRecorder,implementedinfmaster.
c,enablingtheconfigurationofapplicationvariabletimecourseswithaPWM-periodtimeresolution.
4.
1.
6FaultInterruptServiceRoutineTheover-currentfaultinterrupt,whichisraisedbytheGPIOeTPUfunctionrunningoneTPUchannel4,ishandledbytheetpu_ch4_isrfunction.
Thefollowingactionsareperformedinordertoswitchthemotoroff:ResettherequiredspeedDisablethegenerationofPWMsignalsSwitchtheFaultLEDonEnterAPP_STATE_MOTOR_FAULTSetFAULT_OVERCURRENT4.
1.
7eTPUGlobalExceptionInterruptServiceRoutineTheglobalexceptioninterruptishandledbytheetpu_globalexception_isrfunction.
Thefollowingsituationscancausethisinterruptassertion:MicrocodeglobalexceptionisassertedIllegalinstructionflagisassertedSCMMISCflagisassertedSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor27Thefollowingactionsareperformedinordertoswitchthemotoroff:ResettherequiredspeedDisablethegenerationofPWMsignalsEnterAPP_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.
ApplicationStateDiagramON/OFFswitchmovedOFFAPP_STATE_ENABLEAPP_STATE_RUNAPP_STATE_MOTOR_FAULTAPP_STATE_DISABLEAPP_STATE_STOPresetAPP_STATE_INITON/OFFswitchmovedOFFON/OFFswitchmovedONAPP_STATE_GENERAL_FAULTON/OFFswitchmovedOFFover-currentfaultinterruptBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor28Thefollowingparagraphsdescribetheprocessingineachoftheapplicationstates.
4.
2.
1APP_STATE_INITThisstateispassedthroughonly.
Itisenteredeitherafterareset,oraftertheAPP_STATE_GLOBAL_FAULT.
Thefollowingactionsareperformedinordertoinitialize(re-initialize)theapplication:Callmy_system_etpu_initroutineforeTPUmoduleinitializationGeteTPUfunctionsDATARAMaddressesforFreeMASTERGettheaddressesofchannelconfigurationregistersforFreeMASTERInitializetheUARTforFreeMASTERInitializeFreeMASTERCallmy_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,refertoReference14.
Themy_system_etpu_initfunctionfirstconfigurestheeTPUmoduleandmotorsettings.
Someofthesesettingsincludethefollowing:Channelfiltermode=three-samplemodeChannelfilterclock=etpuclkdiv64Theinputsignals(fromquadratureencoder)arefilteredbychannelfilters.
Thefiltersettingsguaranteefilteringallnoisepulsesuptoawidthof1.
707usandpasspulsesfromawidthof2.
56s(at150MHzsystemclock).
TCR1source=etpuclkdiv2TCR1prescaler=1TheTCR1internaleTPUclockissettoitsmaximumrateof37.
5MHz(at150MHzsystemclock),correspondingtothe27nsresolutionofgeneratedPWMsignals.
TCR2source=etpuclkdiv8TCR2prescaler=1Afterconfiguringthemoduleandenginesettings,themy_system_etpu_initfunctioninitializestheeTPUchannels.
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor29Channel1-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-busvoltage9V—Numberofmotorpolepairs2—Speedcontrollerupdatefrequency500Hz—PIcontrollerparameters:P-gainis0.
5(0x004000*2-15),andI-gainis0.
125(0x001000*2-15).
Thecontrollerparameterswereexperimentallytuned.
—Rampparameters:0.
25storampupfromzerotothemaximumspeed,0.
25storampdownfromthemaximumspeedtozero.
—Numberofquadratureencoderpositioncounterincrementsperonerevolution2000Channel4-generalpurposeI/O(GPIO)ThiseTPUchannelisinitializedbythefs_etpu_gpio_initAPIfunction.
Thesettingis—Channelpriority:highThemy_system_etpu_startfunctionfirstappliesthesettingsforthechannelinterruptenableandchanneloutputdisableoptions,thenenablestheeTPUtimers,thusstartingtheeTPU.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor30Figure25.
eTPUConfigurationUsingtheeTPUGraphicalConfigurationTool4.
2.
1.
2InitializationofFreeMASTERCommunicationPriortotheFreeMASTERinitialization,itisnecessarytosetpointerstotheeTPUfunctionsDATARAMbasesandconfigurationregisterbases.
Basedonthesepointers,whicharereadbyFreeMASTERduringtheinitialization,thelocationsofalleTPUfunctionparametersandconfigurationregistersaredefined.
ThisisessentialforcorrectFreeMASTERoperation.
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor31FreeMASTERconsistsofsoftwarerunningonaPCandonthemicroprocessor,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,theGPIOeTPUfunctionisconfiguredasinput,interruptonrisingedge,andAPP_STATE_RUNisentered.
WherethePWMphaseswerenotsuccessfullyenabled,theapplicationstatedoesnotchange.
4.
2.
4APP_STATE_RUNInthisstate,thePWMsignalsareenabledandthemotorison.
TherequiredmotorspeedcanbesetusingtheupanddownbuttonsontheM523xEVBorbyusingFreeMASTER.
ThelatestvalueisperiodicallywrittentotheeTPU.
WhentheON/OFFswitchisturnedoff,theapplicationgoesthroughAPP_STATE_DISABLEtoAPP_STATE_STOP.
4.
2.
5APP_STATE_DISABLEThisstateispassedthroughonly.
Thefollowingactionsareperformedinordertoswitchthemotordriveoff:Resettherequiredspeed.
DisablethegenerationofPWMsignals.
IfPWMphasesweresuccessfullydisabled,APP_STATE_STOPisentered.
WherePWMphaseswerenotsuccessfullydisabled,theapplicationstateremainsthesame.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor324.
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,uint8_tQD_phaseB_channel,SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor33uint8_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)Changeoperationfunctions:int32_tfs_etpu_app_bldcmesl1_enable(bldcmesl1_instance_t*bldcmesl1_instance,uint8_tconfiguration,int32_tqd_pc_interrupt1,int32_tqd_pc_interrupt2)int32_tfs_etpu_app_bldcmesl1_disable(bldcmesl1_instance_t*bldcmesl1_instance)voidfs_etpu_app_bldcmesl1_set_speed_required(bldcmesl1_instance_t*bldcmesl1_instance,int32_tspeed_required_rpm)int32_tfs_etpu_app_bldcmesl1_commutate(bldcmesl1_instance_t*bldcmesl1_instance)Valuereturnfunctions:voidfs_etpu_app_bldcmesl1_get_data(bldcmesl1_instance_t*bldcmesl1_instance,bldcmesl1_data_t*bldcmesl1_data)4.
3.
1int32_tfs_etpu_app_bldcmesl1_init(.
.
.
)ThisroutineisusedtoinitializetheeTPUchannelsforthelBLDCmotorwithquadratureencoderandspeedclosedloopapplication.
Thisfunctionhasthefollowingparameters:BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor34bldcmesl1_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.
QD_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,.
.
.
SoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor35SC_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.
configuration(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.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor364.
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.
4.
4eTPUBlockDiagramTheeTPUfunctionsusedtodrivetheBLDCmotorwithspeedclosedlooparelocatedinthemotor-controlsetofeTPUfunctions(set3-DCmotors).
TheeTPUfunctionswithinthesetserveasbuildingblocksforvariousmotor-controlapplications.
Thefollowingparagraphsdescribethefunctionalityofeachblock.
Figure26.
BlockDiagramofeTPUProcessingPWMCPWMMDCSCappliedvoltagerequiredspeedMotorInverterCPUeTPUHardwareduty-cyclesGPIOFaultfaultinterruptOutputDisableQDQD_IndexShaftEncoderpositiondifference&timedifferencepositioninterruptcommutationSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor374.
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(channels16to32).
Figure27.
FunctionalityofPWMMDC+PWMCFormoredetailsaboutthePWMMDC,PWMF,andPWMCeTPUfunctions,refertoReference10.
4.
4.
2QuadratureDecoder(QD)ThequadraturedecodereTPUfunctionsetisintendedtoprocesssignalsgeneratedbyashaftencoderinamotioncontrolsystems.
Itusestwochannelstodecodeapairofout-of-phaseencodersignalsandtoproducea24-bitbi-directionalpositioncounter,togetherwithdirectioninformation,fortheCPU.
Anadditionalinputchannelscanalsobeprocessed.
Theindexchannelreceivesapulseoneachrevolution.
PWMMDCupdateupdateperiodapplied_voltagePWMCpolarity:active-highORactive-lowvariablePWMperiodscenter-alignedORedge-alignedsinglechannelORcomplementarypairPWMCPWMCupdatenoupdatenoupdatenewinputvaluesnewinputvaluesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor38Basedontheactualdirection,arevolutioncounterisincrementedordecrementedontheindexpulse.
Afurtheradditionalinputchannelcanindicateahomeposition,butitisnotusedinthisapplication.
Figure28.
FunctionalityofQDFormoredetailsabouttheQDeTPUfunction,refertoReference7.
4.
4.
3SpeedController(SC)ThespeedcontrollereTPUfunctionisnotintendedtoprocessinputoroutputsignals.
ItspurposeistocontrolanothereTPUfunction'sinputparameter.
TheSCfunctioncanbeexecutedevenonaneTPUchannelnotconnectedtoanoutputpin.
TheSCfunctionincludesageneralPIDcontrolleralgorithm.
Thecontrollercalculatesitsoutputbasedontwoinputs:ameasuredvalueandarequiredvalue.
Themeasuredvalue(theactualmotorspeed)iscalculatedbasedoninputsprovidedbytheQDfunction.
Therequiredvalueisanoutputofthespeedramp,whoseinputisaSCfunctionparameter,andcanbeprovidedbytheCPUoranothereTPUfunction.
Inthemotor-controleTPUfunctionset,thisfunctionmostlyprovidesthespeedouter-loop.
Figure29.
FunctionalityofSCFormoredetailsabouttheSCeTPUfunction,refertoReference9.
time_differenceQDposition_differencedirectionrevolution_counterQDIndexQDHomeomega_actualomega_rampomega_desiredapplied_voltageSCtimerequested_valuePIcontrollerramptime_differenceposition_differenceomega_actualscaling_factor*position_differencetime_differenceSoftwareDesignBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor394.
4.
4GeneralPurposeI/O(GPIO)ThisfunctionoriginatesfromthegeneraleTPUfunctionset(set1)andisincludedintheDCmotorcontroleTPUfunctionsetaswell.
ItallowstheusertoconfigureaneTPUchannelasageneralpurposeinputoroutput.
Thereare7functionmodessupported:Inputmode-updateperiodicallyInputmode-updateontransition-eitheredgeInputmode-updateontransition-fallingedgeInputmode-updateontransition-risingedgeInputmode-updateonrequest/disabletransitionandmatchupdatesOutputmode-outputlowOutputmode-outputhighGPIOfunctionisconfiguredtogenerateaninterrupttotheCPUincaseofanovercurrentfault.
Thefaultsignal,whichisusuallyconnectedtotheeTPUoutputdisableinput,canbealsoconnectedtotheeTPUchannelassignedaGPIOfunction.
Whenthefaultsignalturnsactive,selectedoutputchannelsareimmediatelydisabledbytheeTPUhardware.
Atthesametime,theGPIOfunctiongeneratesaninterrupt,inordertonotifytheCPUaboutthefaultoccurrence.
FormoredetailsabouttheGPIOeTPUfunction,refertoReference11.
4.
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.
BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SoftwareDesignFreescaleSemiconductor40ThepulseissynchronouswiththePWMperiods,butitspositionvariesintime.
ThismeansthatthetestedchannelactivityissynchronouswiththePWMperiodsandtheservicelatencyvariesinthistimerange.
Figure30.
OscilloscopeScreen-shotandExplanationofeTPUTimingFigure30explainstheapplicationeTPUtiming.
Theoscilloscopescreen-shotdepictsatypicalsituationdescribedbelow.
AliveviewontheoscilloscopescreenenablestheusertoseethevariationofSCandPWMMDCactivitypulses,whichdeterminesthechannelservicelatencyranges.
InFigure30,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.
ThesepulsesdeterminetheservicetimeofanSCrequesttoupdatethenewvalueofappliedSCactivityPWMMDCupdatesPWMperiodscommutationSCPWMCPWMCPWMMDCImplementationNotesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor41motorvoltage.
Apartfromthesepulses,foreveryPWMperiod,apulsewillappearwhichsignalsaPWMupdate.
ThePWMupdateactivitypulseiswidewhenanewvalueofappliedmotorvoltagehasbeenprocessed;itisnarrowwhennonewvaluehasbeenprocessedandthePWMduty-cyclesarenotupdated.
Thefs_etpu_pwmmdc_init_3phfunctionparameterupdate_timeenablestheusertoadjustthepositionofthePWMMDCactivitypulserelativetothePWMperiodframe.
Theactivitypulsehasascheduledupdate_timepriortotheendoftheperiodframe,sothattheupdateisfinishedbytheendoftheperiodframe,evenintheworstcaselatency.
Reference10describeshowtosettheupdate_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,DrivenbyeTPUonMCF523x,Rev.
0ImplementationNotesFreescaleSemiconductor42where: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,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor43Newphaseoptions:—DUTY_POS—DUTY_NEG.
Forafulldescriptionofallcommutationcommandoptions,refertoReference12.
Figure31depictstheMCGBLDCmotor(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,DrivenbyeTPUonMCF523x,Rev.
0ImplementationNotesFreescaleSemiconductor44Figure31.
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)MicroprocessorUsageBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor45((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)Thiswayallcommutationcommandscanbedefined.
6MicroprocessorUsageTable4showshowmuchmemoryisneededtoruntheapplication.
TheeTPUmoduleusageintermsoftimeloadcanbeeasilydeterminedbasedonthefollowingfacts:AccordingtoReference10,themaximumeTPUloadproducedbyPWMgenerationis946eTPUcyclesperonePWMperiod.
ThePWMfrequencyissetto20kHz,thusthePWMperiodis3750eTPUcycles(eTPUmoduleclockis75MHz,halfofthe150MHzCPUclock).
AccordingtoReference9,thespeedcontrollercalculationtakes324eTPUcycles.
Thecalculationisperformedevery40thPWMperiod.
AccordingtoReference8,thecontributionofQDfunctiontotheoveralleTPUtimeloadcanbecalculated.
Itdependsonthenumberofshaftencoderpulses(500)andthemotorspeed(maximum1000rpm).
ThemaximumeTPUbusytimeperoneencoderpulseis732eTPUcycles.
TheGPIOfunctionprocessingdoesnotaffecttheeTPUtimeload.
ThevaluesofeTPUloadbyeachofthefunctionsareinfluencedbycompilerefficiency.
Theabovenumbersaregivenforguidanceonlyandaresubjecttochange.
Foruptodateinformation,refertotheinformationprovidedinthelatestreleaseavailablefromFreescale.
ThepeakoftheeTPUtimeloadoccurswhenboththespeedcontrollercalculationandaQDsignaltransitionareprocessedwithinonePWMperiod.
Thispeakvaluemustbekeptbelow100%,whichensuresthatallprocessingfitsintothePWMperiod,noservicelatencyislongerthanthePWMperiod,andthusthegeneratedPWMsignalsarenotaffected.
Table4.
MemoryUsageinBytesMemoryAvailableUsedFLASH(external)2M30640RAM6K5782eTPUcodeRAM6K6140eTPUdataRAM1.
5K320BLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0SummaryandConclusionsFreescaleSemiconductor46Table5showstheeTPUmoduletimeloadinseveraltypicalsituations.
Formoreinformation,refertoReference13.
7SummaryandConclusionsThisapplicationnoteprovidestheuserwithadescriptionofthedemoapplicationBLDCmotorwithquadratureencoderandspeedclosedloop.
TheapplicationalsodemonstratesusageoftheeTPUmoduleontheColdFireMCF523x,whichresultsinaCPUindependentmotordrive.
Lastly,thedemoapplicationistargetedattheMCF523xfamilyofdevices,butitcouldbeeasilyreusedwithanydevicethathasaneTPU.
8ReferencesTable5.
eTPUTimeLoadSituationAverageTimeLoad[%]PeakTimeLoadWithinPWMPeriod[%]MotorSpeed10RPM(20.
8QDpulsespersecond)25.
542.
0MotorSpeed1000RPM(2083QDpulsespersecond)33.
642.
0Table6.
References1.
MCF5235ReferenceManual,MCF5235RM2.
M523xEVBUser'sManual,M5235EVBUM3.
33395EvaluationMotorBoardDesignerReferenceManualDRM33395/D4.
MCG'sMotorsweb:http://www.
mcg-net.
com5.
QuadratureEncoderHEDS-5640A06distributor'sweb:http://www.
agilent.
com/semiconductors6.
FreeMASTERwebpage,http://www.
freescale.
com,searchkeyword"FreeMASTER"7.
EnhancedTimeProcessingUnitReferenceManual,ETPURM8.
"UsingtheQuadratureDecoder(QD)eTPUFunction,"AN28429.
"UsingtheSpeedController(SC)eTPUFunction,"AN284310.
"UsingtheDCMotorControlPWMeTPUFunctions,"AN2480ReferencesBLDCMotorwithQuadratureEncoderandSpeedClosedLoop,DrivenbyeTPUonMCF523x,Rev.
0FreescaleSemiconductor4711.
"UsingtheGeneralPurposeI/OeTPUfunctions(GPIO),"AN285012.
"UsingtheHallDecoder(HD)eTPUFunction,"AN284113.
"UsingtheDCMotorControleTPUFunctionSet(set3),"AN295814.
eTPUGraphicalConfigurationTool,http://www.
freescale.
com,searchkeyword"ETPUGCT"15.
"DSP56F80xMCPWMModuleinMotorControlApplications,"AN192716.
"3-PhaseBLDCMotorControlwithQuadratureEncoderusingDSP56F80x,"AN1915/DTable6.
ReferencesHowtoReachUs: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.
AN2957Rev.
006/2005
酷锐云是一家2019年开业的国人主机商家,商家为企业运营,主要销售主VPS服务器,提供挂机宝和云服务器,机房有美国CERA、中国香港安畅和电信,CERA为CN2 GIA线路,提供单机10G+天机盾防御,提供美国原生IP,支持媒体流解锁,商家的套餐价格非常美丽,CERA机房月付20元起,香港安畅机房10M带宽月付25元,有需要的朋友可以入手试试。酷锐云自开业以来一直有着良好的产品稳定性及服务态度,支...
至今为止介绍了很多UCLOUD云服务器的促销活动,UCLOUD业者以前看不到我们的个人用户,即使有促销活动,续费也很少。现在新用户的折扣力很大,包括旧用户在内也有一部分折扣。结果,我们的用户是他们的生存动力。没有共享他们的信息的理由是比较受欢迎的香港云服务器CN2GIA线路产品缺货。这不是刚才看到邮件注意和刘先生的通知,而是补充UCLOUD香港云服务器、INTELCPU配置的服务器。如果我们需要他...
厦门靠谱云股份有限公司 双十一到了,站长我就给介绍一家折扣力度名列前茅的云厂商——萤光云。1H2G2M的高防50G云服务器,依照他们的规则叠加优惠,可以做到12元/月。更大配置和带宽的价格,也在一般云厂商中脱颖而出,性价比超高。官网:www.lightnode.cn叠加优惠:全区季付55折+满100-50各个配置价格表:地域配置双十一优惠价说明福州(带50G防御)/上海/北京1H2G2M12元/月...
46sw.com为你推荐
固态硬盘是什么固态硬盘是什么?与普通硬盘有什么区别?移动硬盘与u盘有什么区别?阿丽克丝·布莱肯瑞吉唐吉诃德·多弗朗明哥知道什么秘密原代码源代码是什么意思啊曲妙玲张婉悠香艳版《白蛇传》是电影还是写真集?丑福晋谁有好看的言情小说介绍下51sese.comwww.51xuanh.com这是什么网站是骗人的吗?www.55125.cnwww95599cn余额查询www.765.com哪里有免费的电影网站javmoo.comjavbus上不去.怎么办5xoy.comhttp://www.5yau.com (舞与伦比),以前是这个地址,后来更新了,很长时间没玩了,谁知道现在的地址? 谢谢,
太原域名注册 东莞服务器租用 西安服务器 企业主机 国外idc 视频存储服务器 godaddy支付宝 ssh帐号 服务器架设 nerds 河南移动网 国外的代理服务器 空间服务器 美国vpn代理 paypal登陆 泥瓦工 电脑显示屏不亮但是主机已开机 电脑主机配置 国内免备案空间 海康流媒体服务器 更多