Transcription of Sensored 3-Phase BLDC Motor Control Using …
1 ApplicationReportSLAA503 July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 BhargaviNisarga, ( bldc )motorsareelectronicallycommutatedm otorsthatoffermanyadvantagesoverbrushedD Cmotorsand,therefore, sensored3-phaseBLDC motorcontrolsolutionusingMSP430 : (OneElectricalCycle)..44 Flowchart (PIController)..119 Flowchart C a ,ExcelareregisteredtrademarksofMicrosoft Corporationin July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedSpeed ControlInputMSP 430 Open Loop ControlMotor (rotor)anda fixedarmature(stator).Anelectroniccontro lleris usedformotorcommutationinsteadofthebrush edcommutationusedin ,whichincludeincreasedspeedvstorqueeffic iency,longerlife(asnobrushesareused),noi selessoperation,andincreasedefficiencyin convertingelectricalpowertomechanicalpow er(especiallybecausetherearenoelectrical andfrictionallossesduetobrushedcommutati on).
2 Themotorcommutationin bldc motorsis implementedbyanelectroniccontrollerand,t odeterminetherotorpositionandtoknowwhent ocommutate,eitherHallsensors(sensoredcom mutation)orthebackEMFgeneratedin thestatorwindingsofthemotor(sensorlessco mmutation) ,asnobackEMFis presentwhenthemotorisstationary;thisis workedaroundbystartingthemotorfromanarbi traryposition;however, , bldc motorsareavailablein 1-phase,2-phase, typicalHallsensored3-phaseBLDC motorcontrolis discussedin a simplecontrolsystemin whichthesystemdoesnottracktheoutputofthe processit is ,open-loopcontroldoesnotusefeedbacktodet ermineif usedin systemsin whichtherelationshipbetweeninputandthere sultantstateis well-definedandthefeedbackis : Simplicityin designingthecontrolsystem Lowercostasthefeedbacksignalchainis ,open-loopcontrolis thehalfbridgesofthemotor-drivecircuitand thisin showsa ,theopen-loopcontrolsystemimplementedint heMSP430eitherincreasesordecreasesthePWM dutycycle,whichin July2011 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedVCCADCO penLoopControlTimer BPWMO utputsMSP430 DRIVERPWM1 PWM2 PWM3 PWM4 PWM5 PWM6 Vmotor +Vmotor -LS_ULS_VLS_WHS_WHS_VHS_UPWM2 PWM1 PWM4 PWM3 PWM6 PWM53-ph CommutationHallUHallVHallWNSSUVWM otor Drive CircuitMotorMSP430 Open measuredbytheanalog-to-digital(A/D)conve rterintegratedin linearrelationshipbetweentheADCinputvalu emeasuredandmotorspeedis assumedin thisimplementation,suchthatADCoutputrang ingfrom0 tomaximumcountscorrespondstomotorspeedra ngingfrom0%to100%.
3 Discussedin toVCC. Toboostthevoltagetodrivemotorsathighervo ltagelevels(Vmotor), thethreehalfbridgesareallNFETs,andthePWM signalwithvariabledutycycleis ,anditsdutycycleis usedtocontrolthecurrentthroughthepowerFE Tsandmotorwindingsand,in turn, , Hallsensorstatechangeevent, andFigure3 showthe3-phaseBLDC motorcommutationsequencein accordancewiththestandard120 July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedHall Inputs(U|V|W)State123456 Direction = CCW110101001011010100 PWM2HS_U PWM1LS_U PWM4HS_V PWM3LS_V PWM6HS_W PWM5LS_W (U|V|W)= ( | | )StateDIR= CWDIR= CCWA ctivePWMsandPowerFETs1001110 PWM4,PWM5HS_V,LS_W2011100 PWM2,PWM5HS_U,LS_W3010101 PWM2,PWM3HS_U,LS_V4110001 PWM6,PWM3HS_W,LS_V5100011 PWM6,PWM1HS_W,LS_U6101010 PWM4,PWM1HS_V, (OneElectricalCycle) thedemofirmwarethatis UserConfigurableParameterDefinitionsConf igurableParameter(Definedinmain_open_loo pHeaderFile)CommentsDemoFirmwareValuesCl ockTimingDefinitionsSYSTEM_FREQD efinesMCLK= SMCLK= TimerPWM16000kHzbasefrequency(inkHz)4 Sensored3-PhaseBLDCM otorControlUsingMSP430 SLAA503 July2011 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporated16 MHz= 1023 kHzSYSTEM_FREQPWM_FREQ 122= 41023122 Timer_PWM_Period Dutycycle_MinTimer_PWM_Period 100 kHz 100 ms= 1510 PWM_FREQ MOTOR_STARTUP_TIME=DUTYCYCLE_CHANGE_PERI ODS = 2 Counts100 UserConfigurableParameterDefinitions(con tinued)ConfigurableParameter(Definedinma in_open_loopHeaderFile)CommentsDemoFirmw areValuesPWM_FREQD efinestimerPWMswitchingfrequency15640Hz( inHz)(seeNote(1))TIMER_PWM_PERIODR epresentsthenumberofdutycyclestepsorthen umberofmotorspeedsteps=SPEEDIN_PWM_FACTO R=(seeNote(2))
4 DUTYCYCLE_MIND efinesminimumPWMdutycycleor5%minimummoto rspeed(inpercentage)MIN_PWM_DUTYCYCLED efinesminimummotorspeed(innumber1023 51 Countsofdutycyclecounts)=MotorStart-Upan dOpen-LoopControlDefinitionsMOTOR_STARTU P_TIMED efinesmotorstart-uptime(inms)100msDUTYCY CLE_CHANGE_PERIODSD efinesthenumberoftimerPWMperiods10 PWMP eriodsafterwhichPWMdutycycleupdateisexpe ctedduringmotorstart-uproutine(seeNote(3 ))STARTUP_STEPSD efinesthenumberofPWMdutycycleupdatesteps duringmotorstart-upADC_SAMPLING_PWM_PERI ODSD efinesthenumberoftimerPWMperiods1000 PWMP eriodsafterwhichPWMdutycycleupdateisexpe ctedduringmotorstart-uproutine(seeNote(3 ))MAIN_PWM_BUCKET_PERCENTD efinesthePWMdutycycleresolution( ),alsocalledthebucketstep,thatis usedtoeitherincreaseordecreasePWMdutycyc levaluesand,in turn, (seeNote(4)) =TIMER_PWM_PERIOD MAIN_PWM_BUCKET%(1)ThePWMswitchingfreque ncyshouldbeselectedsuchthatit is , a multipleof2,whichgeneratesa wholenumberforthePWM_SPEEDIN_FACTOR(whic his aratioofthemaximumADCcountstomaximumduty cyclecounts).
5 Thismakesnormalizationandothercomputatio nsin firmwaresimpler shiftleft/rightinstructionsinsteadofmult iplyanddividefunctions.(2)MSP430F5529wit hADC12is usedin thedemofirmwareand,therefore,anADCresolu tionof212is usedin thisapplication.(3)TheTimerPWMperiodinte rvalis usedasa heartbeatsignaltokeeptrackofthePWMdutycy cleupdateandADCsamplingintervals.(4)Ensu rethattheMAIN_PWM_BUCKET_PERCENT selectedyieldsa July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 SubmitDocumentationFeedbackCopyright 2011, ,andthePWMdutycycleis directlyproportionaltothemotorspeed;ther efore,thesetermsareusedinterchangeablyin thedemofirmwareincreasesthemotorspeedfro mminimummotorspeed(pre-definedminimumPWM dutycyclevalue- MIN_PWM_DUTYCYCLE)tothedesiredspeedlevel (basedonthespeedinput)in a pre-definedperiodoftime(MOTOR_STARTUP_TI ME)andpre-definednumberofsteps(STARTUP_S TEPS).Withthedesiredmotorspeedandpre-def inedMOTOR_STARTUP_TIMEandSTARTUP_STEPS,t hebucketstepsizeorthedutycycleincrementv alueis computedruntimein ,in turn,themotorspeedis thedesiredspeedinputlevelis lessthantheminimummotorspeedlevel,thenth emotorspeedis July2011 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedMain()C onfigure MSP430 modulesConfigure System Clock = 16 MHzConfigure as GPIO Inputs (Hall SensorInputs)Configure TimerB PWM Outputs (PWM1-PWM6)with MIN_PWM_DUTYCYCLE andenableTimerB interrupts every PWM periodConfigure ADC to measure analog pot voltageused as Motor speed input controlInitialize variablesMotor_Status = StoppedStart_Motor()Sample_ADC =true?
6 Speed Input MeasurementTrigger ADC Conversion to sample Speed InputWait in LPM until ADC ISR exits hereAverage accumulated conversion resultsTranslate ADC conversion value tocorresponding PWM dutycycle value and updateDesired PWM DutycycleSample_ADC = falseRead Initial Hall States; Start MotorRead hall inputs to detect currentmotor stateBased on the hall input states read,update TimerB PWM output statesas per the commutation sequenceCompute Start-up dutycycle bucketsize (PWM_BucketStep) based ondesired PWM dutycycle, predefinedMOTOR_STARTUP_TIME andSTARTUP_STEPSM otor_Status = StartUpStart Timer (wait for Timer ISR)Initial Speed Input MeasurementTrigger ADC conversion to sampleinitial speed input valueTranslate ADC conversion value tocorresponding PWM dutycycle valueand update Desired PWM DutycycleNOYESS tart_Motor()Stop_Motor()Disable and clear pending hall inputinterruptsDisable timer interrupts and stop allPWM outputsMotor_Status = StoppedENDStop_Motor()ENDS tart_Motor()
7 Thesystemis usedtocontrolthemotorspeedin thecurrentPWMdutycycleishigherorlowertha nthedesiredPWMdutycyclevalue,thePWMdutyc ycleis decrementedorincremented,respectively,in pre-definedPWMdutycyclebucketsteps(MAIN_ PWM_BUCKET_DC)insidetheTimerPWMISR andthis,in turn, asshownin Figure4 Open-LoopControlFunctions7 SLAA503 July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedADC ISRPort ISR(Hall Event Occurred)Accumulate up to 4 ADC ConversionResultExit LPM on ISR exitENDADC ISRT imer_B ISR(Heart Beat Interfal)Update various interval countersPWM_Update_Counter++ADC_Sample_C ounter++Start-upMotor_Status?RunningOpen Loop ControlStart-Up RoutineIf (PWM_Update period elapsed &&Desired_PWM_Dutycycle >Current_PWM_Dutycycle)Increment Current_PWM_Dutycycleby the PWM_BucketStep valueClear PWM_Update_CounterIf (Desired_PWM_Dutycycle <Current_PWM_Dutycycle)Motor_Status = RunningIf (ADC_Sample interval elapsed)Sample ADC flag = trueClear ADC_Sample_CounterIf (Desired_PWM_Dutycycle >Current_PWM_Dutycycle)
8 Increment Current_PWM_Dutycycleby the MAIN_PWM_BUCKET_DCvalueElseDecrement Current_PWM_Dutycyleby the MAIN_PWM_BUCKET_DCvalueENDT imer B ISRENDPort ISR3-phase bldc CommutationRead Hall Input statusBased on hall input states read,update Timer PWM outputs as perthe commutation Open-LoopControlISRs8 Sensored3-PhaseBLDCM otorControlUsingMSP430 SLAA503 July2011 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedSpeed ControlInputMSP430 Closed Loop ControlMotor , ,theMSP430microcontrollerthatis usedastheelectroniccontrollerisconfigure dwitha systemclockof16 MHzand,therefore, (portISR)is approximately6 MCLK cycles= 6/16 MHz= 375ns[1].ThetotaltimetakentodetecttheHal linputstatechangeandupdatethetimerPWMout putstatesasperthecommutationsequenceis approximately130 MCLK cycles= 130/ 16 MHz= s(1)(thisvalueis obtainedfromthedemofirmwareimplementatio n).Themaximummotorspeedis ,witha s, themaximummotorspeedthatcanbeachievedis approximately41000rpm.
9 (2)3 Closed-LoopControlClosed-loopcontrolsare usedin thesystem,stabilityin unstableprocesses,andreducedsensitivityt oparametervariations(dynamicloadvariatio n).A PIDcontrolleris a closed-loopcontrolimplementationthatis widelyusedandis mostcommonlyusedasa , thattheopen-loopcontrolconsidersonlythes peedcontrolinputtoupdatethePWMdutycycle, whereas,theclosed-loopcontrolconsidersbo thspeed-inputcontrolandactualmotorspeed( feedbacktocontroller)forupdatingthePWMdu tycycleand,in turn, showsa fedbacktotheclosed-loopcontroller,whichi s (proportionalandintegralvalues),theclose d-loopcontroleitherincreasesordecreasest hePWMdutycycle,whichin showstheblockdiagramoftheclosed-loopcont rolimplementation.(1)Assumingthedeviceis in LPM0oractivemode(whereDCOclocknotturnedo ff)duringHallstatechangedetection(2)Maxi mumnumberofHallISRspersecondis convertedtorespectiveelectricalandmechan icalcyclesusingformulasin Table3 andappliedtotheHurstMotorDMA0102024C(use din thisdemoapplication)polepairspecificatio n(1/ 3 s 41000rpm).
10 9 SLAA503 July2011 Sensored3-PhaseBLDCM otorControlUsingMSP430 SubmitDocumentationFeedbackCopyright 2011,TexasInstrumentsIncorporatedVCCADCC losedLoopControlTimer BPWMO utputsMSP430 DRIVERPWM1 PWM2 PWM3 PWM4 PWM5 PWM6 Vmotor +Vmotor -LS_ULS_VLS_WHS_WHS_VHS_UPWM2 PWM1 PWM4 PWM3 PWM6 PWM53-ph CommutationHallUHallVHallWNSSUVWM otor Drive CircuitMotorMSP430 Closed LoopControlSpeedControlInputNMotor Speed MSP430 BasedImplementationThespeed-controlinput , Motor -drivecircuit,and3-phaseBLDC commutationimplementedin theclosed-loopsolutionis PIcontrollerisusedtoimplementtheclosed-l oopcontrolthatusesboththespeed-controlin putandtheactualmotor-speedfeedbacktoupda tethetimerPWMdutycyclethat,in turn, (UsingHallSensors)Theactualmotorspeedis calculatedbytrackingthetimeperiodbetween successiveHallevents,whichrepresentsa 3-phaseBLDC motorcontrol,oneelectricalcyclehassixHal lstatesand,dependingonthenumberofpolespa irsin themotor,theelectricalanglemeasuredbetwe ensuccessiveHallstatechangescanbetransla tedtoa ,fora 4-pole3-phaseBLDC motorwiththreeHallsensors,onemechanicalr evolutionis equaltotwoelectricalcycles.
