1AdvancedModel-Based-SystemDesignLecture6:CreatingaGensetandLecture6:CreatingaGensetandBuildingaFormalControllerBuildingaFormalController•CreateaEngine/Generator“genset”tochargethebattery.2chargethebattery.•Addenginespeedcontrol.•Enginestartingandstopping.•Startwiththepreviousmodel.Copyright2009Rose-HulmanInstituteofTechnology.2CompleteModel•Copytheelectricmotormodelandrenameit“Generator.”•Wewillusethesamemodelforthemotor3•Wewillusethesamemodelforthemotorandgenerator.•Ifwewantdifferentpropertiesforthemotorandgenerator,wecanusethesame“motor”blockbutusedifferentlookuptablestogivethemotordifferentproperties.CompleteModel•Copytheenginemodelsubsystemwecreatedearlierandplaceitinthemodel.•Makeconnectionsasshown4•Makeconnectionsasshown.•Connectthedrivelineswiththesharedenvironmentblock.Copyright2009Rose-HulmanInstituteofTechnology.35ModifytheGeneratorSubsystem•Changethenamesofportsfrom“Motor”to“Generator.”Cf6•Changethenameofsignalsonthebusfrom“Motor”to“Generator.”Copyright2009Rose-HulmanInstituteofTechnology.47Changed.Changed.Changed.Changed.ModelConnections•ConnecttheGeneratortotheBatteryvoltage.•Connect“Generator”currentonthe8•ConnectGeneratorcurrentontheBatterytotheGeneratorCurrent•ConnecttheEngineandGeneratorDiagnosticPortstotheVehicle_System_Diagnosticsbus.Copyright2009Rose-HulmanInstituteofTechnology.59ModelConnections10VehicleSystemBusChangesCopyright2009Rose-HulmanInstituteofTechnology.6ControlSystemDesign•Wenowhavethesystemtoapointwherewecanstarttobuildourcontrolsystem.•Theelectricmotordrivesthevehicle11•Theelectricmotordrivesthevehicle.•Whennecessary,theenginecanbestartedwiththegeneratorandthenchargethebattery.EngineSpeedControl•Wewillfirstdevelopamethodtostarttheengineandcontroltheenginespeed.•Wehaveageneratordirectlyconnectedtothe12gyengine.Thisgeneratorcanacteitherasamotororasagenerator.•Wecanusemotor/generatortospinuptheenginetostarttheengine.•Wecanusethemotor/generatortoapplyagppytorqueintheoppositedirectiontotheenginetorquetoregulatetheenginespeed.Copyright2009Rose-HulmanInstituteofTechnology.7EngineSpeedControl•Wewilluseclassicalfeedbackcontrolwithproportionalfeedback.•Theenginethrottlewillbeheldconstant13•Theenginethrottlewillbeheldconstant.•Monitortheenginespeed.–Iftheenginespeedistoslow,reducetheopposingM/Gtorque.–Iftheenginespeedistoohigh,increasetheopposingM/Gtorque.EngineSpeedControl•Thisisaclassicalfeedbacksystem.14•Inourcase,theplantisthesystemcomprisedoftheEnginecoupledtotheMotor/Generator.Copyright2009Rose-HulmanInstituteofTechnology.8EngineSpeedControl•Modifythecontrollerasshownnext.•Forthemoment,wewillnotusetheStateflowchart.15Saeoca•NotethatourtorquerequesttotheM/Gisconstrainedbetween-1and+1.•Wewillpickanarbitraryvaluefortheenginethrottle.ChargingEnginerpmisaconstant•Charging_Engine_rpmisaconstantdefinedintheinitfileandis1800rpm.16Copyright2009Rose-HulmanInstituteofTechnology.9EngineSpeedControl–TopLevel•Modifythetoplevelblockdiagramasshown.17EngineSpeedControl•Whenwerunasimulation–Theengineshouldspeedupto1800rpmimmediatelyandasfastaspossible.18yp–Thegeneratorshouldchargethebatteryatsomecurrentdeterminedbytheenginethrottle.•RunasimulationandplottheenginespeedandM/GspeedandM/Gcurrent.Copyright2009Rose-HulmanInstituteofTechnology.1019BatteryCurrentMlPiiMostlyPositive.SOCIncreasing.RPMconstantat~1860.EngineSpeedControl•Weseethatthefeedbackloopdoescontroltheenginerpmverywell,andthatthegeneratorchargesthatbattery20thegeneratorchargesthatbattery.•Ifwezooninontheenginerpmatthebeginningofthesimulation,weseethattherpmrampsupfrom0to1800rpmveryquickly.Copyright2009Rose-HulmanInstituteofTechnology.1121Herethegeneratoractsasamotor.Energyisremovedfromthebatterytoovercomecompressionandspinuptheengine.Enginerpmgoesfrom0to1800inabout140ms.Thisisquitefast.ppgEngineSpeedControl•Thereareafewissueswiththecontrollerthatwemustfix.•Weneedtomodifyourcontrolschemeto:22•Weneedtomodifyourcontrolschemeto:–Turnontheengineonlywhennecessary.–Rampupenginespeedinacontrolledramp.–Turnontheenginewhenitreachestheappropriatespeed.–Rampdowntheenginewhenwenolongerneedtocharge.Copyright2009Rose-HulmanInstituteofTechnology.12StateflowEngineControl•ReadCharging_Engine_rpmfromtheworkspace.FromStateflowselectAdd,DataandthenParameter23Data,andthenParameterStateflowEngineControl•WewillneedtoknowthemeasuredEnginerpmfromtheSimulinkmodel.FromStateflowselectAddDataand24FromStateflowselectAdd,Data,andthenInputfromSimulinkCopyright2009Rose-HulmanInstituteofTechnology.13StateflowEngineControl•StateflowwillneedtooutputtheEngineThrottleandDesiredEnginerpmtoourSimulinkcontrollerFromStateflowselect25Simulinkcontroller.FromStateflow,selectAdd,Data,andthenOutputtoSimulinkStateflowEngineControl•Next,modifytheStateflowchart.•Whenweneedtocharge–EnableMotor/Generator.26–ChangetheDesiredEnginerpmtothevalueofconstantCharging_Engine_rpm.–Whentheenginereachesthisrpm,changethethrottlefrom0toaspecifiedvalue.•Whenweneedtostopcharging–Changethethrottleto0.–ChangetheDesiredEnginerpmto0.–Whenrpmreaches10rpm,disablemotor/generator.Copyright2009Rose-HulmanInst