control design and simulation module concept · if you are new to the control design and simulation...
TRANSCRIPT
![Page 1: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/1.jpg)
ControlDesignandSimulationModuleJune2008,371894C-01Simulationisaprocessthatinvolvesusingsoftwaretorecreateandanalyzethebehaviorofdynamicsystems.Youusethesimulationprocesstolowerproductdevelopmentcostsbyacceleratingproductdevelopment.Youalsousethesimulationprocesstoprovideinsightintothebehaviorofdynamicsystemsyoucannotreplicateconvenientlyinthelaboratory.Forexample,simulatingajetenginesavestime,labor,andmoneycomparedtobuilding,testing,andrebuildinganactualjetengine.YoucanusetheLabVIEWControlDesignandSimulationModuletosimulateadynamicsystemoracomponentofadynamicsystem.Forexample,youcansimulateonlytheplantwhileusinghardwareforthecontroller,actuators,andsensors.IfyouarenewtotheControlDesignandSimulationModule,considercompletingtheGettingStartedwithSimulationtutorial.Inadditiontothetopicscontainedinthishelpfile,theLabVIEWControlDesignUserManualcontainsinformationaboutusingLabVIEWtodesign,analyze,anddeploycontrollersfordynamicsystems.ThefollowingtabledescribesthetasksyoucanperformwiththeControlDesignandSimulationModuleandthecomponentsyouuseforthesetasks.
Task ComponentDesign,analyze,anddeploycontrollersfordynamicsystemmodels
ControlDesignVIsandfunctions.YoualsocanusetheControlDesignMathScriptfunctionstodesignandanalyzecontrollers.
Configuresimulationparameters,includingtheordinarydifferentialequation(ODE)solver,anddefinethesimulationaspartofaLabVIEWblockdiagram
SimulationLoop
Build,simulate,anddeploydynamicsystemmodels,includingmodelsdevelopedwiththe
Simulationfunctions
![Page 2: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/2.jpg)
LabVIEWSystemIdentificationToolkitortheControlDesignandSimulationModule.Executeoffline,RapidControlPrototype(RCP),andHardware-in-the-Loop(HIL)configurationsGenerateandcombineinputandfeedbacksignalsCollectanddisplaysimulationdata
Trimandlinearizeanonlineardynamicsystemmodel
Trim&LinearizeVIs;LinearizeSubsystemdialogbox
Determinetheoptimalparametersforadynamicsystemmodel,givenasetofconstraints
OptimalDesignVIs
ConvertamodeldevelopedinTheMathWorks,Inc.Simulink®applicationsoftwareintoLabVIEWblockdiagramcode
SimulationModelConverter
©2002–2008NationalInstrumentsCorporation.Allrightsreserved.
![Page 3: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/3.jpg)
Version8.6Features(ControlDesignandSimulationModule)RefertotheLabVIEW8.6FeaturesandChangestopicforinformationaboutnewfeaturesinLabVIEW8.6.Refertothereadme_ControlandSim.htmlfile,locatedinthelabview\readmedirectory,foracompletelistofnewfeaturesandchanges,informationaboutupgradeandcompatibilityissuesspecifictodifferentversionsoftheControlDesignandSimulationModule,andinformationaboutknownissueswiththeControlDesignandSimulationModule8.6.
![Page 4: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/4.jpg)
UsingSimulationSubsystemsOutsideaSimulationLoopYounowcanplaceasimulationsubsystemonablockdiagramoutsideaSimulationLoop.IfyourunasimulationsubsystemonablockdiagramoutsideaSimulationLoop,thesimulationsubsystemexecutesonestepoftheordinarydifferentialequationsolvereachtimethesimulationsubsystemiscalled.
![Page 5: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/5.jpg)
PlacingConstraintsonanMPCControllerUsetheCDCreateMPCControllerVItocreateanMPCcontrollermodelwithconstraintsdefinedusingeitherthedualoptimizationorbarrierfunctionmethod.UsetheCDUpdateMPCWindowVItoprovidesetpointanddisturbanceprofilestotheMPCcontrollerduringimplementation.YoualsocanusetheCDSetMPCControllerVItoupdatespecifiedparameters,includinganyconstraints,ofanMPCcontrolleratruntime.RefertotheLabVIEWControlDesignUserManualformoreinformationaboutsettingconstraintsforanMPCcontroller.
![Page 6: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/6.jpg)
ImplementationPaletteChangesTheControlDesign»Implementationpalettehasthefollowingchanges:
TheCDDiscreteStochasticState-SpacefunctionreplacestheCDDiscreteStochasticState-Space(External)functionandtheCDDiscreteStochasticState-Space(Internal)function.UsetheCDDiscreteStochasticState-SpacefunctionoutsideaSimulationLoop.UsethenewDiscreteStochasticState-SpacefunctioninsideaSimulationLoop.TheCDDiscreteObserverfunctionreplacestheCDPredictiveObserverfunction,theCDCurrentObserverCorrectorVI,andtheCDCurrentObserverPredictorVI.TheCDCurrentObserverCorrectorVIandtheCDCurrentObserverPredictorVInolongerareonthepalettebutstillworkinVIsyoucreatedinapreviousversionoftheControlDesignandSimulationModule.UsetheCDDiscreteObserverfunctionoutsideaSimulationLoop.UsethenewDiscreteObserverfunctioninsideaSimulationLoop.TheCDDiscreteKalmanFilterfunctionreplacestheCDDiscreteRecursiveKalmanCorrectorVIandtheCDDiscreteRecursiveKalmanPredictorVI.TheCDDiscreteRecursiveKalmanCorrectorVIandtheCDDiscreteRecursiveKalmanPredictorVInolongerareonthepalettebutstillworkinVIsyoucreatedinapreviousversionoftheControlDesignandSimulationModule.UsetheCDDiscreteKalmanFilterfunctionoutsideaSimulationLoop.UsethenewDiscreteKalmanFilterfunctioninsideaSimulationLoop.
TheSimulation»CDImplementationpalettehasbeenremoved.ThechangestotheControlDesign»ImplementationpalettealsoapplytotheSimulation»CDImplementationpalette.Additionally,theCDContinuousObserverfunctionandtheCDContinuousRecursiveKalmanFilterfunctionnowareontheSimulation»ContinuousLinearSystemspalette.
![Page 7: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/7.jpg)
LabVIEWControlDesignAssistant3.0UsetheinteractiveLabVIEWControlDesignAssistanttodevelopmodelsthatreflectthebehaviorofsingle-inputsingle-output(SISO)systems.UsingtheControlDesignAssistant,youcanloadorcreateamodelofaplant,analyzethetimeorfrequencyresponse,andthensynthesizeacontroller.TheControlDesignAssistanthaswindowsinwhichyoucanimmediatelyseethemathematicalequationandgraphicalrepresentationthatdescribethemodel.Youalsocanviewtheresponsedataandtheconfigurationofthecontroller.SelectTools»ControlDesignandSimulation»LaunchControlDesignAssistanttolaunchtheControlDesignAssistantfromLabVIEW.
![Page 8: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/8.jpg)
MathScriptNodeontheSimulationDiagramYounowcanplaceaMathScriptNodedirectlyonasimulationdiagram.
![Page 9: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/9.jpg)
RelatedDocumentation(ControlDesignandSimulationModule)ThefollowingdocumentscontaininformationthatyoumightfindhelpfulasyouusetheLabVIEWControlDesignandSimulationModule.
GettingStartedwithLabVIEW—Thismanualcontainsanin-depthintroductiontoLabVIEW,includingseveraltutorialsthatshowcaseLabVIEWfeatures.LabVIEWFundamentals—ThismanualprovidesinformationaboutLabVIEWprogrammingconcepts,techniques,features,VIs,andfunctionsyoucanusetocreatemanytypesofapplications.LabVIEWControlDesignUserManual—ThismanualcontainsinformationaboutusingLabVIEWtodesign,analyze,anddeploycontrollersfordynamicsystems.GettingStartedwiththeLabVIEWReal-TimeModule—Thismanualintroducestheconceptsnecessarytocreatereal-timesimulations.Real-TimeExecutionTraceToolkitdocumentation.NI-CANHardwareandSoftwareManualNI-DAQmxHelpLabVIEWControlDesignandSimulationModuleReadme—Usethisfiletolearnimportantlast-minuteinformation,includinginstallationandupgradeissues,compatibilityissues,changesfromthepreviousversion,andknownissueswiththeControlDesignandSimulationModule.OpenthisreadmebyselectingStart»AllPrograms»NationalInstruments»LabVIEW»Readmeandopeningreadme_ControlandSim.htmlorbynavigatingtothelabview\readmedirectoryandopeningreadme_ControlandSim.html.LabVIEWControlDesignandSimulationModuleexampleVIs—Refertothelabview\examples\ControlandSimulationdirectoryforexampleVIsthatdemonstratecommontasksusingtheControlDesignandSimulationModule.YoualsocanaccesstheseVIsbyselectingHelp»FindExamplesandselectingToolkitsandModules»ControlandSimulationintheNIExampleFinderwindow.
![Page 10: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/10.jpg)
AdditionalLabVIEWdocumentation.YoumusthaveAdobeReader6.0.1orlaterinstalledtovieworsearchthePDFversionsofthesemanuals.RefertotheAdobeSystemsIncorporatedWebsitetodownloadAcrobatReader.RefertotheNationalInstrumentsProductManualsLibraryforupdateddocumentationresources.YoumustinstallthePDFstoaccessthemfromthishelpsystem.
NoteThefollowingresourcesofferusefulbackgroundinformationonthegeneralconceptsdiscussedinthisdocumentation.Theseresourcesareprovidedforgeneralinformationalpurposesonlyandarenotaffiliated,sponsored,orendorsedbyNationalInstruments.Thecontentoftheseresourcesisnotarepresentationof,maynotcorrespondto,anddoesnotimplycurrentorfuturefunctionalityintheControlDesignandSimulationModuleoranyotherNationalInstrumentsproduct.Åström,K.,andT.Hagglund.1995.PIDcontrollers:theory,design,andtuning.2ded.ISA.Balbis,Luisella.2006.Predictivecontroltoolkit.UKACCcontrol,2006.Minisymposia:87–96.Bertsekas,DimitriP.1999.NonlinearProgramming.2ded.Belmont,MA:AthenaScientific.Dorf,R.C.,andR.H.Bishop.2001.Moderncontrolsystems.9thed.UpperSaddleRiver,NJ:PrenticeHall.Franklin,G.F.,J.D.Powell,andA.Emami-Naeini.2002.Feedbackcontrolofdynamicsystems.4thed.UpperSaddleRiver,NJ:PrenticeHall.Franklin,G.F.,J.D.Powell,andM.L.Workman.1998.Digitalcontrolofdynamicsystems.3ded.MenloPark,CA:AddisonWesleyLongman,Inc.Kuo,BenjaminC.1992.DigitalControlSystems.2ded.Ft.Worth:SaundersCollege.Nise,NormanS.2000.Controlsystemsengineering.3ded.NewYork:JohnWiley&Sons,Inc.Ogata,Katsuhiko.1995.Discrete-timecontrolsystems.2ded.EnglewoodCliffs,N.J.:PrenticeHall.
![Page 11: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/11.jpg)
Ogata,Katsuhiko.2001.Moderncontrolengineering.4thed.UpperSaddleRiver,NJ:PrenticeHall.Zhou,Kemin,andJohnC.Doyle.1998.Essentialsofrobustcontrol.UpperSaddleRiver,NJ:PrenticeHall.
Thefollowingbookscontaininformationabouttheordinarydifferentialequation(ODE)solverstheControlDesignandSimulationModuleuses.
Ascher,U.M.,andL.R.Petzold.1998.Computermethodsforordinarydifferentialequationsanddifferential-algebraicequations.Philadelphia:SocietyforIndustrialandAppliedMathematics.Shampine,LawrenceF.1994.Numericalsolutionofordinarydifferentialequations.NewYork:Chapman&Hall,Inc.
![Page 12: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/12.jpg)
OrdinaryDifferentialEquationSolvers(ControlDesignandSimulationModule)Becausemanydynamicsystemmodelsconsistofdifferentialequations,youmustsolvethesedifferentialequationstoobservethebehaviorofthesimulatedsystem.LabVIEWincludesseveralordinarydifferentialequation(ODE)solversthatsolvetheseequations.Beforeyousimulateadynamicsystemmodel,youmustspecifyandconfiguretheODEsolverforthatsimulation.ODEsolversusemethodstoapproximatethesolutiontoadifferentialequation.TheODEsolversimplementthesemethodsinavarietyofways,eachwithvariousstrengthsandweaknesses.DefiningcharacteristicsofanODEsolverincludethefollowingqualities:
AccuracyororderStabilityComputationalspeedUseofafixedtimestepsizeversusavariabletimestepsizeUseofasinglestepversusmultiplestepsSuitabilityforstiffproblems
![Page 13: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/13.jpg)
ConsiderationsforEmbeddedTargets(ControlDesignandSimulationModule)IfyouinstallLabVIEWforaparticularembeddedtarget,youcanusetheLabVIEWControlDesignandSimulationModuletodevelopandexecutesimulationsonthattarget.RefertothedocumentationforthetargetyoupurchasedforinformationaboutdevelopingandexecutingVIsonthattarget.Whendevelopingasimulationforanembeddedtarget,takethefollowingfactorsintoconsideration:
YoucannotusetheTrim&LinearizeVIsorOptimalDesignVIswhendevelopingonanembeddedtarget.Therefore,LabVIEWdoesnotdisplaythesepaletteswhenyouareinanembeddedcontext.YoucanuseaConditionalDisablestructuretoenablereal-worldI/OwhenthesimulationisontheembeddedtargetandsimulatedI/OwhenthesamesimulationisrunningonaWindowscomputer.Usingthismethod,youdonothavetomodifytheVImanuallytousedifferentI/Ocodewhenyouswitchtargets.UseasfewSimulationfunctionsaspossible.CombineasmanysequentialtransformationsaspossibleintoasingleSimulationfunction.Forexample,insteadofusingthreeState-Spacefunctionstodescribeacontrollermodel,combinethosefunctionsintoasingleState-Spacefunction.
NoteYoucanusetheModelInterconnectionVIstocombinedynamicsystemmodels.
Considerthespeed/memorytrade-offwhenusingsimulationsubsystems.Usingfewersimulationsubsystemsmightincreaseexecutionspeedbutmightrequireyoutoduplicatecodeelsewhereonthesimulationdiagram.Considerusingfixedstep-sizeordinarydifferentialequation(ODE)solvers,thatis,thesolversnotmarked(variable).Variablestep-sizeODEsolversintroducecomputationaloverheadwhenchangingstepsizes.
NoteTheControlDesignandSimulationModuledoesnotguaranteeaccuracywhenusingtheBDForRosenbrock
![Page 14: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/14.jpg)
ODEsolversonembeddedtargets.Ifthesesolversappeartoproduceinaccurateresultsonanembeddedtarget,chooseanotherODEsolver.
![Page 15: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/15.jpg)
Glossary(ControlDesignandSimulationModule)A B C D E F H I L M N O P R S T
LabVIEWGlossary
![Page 16: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/16.jpg)
AAckermann Atechniqueforplacingpolesinasystemmodel.Usethe
CDAckermannVItoimplementthistechnique.actuator Aphysicaldevicethatappliesthecontrolactiontotheplant.auto-covariance
Ameasureofhowcloselyavalueofastochasticprocess,suchasnoise,varieswiththesubsequentvalueofthatprocess.
![Page 17: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/17.jpg)
Bbalancedsystemmodel
AsystemmodelwithidenticalcontrollabilityandobservabilitydiagonalGrammians.UsetheCDBalanceState-SpaceModel(Diagonal)VIandtheCDBalanceState-SpaceModel(Grammians)VItobalanceastate-spacesystemmodel.
Bodeplot
Aplotthatshowsthegainandphasemarginsofasystemmodelforacommonfrequencyrange.Bodeplotsshowhowcloseasystemmodelistoinstability.UsetheCDBodeVItocreateaBodeplotforasystemmodel.
![Page 18: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/18.jpg)
CCGD CommonGraphDescription.TheformattheSimulation
ModelConverterusestostoreeachsystem,subsystem,block,andlinefromamodeldevelopedinTheMathWorks,Inc.Simulink®simulationenvironment.
constraints Seeinequalityconstraints.continuousmodel
Adynamicsystemmodelthatrepresentsreal-worldsignals,whichvarycontinuouslywithtime.Youcharacterizeacontinuousmodelbydifferentialequations.Seealsodiscretemodel.
controller Adevicethatregulatestheoperationofadynamicsystem.cost Thescalarvaluethatresultsfromsolvingacostfunction.costfunction
Aperformancemeasureyouwanttominimizewhendesigningoptimalparameters.Acostfunctionisafunctionalequationthatmapsasetofpointsinatimeseriestoasinglescalarvalue.
![Page 19: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/19.jpg)
Ddesign Seeoptimaldesign.directfeedthrough
Arelationshipbetweenafunctioninputandafunctionoutputinwhichthefunctionusestheinputatthecurrentsteptocalculatetheoutputatthecurrentstep.Seealsoindirectfeedthrough.
discretemodel
Adynamicsystemmodelthatrepresentssignalsthataresampledatdiscontinuousintervalsintime.Youcharacterizeadiscretemodelbydifferenceequations.Seealsocontinuousmodel.
distributedparametermodel
Aphysicalmodelthatyoucandescribewithpartialdifferentialequations.Seealsolumpedparametermodel.
dynamicsystem
Asystemwhosebehaviorvarieswithtime.
dynamicsystemmodel
Adifferentialordifferenceequationthatrepresentsthebehaviorofallorpartofadynamicsystem.
![Page 20: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/20.jpg)
Eempiricalmodeling
Amodelingtechniqueinwhichyouuseexperimentaldatatodefineadynamicsystemmodel.Seealsophysicalmodeling.
![Page 21: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/21.jpg)
Ffeedbackcycle
Acycleinwhichdatafloworiginatesfromanoutputofafunctionorsubsystemandterminatesasaninputofthesamefunctionorsubsystem.Seealsoindirectfeedthrough.
![Page 22: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/22.jpg)
HHIL Hardware-in-the-loop.Asimulationconfigurationinwhichyoutest
acontrollerimplementationwithasimulatedsystem.SeealsoRCP.
![Page 23: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/23.jpg)
Iindirectfeedthrough
Arelationshipbetweenafunctioninputandafunctionoutputinwhichthefunctiondoesnotusetheinputatthecurrentsteptocomputetheoutputatthecurrentstep.Seealsodirectfeedthrough.
inequalityconstraints
Anyrestrictionsyouplaceonhowtheoptimaldesignprocessdeterminesoptimalparametervalues.Youcandefineinequalityconstraintsforthecontrolaction,theoutput,therateofchangeofthecontrolaction,andtherateofchangeoftheoutput.
InputNode AcollectionofinputterminalsattachedtotheSimulationLoop.UsetheInputNodetoconfiguresimulationparametersprogrammatically.SeealsoOutputNode.
![Page 24: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/24.jpg)
Llinearmodel Adynamicsystemmodelthatobeystheprinciplesof
superpositionandhomogeneity.Seealsononlinearmodel.
linearize Aprocedurethatapproximatesthebehaviorofanonlinearmodel.Seealsotrim.
lumpedparametermodel
Aphysicalmodelyoucandescribewithanordinarydifferentialequation.Seealsodistributedparametermodel.
![Page 25: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/25.jpg)
Mmodel Seedynamicsystemmodel.
![Page 26: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/26.jpg)
Nnonlinearmodel
Adynamicsystemmodelthatdoesnotobeytheprinciplesofsuperpositionorhomogeneity.Seealsolinearmodel.
![Page 27: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/27.jpg)
Ooffline Asimulationconfigurationinwhichyouusesoftwaretosimulate
thecontrollerandthesystemyouwanttocontrol.Nohardwareisinvolvedinanofflinesimulation.
optimaldesign
Theprocessofselectingparametervaluesthatmaximizeameasureofperformance.
OutputNode
AnoutputterminalontheSimulationLoop.UsetheOutputNodetoviewanyerrorsthesimulationdiagramgenerates.SeealsoInputNode.
![Page 28: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/28.jpg)
Pparameterbounds
Anyrestrictionsyouplaceonpossibleparametervaluesduringtheoptimaldesignprocess.Theoptimaldesignprocessdoesnotconsideranyparametervaluesoutsidetheboundsyoudefine.
parameterdesign
Seeoptimaldesign.
parametermesh
Asetofpointsthatdefinesthedistributionpatternsofsetsofparametervaluesandthenumberofsetstogenerate.
period TheamountoftimeinwhichadiscretelinearSimulationfunctionmustcomplete.
physicalmodeling
Amodelingtechniqueinwhichyouusethelawsofphysicstodefineadynamicsystemmodel.Seealsoempiricalmodeling.
plant Adynamicsystemwhosebehavioryouwanttoobserve,replicate,ormanipulate.
![Page 29: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/29.jpg)
RRCP Rapidcontrolprototype.Asimulationconfigurationinwhichyou
testplanthardwarewithasoftwaremodelofthecontroller.SeealsoHIL.
![Page 30: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/30.jpg)
Ssimulationdiagram
ALabVIEWdiagramthatallowsyoutouseSimulationfunctionswithinaSimulationLooporsimulationsubsystem.Asimulationdiagram,likeotherLabVIEWdiagrams,hasthefollowingsemanticproperties:Theorderofoperationsisnotcompletelyspecifiedbytheuser.Theorderofoperationsisimpliedbydatainterdependencies.Afunctioncanexecuteonlyafterallnecessaryinputshavebecomeavailable.Outputsaregeneratedafterafunctioncompletesexecution.
SimulationLoop
Thestructurethatexecutesthesimulationdiagramovermultipletimesteps.
skew TheamountoftimebywhichyouwanttodelaytheexecutionofadiscretelinearSimulationfunction.
SQP SequentialQuadraticProgramming.Ageneral-purposenumericaloptimizationalgorithm.
subsystem AsectionofasimulationdiagramyourepresentwithasingleiconinsteadofmultipleSimulationfunctionsandwires.
![Page 31: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/31.jpg)
Ttime-invariantmodel
Adynamicsystemmodelwhoseparametersdonotchangewithtime.
time-variantmodel
Adynamicsystemmodelwhoseparameterschangewithtime.
trim Aprocedurethatsearchesforthevaluesofstatesandinputsthatproduceoutputand/orstatederivativeconditionsyouspecify.Seealsolinearize.
![Page 32: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/32.jpg)
BuildingandConfiguringSimulations(ControlDesignandSimulationModule)UsetheLabVIEWControlDesignandSimulationModuletobuildasimulationdiagram,whichgraphicallydisplaysadynamicsystemmodelinLabVIEW.YoubuildandexecuteasimulationdiagrambyplacingSimulationfunctionsandotherLabVIEWVIsandstructuresinsidetheSimulationLoop.Thesimulationdiagramthenusesanordinarydifferentialequation(ODE)solvertocomputethebehaviorofthedynamicsystemmodel.ThesimulationdiagramsupportsstandardLabVIEWdebuggingtechniques.Youcanuseexecutionhighlighting,breakpoints,probes,customprobes,andsingle-steppingonthesimulationdiagram.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 33: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/33.jpg)
ConceptsUsethisbooktolearnaboutconceptsintheLabVIEWControlDesignandSimulationModule.RefertotheHow-Tobookforstep-by-stepinstructionsforusingtheControlDesignandSimulationModule.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 34: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/34.jpg)
UnderstandingDynamicSystemModels(ControlDesignandSimulationModule)Adynamicsystemmodelisamathematicalrepresentationofthedynamicsbetweentheinputsandoutputsofadynamicsystem.Yougenerallyrepresentdynamicsystemmodelswithdifferentialordifferenceequations.Thefollowingfigureshowsasampledynamicsystem.
Thedynamicsysteminthepreviousfigurerepresentsaclosed-loopsystem,alsoknownasafeedbacksystem.Inclosed-loopsystems,thecontrollermonitorstheoutputoftheplantandadjuststheactuatorstoachieveaspecifiedresponse.Youcanusephysicallawsorexperimentaldatatodevelopadynamicsystemmodel.Thefollowingsectionsdescribefeaturesofboththephysicalmodelingandtheempiricalmodelingtechniques.
![Page 35: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/35.jpg)
PhysicalModelsThelawsofphysicsdefinethephysicalmodelofasystem.Thefollowingsectionsdescribevariousclassificationsandfeaturesofphysicalmodels.LumpedversusDistributedParameterModelsIfyoucanuseanordinarydifferentialequationtodescribeaphysicalsystem,theresultingmodelisalumpedparametermodel.Ifyoucanuseapartialdifferentialequationtodescribeasystem,theresultingmodelisadistributedparametermodel.LinearversusNonlinearModelsDynamicsystemmodelsareeitherlinearornonlinear.Alinearmodelobeystheprincipleofsuperpositionandhomogeneity.Thefollowingequationsaretrueforlinearmodels.y1=f(u1)
y2=f(u2)
f(u1+u2)=f(u1)+f(u2)=y1+y2f(au1)=af(u1)=ay1whereu1andu2arethesysteminputs,y1andy2arethesystemoutputs,andaisaconstant.Conversely,nonlinearmodelsdonotobeytheprinciplesofsuperpositionorhomogeneity.Nonlineareffectsinreal-worldsystemsincludesaturation,dead-zone,friction,backlash,andquantizationeffects;relays;switches;andratelimiters.Manyreal-worldsystemsarenonlinear,thoughyoucanlinearizenonlinearmodelstosimplifyadesignoranalysisprocedure.Time-VariantversusTime-InvariantModelsDynamicsystemmodelsareeithertime-variantortime-invariant.Theparametersofatime-variantmodelchangewithtime.Forexample,youcanuseatime-variantmodeltodescribethemassofanautomobile.Asfuelburns,themassofthevehiclechangeswithtime.Conversely,theparametersofatime-invariantmodeldonotchangewithtime.Foranexampleofatime-invariantmodel,considerasimplerobot.Generally,thedynamiccharacteristicsofrobotsdonotchangeovershort
![Page 36: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/36.jpg)
periodsoftime.ContinuousversusDiscreteModelsDynamicsystemmodelsareeithercontinuousordiscrete.Bothcontinuousanddiscretesystemmodelscanbelinearornonlinearandtime-invariantortime-variant.Continuousmodelsdescribehowthebehaviorofasystemvariescontinuouslywithtime,whichmeansyoucanobtainthepropertiesofasystematanycertainmomentfromthecontinuousmodel.Discretemodelsdescribethebehaviorofasystematseparatetimeinstants,whichmeansyoucannotobtainthebehaviorofthesystembetweenanytwosamplingpoints.Continuoussystemmodelsareanalog.Youderivecontinuousmodelsofaphysicalsystemfromdifferentialequationsofthesystem.Thecoefficientsofcontinuousmodelshaveclearphysicalmeanings.Forexample,youcanderivethecontinuoustransferfunctionofaresistor-capacitor(RC)circuitifyouknowthedetailsofthecircuit.ThecoefficientsofthecontinuoustransferfunctionarethefunctionsofRandCinthecircuit.Youusecontinuousmodelsifyouneedtomatchthecoefficientsofamodeltosomephysicalcomponentsinthesystem.Discretesystemmodelsaredigital.Youderivediscretemodelsofaphysicalsystemfromdifferenceequationsorbyconvertingcontinuousmodelstodiscretemodels.Incomputer-basedapplications,signalsandoperationsaredigital.Therefore,youcanusediscretemodelstoimplementadigitalcontrollerortosimulatethebehaviorofaphysicalsystematdiscreteinstants.Youalsocanusediscretemodelsintheaccuratemodel-baseddesignofadiscretecontrollerforaplant.
![Page 37: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/37.jpg)
EmpiricalModelsEmpiricalmodelsusedatagatheredfromexperimentstodefinethemathematicalmodelofasystem.Tosomedegree,physicalmodelsareempiricalbecauseyouexperimentallydeterminecertainconstantsusedtodevelopthemodel.Avarietyofempiricalmodelingmethodsexist.Onemethodofempiricalmodelingusestablesofexperimentaldatathatrepresentthesystemyouwanttomodel.Anothermethodfordevelopingmodelsusessystemidentificationmethods.Systemidentificationmethodsusemeasureddatatocreatedifferentialordifferenceequationrepresentationsthatmodelthedata.
NoteYoucanusetheLabVIEWSystemIdentificationToolkittoconstructmodelsbyusingsystemidentificationmethods.
![Page 38: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/38.jpg)
LinearModelFormsYoucanusetheControlDesignandSimulationModuletorepresentcontinuousanddiscretelinearmodelsinthefollowingthreeforms:
TransferFunction—Thesemodelsusepolynomialfunctionstodefinetherelationshipbetweentheinputsandoutputsofadynamicsystem.Youanalyzetransferfunctionmodelsinthefrequencydomain.Zero-Pole-Gain—Thesemodelsaretransferfunctionmodelsthatyourewritetoshowthegainandthelocationsofthezerosandpolesofthedynamicsystem.Youanalyzezero-pole-gainmodelsinthefrequencydomain.State-Space—Thesemodelsrepresentthedynamicsystemintermsofphysicalstates.Continuousstate-spacemodelsusefirst-orderdifferentialequationstodescribethedynamicsystem,whereasdiscretestate-spacemodelsusefirst-orderdifferenceequations.Youanalyzestate-spacemodelsinthetimedomain.
![Page 39: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/39.jpg)
SISOvs.MIMOModelsWhenyouconfigureacontinuousordiscretetransferfunction,zero-pole-gain,orstate-spacefunction,youcanusetheconfigurationdialogboxtospecifywhetherafunctionissingle-inputsingle-output(SISO)ormultiple-inputmultiple-output(MIMO).SISOmodelshaveonlyoneinputandoneoutput,whereasMIMOmodelshavetwoormoreinputsoroutputs.YoumakethischoicebyselectingtheappropriateoptionfromthePolymorphicinstancepull-downmenu.
![Page 40: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/40.jpg)
ConfiguringSimulationParameters(ControlDesignandSimulationModule)TheSimulationLoop,showninthefollowingfigure,containstheparametersthatdefinethebehaviorofthesimulation.
Youcanconfigurethesesimulationparametersbyusingthefollowingtwomethods:
UsingtheConfigureSimulationParametersdialogboxWiringvaluestotheInputNode
Youalsocanuseacombinationofthesetwomethodsinthesamesimulationdiagram.However,valuesthatyouprogrammaticallyconfigureoverrideanyequivalentsettingsthatyoumakeintheConfigureSimulationParametersdialogbox.
TipUsetheOutputNodetoviewanyerrorsthatoccurduringtheexecutionoftheSimulationLoop.UsetheGetSimulationParametersfunctiontodisplaytheparametersyouconfigureforthesimulation.
TheSimulationLoopisaversionoftheTimedLoop.Bothloopscaniteratedeterministicallyaccordingtoaperiodandpriorityyoudefine.However,theSimulationLoopalsoexecutesthesimulationdiagramaccordingtotheordinarydifferentialequation(ODE)solveryouchoose.TheinsideoftheSimulationLoopalsohasapaleyellowbackgroundtodistinguishthesimulationdiagramfromtheLabVIEWblockdiagram.
![Page 41: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/41.jpg)
Similartootherloopsandstructures,youcanusetunnelstopassdatainandoutoftheSimulationLoop.
![Page 42: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/42.jpg)
ConfiguringSimulationParametersProgrammaticallyThefollowingfigureshowshowyouconfigureasimulationdiagramprogrammatically.
ThepreviousfigureshowshowthegrayboxesontheInputNodedisplayanyvaluesthatyouconfigureintheConfigureSimulationParametersdialogbox.Valuesthatyouconfigureprogrammaticallydonothavegrayboxes.
![Page 43: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/43.jpg)
UsingSimulationFunctionsandVIs(ControlDesignandSimulationModule)TheLabVIEWControlDesignandSimulationModuleincludesbothfunctionsandVIs.TheSimulationfunctionsaretheelementsthatcompriseasimulationmodel.Usethesefunctionstoperformtaskssuchasdefiningdynamicsystemmodels,generatingandcombininginputsignals,andanalyzinganddisplayingsimulationdata.YoucanconfiguremostSimulationfunctionsusingtheconfigurationdialogboxofthatfunction.AfteryouplaceaSimulationfunctiononthesimulationdiagram,double-clickthatfunctiontolaunchitsconfigurationdialogbox.Youalsocanlaunchthisdialogboxbyright-clickingtheSimulationfunctionandselectingConfigurationfromtheshortcutmenu.Forexample,thefollowingfigureshowstheconfigurationdialogboxfortheSineSignalfunction.
TheParameterssectionlistsalltheparametersthatyoucanconfigure
![Page 44: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/44.jpg)
fortheSineSignalfunction.WhenyouselectaparameterfromtheParameterssection,theParameterInformationsectiondisplaysacontrolyoucanusetosetthevalueofthatparameter.UsetheParametersourcecontroltospecifythesourceoftheparametervalue.IfyouselectConfigurationDialogBox,LabVIEWremovesthatinputfromthesimulationdiagram.Youthenmustsetthevalueforthisparameterintheconfigurationdialogbox.IfyouselectTerminal,LabVIEWdisplaysaninputterminalforthatparameteronthesimulationdiagram,andyoucanwirevaluestothisinputtoconfiguretheSimulationfunction.TheparametersyouspecifyforaSimulationfunctionareuniquetothatfunction.Ifyoucreatemultipleinstancesofthesamefunction,youcansetdifferentparametervaluesforeachinstance.
NoteDiscretesimulationfunctionshaveadditionalparametersyouusetoconfiguretheperiodandskewofthefunction.
InadditiontotheSimulationfunctions,theControlDesignandSimulationModuleincludesVIs.UsetheseVIstoperformtasksindirectlyrelatedtothesimulation,suchastrimmingandlinearizingadynamicsystemmodelordesigningoptimalparametersforadynamicsystemmodel.
![Page 45: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/45.jpg)
DynamicSimulationFunctionsThefollowingSimulationfunctionsaredynamicelementsthatdependontheordinarydifferentialequation(ODE)solveryouspecify.
IntegratorTransferFunctionZero-Pole-GainState-Space
![Page 46: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/46.jpg)
ConfiguringDiscreteSimulationFunctions(ControlDesignandSimulationModule)TheDiscreteLinearSystemsfunctionshaveasampleperiod(s)parameterandasampleskew(s)parameter.Theseparametersarelocatedintheconfigurationdialogboxofthatfunction.Thesampleperiod(s)parametersetsthelengthofthestepsizeofthatfunction.Thesampleskew(s)parameterdelaystheexecutionofthatfunction.ThefollowingfigureshowshowthesetwoparametersaffecttheexecutionofadiscreteSimulationfunction.
Thesampleperiod(s)ofadiscretefunctionmustbeamultipleofthediscretestepsizeofthesimulation.Toconfigurethisoveralldiscretestepsize,double-clicktheInputNodeoftheSimulationLooptolaunchtheConfigureSimulationParametersdialogbox.OntheSimulationParameterspage,youcanentertheDiscreteStepSize(s)orautomaticallyconfigurethediscretestepsizeofthesimulation.
NoteIfyouenteravalueof–1forthesampleperiod(s)parameterofaSimulationfunction,thatfunctioninheritsthesamestepsizeasdefinedintheConfigureSimulationParametersdialogbox.
![Page 47: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/47.jpg)
Generating,Collecting,andDisplayingSimulationData(ControlDesignandSimulationModule)TheLabVIEWControlDesignandSimulationModuleincludesseveralfunctionsyouusetogenerate,collect,anddisplaysimulationdata.Thefollowingsectionsprovideinformationaboutusingthesefunctions.
![Page 48: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/48.jpg)
GeneratingandCombiningSignalsUsetheSignalGenerationfunctionstogeneratemanydifferenttypesofsignals,includingsine,ramp,step,pulse,andchirpsignals.Thesefunctionsareusefulwhenyouwanttoseehowadynamicsystemrespondstoaparticulartypeofinput.Forexample,theStepSignalfunctiongeneratesastepsignal,whichyoucommonlyusetotestcontrollerperformance.EachSignalGenerationfunctionhasconfigurationoptionsyoucanusetofittheneedsofaparticularsituation.UsetheSignalArithmeticfunctionstoadd,subtract,multiply,anddividesignals.
![Page 49: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/49.jpg)
CollectingandIndexingSimulationDataTostoreallorpartofasignalhistoryovertheentiresimulationforlateranalysis,usetheCollectorfunction.Thisfunctionstoresvaluesinanarray,similartotheauto-indexingoutputtunnelofaForLoop.However,whereasLabVIEWindexesForLooparraysbytheloopiteration,theControlDesignandSimulationModuleindexesCollectorarraysbysimulationtime.Therefore,afterthesimulationfinishes,youcanseethevaluesthatcorrespondwithcertainpointsintime.TheoppositeoftheCollectorfunctionistheIndexerfunction,whichtakesanarrayofdataandreturnsthecorrectvaluebasedonthesimulationtime.Forexample,youcandefineanarbitrarysignalasanarrayoftimestampsandvaluesateachtimestamp.YouthenwirethisarraytotheInputinputofanIndexerfunction.Whenyourunthesimulation,thisfunctionreturnsthecorrectarrayvalueatthecorrecttime.Ifyoudonotdefineavalueforaspecifictime,thisfunctionlinearlyinterpolatestheexpectedresultaccordingtoseveraloptionsyoucanspecify.TheIndexerfunctionoperatessimilarlytotheauto-indexinginputtunnelofaForLoop,exceptLabVIEWindexesForLooparraysbyloopiterationinsteadofsimulationtime.
![Page 50: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/50.jpg)
DisplayingSimulationDataTheSimTimeWaveformfunctionandBufferXYGraphfunctionoperatesimilarlytotheLabVIEWWaveformChartandXYGraphobjects.However,whereasLabVIEWdisplaystheloopiterationonthex-axisoftheseobjects,theSimulationversionsofthesefunctionsproperlydisplaysimulationtimeonthex-axis.Thisdistinctionisimportantwhenyouareusingavariablestep-sizeordinarydifferentialequation(ODE)solver.Inthissituation,thesimulationmightnotreturnavalueateveryloopiteration,duetochangesinthestepsize.However,theLabVIEWWaveformChartstillplotsavalueeveryloopiteration.TheSimTimeWaveformfunctioncorrectsthisbehaviorandproperlydisplaysunevenly-spacedvaluesonthex-axis.ThefollowingfigureshowshowaSimTimeWaveformChartandaLabVIEWWaveformChartdisplaytheoutputofthePulseSignalfunctionwhensimulatedfor30secondsusingavariablestep-sizeODEsolver.
![Page 51: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/51.jpg)
NoticetheirregularitiesintheLabVIEWWaveformChartwhencomparedtotheSimTimeWaveformChart.
NoteWhenyouplaceaSimTimeWaveformfunctionorBufferXYGraphfunctiononthesimulationdiagram,LabVIEWautomaticallycreatesachartorgraphobjectconnectedtothefunctionoutput.
![Page 52: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/52.jpg)
StoringPrecalculatedDatainLookupTablesLookuptablesareusefulfordefiningsetsofexperimentaldata,suchastheresultofafunction,andthenretrievingthatdatawithoutcalculatingthefunction.Ifyoustorethedatainalookuptable,thesimulationdoesnothavetocomputethefunctioneverytimestep.Instead,youcallthelookuptabletoobtaintheappropriatevalue.Inthissituation,youimprovecomputationperformancebyreducingtheneedtocalculatefunctionsateachiterationoftheSimulationLoop.Alookuptableconsistsoftwodatasets:asetoftablevaluesandacorrespondingsetofdatavalues.Whenyouspecifyaninputvalue,thelookuptablematchesthatinputvaluetoatablevalueandreturnstheappropriatedatavalue.Forexample,consideralookuptablewithtablevaluesof[015]anddatavaluesof[428].Ifyouspecifyaninputvalueof0,thelookuptablereturns4.Ifyouspecifyaninputvalueof5,thelookuptablereturns8.Youalsocanconfigurehowthelookuptableoperatesifyouspecifyaninputvaluethatdoesnotexistasatablevalue.Forexample,youcanconfigurealookuptabletointerpolateorextrapolatetheappropriatedatavaluefromtheavailabletablevalues.UsetheMethodparameteroftheLookupTablesfunctionstodefinethisbehavior.Thisexampleusesaone-dimensionallookuptable;however,theControlDesignandSimulationModulealsoincludesfunctionsthatimplementtwo-andthree-dimensionallookuptables.
![Page 53: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/53.jpg)
TransferringDataBetweenSimulationLoopIterationsUsetheMemoryfunctiontotransferthevalueofasignalfromoneiterationoftheSimulationLooptothenext.ThisfunctionbehavessimilarlytoashiftregisteryoucanplaceonaWhileLoop.ThisfunctionispolymorphicandacceptsanydatatypeyouwiretotheInitialValueinput.Toimplementafixed-timedelay,usetheDiscreteUnitDelayfunction.
![Page 54: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/54.jpg)
ChangingFunctionIconStyles(ControlDesignandSimulationModule)YoucanchangetheiconstyleofaSimulationfunctiononthesimulationdiagram.Right-clickaSimulationfunctionandselectIconStylefromtheshortcutmenutodisplaythefollowingoptions:
Static—DisplaystheSimulationfunctionasastandardVI.Dynamic—DisplaystheSimulationfunctionasanobjectthatyoucanresize.Dynamiciconsalsodisplayapreviewoftheircontents.Forexample,aSineSignalfunctionwithadynamicicondisplaysasinewavewiththefrequency,amplitude,andphasethatyouconfigure.TextOnly—DisplaystheSimulationfunctionasalistofparametervalues.Express—DisplaystheSimulationfunctionwithalistofparametersbelowtheicon.Youcanresizetheparameterlisttodisplaymoreinputsandoutputs.Thisiconstylealsoshowsparametervaluesdirectlyonthesimulationdiagram.
![Page 55: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/55.jpg)
DeterminingFeedthroughBehaviorandDefiningFeedbackCycles(ControlDesignandSimulationModule)TherelationshipbetweenafunctioninputandoutputdefinesthefeedthroughbehaviorofthatI/Opair.AnI/Opaircanhaveindirect,direct,orparameter-dependentfeedthroughbehavior.IfanI/Opairhasindirectfeedthroughbehavior,youcancreateafeedbackcyclebetweenthatinputandoutput.AnI/Opairwithdirectfeedthroughbehaviordoesnotallowafeedbackcycle.Thefollowingsectionsprovidemoreinformationaboutthesebehaviors.
![Page 56: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/56.jpg)
IndirectFeedthroughandFeedbackCyclesWhereasLabVIEWVIsexecuteonlyafterreceivingthevalueofallinputstothatVI,manySimulationfunctionscanexecutewithoutreceivingthevalueofcertaininputs.ConsideraSimulationfunctionwithinputuandoutputy.Atanytimestep,ifthefunctiondoesnotrequirethevalueofutocomputethevalueofy,uhasindirectfeedthroughtoy.Whenindirectfeedthroughexistsbetweenuandy,youcancreateafeedbackcyclebetweentheseparameters.Inafeedbackcycle,thevalueofyattimetreliesonthevalueofuattimet–dt,t–dt2,andsoon.
Forexample,theinputparameteroftheIntegratorfunctionhasindirectfeedthroughtotheoutputparameter.Youcancreateafeedbackcyclebetweenthisinputandoutput.Thefollowingfigureshowsthisbehavior:
YoucanuseoneormoreSimulationfunctionsandotherLabVIEWfunctionsinafeedbackcycleaslongasatleastoneSimulationfunctioninthefeedbackcyclehasindirectfeedthroughbehavior.Theindirectfeedthroughfunctioncanstartthedataflowbyexecutingthefunctionoutputatthecurrentstepbeforereceivinganinputfromthecycleatthecurrentstep.Therefore,theinputatthecurrentstepandtheoutputatthecurrentstepmustnotdependoneachotherdirectlyinatleastonefunctioninthecycle.ThefollowingSimulationfunctionshaveatleastoneI/Opairwithindirectfeedthrough.
DiscreteKalmanFilterDiscreteObserver
![Page 57: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/57.jpg)
DiscreteStochasticState-SpaceDiscreteUnitDelayIntegratorMemoryTransportDelay
![Page 58: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/58.jpg)
DirectFeedthroughIfafunctionoutputyrequiresaninputuinordertoexecute,uhasdirectfeedthroughtoy.Youcannotcreateafeedbackcyclebetweeninputsandoutputswithdirectfeedthrough.Forexample,theinitialconditionparameteroftheIntegratorfunctionhasdirectfeedthroughbehaviortotheoutputparameter.Thisfunctionrequiresavaluefortheinitialconditionparameterinordertocalculatetheoutputparameter.Otherfunctions,suchasFriction,requirethevaluesofallinputsinordertoexecute.Ifyouattempttocreateafeedbackcyclebetweenaninputandoutputwithdirectfeedthrough,thewireappearsbroken.Thefollowingfigureshowsthisbehavior:
Noticethedifferencebetweenthepreviousfigureandthefigureshowingthefeedbackcycle.
![Page 59: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/59.jpg)
Parameter-DependentFeedthroughSeveralfunctionshavefeedthroughbehaviorthatdependsonhowyouconfiguretheparametersofthatfunction.Forexample,considertheTransferFunctionfunction.Thefeedthroughbehaviorofthisfunctiondependsontheorderofthenumeratoranddenominatorpolynomialequationsyouspecify.ThefollowingSimulationfunctionshaveatleastoneI/Opairwithparameter-dependentfeedthrough.
TransferFunctionZero-Pole-GainState-SpaceDiscreteFilterDiscreteIntegratorDiscreteTransferFunctionDiscreteZero-Pole-GainDiscreteState-Space
Ifyouusetheconfigurationdialogboxtodefinetheparametersofthesefunctions,suchasthenumeratoranddenominatorofatransferfunction,LabVIEWautomaticallydeterminestheappropriatefeedthroughbehavioranddisplaysthischoiceintheFeedthroughpull-downmenu.However,ifyouuseblockdiagramterminalstodefinetheparametersofthesefunctions,youmustsetthefeedthroughbehaviormanually.AllSimulationfunctionsnotmentionedinthissectionorintheIndirectFeedthroughandFeedbackCyclessectionhavedirectfeedthrough.
![Page 60: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/60.jpg)
PlacingLabVIEWVIs,Functions,andStructuresontheSimulationDiagram(ControlDesignandSimulationModule)YoucanuseamajorityofLabVIEWVIsandfunctionstodescribeadynamicsystemmodel.However,youcannotplacecertainstructures,suchastheWhileLoop,ForLoop,orEventstructure,directlyonthesimulationdiagram.Instead,youcanplacethesestructuresinasubVI,whichyouthenplaceonthesimulationdiagram.Bydefault,theControlDesignandSimulationModuleexecutesVIsandExpressVIsascontinuousfunctions.YoucanchangethisbehaviorbyusingtheSubVINodeSetupdialogbox.Tolaunchthisdialogbox,right-clicktheobjectandselectSubVINodeSetupfromtheshortcutmenu.YoucanconfigureaVItoexecuteatonlymajortimestepsoftheODEsolver,atbothmajorandminortimestepsoftheODEsolver,asadiscretefunction,oratinitializationofthesimulationdiagram.
![Page 61: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/61.jpg)
UsingCaseStructuresontheSimulationDiagramYoucanplaceaCasestructuredirectlyonthesimulationdiagram.Thevalueyouwiretotheselectorterminaldetermineswhichmodeltoevaluate.Ifaninput-outputpaironanysubdiagramofthecasestructurecontainsdirectfeedthrough,youcannotcreateafeedbackcyclebetweenthatinputandoutput.NationalInstrumentsrecommendsyouuseafixedstep-sizeordinarydifferentialequation(ODE)solverwhenusingaCasestructureonthesimulationdiagram.
NoteYoucannotplacefrontpanelterminalsinsideaCasestructureonasimulationdiagram.
![Page 62: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/62.jpg)
How-ToThisbookcontainsstep-by-stepinstructionsandotherinformationthatmightbeusefulasyouusetheLabVIEWControlDesignandSimulationModule.RefertotheConceptsbooktolearnaboutrelatedconcepts.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 63: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/63.jpg)
ModularizingtheSimulationDiagram(ControlDesignandSimulationModule)TheLabVIEWControlDesignandSimulationModulesupportssimulationsubsystems,whichyouusetomodularizeandencapsulateportionsofthesimulationdiagram.YoucreatesimulationsubsystemssimilarlytocreatingsubVIs.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 64: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/64.jpg)
TypesofSimulationSubsystems(ControlDesignandSimulationModule)Simulationsubsystemsprovideawaytomodularizesimulationdiagramcode.Bycombiningseveralfunctionsintoasubsystem,youreducetheamountofspaceneededonthesimulationdiagram,makingthesimulationeasiertonavigatevisually.Simulationsubsystemsalsoareusefulforvalidating,distributing,andreusingportionsofthesimulationdiagram.YoucanusemanySimulationVIsandfunctionsonlyonasimulationdiagram,suchaswithinaSimulationLoop.Becausesimulationsubsystemsmodularizesimulationdiagramcode,youcanusetheSimulationVIsandfunctionsinsimulationsubsystemsaswell.TheentireblockdiagramofasimulationsubsystemispaleyellowliketheinsideofaSimulationLoop.WhenyouuseSimulationVIsandfunctionsinasimulationsubsystem,youplacetheVIsandfunctionsdirectlyonthesubsystemblockdiagramratherthanwithinaSimulationLoop.Youcanrunsimulationsubsystemsasstand-aloneVIs,withinaSimulationLooporanothersimulationsubsystem,oronablockdiagramoutsideaSimulationLoop.
![Page 65: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/65.jpg)
RunningaSubsystemasaStand-AloneVIWhenyourunasimulationsubsystemasastand-aloneVI,youconfigurethesimulationparametersbyselectingOperate»ConfigureSimulationParameterstolaunchtheConfigureSimulationParametersdialogbox.YoualsocanconfiguretheexecutionandappearanceofthesubsystembyselectingFile»VIProperties.Whenrunningasimulationsubsystemasastand-aloneVI,youcanusestandardLabVIEWdebuggingtechniques,suchasexecutionhighlighting,breakpoints,probes,andsingle-stepping.YoucannotusethesetechniquesonasubsystemthatiswithinanotherSimulationLoop.Youalsocannotstepintothesubsystem.However,youcansetabreakpointontheentiresubsystembyright-clickingthesubsystemandselectingBreakpoint»SetBreakpointfromtheshortcutmenu.Youalsocanuseaprobeoracustomprobetomonitorthesubsystemoutput.ThefollowingfigureshowsthesimulationdiagramofasimulationsubsystemNewton.vi,whichobtainsthepositionofamassbyusingNewton'sSecondLawofMotion.
Inthepreviousfigure,thissubsystemhasfrontpanelcontrolsandindicators,soyoucanrunthissubsystembyclickingtheRunbutton.BecauseNewton.vidoesnothaveaSimulationLoop,youconfigurethe
![Page 66: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/66.jpg)
parametersofthissubsystembyselectingOperate»ConfigureSimulationParameters.
![Page 67: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/67.jpg)
RunningaSubsysteminaSimulationLoopIfyourunasimulationsubsysteminsideaSimulationLoop,thesimulationsubsysteminheritstheparametersfromtheSimulationLoop.ThefollowingfigureshowsNewton.viincludedwithintheSimulationLoopofanothersimulationdiagram.
Inthepreviousfigure,theparametersoftheSimulationLoopoverrideanyparametersyouconfiguredspecificallyforNewton.vi.
NoteYoucreatethissubsystemandthisVIintheGettingStartedwithSimulationtutorial.
![Page 68: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/68.jpg)
RunningaSubsystemOutsideaSimulationLoopIfyourunasimulationsubsystemonablockdiagramoutsideaSimulationLoop,thesimulationsubsystemexecutesonestepoftheordinarydifferentialequation(ODE)solvereachtimethesimulationsubsystemiscalled.Forexample,ifyouplacethesimulationsubsysteminaTimedLoop,onestepoftheODEsolverexecutesateachiterationoftheloop.Youcanuseonlyfixedstep-sizeODEsolversforasimulationsubsystemoutsideaSimulationLoop.SpecifythetimestepusingtheStepSize(s)configurationoptionofthesubsystem.
TipIfyoucreateanapplicationwithasimulationsubsysteminsideaTimedLoopandthendeploytheapplicationtoareal-timetarget,settheStepSize(s)ofthesubsystemequaltotheperiodoftheTimedLoop.
WhenyouplaceasimulationsubsystemonablockdiagramoutsideaSimulationLoop,theiconofthesimulationsubsystemappearsintheExpressstylebydefault.Youcanwirevaluestotheparametersofthesimulationsubsystemtoconfigurethesimulationsubsystemprogrammatically.
NoteTheStaticandDynamiciconstylesaredisabledforsubsystemsoutsideaSimulationLoop.
Youalsocanconfiguretheparametersofthesimulationsubsysteminteractively.Double-clickthesimulationsubsystemtolaunchtheconfigurationdialogboxofthatsimulationsubsystem.Inthisconfigurationdialogbox,youcanconfigurethespecificparametersofthesimulationsubsystemaswellasthefollowinggeneralsimulationparameters:
InitialTime(s)—SpecifiesthetimeatwhichtostarttheODEsolver.ODESolver—SpecifiesthetypeofODEsolverthesimulationuses.Nan/InfCheck—SpecifiesthatyouwanttheControlDesignandSimulationModuletocheckthesimulationvaluesfornotanumber(NaN)andinfinite(Inf)values.TheControlDesignandSimulationModulereturnsanerrorifitencountersaNaNorInfvalue.
![Page 69: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/69.jpg)
StepSize(s)—Specifiestheinterval,inseconds,betweenthetimesatwhichtheODEsolverevaluatesthemodelandupdatesthemodeloutput.DiscreteStepSize(s)—Specifiesthebasetimestepsize,inseconds,forthesimulation.AutoDiscreteTime—AutomaticallycalculatestheDiscreteStepSize(s).
TheseparametersareidenticaltoparametersyoucanconfigureintheConfigureSimulationParametersdialogboxofaSimulationLoop.Intheconfigurationdialogboxofasimulationsubsystem,theseparametersappearassub-itemsoftheSimulationParametersitemintheParameterstree.Ifthesimulationsubsystemalreadycontainsaparameterwiththesamenameasoneofthegeneralsimulationparameterslistedabove,LabVIEWappendsthegeneralsimulationparameternamewithanunderscore.ThefollowingfigureshowsNewton.vionablockdiagramoutsideaSimulationLoop.
![Page 70: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/70.jpg)
Inthepreviousfigure,theTimedLoopdetermineswhenNewton.viexecutesthenextstepoftheODEsolver.BecauseNewton.viisoutsideaSimulationLoop,youcanconfigurethesimulationparameters,includingtheODEsolvertouse,bydouble-clickingthesimulationsubsystem.IfyourunasimulationsubsystemoutsideaSimulationLoop,youcanreinitializethesimulationsubsystembysettingtheInitializeinputofthesimulationsubsystemtoTRUE.ThisinputrestartstheODEsolverfromthespecifiedInitialTime(s).TheInitializeinputisavailableforasimulationsubsystemonlywhenthesubsystemisnotinsideaSimulationLooporanothersimulationsubsystem.
![Page 71: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/71.jpg)
PolymorphicSubsystemsIfyoucreateoneormoresubsystemsthatperformthesameoperationondifferentdatatypes,youcanpackagethosesubsystemstogethertocreateapolymorphicsubsystem.ApolymorphicsubsystemisasingleVIthatpointstooneormoresubsystems,calledinstances.Eachinstanceacceptsadifferentdatatypeforasingleinputoroutputterminal.LabVIEWautomaticallyselectsthecorrectinstancebasedontheinputdatatype.Forexample,onesubsystemcouldoperateonadouble-precisionfloatingpointnumber,whileanothersubsystemperformsthesameoperationona16-bitinteger.Insteadofplacingbothsubsystemsonthesimulationdiagram,youcancreateapolymorphicsubsystemthatautomaticallychoosesthecorrectinstance.Forapolymorphicsubsystemtowork,eachinstanceofthepolymorphicsubsystemmustbeasimulationsubsystem.YoucannotcreateapolymorphicsubsystemwithbothVIsandsubsystemsasinstances.Also,eachsubsystemmusthaveanidenticalconnectorpanepattern.Additionally,thenamesofcorrespondinginputparametersforeachinstancemustbeidentical.
![Page 72: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/72.jpg)
TrimmingandLinearizingNonlinearModels(ControlDesignandSimulationModule)Manyreal-worlddynamicsystemmodelsarenonlinear.Ifyouwanttodesignacontrollerforanonlinearmodel,youmustfirstlinearizethatmodel.Linearizinganonlinearmodelinvolvesapproximatingthebehaviorofthatmodelaroundanoperatingpoint.Theoperatingpointisthesetoftheinputsandstatesofthemodel.Whenyoulinearizeamodel,theresultisalineartime-invariant(LTI)state-spacemodel.
NoteYoucandesignacontrollerforLTImodelsusingtheControlDesignVIsandfunctions.
Trimmingamodelinvolvessearchingforvaluesofmodelinputsandstatesthatsatisfyanyconditionsyouspecify.Forexample,youcanspecifythatthemodeloutputsorstatederivativesmusthaveacertainvalue.Trimmingthemodelusingtheseconditionsreturnsthevaluesoftheinputsandstatesthat,whengiventothemodel,producetheoutputsandstatederivativesyouspecified.Youalsocantrimamodeltodetermineanoperatingpointaboutwhichyoulinearizethemodel.TheLabVIEWControlDesignandSimulationModuleprovidesseveralmethodsfortrimmingandlinearizingmodels.Youcaninteractivelytrimandlinearizeamodel.Youalsocanprogrammaticallytrimandprogrammaticallylinearizeamodel.
NoteTheabovemethodsoperateoncontinuoussimulationsubsystems.Therefore,youmustcreateasimulationsubsystemthatrepresentsthemodelbeforetrimmingorlinearizingthatmodel.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 73: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/73.jpg)
ExecutingSimulationsinRealTime(ControlDesignandSimulationModule)YoucanusetheLabVIEWControlDesignandSimulationModulewiththeLabVIEWReal-TimeModuleandvariousNationalInstrumentsreal-time(RT)targetstoimplementsimulationsandcontrollersinrealtimewithreal-worldinputsandoutputs.Forexample,youcancombinethissoftwareandhardwaretodesignandimplementarapidcontrolprototype(RCP)orhardware-in-the-loop(HIL)configuration.YouconfigurethetimingSimulationLoopaccordingtotheneedsofthesimulation.TheControlDesignandSimulationModulecanexecuteVIsonhardwaretargetsrunningthereal-timeoperatingsystem(RTOS)oftheArdencePharLapEmbeddedToolSuite(ETS)orWindRiverVxWorks.
NoteTheControlDesignandSimulationModulesupportsonlyETSandVxWorkstargetswithatleast32MBofRAM.
TheReal-TimeModuleincludestheGettingStartedwiththeLabVIEWReal-TimeModulemanual,whichintroducestheconceptsnecessarytocreatereal-timeapplications.TheReal-TimeModuledocumentationalsoincludestopicsaboutorganizingandmanagingprojects,creatingdeterministicapplications,andsharingdataindeterministicapplications.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 74: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/74.jpg)
Offline,RCP,andHILConfigurations(ControlDesignandSimulationModule)Thefollowingsectionsprovideanoverviewoftheprocessyoumightusetosimulateadynamicsystem.Thefollowingsectionsalsodescribeexamplesofofflinesimulations,rapidcontrolprototyping(RCP)configurations,andhardware-in-the-loop(HIL)configurations.
![Page 75: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/75.jpg)
OfflineSimulationAnofflinesimulationisonethatisnotconnectedtoanyhardware.YouusetheLabVIEWControlDesignandSimulationModuletosimulateallpartsofthedynamicsystem,includingthecontroller,thesystemyouwanttocontrol,andanyinputsoroutputs.Thefollowingfigurerepresentsasimulationofanofflinecontrolsystem.
IfyouarerunninganofflinesimulationonaWindowscomputer,NationalInstrumentsrecommendsyouplaceacheckmarkintheSynchronizeLooptoTimingSourcecheckboxontheTimingParameterspageoftheConfigureSimulationParametersdialogboxforoptimalperformance.
![Page 76: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/76.jpg)
RapidControlPrototypeConfigurationAnRCPconfigurationreplacesthesimulatedsystemwithanactualsystem.Usethisconfigurationtotestmultiplecontrolleralgorithmswithoutbuildingthecontrolleragaineverytimeyoumakeachange.Inthissituation,thesimulatedcontrollerisconnectedtohardwareactuatorsandhardwaresensors.ToconvertanofflinesimulationtoanRCPconfiguration,removethesystemmodelfromthesimulation.Replacethesysteminputwithanoutputfromahardwaredevice,andreplacethesystemoutputwithaninputfromahardwaredevice.ThefollowingfigurerepresentsanRCPconfiguration.
Inthepreviousfigure,thesimulatedcontrollerusesNationalInstrumentsreal-timehardware,suchasaDAQdevice,tosenddatatothehardwaresystem.
![Page 77: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/77.jpg)
Hardware-in-the-LoopConfigurationAHILconfigurationinvolvestheactualcontrollerprovidinginputtoasimulatedsystem.Usethisconfigurationtotestacontrolleronasystemwithoutactuallyhavingthatsystemavailable.Forexample,ifyouweretestinganenginecontrolunit(ECU)foracar,youcouldtesttheECUwithouthavingtobuildthecarmultipletimes.HILconfigurationsalsoareusefulfortestingcontrollersunderextremeconditionsthatyoucannotreplicateconvenientlyinalaboratory.ToconvertanofflinesimulationtoaHILconfiguration,removethecontrollermodelfromthesimulation.Replacethecontrollerinputwithanoutputfromahardwaredevice,andreplacethecontrolleroutputwithaninputfromahardwaredevice.TheresultissimilartotheRCPconfiguration,exceptwiththecontrollermodel,notthesystemmodel,replacedwithphysicalhardwareinputsandoutputs.ThefollowingfigureshowsaHILconfigurationoftheexampleinthepreviousfigure.
Inthepreviousfigure,thecontrollerusesNationalInstrumentsreal-timehardware,suchasaDAQdevice,tosenddatatothesimulatedsystem.
![Page 78: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/78.jpg)
DeterministicODESolvers(ControlDesignandSimulationModule)Runningasimulationorcontrollerinrealtimemeansthatthesimulationtimemustequalthewall-clocktimeateachpointthatthesimulationorcontrollerinteractswiththerealworld.Generally,thesephysicalinteractionpointscorrespondtothesamplingpointsoftheinputandoutputhardware.Therefore,ateachsamplingtime,thesimulationtimemustequalthewall-clocktime.Tomeetthereal-timedeadline,youcanconfiguretheLabVIEWControlDesignandSimulationModuletoexecutedeterministicallybyplacingastrictupperboundontheexecutiontimeoftheSimulationLoop.NationalInstrumentsalsorecommendsyouconfiguretheSimulationLooptouseafixedstep-sizeordinarydifferentialequation(ODE)solver.TheseODEsolversaredeterministic,whichensuresthatblockdiagramcoderunningateachtimestepmeetsthedeadlinesimposedbythetimingofthehardwareinputsandoutputs.TheControlDesignandSimulationModuleincludesthefollowingdeterministicODEsolvers:
Runge-Kutta1RungeKutta2Runge-Kutta3Runge-Kutta4DiscreteStatesOnly
Variablestep-sizeODEsolversarenotappropriateforreal-timeapplicationsbecausethesesolversadjustthestepsizebasedontheestimatederrorofthesolution.Thisadjustmentrequiresadditionalcomputationalresources,whichcaninterferewiththetimingrequirementsofareal-timeapplication.
![Page 79: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/79.jpg)
ConsiderationsforETSTargets(ControlDesignandSimulationModule)IfyouareexecutingasimulationonanArdencePharLapEmbeddedToolSuite(ETS)target,NationalInstrumentsrecommendsyoulettheLabVIEWControlDesignandSimulationModulecalculatethenecessaryvalueofthesimulationperiod.Toautomaticallycalculatetheperiod,placeacheckmarkintheAutoPeriodcheckbox,whichislocatedontheTimingParameterspageoftheConfigureSimulationParametersdialogbox.Whenyoufollowthisprocedure,othertaskscantocontinuetoexecutewhenthesimulationisnotscheduledtoexecute.
![Page 80: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/80.jpg)
LabVIEWProjectsandSharedVariables(ControlDesignandSimulationModule)Toexecuteasimulationonareal-time(RT)target,youmustcreateaproject.AprojectprovidesawaytomanageVIs,RTtargets,dependencies,buildspecifications,andotherfilesrelatedtotheproject.UsetheProjectExplorerwindow,availablebyselectingFile»NewProject,tomanagethecontentsofaproject.Anothercomponentofareal-timesimulationisthesharedvariable.YoucreatesharedvariablestosimplifytheprocessofsharinglivedatabetweentheWindowscomputerandtheRTtarget.FormoreinformationabouttheLabVIEWprojectandthesharedvariable,includingtutorialsthatintroduceyoutotheseconcepts,refertotheGettingStartedwiththeLabVIEWReal-TimeModuledocument,locatedinthelabview\manualsdirectory.IfyouhavenotinstalledtheLabVIEWReal-TimeModule,youcanaccessthisdocumentatni.com/manuals.
![Page 81: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/81.jpg)
OptimizingDesignParameters(ControlDesignandSimulationModule)Oneimportantapplicationofsimulatingdynamicsystemmodelsisusingthesimulationtodetermineparametervaluesthatmaximizesomemeasureofperformance.TheLabVIEWControlDesignandSimulationModuleincludestheSIMOptimalDesignVI,whichyoucanusetoobtainparametersthatminimizeacostfunctionwhilesatisfyingconstraintsonadynamicsystem.YoucanusethisVIwithbothlinearandnonlinearsystems,althoughtheControlDesignandSimulationModuleincludespre-definedoptionsforonlylinearsystems.Designproblemscanrangefromdesigningphysicalelements,suchassprings,todesigningmoreabstractelementssuchascontrollersordigitalfilters.Correspondingly,performancespecificationsmightrangefromsimplemechanicallimitsonoutputstomoresophisticatedrequirementssuchasfrequencydomainnormsforcontrolledsystems.Forexample,whendesigningasuspensionsystemforacar,youmustselectastiffnessconstantforaspringandadampingconstantforadissipativeelement.Thegoalistofindaparametersetthatprovidesmaximumcomfort.Thisoptimalparametersetcorrespondstoaperformancemeasure,suchastheaveragedeviationofthepassengerfromadesiredheightasthecartravelsdowntheroad.Youuseparameterdesigntodeterminethisoptimalparametersetwhiletakingintoaccountthedynamicsofthesystemandtheexpectedoperatingconditionsanddisturbances.Youcanuseseveraltechniquestodeterminethisparameterset.Forsomeproblems,youmightbeabletocomputetheoptimumanalytically.However,analyticalsolutionstypicallyaredifficultorimpossibletocompute.Insuchcases,youcanusenumericaloptimizationinstead.ApowerfulandgeneralpurposenumericaloptimizationalgorithmisSequentialQuadraticProgramming(SQP).TheSIMOptimalDesignVIusesthisalgorithm.ThisVIprovidesdomain-specificfunctionsyoucanusetoperformparameteroptimizationfordesignpurposes.Specifically,youcanusethisVItodetermineoptimalparametersfromfinite-horizontime-domaindynamicssimulations.Thefollowingexpressionsdefinethenonlinearoptimizationproblem.min(J(p))
![Page 82: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/82.jpg)
hl≤H(p)≤hupl≤p≤puwherepisaparametervalue,J(p)isacostfunction,andH(p)isasetofconstraints.TheobjectiveoftheSQPalgorithmistominimizeJ(p)andsatisfytheconstraintsdefinedbyhl≤H(p)≤huwhilekeepingpwithinspecifiedminimumandmaximumvalues.DesigningasystemusingtheSQPalgorithminvolvesthefollowingsteps:
1. Constructingthedynamicsystemmodelandspecifyingthecomponentofthatmodelforwhichyouwanttofindoptimalparametervalues.
2. Definingaperformancemeasure,alsoknownasacostfunction,youwanttominimize.
3. Defininganyconstraintsonthedynamicsystemthatanyfeasibleparametervaluesmustsatisfy.
4. Definingminimumandmaximumvaluesforeachparameter.5. Definingasetofinitialparametervaluesandaninitialparameters
mesh,whichgeneratesadditionalsetsofinitialparametervalues.6. ExecutingtheSQPalgorithm,usingtheinformationyouspecified
insteps1through5,byrunningtheSIMOptimalDesignVI.Thecostfunction,inequalityconstraints,andcomponenttooptimizemakeuptheProblemSpecificationparameteroftheSIMOptimalDesignVI.Foreachoption,youcanchoosefrompre-definedtypesorspecifyacustomizedversion.
NoteTheControlDesignandSimulationModuleincludesacasestudythatdeterminestheoptimalparametersforaproportional-integral-derivative(PID)controller.
![Page 83: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/83.jpg)
ConstructingtheDynamicSystemModel(ControlDesignandSimulationModule)Bydefault,theSIMOptimalDesignVIcomputesoptimaldesignparametersforaproportional-integral-derivative(PID)controllerplacedinaclosed-loopdynamicsystem.Thefollowingfigureshowsthiscontrollerandthedynamicsystemstructure.
F1,F2,C,G1,G2,andSconsistoftransferfunctionsandassociatedinformation,suchasdelaysandsamplingtime.YoucanusetheSIMConstructDefaultSystemVItoconstructthesetransferfunctionsandspecifyreferenceinputsignalsr,ru,andry.ThisVIreturnsthenecessarydynamicsysteminformationintheSystemDataoutput,whichyouthencanwiretotheSystemDatainputoftheSIMOptimalDesignVI.TheSIMOptimalDesignVIthenexcitesthesystemusingthedefinedinputsandobtainsthetimeresponse.UsetheSystemresponsetypeparameteroftheSIMOptimalDesignVItospecifyifyouwantthisVItoreturnoptimalparametervaluesforC,F1,orF2.Bydefault,CisaparallelPIDcontrollerdefinedbythefollowingequation:
where =0.01,Uisthecontrolaction,sistheLaplacevariable,andKP,KI,andKDaretheproportional,integral,andderivativegains,respectively.YoualsocandefineacustomtypeofsystemresponsedatayouwanttooptimizebyusingVItemplates.Toaccessthesetemplates,select
![Page 84: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/84.jpg)
File»NewtolaunchtheNewdialogbox.ThenselectVI»FromTemplate»Simulation»OptimalDesignfromtheCreateNewtree.Double-clickSystemResponse(ModifyControllerOnly)tomodifyonlythestructureofthecontroller.Double-clickSystemResponse(General)todefineanewdynamicsystemstructure.Ifyoudefineanewdynamicsystemstructure,theblockdiagramcodeyouwritemustgeneratetheoutputvectoryandthetimevectorTime.Thecodealsomustgeneratethecontrolactionvectoruunlesstheoptimizationproblemdoesnotrequireacontrolaction.Forexample,ifyouusetheSIMOptimalDesignVItodesignthephysicalparametersofamechanism,youdonotneedtospecifyacontrolaction.Inthissituation,ensurethecostfunctionandinequalityconstraintsyouspecifydonottakeacontrolactionintoaccount.
![Page 85: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/85.jpg)
DefiningaCostFunction(ControlDesignandSimulationModule)Acostfunctionistheperformancemeasureyouwanttominimize.Examplesofcostincludetotalpowerconsumption,integratederror,anddeviationfromareferencevalueofasignal.Thecostfunctionisafunctionalequation,whichmapsasetofpointsinatimeseriestoasinglescalarvalue.Thisscalarvalueisthecost.UsetheCosttypeparameteroftheSIMOptimalDesignVItospecifythetypeofcostfunctionyouwantthisVItominimize.TheLabVIEWControlDesignandSimulationModuleincludesthefollowingtypesofcostfunctions:
IE—Acostfunctionthatintegratestheerror.IAE—Acostfunctionthatintegratestheabsolutevalueoftheerror.ISE—Acostfunctionthatintegratesthesquareoftheerror.ITAE—Acostfunctionthatintegratesthetimemultipliedbytheabsolutevalueoftheerror.ITE—Acostfunctionthatintegratesthetimemultipliedbytheerror.ITSE—Acostfunctionthatintegratesthetimemultipliedbythesquareoftheerror.ISTE—Acostfunctionthatintegratesthesquareofthetimemultipliedbythesquareoftheerror.LQ—Alinearquadraticcostfunction.SumofVariances—Acostfunctionbasedonthevarianceoftheerrormultipliedbythevarianceofthecontrolaction.
YoualsocandefineacustomcostfunctionusingaVItemplate.Toloadthistemplate,intheNewdialogbox,selectVI»FromTemplate»Simulation»OptimalDesign»ComputeCostfromtheCreateNewtree.Theblockdiagramofthistemplatecontainsseveralparametersincludingthecontrolactionu,thedynamicsystemoutputy,anarrayofinputsignals,andatimeseriesvector.Youalsocanspecifyanyweightsonanypartofthecostfunction.
![Page 86: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/86.jpg)
Afteryoudefinetheseparameters,youcanwriteLabVIEWblockdiagramcodetomanipulatetheparametersaccordingtothecostfunction.Forexample,thefollowingequationdefinestheIEcostfunction.
wheree(t)isthemeasurederror,Nisthetotalnumberofsamplesinthetimeresponse,nisthecurrenttimeresponsesample,andiistheindexofthecurrentoutput.YoucanviewtheVIthatimplementsthiscostfunctioninthelabview\vi.lib\Simulation\OptimizationBasedDesign\Costdirectory.
NoteIfyoucreateacostfunctionVIthatdoesnottakethecontrolactionintoaccount,donotdeletetheuparameterfromtheblockdiagram.DeletingthisparameterbreakstheconnectorpanestructureonwhichtheSIMOptimalDesignVIdepends.Instead,leavetheparameterunwired.
AfteryousavethecustomcostfunctionasaVI,youmustspecifythelocationofthecustomfunctionintheProblemSpecificationparameteroftheSIMOptimalDesignVI.SelectUserdefinedfortheCosttypeparameterandspecifythepathtotheVIintheFilepathuserdefinedcustomcostcalculationpathcontrol.
![Page 87: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/87.jpg)
DefiningInequalityConstraints(ControlDesignandSimulationModule)Inequalityconstraintsrepresenttrade-offsimplicitintheproblemspecification.Forexample,youmightbeabletoremoveerrorsinacontrolloopbyapplyingaverylargecontrolaction.However,thenecessarycontrolactionmightbeimpossibletoachieveintherealworld.IfyouspecifyconstraintsonthecontrolactionbeforeexecutingtheSequentialQuadraticProgramming(SQP)algorithm,youcaneliminateoptimalvaluesthatrequireanunfeasiblecontrolaction.
NoteConstraintsaddagreatdealofcomplexitytotheoptimizationproblem.Ifpossible,minimizethenumberofconstraintsbeforeexecutingtheSQPalgorithm.Onestrategytominimizethenumberofconstraintsinvolvesfirstfindingoptimalvalueswithnoconstraints,thengraduallyaddingconstraintsanddeterminingtheleastamountofconstraintsrequiredforthedynamicsystem.
Becausetheoptimizationproblemisbasedonafinite-horizontime-domainsimulation,youspecifytheinequalityconstraintsasenvelopesthatboundthetimeresponseofthecontrolactionandtheoutput.Youalsocanplaceinequalityconstraintenvelopesontherateofchangeofthecontrolactionandtherateofchangeoftheoutput.Theseenvelopesarepiecewiselinearcurvesthatspecifytheupperandlowerlimitsonasignalduringthesimulation.TheSIMOptimalDesignVIthencalculatesH(p)astheminimumandmaximumdistanceofthetimeseriespointsfromtheseenvelopes.UsetheInequalityConstraintsparameteroftheSIMOptimalDesignVItodefinetheseenvelopes.Thisparameterspecifiestheupperandlowerconstraintenvelopesonthefollowingfourareasofthedynamicsystem:thecontrolaction,theoutput,therateofchangeofthecontrolaction,andtherateofchangeoftheoutput.
NoteYoucanusetheGraphicallySpecifyInequalityConstraintsVI,locatedinthelabview\examples\ControlandSimulation\Simulation\OptimalControlDesign\GraphicallySpecifyInequalityConstraintsdirectory,todrawtheupperandlowerenvelopes.ThisVIreturnsasetofpointsyouthencanwiretothe
![Page 88: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/88.jpg)
InequalityConstraintsparameter.
Forexample,consideranoutputyi(t)constrainedbyenvelopes,asshowninthefollowingfigure.
A,B,C,andDarepointsthatdefinetheupperenvelopeUEi(t),andE,F,G,andHarepointsthatdefinethelowerenvelopeLEi(t).TheSIMOptimalDesignVIthenconstrainsyi(t)tothefollowingrelationship:
LEi(t)<yi(t)<UEi(t)
ThisVIencodesthisconstraintbycomputingtheclearancebetweentheoutputandeachenvelope.TheupperclearanceUCiisdefinedasmax(UEi(t)–yi(t)).ThelowerclearanceLCiisdefinedasmax(yi(t)–LEi(t)).Theseclearancesclarifythattheconstraintsmustbepositive,asthefollowingrelationshipsshow:–ε<UCi<∞
–ε<LCi<∞
whereε=1E–21.Youalsocanplaceconstraintsontherateofchangeofcontrolactionsandoutputs.Ifatleastfivepointsareavailable,thisVIcomputestheseratesofchangeusingthefollowingequation:
wheretisthesimulationtime,histhespacebetweentimesteps,andf(t)
![Page 89: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/89.jpg)
isanoutputorcontrolactionsignal.Atboundaries,oriffewerthanfivepointsareavailable,thisVIusesthefollowingequationsinstead:
or
YoucanuseaVItemplatetospecifycustomcalculationsforimplementingtheinequalityconstraints.Toloadthistemplate,intheNewdialogbox,selectVI»FromTemplate»Simulation»OptimalDesign»ComputeInequalityConstraintsfromtheCreateNewtree.Toseeanexampleofhowtodefineandmanipulatetheseparameters,opentheSIMoptComputeInequalityConstraints(Default)VI,locatedinthelabview\vi.lib\Simulation\OptimizationBasedDesign\Constraintsdirectory.ThisVIimplementstheinequalityconstraintsthepreviousequationsspecified.AfteryousavethecustominequalityconstraintcalculationsasaVI,youmustspecifythelocationofthecustomfunctionintheProblemSpecificationparameteroftheSIMOptimalDesignVI.SelectUserdefinedfortheInequalityconstraintstypeparameterandspecifythepathtotheVIintheFilepathuserdefinedinequalityconstraintspathcontrol.
![Page 90: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/90.jpg)
DefiningParameterBounds(ControlDesignandSimulationModule)Parameterboundsareconstraintsonparametervaluesbeingoptimized.Forexample,whilesearchingforthebestvalueofaspringconstant,youmightknowthatspringsareavailableonlywithcertainphysicalproperties.Inthiscase,youcanspecifythattheparameterkmuststaywithinminimumandmaximumvalues.ParameterboundsareimportantbecausetheseboundsdefinetheparameterspaceinwhichtheSequentialQuadraticProgramming(SQP)algorithmsearchesforoptimalvalues.UsetheParameterBoundsparameteroftheSIMOptimalDesignVItospecifyminimumandmaximumvaluesforeachparameter.
![Page 91: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/91.jpg)
DefiningInitialParameterValuesandaMesh(ControlDesignandSimulationModule)Afteryoudefinetheparameterspaceusingtheminimumandmaximumvaluesofeachparameter,youmustspecifytheinitialvaluesofeachparameter.TheseinitialparametervaluesdeterminewheretheSequentialQuadraticProgramming(SQP)algorithmbeginsthesearchforoptimalvalues.However,ifyouchooseonlyasingleinitialsetofinitialvalues,theSQPalgorithmmightreturnlocaloptimalvalues.Localoptimalvaluesarevaluesthatminimizethecostfunctionwithinonlyasubsetofparameterspace.LocaloptimalvaluesarenotthetruesolutiontotheSQPalgorithmbecausethetrueoptimalvaluesmightexistoutsidetheparameterspacethealgorithmsearched.Tomitigatethisproblem,youcanexecutetheSQPalgorithmseveraltimes,usingadifferentsetofinitialparametervalueseachtime.Ifyouusealargeenoughrangeofinitialparametervalueswithinthegivenparameterspace,youcanberelativelyconfidentthattheSQPalgorithmfindstheglobaloptimalvalues.Youcanimplementthisstrategybydefininganinitialparametersmesh.Theinitialparametersmeshdefinesthedistributionpatternofthesesetsofinitialvaluesandthetotalnumberofinitialvaluesetstogenerate.Youcanchoosefromfourpatternsdependingontheneedsoftheproblem:Uniformgrid,Uniformrandom,Quasirandom,andRandomwalk.Eachpatternhasuniquecharacteristicsandstrengths.Forexample,thesimplestpossibleoptionistheuniformgrid,whichgeneratesaspecifiednumberofequally-spacedlocationsintheparameterspace.However,theuniformrandomandquasirandomoptionsoftenprovidebettercoverageoftheparameterspacewhileusingafewernumberofpointsthantheuniformgridoption.Therandomwalkoptionbiasesthesearchtoexploreclosetotheinitialvaluesbuteventuallyexploresalargerregionofparameterspace.Thisoptionisusefulifyouthinkaparticularparameterspacecontainstheoptimalvaluesandyouwanttofocusonacertainregionofthatspace,suchasthecenter.UsetheInitialParametersparameteroftheSIMOptimalDesignVItospecifyinitialparametervalues.UsetheInitialParametersMeshparameterofthisVItodefineaninitialparametersmesh.
![Page 92: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/92.jpg)
ExecutingtheSQPAlgorithm(ControlDesignandSimulationModule)TheSIMOptimalDesignVIusesaninternalsimulationdiagramtoobtainthefinite-horizontime-domainresponseofthedynamicsystemmodel.UsetheSolverParametersparameterofthisVItoconfigurethesimulation.YoualsocanconfiguretheSequentialQuadraticProgramming(SQP)algorithmusingthebeginningstate,cnosettings,andstoppingcriteriaparameters.ThisVIreturnsthefollowinginformation:
Signals—Thefinite-horizontime-responsedatafortheoutputandcontrolactionofthedynamicsystem,evaluatedateachpointspecifiedintheOptimalparametersarray.Designparameters—Thesetofparametervaluesthatminimizethespecifiedcostfunction.Thesevaluesaretheoptimalparametervalues.Designcost—TheresultofthespecifiedcostfunctionifyouapplythevaluesfromtheDesignparametersarray.Optimalparameters—Alistofpossibleoptimalparametervalues.EachcolumnofthisarraycorrespondstooneparameteryouspecifiedintheParameterBoundsarray.EachrowofthisarraycorrespondstooneexecutionoftheSQPalgorithm.Optimalcosts—TheresultsofthespecifiedcostfunctionthatcorrespondtoeachrowoftheOptimalparametersarray.
TheSQPalgorithmtakesaslongtoexecuteastheproductofthenumberoffunctionevaluationsandtheruntimeofthesimulation.Ifyouspecifyonlyonesetofinitialparametervalues,thealgorithmmustsolve,onaverage,between30and200functions.ThefrontpaneloftheSIMOptimalDesignVIincludesaCurrentDatapagethatyoucanusetomonitortheprogressofthealgorithmastheVIruns.ThispageupdateseachtimetheSQPalgorithmexecutesfromonesetofinitialparametervalues.TheOptimalDesignParameterspageofthisVIalsoincludestheBestParameters(InfeasibleConstraints)andBestcost(Infeasibleconstraints)parameters.Theseparametersreturnoptimalparametervaluesandtheassociatedcostfunctionresultwithnoconstraints.This
![Page 93: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/93.jpg)
informationcanbeusefulwhenrevisingtheconstraintenvelopes.IfthedynamicsystemhasconstraintsandtheSQPalgorithmdoesnotreturnfeasibleoptimalvalues,tryensuringthatthespecifiedcostfunctionremainsconstantwhenparametervaluesareoutsidethefeasiblerange.Thismethodhelpsyousetreasonableparameterbounds.Additionally,reducingsystemdiscontinuitieshelpstheSQPalgorithmexecuteprecisely.Youcanuseseveralmethodstoreducediscontinuities,forexample,avoidingsaturationeffectsandratelimitersinthesystemmodel.
![Page 94: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/94.jpg)
UsingtheSimulationModelConverter(ControlDesignandSimulationModule)YoucanusetheSimulationModelConvertertoconverta.mdlfile,developedinTheMathWorks,Inc.Simulink®simulationenvironment,intoaLabVIEWVIthatconsistsofasimulationdiagramcontainingLabVIEWfunctions,wires,andsimulationsubsystemscorrespondingtothecontentsofthe.mdlfile.Aspartoftheconversionprocess,theSimulationModelConverterusestheMathWorks,Inc.MATLAB®applicationsoftwareandtheSimulinkapplicationsoftwaretocompilethe.mdlfileandexecuteany.mfilesthatyouspecifyinthedialogbox.IftheMATLABsoftwareortheSimulinksoftwareisnotinstalledonthesamecomputerastheLabVIEWControlDesignandSimulationModule,theresultsoftheconversionmightbelessaccurate.
NoteTheSimulationModelConvertercannotconvertdiagramsdevelopedwithTheMathWorks,Inc.Stateflow®applicationsoftwareorotherSimulinkblocksets.
(Windows)Toviewrelatedtopics,clicktheLocatebutton,shownatleft,inthetoolbaratthetopofthiswindow.TheLabVIEWHelphighlightsthistopicintheContentstabsoyoucannavigatetherelatedtopics.
![Page 95: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/95.jpg)
CommonWarnings(ControlDesignandSimulationModule)IftheSimulationModelConvertercannotfindavalueforaparameterinthe.mdlfileitisconverting,LabVIEWdisplaysawarning.Inthesecases,theSimulationModelConverterusesthedefaultvalueoftheparameterinthecorrespondingLabVIEWfunction.
NoteInsomecases,theSimulationModelConvertercannotfindavalueforaparameterbecausetheparametercontainsanexpressioninsteadofaconstantvalue.IftheMathWorks,Inc.MATLAB®softwareisinstalledonthecomputer,theSimulationModelConverterattemptstoevaluatetheMATLABsoftwareexpressionsinthe.mdlfilepriortoconvertingthefile.IftheSimulationModelConvertersuccessfullyevaluatestheexpression,theSimulationModelConverterusestheresultofthatevaluationastheparametervalueanddoesnotproduceawarning.
TheSimulationModelConvertercannotfullyconvertallfunctionsofeverymodeltoLabVIEWblockdiagramcode.IftheSimulationModelConverterencountersablockitcannotconvert,youreceiveawarning.Inthesecases,theSimulationModelConvertercreatesaplaceholdersimulationsubsystem.YoumustcreateasimulationsubsystemusingaLabVIEWVItoaccomplishthesamefunctionalityastheblocktoreplacethisplaceholdersimulationsubsystem.BecauseLabVIEWisstrictaboutdatatypes,theconvertedsimulationsubsystemmighthavebrokenwires.Inthiscase,addblockdiagramcodetoconvertbetweenconverteddatatypes.
![Page 96: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/96.jpg)
UnsupportedBlocks(ControlDesignandSimulationModule)TheSimulationModelConverterdialogboxcannotconvertthefollowingblocksusedinTheMathWorks,IncSimulink®applicationsoftware.Inthesecases,theSimulationModelConvertercreatesaplaceholdersimulationsubsystem.YoumustcreateasimulationsubsystemusingaLabVIEWVItoaccomplishthesamefunctionalityastheblocktoreplacethisplaceholdersimulationsubsystem.
AlgebraicConstraintAtomicSubsystemBand-LimitedWhiteNoiseConfigurableSubsystemEnabledEnabledandTriggeredForSubsystemFromWorkspaceFunction-CallFunction-CallGeneratorIfIfActionSubsystemInterpolation(n-D)usingPreLook-UpLook-UpTable(n-D)MemoryMergeModelInfoPreLook-UpIndexSearchProbeRandomNumberRateTransitionRepeatingSequenceS-FunctionS-FunctionBuilderSwitchCaseActionSubsystem
![Page 97: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/97.jpg)
SwitchCaseToWorkspaceTriggeredWhileIteratorSubsystem
![Page 98: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/98.jpg)
AdditionalImportantInformation(ControlDesignandSimulationModule)TrademarksPatents
![Page 99: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/99.jpg)
TrademarksNationalInstruments,NI,ni.com,andLabVIEWaretrademarksofNationalInstrumentsCorporation.RefertotheTermsofUsesectiononni.com/legalformoreinformationaboutNationalInstrumentstrademarks.MATLAB®,Stateflow®,andSimulink®areregisteredtrademarksofTheMathWorks,Inc.Otherproductandcompanynamesmentionedhereinaretrademarksortradenamesoftheirrespectivecompanies.MembersoftheNationalInstrumentsAlliancePartnerProgramarebusinessentitiesindependentfromNationalInstrumentsandhavenoagency,partnership,orjoint-venturerelationshipwithNationalInstruments.
![Page 100: Control Design and Simulation Module Concept · If you are new to the Control Design and Simulation Module, consider completing the Getting Started with Simulation tutorial. In addition](https://reader034.vdocuments.site/reader034/viewer/2022042104/5e81aa597c3af44c935c8898/html5/thumbnails/100.jpg)
PatentsForpatentscoveringNationalInstrumentsproducts,refertotheappropriatelocation:Help»Patentsinyoursoftware,thepatents.txtfileonyourmedia,orni.com/patents.Youareonlypermittedtousethisproductinaccordancewiththeaccompanyinglicenseagreement.AllrightsnotexpresslygrantedtoyouinthelicenseagreementaccompanyingtheproductarereservedtoNI.Further,andwithoutlimitingtheforgoing,nolicenseoranyrightofanykind(whetherbyexpresslicense,impliedlicense,thedoctrineofexhaustionorotherwise)isgrantedunderanyNIpatents.