Repositorio Institucional de Documentos
Abstract
El proyecto describe el funcionamiento y control de un motor DC Brushless. En el documento queda recogida la realización de las placas electronicas correspondientes al controlador y la electrónica de potencia. Fraguas Tejero, Diego; Steenbuch Vester, Heiko
Full text
Diego FraguasTejero CRUISE CONTROL ON AN ELECTRIC BIKE Report Report regarding the Electrical Power Engineering Project, from the corresponding course, at the Southern Denmark University, during the Autumn semester. Supervisor: Heiko Steenbuch Vester ODENSE 2011
Índice 1. SYNOPSIS....................................................................... 1 2. PREFACE ....................................................................... 1 3. IN TR ODUC T ION ............................................................ 2 4. THE BATTERY.................................................................. 4 5. THE MOTOR .................................................................. 6 5.1. INTRODUCTION ..................................................... 6 5.2. WORKING PRINCIPLE ........................................... 6 5.3. KIND OF DC BRUSHLESS MOTOR ........................ 8 5.4. OUR MO T OR .......................................................... 9 5.5. FEEDING SEQUENCE............................................. 12 6. SENSOR ......................................................................... 14 6.1 NUMBER OF POLES. ............................................... 15 7. CONTROLLER AND POWER ELECTRONIC ................ 17 7.1. CONTROLLER......................................................... 18 7.1.1. Introduction.................................................... 18 7.1.2. Analogic ......................................................... 18 7.1.3 Digital ............................................................... 22 7.2 POWER E L EC T RONICS ...........................................38 7.2.1 Power supply ................................................... 38 7.2.2. Driver ............................................................... 41 8. CONCLUSIONS............................................................. 46 9. BIBLIOGRAPHY .............................................................. 48 ANNEX A – MOTOR DATASHEET .................................... 49 ANNEX B – F IRMWARE ..................................................... 51 ANNEX B -CIRCUIT ........................................................... 67 ANNEX C- CIRCUIT WITH OPTOCOUPLER..................... 68
1 1.SYNOPSIS Themaingoalofthisprojectisapplythelearntknowledgeduringthissemesteratthe SDUinthecoursesofPEMandCES. Theprojectthatwehavechosenconsistsoncontrolanelectricbikemotor,soitcan assisttheride.So,ifthespeedislowerthanthedesiredspeed,themotormustspeed up,andviceversa. Inordertoachievethisgoal,weneedtodealwiththreedefinedsubjects:themotor, thecontrollerandthepowerelectronics. 2.PREFACE Thefirsttwowheelvehiclewithsteeringsystemwasdesignedin1816byaGerman scientist.Although,thereareoldtestimoniesaboutthisvehicle.ItissaidthatLeonardo DaVincipaintedacycleinoneofhisworks. In1839,pedalswereincludedinthismachinewiththepurposeofridingitwithout touchingthegroundwiththefeet. Inthefollowingyears,theexpertsdedicatedthetimetoimprovethepreviousmodels anddesigns. Asananecdote,wewanttocommentthatin1887,ThomasStevens,originfromthe USA,wasthefirstmanwhowentaroundtheworldridingacycle.Hetook3yearsto completethewholetrip. In1889,thefirstofficialcyclingcompetitionappears.Fromthenonwards,thereis morecuriosityinimprovingthecharacteristicsandtheperformanceofthecycle. Inthelastdecade,theelectricalbicycleshavebeguntomarket.Theyhaveanengine tohelpthecyclistinhisride.Theusuallybikesdon´tneedenergythereforeitsusedis increasing,butalthoughthisisadisadvantagefortheelectricalbikes,theyarevery usefulinplaceswithlargeslopes,andfactorslikethewindwillbeeliminated.Onthe otherhand,youcanridebiggerdistanceswithmuchlesseffort.
2 3.INTRODUCTION Fortherealizationofthisprojectwehavetotakeintoaccountsomeaspectsrelated withtheideaofourproject:cruisecontrolonanelectricbike. Firstofall,wemusthaveaclearideaaboutwhatanelectricalbikeconsiston:isa machinedesignedtomovethroughtheeffortofthecyclistusinganelectricalmotorin ordertohelpthecyclist,andnottoreplace.Incasethereisnoeffortofthecyclist,the vehiclewillbeconsideredasamotorbike. Therearesomeaspectsthatdeterminethecycling:thewaytodrive,thestateofthe bicycle(forexamplethetirepressure),thestateofthebattery,ambienttemperature, thewind,topography,theweight,theage,therider´sphysicalcondition… Ontheotherhand,acruisecontrolisanelectronicsystemthatautomaticallycontrols thespeedofavehiclemotorandmaintainsitsteadyassetbythedriverwithoutuse theacceleratororbreak. Wethinkthatourcruisecontrolmustsatisfysomeconditions: ‐Themotorcanalsobeturnedonoroffusingaswitch,inordertolettherider chooseuseitornot. ‐Thespeedmustbesteadywithouttakingcareabouttherequiredtorque. ‐Asasafetycondition,themotorhastostopwhenthecyclistbreaks. ‐Theenergydissipatedduringthebreak,willbeusedtochargethebattery.
3 Thesystemcanbedescribedintheimageshownbelow: Aswecansee,oursystemisdividedinfourparts:themotor,thesensor,thecontroller andthepowerelectronics.Aswell,we’llneedapowersupplytofeedoursystemanda load(bicycletorque). Theelectricaldriveisasystemwhichperformstheconversionofelectricalenergyto mechanicalenergy. Nowwearegoingtodescribebrieflythecomponentsoftheelectricaldrive: Themotor:Themotorobtainpowerfromelectricalsources.Itconvertselectrical energyintomechanicalenergy.ThemotorscanbeclassifiedinACorDCmotors. Powerprocessor:Withcontrollablesources,themotorcanbereversed,bakeorcan beoperatedwithvariablespeed.Thecharacteristicofthemotorscanbechangedat will.Powerelectronicconvertershaveseveraladvantagessuchasmoreefficiencyor flexibility Controller:Thecomplexityofitdependsonthedesireddriveperformanceandthe typeofmotorused.Themaincontrollerscanbe:analog,digital,DSP/microprocessor Source:Electricalsourcesorpowersuppliesprovidetheenergytotheelectricalmotor. Forhighefficiencyoperation,thepowerobtainedfromtheelectricalsourcesneedto beregulatedusingpowerelectronicconverters. PowersourcescanbeofACorDC.Therecanbeseveralfactorsthataffectthe selectionofdifferentconfigurationofelectricaldrivesystemsuchas:torqueand
4 speed,capitalandrunningcostorspaceandweightrestrictionsenvironmentand location Withtheprovidedinformationinthisintroduction,wecanconcludethatthepurpose ofourprojectistocreateanelectronicsystem,whichcontrolamotor.It’sformedbut twoquitedifferencedparts:controllerorlogicalpartanddriverorpowerelectronics part. Toachievethisgoal,weneedtostudythedifferentpartsdescribedbefore,inorderto knowthespecificationsofoursystem.
5 MAINREPORT 4.THEBATTERY AswehaveaDCmotor,wewillneedtofeeditwithsomesource,asDCpowercanbe stored,wearegoingtouseabattery. ThebatterythatwewasgivenisaLiFePO4one,anditfitsperfectlywithourmotor. Themainadvantagesofthiskindofbatteriesare,astheconventionallithium‐ion battery: ‐Lightweightthatfitswiththepoweritgives ‐Nomemoryeffect(effectthatcausethebatterytoholdlesscharge) ‐Self‐dischargerateapprox.5‐10%permonth ‐Environmentalfriendly ‐Butitalsohashighercurrentandmorepeakpowercurrent.
6 Someofthespecificationsare: ‐ 5.26kgofweigh ‐ 361x149x83mm ‐ 36V ‐ 10AH Wemustsaythatthespecificationsareratedvalues.Whenthebatteryiscompletely chargedisexpectedtohavehighervaluesofvoltageandmaximumcurrentthanthe ratedvalues.Tomakesurethatourelectronicdevicescanhandlethispeaks,we decidedtotestthebattery. Wemeasuredthevoltageofthebatteryfullychargedwithoutload;wemeasureda valueof41V.Knownthepowerofthemotor:500W,wecancalculatealoadvaluein ordertogetthecurrent. Ω== 362.3 2 P U R Inthelaboratorytherewerethreevariableresistances,abletohandlethispower, whichminimumvaluewas10ohms,soweconnectedtheseresistanceswiththeir minimumvalueinparallelinordertogetavalueclosedtothedesiredresistance. Ω= ++ =33.3 111 1 321 RRR Req Tomeasurethecurrentwecouldn’tuseanammeterbecauseitsfusejustcanhandle 10Aasmaximumvalue,soweusedapegpluggedtotheoscilloscope,gettingthe followingvalue:
7 Thepeghasagainof100mV/A)sothecurrentisof10.8A 5.THEMOTOR 5.1.INTRODUCTION DuetotheDCpowersupply,ourmotormustbeaDCone.WecanfindtwokindofDC motor:brushedandbrushlessmotor.Duetotheimprovementthatthebrushless motorhas(lessmaintenance,moreefficiency...)wechooseit. 5.2.WORKINGPRINCIPLE InaDCbrushedmotorthetorqueisobtainedbytheinteractionofthemagneticfield inductionandthecurrentoftherotatingarmaturewinding. TheDCbrushlessmotorisverysimilartotheconvectionalDCmotorbuttheyarebuilt indifferentway: ‐Theswitchingisdoneelectronicallyratherthanmechanically. ‐Permanentmagnetsareintherotorinsteadofthestator. ‐Thecoilsarelocatedinthestator,formingasingle‐phasewinding. Brushlessdcmotorsaretypicallyconfiguredaspermanentmagnetsynchronous motors..Itsperformanceisbasedonsequentialfeedingofeachstatorphasesin synchronismwiththemovementoftherotor.Sothepermanentmagnetsfollowthe movementofthemagneticfield.
14 6.SENSOR TheHallsensorusestheHalleffecttomeasuremagneticfieldsorcurrentsinorderto determinetherotorposition. IfcurrentflowsthroughaHallsensorandit’sclosetoamagneticfieldwhichflows perpendiculartothesensor,thesensorcreatesavoltageproportionaltotheproduct projectionofthemagneticfieldandcurrent.Thenwiththecurrentvalue,wecan calculatethemagneticfieldforce.Ifthemagneticfieldcreatedbycurrentflowing throughawinding,thenyoucanmeasurethevalueofthecurrentintheconductoror coil. Inordertodeterminethemotorspeedweneedasensor,ourmotorisprovidedwith threehallsensors,duetothefactthatisabrushlessDCmotor. TheHallsensordetectsthedirectionandthemagneticfieldfromthemotor.The outputofthesesensorsis5Vwhentherotorisclosetoit.
15 Usingthedigitaloscilloscopewecanknowthesequencethatfollowourmotor,it’s showninthefollowingimage: TheyellowwaveisthehallsensorA,thegreenoneisthehallsensorBandtheblue oneisthehallsensorC. 6.1NUMBEROFPOLES. Nowwearegoingtocalculatethenumberofpolesofourmachine. Howcanwedothis? Weperformedthemotorwithnoloadandtheratedvalues.Wecanfindthespeedfor thatcaseinthedatasheet,n=343.4rpm,soweneedtoknowthevalueofthe physicalfrequencyorperiod: 1º)Passtherpmtorevolutionpersecond. 2º)Wehave5.75revolutionspersecond,sowecanknowhowmanytimespendin onerevolution,theinverseistheperiodofaphysicalrevolution.Tp=174,67ms. 3º)Inthepictureofthehallsensorstest,wecanmeasuretheperiodofaelectrical cycle,ifeachsquareis5m/s,andonecyclespend4squaresandaquarterofother square,theperiodofthecycleisTe=21.5ms
16 4º)Theratiobetweenthephysicalperiodandtheelectricalperiodisthenumberof poles. Sowecanconcludethatourmotorhas4pairofpoles.
17 7.CONTROLLERANDPOWERELECTRONIC 7.1.CONTROLLER 7.1.1.Introduction Thecontrollerisoneofthemostimportantthingsinourproject.It’sadevicewhich doesn’thandlehighvaluesofvoltagesandcurrent,buthastoprocessalotof informationencodedinsignals,inordertogetthedesiredbehaviourofourmotor. Thecontrollermusthavethefollowingfeatures: ‐Furnishthecorrectvoltageaccordingtodesiredspeed ‐Feedthewindingsinthecorrectsequence ‐Acquirethemeasuredspeed Afterdiscussingaboutwhichkindofcontrollerwasmoresuitableforourproject,we decidedtoimplementadigitalcontroller.Inordertoshowtheimprovementsthatthis kindofcontrollerprovidesus,wearegoingtoshowabitofinformationaboutanalogic controllersaswell. 7.1.2.Analogic ‐ Closedloopcontrol Aswecanseeinthefollowingimagethemaincharacteristicisthatafeedbackisused tocontroltheprocess.Thefeedbackismeasuredbyasensorwhichsendasignalto thecontroller. Thesystemsareshownasblackboxeswhereyoucanchecktheinputandtheoutput, that’scalledtransferfunction.WorkingintheLaplacedomainyoucanmakea mathematicalmodelofanyprocess.
18 ‐PIDcontroller ThePIDcontrolleristhemostextendedoneintheindustrialsector.Thecontroller transferfunctionisshownbelow: sk s k ksR d i p⋅++=)( Accordingtothisparametres,wecanmakethatoursystemgetadesiredbehavior. Theproportionalpartusetomakearoundthe80%ofthetask,theintegralpartmake aroundthe15%ofthetaskandthederivativeparttherest. Theproportionalpartusetofixtheerrorbetweenthedesiredvalueandthemeasured value(feedback)whiletheintegralparttakescareofthedesiredresponsetime.Tofix thisvalueswealwayshavetotakecareaboutthestabilityofthesystem.Ifweneedto makethesystemstableweshouldincreasethederivativepart. Now,weshowsomeimagesoftheresponsesthatwecangetfromaregulator accordingtotheparametersdescribedbefore:
19 Desired response Low integral gain Ver y hi g h PID g ains Very low PID gains Very high derivative gain Very high integral gain and very low
20 Aswecanseeintheimages,thekindofsignalthatwecangetischangingwiththe gains,soisimportanttochooseasuitablePIDgains. Therearemanywaystoimplementthiskindofcontrollers; Wecanclasifythemaccordingtothekindofelectronicsused:analogicanddigital controllers. Inthenextsub‐chapters,wearegoingtoseewhattheyconsiston,inordertodecide whichisthemoresuitableforthisproject. Now,weexplaintheanalogiccontroller. ‐PIDanalogiccircuit ThePIDtransferfunctionandthedifferencebetweenthetwooutputscanbe representedwiththefollowingelectroniccircuit: Thetwoinputs(u1andu2)arevoltageproportionaltothespeed,accordingtothe usedsensorgain.
21 Thefirstoperationalamplifierworksasasubstractor,whichrepresentthesubstractor drawninthetransferfunction. 1 3 1 1 13 42 4 21 R R U R RR RR R UV ⋅− + ⋅ + ⋅= Thisvoltageisconnectedtothreeoperationalamplifierswhichworkasaninverter, integratorandderivator,respectively: 1 5 6 2V R R V⋅−= ∫⋅⋅ ⋅ −= tdttV CR V 0 1 17 3)( 1 dt tdV CRV )( 1 284 ⋅⋅−= Thelastoperationalamplifierworksasanadder. )( 11 4 10 3 9 2 12 R V R V R V RVo++⋅−= So: dt tdV R CR dttV CRR tV R R RV t o )( )( 1 )(( 1 10 28 0 1 1710 1 7 6 12 ⋅ ⋅ +⋅ ⋅⋅ +⋅= ∫ )() 1 ( 1 3 1 1 13 42 4 2 11 82 107195 6 12 R R V R RR RR R V R RC RRCRR R RVo⋅− + ⋅ + ⋅⋅ ⋅ + ⋅⋅ + ⋅ ⋅= Aswecansee,thecircuitrepresentthebehaviourofaPID,whereitsconstantscanbe adjustedwithcapacitorsandresistances. 95 6 RR R Kp⋅ = 1071 1 RRC Ki⋅⋅ =
22 11 82 R RC Kd ⋅ = Theanalogicoutputhaveavoltagesignal,soinordertoproduceaPWMweneedto converttheoutput,usingadivicelikeLM331orAD650. Finally,withthiskindcontrollerwecan’tusethehallsensorsignalinasimpleway, lookingasensorlessdriveraeasierway,butwearen’tgoingtogetsuchasmooth performanceaswecangetusingthehallsensor.Alsoanotheranalogicsensorwe’llbe needed. Ontheotherhand,wehavethedigitalcontroller,whichofferusasimplercircuit,with thedisadvantageofacomplexprogramming.Ithasenoughinputtohandlethesignals fromthethreehallsensorandthethrottle,andcanmeasurethespeedwithoutany additionalsensor,sothebudgetisalsosomethingthatbetfortheanalogicway. 7.1.3Digital Digitalcontrolisaverydifferentapproachfromtheanalogueway,becauseitallows youtoactivelymanagethesystem.Also,itobtainsmoreflexibility,moreopportunity tomanagethesystemandmoresafetyincaseofsomefaultofthesystem,like overcurrentorovervoltage. Thepurposesofthedigitalcontrollerare: ‐Closed‐loopspeedcontrolforprecisespeedregulation ‐Readsetspeed(Speedcruisecontrol) ‐Implementthecruisecontrol ‐Readthepositionofrotorwiththehallsensorandmeasurethespeed ‐Logicprotectionforover‐voltage,over‐currentandthermalprotection Torealizethisdigitalcontrollerweneedamicrocontrollerwithadriver,thatit’s performedtocontrolabrushlessDCmotor(BLDC).
23 ThefollowingfigurerepresentsthediagramblockoftheDigitalsystem: Thediagramblockiscomposedbyamicroprocessor,the3‐phaseMosfetBridge (driver),signalconditioningforthehallsensorandthethrottle. ThedesigninvolvesrunningtheBLDCmotorinaclosedloop,withthespeedsetbythe throttle,thatit’srealizedwithapotentiometerthatgiveanoutputof0‐5V.Thissignal isreadbytheAnalog‐DigitalConverter(ADC)ofthemicrothatconvertstheinput voltageinadigitalvaluethatrepresentsthesetspeed. Thisvalueisreadbythelogicunitthatconvertsthisvalueinaproportionalsignalthat issenttothePWMmodule. ThePWM(pulsewidthmodulation)isatypeofdigitalmodulation,whichallowsfora mediumvoltagevariabledependentontherelationshipbetweenthedurationofthe positiveand0V.Thedurationofeachpulsecanbeexpressedinrelationtotheperiod
30 programming,thecodeisstoredinthemicroandwhenthesupplyvoltageisfurnished tothemicro,thefirmwarestartstorun. Themicroworksatthefrequencyof20Mhz,thatisprovidedbyacrystal. Thethrottleisavariableresistancethatfurnishesavoltagesignalproportionaltothe setresistance. Theinterfaceofthethrottleiscomposedbyaconnectorthatfurnishes5v,middle signalandgnd.Themiddlesignalisaninputtothemicrocontrollerthatisinsertedin oneofthepinsthatimplementstheADCconverter. Thereadvoltage(0‐5V)bytheADCisconvertedinadigitalvaluethatisproportional tothespeedfortheCruiseControl. Thisvalueisimportantbecauseitsetstherelativeaveragecurrentthatflowinthe motor.So,thisisrealizedwiththePWMsignalofthemicrocontroller. Thismicrohas3PWMmodules,whereeverymoduleiscomposeby2PWMsignal(one directandoneincomplementarymode).Intotal,themicrohas6PWMsignal. Themicrousesthissignaltocontrolthedriverofthepowerelectronicsandfinallythe motor. Then,themicrohastoturnonoroffthecorrectPWMsignalaccordingtotherelative sequenceofthehallsensor.ThisPWMsignalisasignalwithavariableaverage voltage,dependentontherelationshipbetweenthedurationofthehighlogiclevel (5V)andlowlogiclevel(0V).Theswitchingfrequencyissetto20KHz. ThedutycycleofthePWMisdirectlyproportionaltothethrottlepotentiometerinput. Thechangesinthedutycyclecontrolthecurrentthroughthemotorwinding,thereby controllingmotortorque. ThisPWMsignalisactivatedinasequencethatisgivenbytheHallsensorssignal, whichindicatethepositionoftherotor.Aninterruptisgeneratedwhentheinputstate onanypinchanges.Thissignalispluggedintheboardintoaconnectorthatprovides3 hallsensorssignal(Ha,HbandHc),5voltsandground.Also,thehallsensorsignal needsaninterfaceofpull‐upresistortowork. So,whenthemotorisrunning,thestateofthethreeHallsensorschangesaccordingto therotorposition.Thesupplyofeachmotorphaseisswitchedbasedonthestateof thesensors(commutation).Also,Hallsensorsinterruptsarecountedtomeasurethe
31 motorspeedthatiscalculatedeverysecondwithaninternaltimerofthemicro.This valuerepresentstheRPS(RevolutionPerSecond),thatit’sobtainedwiththisformula: Ifit’smultiplyby60,it’sobtainedinRPM(RoundperMinute). Similarly,thespeedreferenceinputistranslatedintoaspeedvalueinordertohave bothreferenceandfeedbackinthesameplatform.Nextequationshowsconverting speedreferencefromapotentiometersettingreadthroughanADchannel. Inthenextsection,thecalculationerrorisdescribedinordertocontrolthespeed. Also,thisboardmanagesthesystemincaseofoverload,under‐voltage,andovertemperaturewithsomesignaltakenfromthedriver. Firmwareimplementation Generally,thefirmwareisaprogramthatinternallycontrolsvariouselectronicdevices. Inthiscase,thefirmwareisinsidethemicroandcontrolsalltheperipheralsofthe microandofthesystem.Then,it’sthemainpartofthecontroller,becauseitdescribes howthesystemisworking. Insidethefirmware,theclosed‐loopspeedcontrolisimplemented,reducingtheerror betweenthespeedsetbythepotentiometerandtheactualmotorspeed.Theoutput oftheloopchangesthedutycycleofthePWMmodule,therebychangingtheaverage voltagetothemotor. Thefirmwareiscomposedbythreeparts: ‐ Mainloop ‐ InterruptHandlerofHallsensor ‐ Speederrorcalculation(Cruisecontrol)
32 FlowchartofMainloop Themainloopflowchartdescribesthemainfunctionofthefirmware,thatexecute everycycleofthecode.Theinitialpartisfortheinitializationofthemicro.Oneofthe mostimportantinitializationsregardstheroutineoftheinterruptthatdetectsthe changeofthestateofthehallsensorsignal.Thenextstepintheloopischeckingthe stateofthepinRC2,thatit’slinkedtothejumperoraswitch.Whenthejumperorthe switchisclosed,themotorstarttorunatthesetspeedthatisreadfromtheADC.
33 FlowchartofInterruptHandlerofHallsensor ThisflowchartexplainshowtheInterruptoftheHallsensorworks.Theinterrupthasa specialfunctionthatit’sexecuting(inthiscase),whenonesignalofthethreeHall sensorchangesitsstate.Thisfunctionisveryimportantbecause,it’spossibleto energizethecorrectwinding,accordingtotheactualstateoftheHallsensor(position oftherotor).Also,thisroutinesetstheactualspeedthatisreadbytheADC.
34 FlowchartofSpeederrorcalculation TheSpeederrorcalculationisthefunctionthatimplementstheCruiseControl.This functioncalculatestheerrorfromthesetspeedofthethrottleandtheactualspeed. Theerrormaybepositiveornegative,indicatingifthespeedismoreorlessthanthe setspeed.ThiserrorispassedthroughaPIDalgorithmtoamplifytheerror.The amplifiederrorisusedtoreadjustthePWMdutycyclesoriginallycalculated. Then,nowit’spossibletodescribethesystemwithablockdiagramofacontrolloop withaPIDalgorithm.
35 BlockdiagramofacontrolloopwithaPIDalgorithm Realizationandtest TheLogicalcircuitisrealizedinaprototypeboard,thatit’ssuppliedbythepower supplypartwith5V.Themicrocontrollerisprogrammedwiththefirmware,described intheflowchartofthemainloopandoftheInterruptHandlerofHallsensor,butnot aboutFlowchartofSpeederrorcalculation.Itmeansthat,themicrocontroller executesthepartofinitializationandacquiresthechangeofthestateoftheHall sensor,withtheactivationoftherelativePWM.
36 TheSpeederrorcalculationisnotimplementedbecausewedidn´thaveenoughtime tomakethispart.So,thatmeansthattheCruiseControlisnotimplemented.But,we willexplainhowtoimplementthispart. Beforeactivatingtheboard,werealizedthetestofisolationandcontinuitytoensure thatthereisn’tanyshortcircuitoranywrongconnection. Inthenextphoto,it’spossibletoseehowtheHallsensorisworking.Theledindicates theactualsequenceofthehallsensor,wherethefirstledinthetopisHallsensorA, thesecondinthemiddleisB,thethirdisHallsensorisCandthelastindicatesthe5V intheboard.Inthiscase,thereisthesequence101.
37 7.2POWERELECTRONICS 7.2.1Powersupply Thisistheelectricalcircuitofthepowersource.Thiscircuitisveryimportantbecause withoutthis,alltheelectronicpartwouldnotworkcorrectly.Themaingoalofthis circuitistosupplythecorrectvoltagetotherestoftheelectronicboard. Asweknow,ourboardisdividedin3differentiatedparts(thepowersupply,the logicalpart,andthedriverforthemotor). Allthese3partsworkatdifferentvoltagesandwedon´thaveinthecircuit,3different variablepowersourcestosupplyeachofthecircuits.Thisisthereasonforwhatwe needthispowersupplycircuit. Weonlydisposeonebattery.Thisonewillworkasourpowersupplyanditwillgiveus 36Volts.Withthisreferencevoltageweshouldgetanother2differentvoltages. Thelogicalpartwherethemicrocontrollerisconnectedisgoingtoworkwith5volts. Wehavetobeverycarefulwiththesevaluesbecauseahighvoltagecanburnand destroyalltheelectronicpart.Thedriversectionwillneedavoltageof15volts Togetthesevoltageswearegoingtouse2regulators.Theregulatorhas3pins,Input, Groundandoutput.Withtheseregulators,whichevervoltageentersfromtheinput, theregulatorprocessesitandtakesoutthroughtheoutput,thedesirevoltage.Inour case,howwementionedbefore,weneed15Vand5V. TheLEDdiodesareonthecircuitjusttoindicateusthatthereiscurrentandvoltage flowingthroughthecircuit.
38 Thiscircuitalsoneedssomeelectrolyticcapacitors.Theirmissionistostabilizethe voltagethatgoestotheregulator.Weneedtomaintainthevoltagethatentersinto theregulatortoafixvaluesandsometimesthesource(battery,commonelectric network)hasvoltagepeaksthatcanburntheregulatorandthecapacitorsmaintain thelevelofthevoltageinastabilizedvalue. Realization: Toimplementthispartofthecircuitwehavetobeveryattentivetoallthe componentsthatweuseandthevaluesandthedirectionsthatweintroducethemin theboard Abouttheregulators,wehadsomeproblemsfixinganddecidingthem.Concretelythe onewhichsuppliesthe15voltageattheoutputhasaproblembecausethe36volts thatcomestraightfromthebatterywillarrivedirectlytotheregulator. Lookingatthedatasheetofthefirstregulatorthatwaschosen(7815)werealizedthat thisonewasnotgoingtobecorrectbecausethemaximumallowancevoltageofthis regulatoris35Vandjustthebatterygivesminimum36Vanditcangivemorewhenis fullycharged. Tosolvethiswehavetolookforanotherregulatorthatbearshighvoltage.Wefound theregulatorLM317HVthathasthecapacityofhandlinghighvoltage(60volts). Anotherfactortotakeintoaccountisthepolarityoftheelectrolyticcapacitor.Itis veryimportanttoputthecapacitorinarightwaybecauseaproblemwiththis,can automaticallyburnthecomponents.
39 Inthisimagewecanseethevoltagethatthebatterygivesus.Howwesaidbeforeitis notexactly36Volts.Normallythisshouldnotbeaproblem,butwehaditbecauseour regulatoracceptedmaximum36Volts.Becauseofthisreasonwehadtochangeitand putanotheronethatcouldbearmorevoltage. Inthispicturewearetestingtheoutputofthefirstregulatorwhenweputthevoltage ofthebatteryintothepowercircuit(40volts).Wecanseethatispractically15V.How wementioned,thisvoltagewillgostraighttothedriver.
46 correctlythewindingsofthemotoraccordingtothesequencewithourownelectronic board. Alsowehavetotakeintoaccountthegoalsthatwecouldn’tachieve:testthedriver, installthedriverheatsink,programagenerativebreakinordertomakethemotor workasageneratorwhileit’sbreakingandchargeourbatteryandbuildourcircuitina PCBboardaftertestingtheproto‐board.Finally,inordertoavoidnoisefromthe powerpartinthelogicalpart,weshouldhaveseparatedopticallythetwoparts(we showtheschematicintheannex). Althoughwegetalongverywellwiththegroup,wecanmakeacriticalviewaboutour workingmethod,thewaywefocusedtheprojectwasn’ttheoptimalone.Inour opinionweshouldhavemadeabetterplanningandtasksdistributionsoeverybody wouldworknotonlythesame,butfasterandeasier.Ifwerecognizeourselvesthat despitethefinalworkisdonewemadethesemistakes,nexttimewemayworkso muchbetter.
47 9.BIBLIOGRAPHY AN857_BrushlessDCMotorControlMadeEasy AN898_DeterminingMOSFETDriverNeedsforMotorDriveApplications AN899_BrushlessDCMotorControlUsingPIC18FXX31MCUs AN885_BrushlessDC(BLDC)MotorFundamentals DCMotorControlTips‘nTricks ElectricBikeBLDCHubMotorControlUsingtheZ8FMC1600MCU AVR448:ControlofHighVoltage3‐PhaseBLDCMotor ElectronicCircuitsDesingForBeginners–Chapter5 IRAM136‐3023B_IntegratedPowerHybridICforLowVoltageMotorApplications PIC18F2331/2431/4331/4431_MicrocontrollerswithnanoWattTechnology,High‐ PerformancePWMandA/D BOOKS: FirstcourseonPowerelectronics_NedMohan,year2003Edition PrinciplesofElectricsMachinesandPowerElectronics_P.C.Sen,SecondEdition ElectricalMachines,Drives,andPowerSystems_TheodoreWildi,FifthEdition WEBSITES: http://www.goldenmotor.com/hubmotors/HBS‐36V500W%20Performance.pdf http://bicicletaselectricas.wordpress.com/electronica‐de‐una‐bicicleta‐electrica/ http://ww1.microchip.com/downloads/en/AppNotes/00857a.pdf http://www.brushlessmotor.com.ar/Caracteristicas.html
48 ANNEXA–MOTORDATASHEET
49
50 ANNEXB–FIRMWARE #include<18F2431.h>//headerfileforthisPIC #deviceADC=10//initializeforADC #fuses HS,NOFCMEN,NOIESO,PUT,BROWNOUT,BORV45,NOWDT,NOPWMPIN,LPOL_LOW,HPO L_LOW,NOLVP,NOPROTECT #usedelay(clock=20000000)//setclockofthemicro #usefast_io(A)//initializeINPUT‐OUTPUT #usefast_io(B) #usefast_io(C) #byteOVDCOND=0x0F6B//initializeregisterofthemicro #byteOVDCONS=0x0F6A #byteFLTCONFIG=0x0F6C #bytePWMCON1=0x0F6E #bytePDC0L=0x0F79 #bytePDC1L=0x0F78 #bytePDC2L=0x0F77 #bytePDC0H=0x0F76 #bytePDC1H=0x0F75 #bytePDC2H=0x0F74 #bytePORTA=0x0F82 #bytePORTB=0x0F81
51 #bytePORTC=0x0F80 #byteSSPBUF=0x0FC9 #byteSSPSTAT=0x0FC7 #byteSSPCON=0x0FC6 //encoder: #byteCAP1CON=0x0F63 #byteCAP2CON=0x0F62 #byteCAP3CON=0x0F61 #byteDFLTCON=0x0F60 #byteMAXCNTL=0x0F64 #byteMAXCNTH=0x0F65 #bytePOSCNTL=0x0F66 #bytePOSCNTH=0x0F67 //#byteQEICON=0x0FB6 #byteVELRH=0x0F69 #byteVELRL=0x0F68 #include<stdio.h> #defineFW_VERSION13 charbuildVers[10]={__DATE__}; //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //DEFINESPERI/O: //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
52 //#defineDEBUG1 #defineLED_MOTOR_ONoutput_low(PIN_B7) #defineLED_MOTOR_OFFoutput_high(PIN_B7) #defineLED_DIR_ONoutput_low(PIN_B6) #defineLED_DIR_OFFoutput_high(PIN_B6) #defineLED_CYCLE_ONoutput_low(PIN_C0) #defineLED_CYCLE_OFFoutput_high(PIN_C0) #defineOFF0x00//motorOFF #defineON0x01//motorON #defineBACKWARD0x00//directionbackward #defineFORWARD0x01//directionforward #defineMAX_SPEED80 #defineDEFAULT_SPEED72 #defineMID_SPEED8 #defineMIN_SPEED1 //Dutycyclelimitdefinition,for20KHz@20MHz,2uSdeadtime //minimumdutycyclecorrespondsto3xdeadtime=3x2uS=6uSPDC= 6uS/(4/Fosc) #defineMIN_DUTY_CYCLE0x003C//trydoublingfrom0x1E;
53 #defineMAX_DUTY_CYCLE0x03E0//maximumdutycycleis4xPTPER #defineGO_MIN0x44 #defineTYPE_COMMAND0x4C enumSTATUS_ENUM { STATUS_OFF=0, STATUS_RUN_FW, STATUS_RUN_BK, STATUS_BRAKE, STATUS_BRAKE_IN_POSITION, STATUS_GOTO_IN_POSITION }; //variabiliglobali unsignedint8_direction=0;//flagdirection unsignedint8_status=STATUS_OFF; unsignedint8_phaseOffset1;//Phase1offsettotheSinetable(0) unsignedint8_phaseOffset2;//Phase2offsettotheSinetable(120) unsignedint8_phaseOffset3;//Phase3offsettotheSinetable(240) voidinit_PCPWM(void) { unsignedcharportbStatus;
54 //setup_power_pwm(modes,postscale,time_base,period,compare, compare_postscale,dead_time); //clockxPWMdiviso4,freerun,clockperdeadtimeclockdiviso2,postscale1:1,time base=0,periodo=F9. //compareecomparepostscale=0,deadtime=18(1secsecondoilsourceassembly) setup_power_pwm(PWM_CLOCK_DIV_4|PWM_FREE_RUN |PWM_DEAD_CLOCK_DIV_2,1,0,0xF9,0,0,20); set_power_pwm0_duty(0); set_power_pwm2_duty(0); set_power_pwm4_duty(0); set_power_pwm6_duty(0); if(_status==STATUS_BRAKE) { setup_power_pwm_pins(PWM_ODD_ON,PWM_OFF,PWM_OFF,PWM_OFF); portbStatus=PORTB&0xC0; PORTB=portbStatus|0x1B; } else { portbStatus=PORTB&0xC0; PORTB=portbStatus|0x3F; setup_power_pwm_pins(PWM_COMPLEMENTARY, PWM_COMPLEMENTARY,
55 PWM_COMPLEMENTARY, PWM_OFF); } OVDCOND=0xFF; PWMCON1=1; OVDCONS=0;//OVDCONSisconfiguredsuchthatallPWMoutputsare0upon power‐up. //bsfTRISC,1;EnsurethatRC1isaninput FLTCONFIG=0; } voidinitMotorStart(void) { _phaseOffset1=0; if(_direction==BACKWARD) { _phaseOffset2=12; _phaseOffset3=24; } elseif(_direction==FORWARD) {
62 { if(!CheckInput(PIN_A3)) { LED_DIR_ON; }else{ LED_DIR_OFF; } } #INT_IC3DR voidHall_C()//inputcaptureIC3 { //LED_CYCLE_ON; if(!CheckInput(PIN_A4)) { LED_CYCLE_ON; }else{ LED_CYCLE_OFF; } } voidmain(void) { unsignedint8i;
63 //Inizializzazioni set_tris_a(0xFD);//allinputexceptRA1 set_tris_b(0x00);//alloutput set_tris_c(0x7E); output_a(0xFD); output_b(0xFF); output_c(0xFF); setup_wdt(WDT_OFF); setup_timer_0(RTCC_DIV_1|RTCC_INTERNAL); setup_timer_1(T1_DIV_BY_1|T1_INTERNAL); setup_adc_ports(sAN0); set_adc_channel(0);//initializeADC //initializeADC setup_adc(ADC_CLOCK_DIV_8); //Setencoder DFLTCON=0x7E; MAXCNTH=0x00; MAXCNTL=0xFF; CAP1CON|=0b01001000; CAP2CON|=0b01001000; CAP3CON|=0b01001000;
64 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ //inizializzazioneperpilotaggiodiodiIRED: //Timer=4*Tx_DIV_x)/clock //Timer=(4*8)/20000000=0.0000016 //‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ setup_timer_5(T5_INTERNAL|T5_DIV_BY_1); enable_interrupts(INT_TIMER5); enable_interrupts(INT_IC1);//INTERRUPTINPUTCAPTURE enable_interrupts(INT_IC2QEI); enable_interrupts(INT_IC3DR); _speed=DEFAULT_SPEED; _status=STATUS_OFF; enable_interrupts(INT_SSP); enable_interrupts(INT_TIMER1); enable_interrupts(GLOBAL); for(;;) { LED_CYCLE_ON; delay_ms(200);
65 LED_CYCLE_OFF; delay_ms(200); if(!CheckInput(PIN_A4)) { LED_CYCLE_ON; }else{ LED_CYCLE_OFF; } _speed=misura()&0x7F;//numerochevariada0a15 if(CheckInput(PIN_C2)) { _status=STATUS_RUN_FW; startMotor(_status); LED_MOTOR_ON; } else { stopMotor(); LED_MOTOR_OFF; }
66 ANNEXB‐CIRCUIT
67 ANNEXC‐CIRCUITWITHOPTOCOUPLER