Introduction to Hardware-in-the
Transcription
Introduction to Hardware-in-the
UniversityCollegeofSoutheastNorway Hardware-in-the-LoopSimulation Introduction WhatisHardware-in-the-Loop(HIL)SimulationorWhatisHardware-in-the-Loop(HIL)Test? TheHardware-in-the-Loopprocesshasexistedfornomorethan15to20years.Itsrootsare foundintheAviationindustry.ThereasontheuseofaHILprocessisbecomingmore prevalentinallindustriesisdrivenbytwomajorfactors:timetomarketandcomplexity. Hardware-in-the-loop(HIL)simulationisatechniquethatisusedinthedevelopmentand testofcomplexprocesssystems.HILsimulationprovidesaneffectiveplatformbyaddingthe complexityoftheplantundercontroltothetestplatform.Thecomplexityoftheplantunder controlisincludedintestanddevelopmentbyaddingamathematicalrepresentationofall relateddynamicsystems.Thesemathematicalrepresentationsarereferredtoasthe“plant simulation.” Hardware-In-the-Loopisaformofreal-timesimulation.Hardware-In-the-Loopdiffersfrom real-timesimulationbytheadditionofarealcomponentintheloop.Thiscomponentmay bean“ElectronicControlUnit”(ECU). ThepurposeofaHardware-In-the-Loopsystemistoprovidealloftheelectricalstimuli neededtofullyexercisetheECU.Inthiswayyou“fool”theECUintothinkingthatitisindeed connectedtoarealplant. TheHILsimulationincludesamathematicalmodeloftheprocessandahardware device/ECUyouwanttotest,e.g.anindustrialPIDcontrollerwewilluseinourexample.The hardwaredeviceisnormallyanembeddedsystem. WhyuseHILsimulation? Thisquestionisanimportantpartofunderstandingreal-timetechnology.Torestatethe questionusingacontrolsystemsterm:Whynotconnecttheembeddedsystemundertestto the“realplant”,thatisthedynamicsystembeingcontrolled,toperformdevelopmentand testing?Inmanycases,themosteffectivewaytodevelopanembeddedsystemisto connecttheembeddedsystemtotherealplant,ifsuchaplantexists.Increasinglyhowever, HILsimulationismoreefficientandorrequired. ThemainpurposewiththeHILSimulationistotestthehardwaredeviceonasimulator beforeweimplementitontherealprocess. http://home.hit.no/~hansha 2 Themetricofdevelopmentandtestefficiencyistypicallyaformulathatincludesthe followingfactors: • • • Cost Duration Safety Youmaywanttotestthedifferentpartofthesystemindividuallytomakesureitworksas plannedandHILsimulationisimportantindesignandtestingofthedifferentsystems. Itmaybeveryuseful,e.g.,totestacontrollerfunctionwithasimulatedprocessbeforethe controllerisappliedtothereal(physical)process.Ifthemathematicalmodelusedinthe simulatorisanaccuraterepresentationoftherealprocess,youmayeventunethecontroller parameters(e.g.thePIDparameters)usingthesimulator. Itisalsoveryusefulfortrainingpurposes,i.e.,theprocessoperatormaylearnhowthe systemworksandoperatebyusingthehardware-in-the-loopsimulation. AnotherbenefitofHardware-In-the-Loopisthattestingcanbedonewithoutdamaging equipmentorendangeringlives.Forinstance,potentiallydamagingconditionsinanengine, suchasover-temperature,canbesimulatedtotestiftheECUcandetectandreportit. Anotherinstancewouldbeananti-lockbraking(ABS)simulationatperformanceextremes.If simulated,theperformanceoftheABSsystemcanbeevaluatedwithoutrisktothevehicle oroperator. HILshouldbeanintegratedpartofthedesignandtestingcycle. Asthecomplexityofthehardwarebeingcontrolledincreases,sotoodoesthecomplexityof theembeddedsystemthatisdesignedtocontrolthehardware.Hardware-in-the-Loop(HIL) simulationisatechniquethatisusedincreasinglyinthedevelopmentandtestofcomplex real-timeembeddedsystems. ThepurposeofHILsimulationistoprovideaneffectiveplatformfordevelopingandtesting real-timeembeddedsystems,oftenincloseparallelwiththedevelopmentofthehardware. Softwaredevelopmentnolongerneedstowaitforaphysicalplantinordertowriteandtest code. HILsimulationprovidesaneffectiveplatformbyaddingthecomplexityoftheplantunder controltothedevelopmentandtestplatform.Thecomplexityoftheplantundercontrolis includedintestanddevelopmentbyaddingamathematicalrepresentation(model)ofall relateddynamicsystems.Thesemathematicalrepresentationsarereferredtoasthe“plant simulation.” Challenges IntroductiontoHardware-in-the-LoopSimulation 3 Whentesting,wehavelotsofchallenges: • • • • • Costtotest Costoffailure Availability Systemvariation Repeatability Inthesesituations,isHILsimulationapowerfultechnique.WithHILTestingwewillreduce costandrisk. WithHILTestingcostandriskwillbereduced: • • • Increasedreliabilityandquality Moreefficientdevelopment Lowercosttoinnovate Applications EmbeddedControlSystems HILsimulationiswidelyusedindevelopingEmbeddedControlSystems,suchas: • • • • • • • MedicalDevices Industrialmachines PowerGeneration Systems WhiteGoods Aerospace Automotive ProcessControl Procedure ThemainstepsinHILSimulationareasfollows: 1. Developamathematicalmodel.Createamathematicalmodelofthereal environmentwherethehardwaredeviceismeanttobeused. 2. HILSimulation(Software+Hardware).Testyourdeviceonasimulatedprocess (mathematicalmodel). IntroductiontoHardware-in-the-LoopSimulation 4 3. ImplementyourhardwareontheRealProcess(Hardwareonly).IfeverythingisOK, youmaywanttoimplementyourhardwaredeviceintherealenvironmentwhereit meanttobeused. ThesetasksfollowthemainideawithaHILsimulation.Firststepistosimulateyoursystem insoftware.Nextistotestyourhardwareonthesimulatedprocess.Finallyyouimplement yourhardwareontherealsystem. IntroductiontoHardware-in-the-LoopSimulation 5 PracticalExample Introduction Itmaybeveryusefultotestacontrollerfunctionwithasimulatedprocessbeforethe controllerisappliedtothereal(physical)process.Ifthemathematicalmodelusedinthe simulatorisanaccuraterepresentationoftherealprocess,youmayeventunethecontroller parameters(e.g.thePIDparameters)usingthesimulator. Ifthecontrollertobetestedisimplementedinthecontrollerhardware,oftendenotedthe electroniccontrolunit(ECU),andthesimulatorhastoruninrealtime,i.e.thesimulation timedevelopsasrealtime.Thisrealtimesimulationisobtainedbysettingthesimulation algorithmcycletimeequaltothesimulationtimestep. Typically,thesimulatorcommunicateswiththeECUviaordinaryI/O(current,voltage, digital).Suchasystem-wheretherealcontrolleriscontrollingasimulatedprocess-is denotedHardware-in-the-loop(HIL)simulation.HIL-simulationisusedinmanyindustries, e.g.automotiveindustryfortestingclutchautomationsystemsandinmarineandaircraft industrytotestautopilotsofvessels. TheFigurebelowillustratestheprincipleoftestingacontrolsystembyreplacingthephysical system(orprocess)tobecontrolledbyasimulatedsystem.Thecontrollerisassumedtobe aPIDcontroller,butthefigureappliestoanycontrollerfunction. SimulatedProcess Inthisexampleamathematicalmodelofthefollowingsmall-scaleprocessisused(“Air Heater”): IntroductiontoHardware-in-the-LoopSimulation 6 Themathematicalmodelis: 𝑇"#$ = 1 −𝑇"#$ + 𝐾+ 𝑢 𝑡 − 𝜃. + 𝑇/01 𝜃$ Where: • • • • • 𝑢[V]isthecontrolsignaltotheheater. 𝜃$ [s]istime-constant. 𝐾+ [𝑑𝑒𝑔𝐶/𝑉]istheheatergain. 𝜃. [𝑠]isthetime-delayrepresentingairtransportationandsluggishnessinthe heater. 𝑇/01 istheenvironmental(room)temperature.Itisthetemperatureintheoutletair oftheairtubewhenthecontrolsignaltotheheaterhasbeensettozerofor relativelylongtime(someminutes). Hardware ThemainpurposewiththeHILSimulationistotestthehardwaredeviceonasimulator beforeweimplementitontherealprocess. InthisweuseanordinaryindustrialPIDcontroller,suchasFujiPGX5. IntroductiontoHardware-in-the-LoopSimulation 7 WewilltesttheFujiPGX5PIDcontrolleronamodel,andifeverythingisOKwewill implementthecontrollerontherealsystem. WewilluseLabVIEWinordertoimplementtheHILSimulation.LabVIEWisagraphical programminglanguagefromNationInstruments,anditiswellsuitedforsuch implementation. Procedure Theprocedureisasfollows: 4. PIDControlandSimulationinLabVIEW(Softwareonly).Simulatethemodeland implementthebuilt-inPIDcontrollerinLabVIEW.Nohardwareinvolved. 5. ConfiguretheFujiPGX5PIDcontroller(Hardwareonly).Configureandbefamiliar withtheindustrialFujiPGX5PIDcontroller. 6. HILSimulationinLabVIEW(Software+Hardware).TestyourindustrialFujiPGX5PID controlleronyoursimulatedprocess. 7. PIDTuning(Software+Hardware).FindproperPIDparameters,etc.forthe controllerbasedonthemodel. 8. Implementyourhardware,i.e.,theFujiPGX5PIDcontrollerontheRealProcess (Hardwareonly).NowthatyouhavetestedyourFujiPGX5PIDcontrolleronthe IntroductiontoHardware-in-the-LoopSimulation 8 simulatedprocess,it’stimetoimplementitontherealprocess.Fine-tunePID parametersifneccecary. ThesetasksfollowthemainideawithaHILsimulation.Firststepistosimulateyoursystem insoftware.Nextistotestyourhardwareonthesimulatedprocess.Finallyyouimplement yourhardwareontherealsystem. Belowweseethedifferencebetweenatraditionalprocesssystemusingasoftwareprogram forimplementingthecontrolsystemandaHILsimulation. Traditionalprocesssystemusingasoftwareprogramforimplementingthecontrolsystem: InthiscaseyouneedtoscalethevoltagesignalyougetfromtheprocessandtheDAQtoa temperaturevalue(1 − 5𝑉 → 20 − 50℃). HILSimulation: Inthiscaseyouneedtoscalethetemperaturevalueyougetfromthesimulatedprocess beforeyousendthevaluetotheFujiPGX5PIDcontroller(20 − 50℃ → 1 − 5𝑉). HILSimulationinLabVIEW IntroductiontoHardware-in-the-LoopSimulation 9 BelowweseeanexcerptoftheprogramcreatedinLabVIEW: Intheexamplewehaveuseda“SimulationLoop”inLabVIEW,butanordinaryWhileLoop mayalsobeused.ThemodelisimplementedinaSimulationSubsystem. PXG5PID.vi: InsidetheSubVI“PXG5PID.vi”istheI/OfromandtothePXG5PIDcontrollerimplemented usinganordinaryDAQdevice(NIUSB-6008USBDAQdevice),i.e.,thesimulatedprocess valueneedstobesenttothecontrollerandthemanipulatedvaluefromthecontrollerneed tobesenttothesimulatedprocess.ScalingisalsoimplementedinthisSubVI. Belowweseethe“PXG5PID.vi”: MathematicalModel: IntheModel–AirHeater.visimulationsubsystemisthemathematicalmodelimplemented asshownbelow: IntroductiontoHardware-in-the-LoopSimulation 10 Results: Thesimulationresultsbecome: TheSetPoint(SP)issetonthePXG5PIDcontroller(inthiscase30℃attime𝑡 = 2𝑠).The simulationisbasedonPIDparameterssetonthePXG5PIDcontrollerusingthebuilt-inAutotuningfunctionalitythatthePXG5PIDcontrollerhas. IntroductiontoHardware-in-the-LoopSimulation 11 References Thefollowingreferenceshavebeenusedinthisdocument: • NationalInstruments(2011)-http://www.ni.com/hil/ • OPAL-RTTECHNOLOGIES(2011)-http://www.opal-rt.com/about-hardware-in-theloop-and-hardware-in-the-loop-simulation • PrecisionMBA(2011)-http://www.precisionmba.com/hardware_in_the_loop.htm • Wikipedia(2011)-http://en.wikipedia.org/wiki/Hardware-in-the-loop_simulation IntroductiontoHardware-in-the-LoopSimulation Hans-PetterHalvorsen,M.Sc. E-mail:hans.p.halvorsen@hit.no Blog:http://home.hit.no/~hansha/ UniversityCollegeofSoutheastNorway www.usn.no