MBSD2 Lecture 14 Real-Time Simulations

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

8/28/20091AdvancedModel-Based-SystemDesignLecture14:Lecture14:Real-TimeVehicleModelModels•WenowhaveagoodmodelofthevehiclethatrunsintheSimulinkenvironment.•WeknowhowtousetheNational2•WeknowhowtousetheNationalInstrumentsSimulationInterfaceToolkittorunSimulinkmodelsinreal-time.•Next,wewillputthetwotogetherandrunourvehiclemodelinreal-timeonthePXIplatformandhaveacooldisplaytoshowvehicleperformance.Copyright2009Rose-HulmanInstituteofTechnology.8/28/20092Foreshadowing•Wewillneedtomakesomemodificationstothemodel.•WewillneedtocreatetheLabVIEWfront3•WewillneedtocreatetheLabVIEWfrontpanelfromscratch.•Wewillrunintosomenumericalsolverissuesthatwillmakethesystembehavebadly.Models•WewillstartwithmodelLecture_14_Model0.mdlthatwillbepassedouttotheclass.•ThisisaSimulinkmodelwithpush-buttonsandslidergainblocksinthedriversubsystem4gainblocksinthedriversubsystem.•Thedriverblockcanbeusedtodrivethevehicle,butitiskindofclunky.•WewillreplacetheSimulinkdrivercontrolswithLabVIEWcontrolstomakethevehicleeasiertodrive.•WewillusetheDisplay_and_Loggingsubsystemtomonitorthemodeloutputsinwhichweareinterested.•SavethemodelasLecture14_Model1andmakethechangestothedriverblockasashowonthenextslide.Copyright2009Rose-HulmanInstituteofTechnology.8/28/20093DriverBlockModifications•Wehavereplacedallofthecontrolsbyconstants.5•Notethatthenamesoftheconstantblockshavebeenchangedtothenameofthesignalinthebus.•ThismakestheconstantseasytoidentifywhenconnectingsignalswiththeLabVIEWSIT.•Notethattheconstantshaveavalueof0.Thissetsthedefaultvalueofthelvcontrolswhenthesimulationsstarts.DriverBlock•Eventhoughwearesettingthedrivercontrolstoaconstantvalueofzero,wewillbeabletodrivethevehiclebecause6willbeabletodrivethevehiclebecausewewillconnecttheconstantblockstoLabVIEWcontrols.•TheLabVIEWcontrolswillspecifythevalueoftheconstantsandthuschangethedriverinputtothevehicle.Copyright2009Rose-HulmanInstituteofTechnology.8/28/20094Display_and_Logging•TheothersubsystemthathastochangeistheDisplay_and_Loggingsubsystem.•Weneedto:7–Removeallscopes.–Deleteall“ToWorkspaceBlocks”–Terminatealloutputsinwhichwehavenointerest.–Addgainblocksandsignalprobestothesignalsthatwewishtomonitor.•ThenextfewslidesshowthemodificationstotheLogging_and_DisplaySubsystem.8Copyright2009Rose-HulmanInstituteofTechnology.8/28/200959Wewillnotdisplaythissignal,sowecanterminateit.Wewanttodisplaythissignalonthefrontpanel.Addagainblockwithagainof1.Namethegainblockthesameasthesignalnametomakeiteasytorecognizerecognize.Thesebluethingsareprobes.ToaddaTestpoint:•Right-clickonasignallineandselectSignalandselectSignalProperties.•Inthedialogboxthatappears,checktheboxnexttoTestpointtoaddatestpoint.LoggingandDisplayBlock•Theonlysignalsfromthecontrollerthatwewillbedisplayaretheforward,reverse,andparkLEDindicators10andparkLEDindicators.•Wewillconnectthesesignalstofrontpanelindicatorssoshowwhenthevehicleisactuallyinpark,forward,orreverse.•TheStatesignalisdisplayedfordebuggingpurposessothatwecantellwhichstateweareinontheStartup_and_ShiftingStateflowchart.Copyright2009Rose-HulmanInstituteofTechnology.8/28/2009611AllsignalsshownarefromtheVehicle_System_Diagnosticsbus.Wearemoniotringthefollowingsignals:•Vehicle_Speed_mpg•Battery_Current_A•Battery_Voltage_V•Battery_SOC•Motor_Current_A•Generator_Current_A•Measured_Engine_rpmSolver•Thelastthingsweneedtodoaresetupthesimulationconfigurationparametersand:12and:–Specifyafixedstepsolvertype.–Pickafixedstepsolver.–Choosethefixedstepsize.–IntheReal-TimeWorkshopsection,specifyNIDLLtlthStttfilNIDLL.tlcastheSystemtargetfile.Copyright2009Rose-HulmanInstituteofTechnology.8/28/20097Lecture14Exercise1•Buildthedllforthemodel.•Createthefrontpanelshownonthenextslide13slide.•UseNationalInstrumentsSITtoconnectthefrontpanelcontrolsandindicatorstotheSimulinkmodel.•Determinethesolverandfixedstepsize,Determinethesolverandfixedstepsize,sothatthemodelrunsinreal-time.•Forreal-timeoperation,thecpuprocessorutilizationshouldbelessthan70%.14Demo___________CPUUtilization_______%Lecture14Exercise1Copyright2009Rose-HulmanInstituteofTechnology.8/28/20098Lecture14Exercise2•Wenoticethatthegeneratorcurrentbouncesallaround,independentofthestepsizeandintegrationmethods15stepsizeandintegrationmethods.•Togetabetterideaofthesystembehavior,addthegraphstothefrontpanelasshownnext:16Demo___________CPUUtilization_______%Lecture14Exercise2Copyright2009Rose-HulmanInstituteofTechnology.8/28/20099ModelProblems•Wenoticeoneobviousprobleminthatthemotorcurrentbouncesallaroundeventhoughweareaskingforaconstantacceleration.17•OccasionallythemodelgoeswildandthevehiclespeedgoestoinfinityandsomeofthedisplaysshowavalueofNaNratherthanarealnumericalvalue.(NaNstandsforNotaNumber.)•BothoftheseproblemscanbesolvedbyusingtheODE14xsolverwithasmalltimestep.ModelProblems•Theproblemwithusingasmalltimestepisthatthemodelmustbeexecutedonceeachtimestep.Itdoesnotmatterwhatourtimestepis,thesamecalculations18occurwhetherweuseatimestepof0.1oratimestepof0.001.•Theproblemwithasmallertimestepisthatallofthemodelcalculationsmustbecompletedbythenexttimestep.•Comple

1 / 15
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功