您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > MBSDLecture 2014-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
本文标题:MBSDLecture 2014-Real-Time Simulations
链接地址:https://www.777doc.com/doc-3327094 .html