introduction to hardware-in-the-loop simulation

12
University College of Southeast Norway http://home.hit.no/~hansha Hardware-in-the-Loop Simulation Introduction What is Hardware-in-the-Loop (HIL) Simulation or What is Hardware-in-the-Loop (HIL) Test? The Hardware-in-the-Loop process has existed for no more than 15 to 20 years. Its roots are found in the Aviation industry. The reason the use of a HIL process is becoming more prevalent in all industries is driven by two major factors: time to market and complexity. Hardware-in-the-loop (HIL) simulation is a technique that is used in the development and test of complex process systems. HIL simulation provides an effective platform by adding the complexity of the plant under control to the test platform. The complexity of the plant under control is included in test and development by adding a mathematical representation of all related dynamic systems. These mathematical representations are referred to as the “plant simulation.” Hardware-In-the-Loop is a form of real-time simulation. Hardware-In-the-Loop differs from real-time simulation by the addition of a real component in the loop. This component may be an “Electronic Control Unit” (ECU). The purpose of a Hardware-In-the-Loop system is to provide all of the electrical stimuli needed to fully exercise the ECU. In this way you “fool” the ECU into thinking that it is indeed connected to a real plant. The HIL simulation includes a mathematical model of the process and a hardware device/ECU you want to test, e.g. an industrial PID controller we will use in our example. The hardware device is normally an embedded system. Why use HIL simulation? This question is an important part of understanding real-time technology. To restate the question using a control systems term: Why not connect the embedded system under test to the “real plant”, that is the dynamic system being controlled, to perform development and testing? In many cases, the most effective way to develop an embedded system is to connect the embedded system to the real plant, if such a plant exists. Increasingly however, HIL simulation is more efficient and or required. The main purpose with the HIL Simulation is to test the hardware device on a simulator before we implement it on the real process.

Upload: vuongdat

Post on 01-Jan-2017

226 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: 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.

Page 2: Introduction to Hardware-in-the-Loop Simulation

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

Page 3: Introduction to Hardware-in-the-Loop Simulation

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).

Page 4: Introduction to Hardware-in-the-Loop Simulation

4

IntroductiontoHardware-in-the-LoopSimulation

3. ImplementyourhardwareontheRealProcess(Hardwareonly).IfeverythingisOK,youmaywanttoimplementyourhardwaredeviceintherealenvironmentwhereitmeanttobeused.

ThesetasksfollowthemainideawithaHILsimulation.Firststepistosimulateyoursysteminsoftware.Nextistotestyourhardwareonthesimulatedprocess.Finallyyouimplementyourhardwareontherealsystem.

Page 5: Introduction to Hardware-in-the-Loop Simulation

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”):

Page 6: Introduction to Hardware-in-the-Loop Simulation

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.

Page 7: Introduction to Hardware-in-the-Loop Simulation

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

Page 8: Introduction to Hardware-in-the-Loop Simulation

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

Page 9: Introduction to Hardware-in-the-Loop Simulation

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:

Page 10: Introduction to Hardware-in-the-Loop Simulation

10

IntroductiontoHardware-in-the-LoopSimulation

Results:

Thesimulationresultsbecome:

TheSetPoint(SP)issetonthePXG5PIDcontroller(inthiscase30℃attime𝑡 = 2𝑠).ThesimulationisbasedonPIDparameterssetonthePXG5PIDcontrollerusingthebuilt-inAuto-tuningfunctionalitythatthePXG5PIDcontrollerhas.

Page 11: Introduction to Hardware-in-the-Loop Simulation

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

Page 12: Introduction to Hardware-in-the-Loop Simulation

Hans-PetterHalvorsen,M.Sc.

E-mail:[email protected]

Blog:http://home.hit.no/~hansha/

UniversityCollegeofSoutheastNorway

www.usn.no