Introduction to Hardware-in-the-Loop Simulation
Transcript of Introduction to Hardware-in-the-Loop Simulation
UniversityCollegeofSoutheastNorway
http://home.hit.no/~hansha
Hardware-in-the-LoopSimulation
Introduction
WhatisHardware-in-the-Loop(HIL)SimulationorWhatisHardware-in-the-Loop(HIL)Test?
TheHardware-in-the-Loopprocesshasexistedfornomorethan15to20years.ItsrootsarefoundintheAviationindustry.ThereasontheuseofaHILprocessisbecomingmoreprevalentinallindustriesisdrivenbytwomajorfactors:timetomarketandcomplexity.
Hardware-in-the-loop(HIL)simulationisatechniquethatisusedinthedevelopmentandtestofcomplexprocesssystems.HILsimulationprovidesaneffectiveplatformbyaddingthecomplexityoftheplantundercontroltothetestplatform.Thecomplexityoftheplantundercontrolisincludedintestanddevelopmentbyaddingamathematicalrepresentationofallrelateddynamicsystems.Thesemathematicalrepresentationsarereferredtoasthe“plantsimulation.”
Hardware-In-the-Loopisaformofreal-timesimulation.Hardware-In-the-Loopdiffersfromreal-timesimulationbytheadditionofarealcomponentintheloop.Thiscomponentmaybean“ElectronicControlUnit”(ECU).
ThepurposeofaHardware-In-the-LoopsystemistoprovidealloftheelectricalstimulineededtofullyexercisetheECU.Inthiswayyou“fool”theECUintothinkingthatitisindeedconnectedtoarealplant.
TheHILsimulationincludesamathematicalmodeloftheprocessandahardwaredevice/ECUyouwanttotest,e.g.anindustrialPIDcontrollerwewilluseinourexample.Thehardwaredeviceisnormallyanembeddedsystem.
WhyuseHILsimulation?
Thisquestionisanimportantpartofunderstandingreal-timetechnology.Torestatethequestionusingacontrolsystemsterm:Whynotconnecttheembeddedsystemundertesttothe“realplant”,thatisthedynamicsystembeingcontrolled,toperformdevelopmentandtesting?Inmanycases,themosteffectivewaytodevelopanembeddedsystemistoconnecttheembeddedsystemtotherealplant,ifsuchaplantexists.Increasinglyhowever,HILsimulationismoreefficientandorrequired.
ThemainpurposewiththeHILSimulationistotestthehardwaredeviceonasimulatorbeforeweimplementitontherealprocess.
2
IntroductiontoHardware-in-the-LoopSimulation
Themetricofdevelopmentandtestefficiencyistypicallyaformulathatincludesthefollowingfactors:
• Cost• Duration• Safety
YoumaywanttotestthedifferentpartofthesystemindividuallytomakesureitworksasplannedandHILsimulationisimportantindesignandtestingofthedifferentsystems.
Itmaybeveryuseful,e.g.,totestacontrollerfunctionwithasimulatedprocessbeforethecontrollerisappliedtothereal(physical)process.Ifthemathematicalmodelusedinthesimulatorisanaccuraterepresentationoftherealprocess,youmayeventunethecontrollerparameters(e.g.thePIDparameters)usingthesimulator.
Itisalsoveryusefulfortrainingpurposes,i.e.,theprocessoperatormaylearnhowthesystemworksandoperatebyusingthehardware-in-the-loopsimulation.
AnotherbenefitofHardware-In-the-Loopisthattestingcanbedonewithoutdamagingequipmentorendangeringlives.Forinstance,potentiallydamagingconditionsinanengine,suchasover-temperature,canbesimulatedtotestiftheECUcandetectandreportit.Anotherinstancewouldbeananti-lockbraking(ABS)simulationatperformanceextremes.Ifsimulated,theperformanceoftheABSsystemcanbeevaluatedwithoutrisktothevehicleoroperator.
HILshouldbeanintegratedpartofthedesignandtestingcycle.
Asthecomplexityofthehardwarebeingcontrolledincreases,sotoodoesthecomplexityoftheembeddedsystemthatisdesignedtocontrolthehardware.Hardware-in-the-Loop(HIL)simulationisatechniquethatisusedincreasinglyinthedevelopmentandtestofcomplexreal-timeembeddedsystems.
ThepurposeofHILsimulationistoprovideaneffectiveplatformfordevelopingandtestingreal-timeembeddedsystems,oftenincloseparallelwiththedevelopmentofthehardware.Softwaredevelopmentnolongerneedstowaitforaphysicalplantinordertowriteandtestcode.
HILsimulationprovidesaneffectiveplatformbyaddingthecomplexityoftheplantundercontroltothedevelopmentandtestplatform.Thecomplexityoftheplantundercontrolisincludedintestanddevelopmentbyaddingamathematicalrepresentation(model)ofallrelateddynamicsystems.Thesemathematicalrepresentationsarereferredtoasthe“plantsimulation.”
Challenges
3
IntroductiontoHardware-in-the-LoopSimulation
Whentesting,wehavelotsofchallenges:
• Costtotest• Costoffailure• Availability• Systemvariation• Repeatability
Inthesesituations,isHILsimulationapowerfultechnique.WithHILTestingwewillreducecostandrisk.
WithHILTestingcostandriskwillbereduced:
• Increasedreliabilityandquality• Moreefficientdevelopment• Lowercosttoinnovate
Applications
EmbeddedControlSystems
HILsimulationiswidelyusedindevelopingEmbeddedControlSystems,suchas:
• MedicalDevices• Industrialmachines• PowerGeneration
Systems• WhiteGoods• Aerospace• Automotive• ProcessControl
Procedure
ThemainstepsinHILSimulationareasfollows:
1. Developamathematicalmodel.Createamathematicalmodeloftherealenvironmentwherethehardwaredeviceismeanttobeused.
2. HILSimulation(Software+Hardware).Testyourdeviceonasimulatedprocess(mathematicalmodel).
4
IntroductiontoHardware-in-the-LoopSimulation
3. ImplementyourhardwareontheRealProcess(Hardwareonly).IfeverythingisOK,youmaywanttoimplementyourhardwaredeviceintherealenvironmentwhereitmeanttobeused.
ThesetasksfollowthemainideawithaHILsimulation.Firststepistosimulateyoursysteminsoftware.Nextistotestyourhardwareonthesimulatedprocess.Finallyyouimplementyourhardwareontherealsystem.
5
IntroductiontoHardware-in-the-LoopSimulation
PracticalExample
Introduction
Itmaybeveryusefultotestacontrollerfunctionwithasimulatedprocessbeforethecontrollerisappliedtothereal(physical)process.Ifthemathematicalmodelusedinthesimulatorisanaccuraterepresentationoftherealprocess,youmayeventunethecontrollerparameters(e.g.thePIDparameters)usingthesimulator.
Ifthecontrollertobetestedisimplementedinthecontrollerhardware,oftendenotedtheelectroniccontrolunit(ECU),andthesimulatorhastoruninrealtime,i.e.thesimulationtimedevelopsasrealtime.Thisrealtimesimulationisobtainedbysettingthesimulationalgorithmcycletimeequaltothesimulationtimestep.
Typically,thesimulatorcommunicateswiththeECUviaordinaryI/O(current,voltage,digital).Suchasystem-wheretherealcontrolleriscontrollingasimulatedprocess-isdenotedHardware-in-the-loop(HIL)simulation.HIL-simulationisusedinmanyindustries,e.g.automotiveindustryfortestingclutchautomationsystemsandinmarineandaircraftindustrytotestautopilotsofvessels.
TheFigurebelowillustratestheprincipleoftestingacontrolsystembyreplacingthephysicalsystem(orprocess)tobecontrolledbyasimulatedsystem.ThecontrollerisassumedtobeaPIDcontroller,butthefigureappliestoanycontrollerfunction.
SimulatedProcess
Inthisexampleamathematicalmodelofthefollowingsmall-scaleprocessisused(“AirHeater”):
6
IntroductiontoHardware-in-the-LoopSimulation
Themathematicalmodelis:
𝑇"#$ =1𝜃$
−𝑇"#$ + 𝐾+𝑢 𝑡 − 𝜃. + 𝑇/01
Where:
• 𝑢[V]isthecontrolsignaltotheheater.• 𝜃$[s]istime-constant.• 𝐾+[𝑑𝑒𝑔𝐶/𝑉]istheheatergain.• 𝜃.[𝑠]isthetime-delayrepresentingairtransportationandsluggishnessinthe
heater.• 𝑇/01istheenvironmental(room)temperature.Itisthetemperatureintheoutletair
oftheairtubewhenthecontrolsignaltotheheaterhasbeensettozeroforrelativelylongtime(someminutes).
Hardware
ThemainpurposewiththeHILSimulationistotestthehardwaredeviceonasimulatorbeforeweimplementitontherealprocess.
InthisweuseanordinaryindustrialPIDcontroller,suchasFujiPGX5.
7
IntroductiontoHardware-in-the-LoopSimulation
WewilltesttheFujiPGX5PIDcontrolleronamodel,andifeverythingisOKwewillimplementthecontrollerontherealsystem.
WewilluseLabVIEWinordertoimplementtheHILSimulation.LabVIEWisagraphicalprogramminglanguagefromNationInstruments,anditiswellsuitedforsuchimplementation.
Procedure
Theprocedureisasfollows:
4. PIDControlandSimulationinLabVIEW(Softwareonly).Simulatethemodelandimplementthebuilt-inPIDcontrollerinLabVIEW.Nohardwareinvolved.
5. ConfiguretheFujiPGX5PIDcontroller(Hardwareonly).ConfigureandbefamiliarwiththeindustrialFujiPGX5PIDcontroller.
6. HILSimulationinLabVIEW(Software+Hardware).TestyourindustrialFujiPGX5PIDcontrolleronyoursimulatedprocess.
7. PIDTuning(Software+Hardware).FindproperPIDparameters,etc.forthecontrollerbasedonthemodel.
8. Implementyourhardware,i.e.,theFujiPGX5PIDcontrollerontheRealProcess(Hardwareonly).NowthatyouhavetestedyourFujiPGX5PIDcontrolleronthe
8
IntroductiontoHardware-in-the-LoopSimulation
simulatedprocess,it’stimetoimplementitontherealprocess.Fine-tunePIDparametersifneccecary.
ThesetasksfollowthemainideawithaHILsimulation.Firststepistosimulateyoursysteminsoftware.Nextistotestyourhardwareonthesimulatedprocess.Finallyyouimplementyourhardwareontherealsystem.
BelowweseethedifferencebetweenatraditionalprocesssystemusingasoftwareprogramforimplementingthecontrolsystemandaHILsimulation.
Traditionalprocesssystemusingasoftwareprogramforimplementingthecontrolsystem:
InthiscaseyouneedtoscalethevoltagesignalyougetfromtheprocessandtheDAQtoatemperaturevalue(1 − 5𝑉 → 20 − 50℃).
HILSimulation:
InthiscaseyouneedtoscalethetemperaturevalueyougetfromthesimulatedprocessbeforeyousendthevaluetotheFujiPGX5PIDcontroller(20 − 50℃ → 1 − 5𝑉).
HILSimulationinLabVIEW
9
IntroductiontoHardware-in-the-LoopSimulation
BelowweseeanexcerptoftheprogramcreatedinLabVIEW:
Intheexamplewehaveuseda“SimulationLoop”inLabVIEW,butanordinaryWhileLoopmayalsobeused.ThemodelisimplementedinaSimulationSubsystem.
PXG5PID.vi:
InsidetheSubVI“PXG5PID.vi”istheI/OfromandtothePXG5PIDcontrollerimplementedusinganordinaryDAQdevice(NIUSB-6008USBDAQdevice),i.e.,thesimulatedprocessvalueneedstobesenttothecontrollerandthemanipulatedvaluefromthecontrollerneedtobesenttothesimulatedprocess.ScalingisalsoimplementedinthisSubVI.
Belowweseethe“PXG5PID.vi”:
MathematicalModel:
IntheModel–AirHeater.visimulationsubsystemisthemathematicalmodelimplementedasshownbelow:
10
IntroductiontoHardware-in-the-LoopSimulation
Results:
Thesimulationresultsbecome:
TheSetPoint(SP)issetonthePXG5PIDcontroller(inthiscase30℃attime𝑡 = 2𝑠).ThesimulationisbasedonPIDparameterssetonthePXG5PIDcontrollerusingthebuilt-inAuto-tuningfunctionalitythatthePXG5PIDcontrollerhas.
11
IntroductiontoHardware-in-the-LoopSimulation
ReferencesThefollowingreferenceshavebeenusedinthisdocument:
• NationalInstruments(2011)-http://www.ni.com/hil/
• OPAL-RTTECHNOLOGIES(2011)-http://www.opal-rt.com/about-hardware-in-the-loop-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
Hans-PetterHalvorsen,M.Sc.
E-mail:[email protected]
Blog:http://home.hit.no/~hansha/
UniversityCollegeofSoutheastNorway
www.usn.no