




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
.
.
.
.
.
.
.
.
.
PAGE
2
PAGE
2
DCMotorControl
RogerAarenstrup
roger.aarenstrup@
Contents
Introduction
3
Thedcmotormodel
4
Speedcontrolwithpid
6
Continuouscontrol
6
DiscreteControl
7
Choosingparameters
9
HandCodetesting
10
UsingSimulinkControlDesignProducts
10
RapidPrototyping
10
FixedPoint
11
ProductionCodeGeneration
11
Positioncontrolusingstatefeedbackpoleplacement
12
Attempt1-statefeedbackandstaticgain
12
Attempt2–integralaction
12
Attempt3–Observer
13
Attempt4–Theservocase
13
Considerations
14
Bandwidth
14
Samplerate
16
References
17
Introduction
ThisexampledescribeshowtodevelopspeedandpositioncontrolsystemsforaDCmotorwithaload.Variousmethodsareusedandthefocusisonhowtomodelandimplementthevariouspartsandnotofparametertuning.Animportantthingtonoteisthatagoodcontrollerisnotjustatextbookimplementationbutrequiresanumberofadditionalpartstoworkproperly.Itisagoodideatogothroughthistexttogetherwiththemodelsandsomecontroldesignliteraturethatgivesmoredetailsaboutthetheory.Pleaseseethereferenceschapterforsomesuitablebooks.
Thistextandmodelscomewithabsolutelynoguaranteeifyoufindanythingincorrectpleaseletmeknow:
Roger.aarenstrup@
Thedcmotormodel
Themodelsusedherecanbedownloadedfrommatlabcentralwiththelink;
/matlabcentral/fileexchange/loadFile.do?objectId=11829&objectType=file
ThemodelisaquitesimplelinearDCmotormodelwithaflexibleload.InthelibrarythereareMATLABfilesdescribingastate-spacerepresentationofthemodel.Howtoderivethemisdescribedinmanycontrolsystembooksandalsointhecontrolsystemtoolboxdocumentation:
/access/helpdesk/help/toolbox/control/getstart/buildmo4.html
Themodeldescribedtheredoesn’tincludetheflexibleloadhowtoaddthatisdescribedhereandinthemodelsincluded.
IhavefoundthatalinearmodelisgoodenoughformanycontrolsystemswithDCmotors.Modelingisnotaboutmakingthemostdetailedmodelbuttomakeamodelgoodenoughforthetask.
Thereareafewthingsworthtonotice.Ihavetakenthedcmotorparametersfromthemaxonmotorsproductcatalog.InthefutureIhopethatitispossibletodownloadmodelsdirectlyfromtheirwebpage,justlikeitnowispossibletodownloadCADmodelsoverthemechanics.Inthecatalogthereisnospecificvalueforthemechanicaldamping.Usingthecommonexpressionforthemechanicaltimeconstant,Tm=bm/Jm,wherebmisthemechanicaldampingandJmistherotorinertiadoesn’tgivethecorrectno-load-current.Thismightbeduetonon-linearpartshere.Iusedsimulationstoestimateamechanicaldampingthatgivesaclosematchforthemechanicalrisetimeandno-load-current.Ifyouknowmoreaboutthis,pleaseletmeknow.
ThefigurebelowpresentstheDCmotormodelandload.Theloadisrepresentedbyadoubleintegratorwithinertia.Sinceitiscoupledwiththemotorrotorthroughasomewhatflexiblelinktherewillbeaspringactionifthepositionsoftherotorandtheloaddiffer.Thedifferenceinposition(angle)isthusfeedbackasacountertorquemultipliedbythespringconstant.Thesameistrueforthedamping.Thedifferenceinvelocitiesbetweenthetwobodieswilldampthesystem.Fordetails,pleaseseetherealmodel.
we
Figure,DCmotormodelwithflexibleload.
Speedcontrolwithpid
InthischapterwewillusemodelelaborationtogofromacrudemodeltoadiscreteimplementationofaPIDbasedcontrolsystemforaDCmotorwithload.
Continuouscontrol
Thisfirstattempttocontrolthedcmotorandloadusesacontinuoustime(LaPlacerepresentation)PIDwithapproximatederivative,seefigurebelow.Seemodela_pid_cont.mdlforthecompletemodel.Whentuningtheparametersitisimportanttoconsiderthecontrolsignal(outputfromthecontroller)tomakesureitwon’texceedthelimitsoftheamplifier.Tomeetthisfortheentirestepthecontrollergain(proportional)hastobequitelow,wewillseehowtoimprovethisfurtheron.
Figure,PIDwithapproximatederivative(froma_pid_cont.mdl).
Insomecasesitisnotdesirabletoderivethecommandedinputsignalbecauseitmightbeasteporsimilarthatwillgivebadresultswhenderived.Inthenextmodelb_pid_cont.mdlavariantofthePIDcontrollerisusedwhereonlytheoutputoftheplantisderived.
Figure,PIDwithapproximatederivativeoftheplantoutput.Notethatthederivativepartusesonlyy,theoutputfromtheplant,andnottheerror.(fromb_pid_cont.mdl)
Now,letsaddsomemoredetailstothemodel.Thisismodel-based-design,MBD,wheremoreandmoredetailsareaddeduntilthefinalimplementationisreached.AndduringdevelopmentthemodelcanbeverifiedcontinuouslybySimulationandlatercodegeneration.Let’saddasimplemodelofanamplifier.Theamplifierworksasalow-passfilterandasaturationoftheoutputsignal.Sometimesitisusefultouseanamplifierthatcanoutputavoltagelargerthanthenominalvoltageforthedcmotor,toimprovecontrolduringshortperiodsoftime.Let’salsoaddthetachometermodel.Theresultingmodelisc_pid_cont.mdl.
Itisoftenagoodideanottohaveapurestepasinputbecausethestepcancausespikesandmightexcitemodesinthesystem.Tomakethereferencesignalmoresmoothasimplelow-pasfilterisadded.However,itisusuallyagoodideatocalculateafunction,aspolynomialsforexample,fortheinput.
Themainresultfromasimulationwiththismoredetailedmodelisthattherearenowrippleontheoutputcausedbythetachometer.
DiscreteControl
TobeabletoimplementthecontrolleronamicroprocessorwefirstneedtoconvertittodiscretetimeinSimulink.Thereareanumberofdifferentwaytodothat,theonechosenhereistakenfrom[1].Seed_pid.mdlforamodelexample.Heresampletimecolorsareturnedonshowingthatthecontrollerpartisdiscretewithasampletimeof100us.Moreaboutchoosingsampletimeslater.Thesampletimeissetinamodelcallback,calledwhenthemodelisloaded.
Inthediscreteversionthederivativepartdependsonlyontheplantoutput,justlikethesecondcontinuousversion.Itisalsoadvantageous,inmanycases,tolettheproportionalgainonlytodependonapartofthecommandedsignal.Thisfactorisalsointroducedinthediscretecontrollerandiscalledb.
Figure,DiscretePIDcontroller.(Fromd_pid_disc.mdl)
Let’scontinuewithanti-windupfortheintegrator.Thereareseveralwaystoaddanti-windupforanintegrator.Theeasiestwayistojustlimittheinternalstateoftheintegratortoareasonablevalue,thiscanbedonedirectlyintheDiscrete-TimeIntegratorBlock.Itisalsopossibletojuststopupdatingtheintegratorstatewhentheactuatorissaturated.Sincewindupgenerallyisaproblembecausethereisanactuator(amplifier)thathasabounded(non-linear)output,anotherwayistotakethedifferencebetweentheinputtotheactuatorandsubtractthatfromtheoutputoftheactuatorandfeedthatsignalbacktotheintegratorpathinthecontroller.Thismeansthatiftheactuatorissaturatedthefeedbackwilldecreasetheintegralaction.Anadvantagewiththismethodisthatitcanbeappliedtoanykindofactuators,notjustactuatorswithlimitedoutput.
Thelastcaseaboveisimplementedinthenextmodel.Theimplementationismainlytodemonstratehowtoimplementanti-windup,sincethereisnotanyrealwindupprobleminthismodel.Youcanexperimentwiththeinputtoseeifyougetwindup.
Thenewcontroller,inthefigurebelowandmodelfilee_pid_cont.mdl,usesamodeloftheactuator,asaturationblock,togetthesaturatedvalue.Anotherwaywouldbetomeasuretheactualvaluebutthatwouldaddcosts.
Figure,DiscretePIDwithanti-windup.(Seee_pid_disc.mdl)
Themodelwiththiscontroller,e_pid.mdl,alsosamplesthereferencesignalfromanexternalsourceandisolatesthesampledpartsthatwilllaterbeimplementedonamicrocontroller.
Choosingparameters
ThereareanumberofparametersthathavetobechosenforthediscretePIDcontroller;K,Ti,Td,Tt,b,N,Umin,UmaxandTs.ParametertuningandselectionisnotthepurposeofthistutorialbutIincludesomeguidelines.
Forthecontrollerparameters,K,Ti,TdandTi,thereareseveralmethodstochoosefrom,see[1].
Tt,theintegratoranti-windupfeedback,isrelatedtoTiandcansometimesbeequaltoitbuttypicallyitis0.1-0.5Ti[1].
Parameterb,howmuchofthereferencesignaltobeusedfortheproportionalgain,shouldbeintheinterval0.1to1.
Nistypically3-20butcanbeashighas100.
UminandUmax,thesaturationpointsfortheactuatormodelinthecontroller,shouldbeasclosetotherealactuatoraspossible.
Ts,thesampletime,isrelatedtomanythings.ForPIDcontrollersithastobelowerthanforPIforexample.Itisalsorelatedtodisturbances.IntheexamplesaboveIuse100uswhichisprobablyfasterthannecessary.
HandCodetesting
Nowifyou’renotusinganyadvancedtoolsforcodegenerationandyouareusingafloatingpointprocessor,youcanwriteanequivalentdiscretecontrollerinc-codeandincludeit,withans-functionblock,inthesimulationtoverifytheimplementation.Inthemodeldirectorythereisac-filewiththediscretecontrollerimplemented,withoutanti-windup.Youcancompilefrommatlabwith:
mexsfun_wrp_pid.chandcode_pid.c
Thefilesfun_wrp_pid.cisans-functionwrapperforthecontrollerhandlingtheinterfacebetweenSimulinkandthecontrollercode.
Nowyoucanexperimentandverifyyourfinalimplementationsoyouaresureitworksbeforemessingwiththerealhardware,usemodelf_pid_disc.mdl.Ifyouhaveafixed-pointprocessoryoushouldfirstmodelthecontrollerusingSimulinkFixedPointthenyoucandothesamethingwithit,seelatersectionaboutfixed-point.
UsingSimulinkControlDesignProducts
ThereareseveraltoolsfromtheMathWorksthatcanbeusedforcontroldesign.ThemostwidelyusedisControlSystemToolboxthatincludesmanyusefultools.ForSimulinktherearethreeproductsinparticularthatarethemostuseful;SimulinkControlDesign,SimulinkParameterEstimationandSimulinkResponseoptimization.WiththeresponseoptimizationtoolforexampleyoucanspecifyadesiredtimedomainresponseandletSimulinkoptimizethecontrollerparameterstofitthedesiredresponse.
RapidPrototyping
Modelsdon’talwaysdescribetherealsystemperfectly.Beforeputtingeffortinthefinalimplementationitisgenerallyagoodideatotestitwiththerealplant.ThisisdonebyrapidprototypingwherecodeisautomaticallygeneratedfromSimulinkwithReal-TimeWorkshopanddownloadedtoatargetsystemlikethexPCtargetbox.Thenyoucantrytheimplementationofthecontrollerandtuneparametersagainsttherealplant.
Figure,examplemodelthatcanbecompiledforthexPCtargetforrapid-prototyping,g_pid_disc.mdl.
IfyouontheotherhandhavethecontrollerimplementedonthetargetprocessorandwanttotestityoucancompiletheplantinsteadofthecontrollerandruntheplantonthexPCtargetagainstyourprocessor.Inthiswayyoucanverifyyourimplementationbeforeyouhavetheplantandwithoutdamagingit.ThisiscalledHardware-In-The-Loop.
FixedPoint
Ifyouareusingafixed-pointprocessoritisnowtimetoconvertthefloatingpointmodeltofixedpointusingSimulinkFixed-Point.Itisoutofthescopeheretoshowthat.
ProductionCodeGeneration
Thenextstepwouldbetoproducecodethatissuitableforproduction.Itcanofcoursebehandcoded,liketheoneweusedbeforeinans-functionbutthereareanumberofbigadvantagesusingproductioncodegenerationwithReal-TimeWorkshopEmbeddedCoder.Itisnotjustatimesavingthing;youalsoavoidhandcodingerrorthatisusuallyrandomtothenature.Ifyouhavetochangeyourcontrollerlateritisaloteasiertojustregeneratethecodethanstartingaprojecttore-writesomeoldhandcode.Itisalsoalothardertomakesurethatthefinalimplementationactuallymatchesthesimulatedversion.ISimulinkyoudobit-accuratesimulations.
InthenextsectionthereisexamplecodeproducedbyReal-TimeWorkshopEmbeddedCoderintheController_ert_rtwfolder.
Positioncontrolusingstatefeedbackpoleplacement
Nowwearegoingtomakeapositioncontrollerinsteadofspeedcontroller.Inthisversionwewilluseadifferentamplifierthatcontrolsthecurrentfedtothedcmotorinsteadofthevoltage.Thecurrentismeasuredintheamplifierandwithasimplefeedbackthecurrentiscontrolled.ThisprovidesagreatadvantagesincethetorqueofthedcmotorisdirectlyproportionaltothecurrentthroughthetorqueconstantKt.Theresultisthatwecanneglecttheelectricalpartofthedcmotorandthushaveonestatelessinourcontroldesign,savingcomputationaltimeanddevelopmenteffort.
Inthefiless_dc_motor_load.mthereisareducedstatespacemodelforthisnewapplication.Thefilealsoincludesthecontroldesigncodeforthemodelsinthispart.
TheideaistofeedallstatesbackwithavectorgainL,bydoingsoitispossibletouseamethodtoplacetheclosedlooppolesondesiredlocations.Poleplacementisveryefficientingettingdesiredperformancebutmightnotgiveoptimalsolutionsforpowerconsumptionforexample.Itisalsonotsuitableforhigherordersystems.Higherordercanbe5-7andup.InthesecasesanLQGapproachmightbeabetterchoice.ButfortheDCmotorwithloadinthiscaseapoleplacementapproachworksfine.
Attempt1-statefeedbackandstaticgain
Thefirstapproachcanbeseenina_ss_controller.mdl,andinthefiless_dc_motor_load.mitiscalledattempt1.Herethefourclosedlooppolesareplacedonthepositiverealaxis(discretesystemsarestablewhenpolesareinsidetheunitcircle)on0.9875,0.9863,0.9850and0.9838.Forthepoleplacementalgorithmtoworkwellthepolescan’tbetooclosetoeachother.Whensimulatingonlythispart,withouttheKstatconstant,givesareasonableresult.Howeverthestaticgainisquitehigh,ca478.4.Usuallyitisdesirabletohaveastaticgainof1.ByjustaddingtheKstat=1/478.4thisiscorrected.TheKstatcanbeobtainedbysimulationorbycalculatingtheclosedloopstaticgain,asinthess_dc_motor_load.mfile.
Thisgivesaquitereasonableresultandthedesignisveryeasy,comparedtoPIDtuning.However,thestaticgainwillbesensitivetomodelerrorsandalsothereisnothingthatcompensatesfordisturbancesinthisfirstapproach.
Attempt2–integralaction
Asalwaystogetastaticgaintobe1andtoreducesensitivitytodisturbancesweintroduceintegralaction.Thisintegralpartshouldhaveananti-windupmechanismsimilartothePIDversionbutthatisnothandledhere,takeitasanexercisetoaddit.Byintroducinganintegratorweintroduceonemorestateinourmodel,seeattempt2inss_dc_motor_load.m.Theintegratorshouldbeconnectedtotheerroroftheoutputweneedtocontrol,inthiscasethepositionoftheload.Itis,however,morecommonthatanencoderisattachedtotherotoroftheDCmotorthantotheload.Alsosincethestaticpositionoftheloadandtherotorisequal,itispossibletousetherotorencoderinsteadofthepositionoftheloadfortheintegralaction.
Nowwehaveonemorepoletoplacebecauseoftheintegrator.Whereshouldweputit?Itistemptingtomakeitfaster(closerto0)thantheotherpolesnottointerferewiththeresponsetimeofthesystem.However,bydoingsowillincreasethesensitivitytodisturbancessignificantly.Abetterchoiceistoputitslightlyslowerthantherest.Thiswillmakethesystemresponsesomewhatsloweralsobutlesssensitivetodisturbances.Thisisacceptableforthecontrolcasebutnotfortheservocase.Intheservocasewewillnottrackthereferencesignalfastenough.Sowhatshouldwedo?IfwekeepthefeedforwardgainKffwewillintroduceazerointheclosedloopsystem.Byselectingthatzerocarefullywecanuseittocanceltheslowerpoleintroducedbytheintegrator.BydoingthesymbolicmathitturnsoutthatcancellationhappenswhenKff=Lint/(pint–1).WhereLintisthefeebackfortheintegratorandpintisthepoleplacedfortheintegrator.Seess_dc_motor_load.mfileforhowthisisdone.
IwouldalsoliketoremindyouthattheSimulinkControlDesigntoolthatcreatesalinearmodelisaveryefficienttooltoexamineanyverifydesigns.Justselectinputsandoutputsandcreatethelinearmodel.Thenyoucanwatchpolesandzeroes,stepresponse,bodeplotsetc,withtheLTIViewer.
Attempt3–Observer
Inattempt2wegotaquiteniceresult,wehavecontroloverthemovementandwearenotverysensitivetodisturbancesandmodelingerrors.However,tocontrolweuseinformationaboutallfourstatesplustheoutputwearetryingtocontrol.Thisinformationiseasytoobtaininthemodelforsimulationbutinarealsystemthatwouldrequiteustomeasureallthestateswhichgenerallyisnotpossibleorsuitable.Thesolutionistouseanobserver.Theobservertakestheinputtotheamplifierandtheoutputfromtheencoderandcalculatesanestimationofthestates.Thosestatescanthenbeusedbyourcontroller.Modelc_ss_controller.mdlshowshowthiscanbeimplemented.
Itturnsoutthatobtaininganobserverfromthestate-spacemodeloftheplantisverysimilartodesigningthefeedbackgain.Seeattempt3inss_dc_motor_load.m.Aninputisaddedforthemeasuredpositionandthenthesamepoleplacementisappliedandwegettheobserver.Pleaseseereferenceliteraturefordetails.Tomaketheobserverworkwelltogetherwiththecontrolleritspolesshouldbeplacedquitealotcloserto0oreveninthenegativerealaxis.Seec_ss_controller.mdl.
Note1!Thiscaseillustrateshowefficientsimulationtoolsarefordesigningcontrolsystems.Wecandesigntheinitialcontrollerandverifyitbysimulationthenadddetails,modelelaboration,suchastheobserverandsimulateagaintoverify.Withoutsimulationtoolsweneedtoimplementtheentirecontrollerwithobserverwithoutpossibilitytoverifytheimplementationnortheparametersforit.Ifweaddrapidprototypingtotestthealgorithmandtuneparameterswehaveprobablysaved90%developmenttime.
Note2!Thereasonwhyanobserver,withbothinputandoutputfromtherealplant,isusedinsteadofjustamodelovertheplantisthatwiththefeedbackK,wearemorerobusttomodelingerrors.
Attempt4–Theservocase
Thiscaseisjusttoshowanexampleofhowtheservercontrolcanbeimplemented.Irefertoliteratureabouthowtodesignthesecontrollers,forexample[1].Theexamplemodelisnamedd_ss_controller.mdl.
Considerations
Bandwidth
Herewewillmakethreedifferentdefinitionsofbandwidth,see[2]formoredetails.
Definition1:Bandwidthisthefrequencyareainwhichcontroliseffective[ω1ω2].
Usuallywewantthelowerfrequencytobe0,sincewedon’twantanystaticerror,wecanthencallω2=ωBthebandwidth.
Thewordeffectiveisnotclearbuthereweassumethatitmeansthatwegainsomethingbyusingthecontrollerinthisarea.
IfTistheclosedloopsystem,Sisthesensitivityfunction(S=1-T),risthereferenceinput,yistheoutputandeistheerror,e=y–r,wegetthefollowing:
y=Tr
e=y–r=(T–1)r=-Sr
FromthisweseethatTshouldbeascloseto1aspossible.–Sshouldbeaslowaspossible,sinceittellshowmuchoftheerrorthataffectstheoutput.Thisisveryinterestingbecauseitgivesustwomoreprecisedefinitionsofbandwidth.
Westartwiththeonebasedony=Tr.Ifwesaythatcontroliseffectiveaslongas|T(jω)|>-3dB,thebandwidthwillbethefrequencywhere|T(jω)|crosses–3dBfromabove.|T(jω)|isplottedinthefigurebelow.
Figure,|T(jω)|forthesysteminmodelc_ss_controller.mdl.Itispositioninputtoencoderoutputthatisplotted.
TheSandTfunctionsaredefinedinthess_dc_motor_load.mfileandcanbeexaminedwithltiview(S,T).
Fromthefigurewecanseethatthebandwidth,accordingtothedefinitionabove,issomewherebetween50and60rad/s.Thebandwidthisdirectlyrelatedtothepolesweplaced.Ifyouincreasethefrequencyofthepolesyouwillgetahigherbandwidth.Sowiththisdefinitionwecanspecifyourbandwidthwiththepole
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025至2030年中国四路数字硬盘录像机数据监测研究报告
- 【假期提升】五升六语文暑假作业(九)-人教部编版(含答案含解析)
- 2025年消防设施操作员之消防设备中级技能考前冲刺模拟试卷A卷含答案
- 2025年消防设施操作员之消防设备高级技能每日一练试卷A卷含答案
- 广东省广州市海珠区南武集团2022-2023学年八年级下学期期中物理试题(含答案)
- 烟草公司2023招聘考试全真笔试试题(综合能力测试卷)和答案解析
- 酒店用品销售代理合同(2篇)
- 采购分包配送合同(2篇)
- 广告行业广告创意版权保护协议
- 社区农业服务提供合同书
- 计算机应用基础教程(Windows10+Office2016)PPT全套完整教学课件
- 部编人教版二年级道德与法治下册同步练习(全册)
- 消化内科实习生入科教育
- 第二章-幼儿园课程的基础课件
- 后路腰椎椎间融合翻修术
- 食材配送企业管理制度(完整)
- (带答案)初中物理第八章运动和力重难点归纳
- 梅毒的诊断与治疗资料
- 报价单模板完整版
- GB/T 18658-2018摆锤式冲击试验机间接检验用夏比V型缺口标准试样
- 罚款单的模板
评论
0/150
提交评论