simulation in labview - overview
TRANSCRIPT
![Page 1: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/1.jpg)
SimulationinLabVIEW
Hans-PetterHalvorsen,M.Sc.
http://home.hit.no/~hansha/?page=labview
withSelf-pacedStep-by-StepExercises
![Page 2: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/2.jpg)
LabVIEWInstallation
Downloadthesoftwarehere:
http://home.hit.no/~hansha/?page=labviewThesearethemainmodulesweuseinthedifferentcoursesatTelemark UniversityCollege:
• LabVIEW (LabVIEW ProfessionalDevelopmentSystem32-Bit:English)
• NI-DAQmx(HardwareDriverforNIUSB-6008,NITC-01,etc.)• LabVIEW ControlDesignandSimulationModule• LabVIEWMathScript RTModuleNote!Thesepackagesareseparate downloads!
Note!YougettheSerialNumber fromyourTeacher,butthesoftwarecanbeused for30daysbeforeyouneed toenteravalidSerialNumber.
AllLabVIEWSoftwarecanbedownloadedhere:www.ni.com/download
![Page 3: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/3.jpg)
LabVIEWTraining
• LabVIEWTrainingforStudents(NationalInstruments):
http://ni.com/students/learnlabview
• LabVIEWCourse:http://home.hit.no/~hansha/?training=labview
Hereyouwillfind lotsofVideos,TutorialsandExercises
Itisrecommendedthatyouwatchsomeofthevideosbeforeyoureadfurter
LearningbyDoing!
![Page 4: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/4.jpg)
Contents• IntroductiontoLabVIEW• Installation• BlockDiagramSimulationbasedondifferentialEquations– SimulationLoop
• PIDControlwithbuilt-inPIDblocks/functions• CreatingandusingSimulationSubsystems• SimulationsusingaWhileLoopwithSubsystemsinside• Discrete Simulation– FormulaNode
• MathScript
![Page 5: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/5.jpg)
NationalInstrumentsisthevendorofLabVIEW
NationalInstrumentscreatesbothHardware andSoftware
![Page 6: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/6.jpg)
Hardware
cRIO
ZigBee
VisionSystem
Arduino
USB-6008
Wi-FiDAQ
TC-01
NOxSensor
Pt-100
AirHeater
WaterTank
![Page 7: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/7.jpg)
DAQmxistheHardwareDriverneeded inorder tousehardwaredevices likeNIUSB-6008,NITC-01,etc.insideLabVIEW.Themoduleisavailableasapaletteonyourblockdiagram.
LabVIEWThisisthecoreLabVIEWinstallationthatinstallstheLabVIEWProgrammingEnvironment.
Thismoduleisatext-based toolthatisverysimilartoMATLAB.Thesyntaxissimilarto MATLAB,youcancreateandrunso-calledmfiles,etc.ThemoduleisavailablefromtheToolsmenuinsideLabVIEW.
LabVIEWMathScriptRTModule
LabVIEWControlDesignandSimulationModuleThismoduleisusedforcreatingControlandSimulationapplicationswithLabVIEW.HereyouwillfindPIDcontrollers,etc.Themoduleisavailableasapaletteonyourblockdiagram.
NI-DAQmx
![Page 8: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/8.jpg)
http://www.ni.com/pdf/manuals/376039a.pdf
Students:TrysomeoftheseShortcutsandTools
![Page 9: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/9.jpg)
ControlandSimulationinLabVIEWControlDesign&SimulationPaletteinLabVIEW
SimulationPaletteinLabVIEW
PIDPaletteinLabVIEW
ControlDesignPaletteinLabVIEW
Students:Checkthatyouhaveallthesepalettes.Openthedifferentsubpalettes,etc.
SimulationLoop
![Page 10: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/10.jpg)
LabVIEWControlandSimulationExample
Wearegoingtolearntocreatesuchasystem(andmuchmore)!
ExampleofSimulation (andcontrol)ofadynamicsystembasedontheblocksintheSimulationPalette
![Page 11: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/11.jpg)
ModellingofDynamicSystems
Hans-PetterHalvorsen,M.Sc.
![Page 12: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/12.jpg)
DynamicSystemsExamplesWaterTank:
MathematicalModels(differentialequations):
AirHeater:
Alt1(Integrator):
Alt2(Timeconstant/1.order):
Alt3(Nonlinear):h– Levelinthetank
T– Temperatureinthetube
Thesearesmall-scaleprocesseswehaveatHiT
![Page 13: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/13.jpg)
DynamicSystemsExamples2Tank:MathematicalModels(differentialequations):
4Tank:
Thesearesmall-scaleprocesseswehaveatHiT
![Page 14: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/14.jpg)
Integratorsymbol
Dynamicsystemrepresentedasadifferentialequation
DynamicSystems
Dynamicsystemrepresentedasablockdiagram
Whenwehavetheblockdiagramforthesystem,wecaneasilyimplement itinLabVIEW
Note Wecan“easily”createablockdiagramfromthedifferentialequation(s)
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 15: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/15.jpg)
BlockDiagramExamples
Students:Findtheblockdiagramsfor thedifferentialequationsabove(pen&paper)
Example1:
Example2:
![Page 16: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/16.jpg)
BlockDiagrams- Solutions
or:
Example1:
Example2:
![Page 17: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/17.jpg)
BlockDiagramExamples
Students:Findtheblockdiagramfor thedifferentialequationabove(pen&paper)
HigherorderdifferentialequationsMass-Spring-DamperExample:
![Page 18: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/18.jpg)
BlockDiagram- SolutionsHigherorderdifferentialequationsMass-Spring-DamperExample:
![Page 19: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/19.jpg)
SimulationTools• MATLAB– Text-basedProgrammingTool– www.mathworks.com
• Simulink– Blockdiagram-basedSimulation,IntegratedwithMATLAB
• LabVIEW• MathScript– UsesMATLABsyntax,IntegratedwithLabVIEW
• Modelica– https://www.modelica.org
• HYSYS– http://www.aspentech.com/products/aspen-hysys.aspx
• ...
![Page 20: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/20.jpg)
SimulationinLabVIEW
Hans-PetterHalvorsen,M.Sc.
![Page 21: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/21.jpg)
SimulationinLabVIEWSimulationPaletteinLabVIEW SimulationLoop:SimilartoaWhileLoop,butcusomized forused
togetherwiththeSimulationBlocksavailableinLabVIEW
DifferentSimulationBlocksbyCategory• Continuous Systems• DiscreteSystems• NonlinearSystems• etc.
http://home.hit.no/%7Efinnh/videos/sim_module/sim_palette_overview/sim_palette_overview.html
SimulationPaletteOverviewVideo(15minutes)
Students:YoushouldwatchthisVideobeforeyougofurther!
![Page 22: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/22.jpg)
SimulationExample
Students: ImplementandSimulatethissysteminLabVIEW
Integratorsymbol
Dynamicsystemrepresentedasadifferentialequation
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 23: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/23.jpg)
SimulationExample- ConfigurationIntheexamplethefollowing simulationparameterscouldbeused(right-clickontheSimulationLoopborderandselect“ConfigureSimulationparameters…”):
![Page 24: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/24.jpg)
SimulationExample- Solutions
StepResponseWeseetheStepResponseisasexpected!
Correctresults? – Checkstaticresponse:
Trywithdifferentvaluesforu
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 25: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/25.jpg)
PIDControlinLabVIEW
Hans-PetterHalvorsen,M.Sc.
![Page 26: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/26.jpg)
ControlSystems
PID Process
Sensor
r e u y
-
Kp Ti Td
v
ExampleofIndustrialControllers
Students:Whatisr,e,u,v,y,Kp,Ti,Td?
TypicalBlockDiagram:
DeltaVPIDController
![Page 27: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/27.jpg)
ControlSystem
PID Process
Sensor
r e u y-
Kp Ti Td
v
r– ReferenceValue,SP(Setpoint),SV(SetValue)y– MeasurementValue(MV),ProcessValue(PV)e– Errorbetweenthereferencevalueandthemeasurementvalue(e=r– y)v– Disturbance,makesitmorecomplicatedtocontroltheprocessKp,Ti,Td– PIDparameters
PIDAlgorithm:
![Page 28: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/28.jpg)
ControlSystemimplementationinLabVIEW
PID Process
Sensor
r e u y-
Kp Ti Td
vControlSystemimplementationwith“Pen&Paper”
Thetransition from“paper”toLabVIEWiseasy,becausetheimplementation isverysimilartothe“paper”version
Herewehaveusedthe“SimulationLoop”
![Page 29: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/29.jpg)
PID Process
Sensor
r e u y-
Controller
Kp Ti Td
v
ControlSystemimplementationinLabVIEW
ControlSystemimplementationwith“Pen&Paper”
Allthisisnormallyincluded inthecontroller
Thetransition from“paper”toLabVIEWiseasy,becausetheimplementation isverysimilartothe“paper”version
HerewehaveusedanordinaryWhileLoop(whichisrecommended!)
![Page 30: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/30.jpg)
PIDControlinLabVIEWPIDPaletteinLabVIEW(PIDToolkit)
Note!Thefunctions“PID.vi”and“PIDAdvanced.vi”requires thatTi andTdareinminutes,whileit’snormal tousesecondsastheunitfortheseparameters.Youcanusethefollowingpieceofcodeinordertotransformthem:ThismeansweentervaluesforTi andTdinsecons ontheFrontPanelandthevaluesareconvertedtominutes inthecode.
Alternative1: Alternative2:
Thisalternativeusesseconds!
![Page 31: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/31.jpg)
LabVIEWPIDExample
Students:Replaceuinthepreviousexamplewiththebuilt-inPIDController (useAlternative2)
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 32: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/32.jpg)
PIDExample- Solutions
FrontPanel:
Students:Findproper𝐾*,𝑇, ,𝑇- Parametersforthissystem.Use“TrialandError”oroneofthemethodsexplainedintheTextBook
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 33: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/33.jpg)
PIDExample- Solutions
BlockDiagram:
Right-click(Configuration) onthePIDblocktoselectKp,Ti,TdasInputs(->Terminals)
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 34: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/34.jpg)
NextStep:Continuous Simulation
Students:ChangeyourSimulationSettingsandRunyourSimulationwiththesechanges
AddaStopButtonanda“HaltSimulation”block
Right-clickontheSimulationLoopborderandselect“ConfigureSimulationParameters…”
Simulation in“RealTime”Inf=Infinite
![Page 35: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/35.jpg)
PIDExample– Continuous Simulation- Solution
TheSimulationnowrunsuntilyoupresstheStopbutton
Students:ExtendtheexamplewithanewChartoftheControlSignal(u)andinclude thereferencesignal(r)intheexistingChart,soyoucaneasilyseethechangesinrandhowthesystemhandleit.
![Page 36: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/36.jpg)
SimulationSubsystems
Hans-PetterHalvorsen,M.Sc.
![Page 37: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/37.jpg)
CreateaSubsystemofthispart(yourprocessmodel)
SimulationSubsystemAWaytostructureyourcode,similartoSubVIs
Students:ChangeyourcodeabovewhereyoucreateaSimulationSubSystemforyourProcess
File->New…
Thisistherecommendedwaytodo it!– Youcaneasly reuseyourSubsystemsindifferentVIsandyourcodebecomesmorestructured!
SelectFile->New...,Thenchoose“SimulationSubsystem”.Copy(ormove) theblockscontainingyourprocessintotheNewVI(SimulationSubsystem)
![Page 38: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/38.jpg)
SimulationSubsystem- Solutions
File->New…
![Page 39: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/39.jpg)
SimulationSubsystem2(PIDController)
CreateaSubsystemofthispart(thePIDcontroller)
Students:ChangeyourcodeabovewhereyoucreateaSimulationSubSystemforthePIDControlleraswell.
![Page 40: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/40.jpg)
SimulationSubsystem– Solutions2
Nowyourcodehasbecomereallysimpletounderstand!
Note!Youmayselectdifferenticonstyle
SimulationSubSystems
![Page 41: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/41.jpg)
SimulationsusingaWhileLoopNote!TheSimulationLoophassomedrawbacks/ismorecomplicatedtousethananordinaryWhileLoop.IfweuseSimulationSubsystems,wecanusetheminsideaWhileLoopinstead!-whichbecomesveryhandy!
Soforrealapplicationsthatinvolvesmorethanjustsimulations(suchasDAQ,FileLogging,PIDcontroloftherealprocess,etc.),IrecommendtouseaWhileLoopinsteadofaSimulationLoop.
SimulationSubsystems
Students:AddyourControllerandProcessSubsystemsinsideaWhileloopasshownabove.Simulatethesystem.Doyougetthesameresults?
![Page 42: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/42.jpg)
DataloggingwithLabVIEW
Hans-PetterHalvorsen,M.Sc.
![Page 43: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/43.jpg)
SaveDatatoFile(Datalogging)
Right-click-Properties
RecommendedSettings
![Page 44: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/44.jpg)
DataloggingExample
![Page 45: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/45.jpg)
Students:(1) LogDatafromyoursystem,i.e.,theControlSignal(u)andtheoutputoftheprocess(y)toa“MeasurementFile”.(2) ThenPlottheDatafromtheFileinExcel.
DataloggingExample– BlockDiagram
![Page 46: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/46.jpg)
DiscreteSystems
Hans-PetterHalvorsen,M.Sc.
![Page 47: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/47.jpg)
ContinuousSignal
DiscretSignal Acomputercanonlydealwithdiscretesignals
k=0,1,2,3,4,....
Ts=SamplingTime
Note!Differentbooksusedifferentnotations WhenTs->0,wehaveacontinuoussignal,
butinacomputerthatisnotpossible.
![Page 48: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/48.jpg)
DiscretizationExample
Inorder tosimulatethissysteminLabVIEWusing theFormulaNodeweneedtofind thediscrete differentialequation.
Giventhefollowingdifferentialequation:
Wecanusee.g.,theEulerApproximation:Ts – SamplingTime
Thenweget:
Thisgivesthefollowingdiscretedifferentialequation:
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 49: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/49.jpg)
FormulaNode/MathScript
Hans-PetterHalvorsen,M.Sc.
![Page 50: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/50.jpg)
FormulaNode&MathScriptNode
MathScriptNode:CreateanduseMathScript/MATLABcodewithinLabVIEW
FormulaNode:CreateanduseCcodewithinLabVIEW
Example:
Veryuseful formathematicalexpressionsandsimulations!
Right-clickon theborder toAdd InputorAddOutput
![Page 51: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/51.jpg)
FormulaNode/MathScriptNode
Students:CreatethisExampleboth inFormulaNodeandinMathScriptNode
Students:TrythisFormulaaswell(both inFormulaNodeandinMathScriptNode):
![Page 52: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/52.jpg)
SimulateDiscrete SystemsusingtheFormulaNodeinLabVIEW
Example
Inorder tosimulatethissysteminLabVIEWusing theFormulaNodeweneedtofind thediscrete differentialequation.
Giventhefollowingdifferentialequation:
WecanusetheEulerApproximation: Ts– SamplingTime
Thenweget:
Thisgivesthefollowingdiscretedifferentialequation:
Students:SimulateandPlotthediscretesystemaboveusingaFormulaNodeandaForLoopinLabVIEW Ts=0.1s
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 53: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/53.jpg)
FormulaNodeinLabVIEW- Solutions
Asexpected,wegetthesameresultsasinthepreviousexampleusingablockdiagramsimulation
Students: Improveyour solutionbycreatingaSubVI ofyourmodel
xk1=(1-a*Ts)*xk + Ts*b*uk;
Discretemodel:
![Page 54: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/54.jpg)
FormulaNodeinLabVIEW– Solutions2
SubVI
MainVI
AdvantagesusingSubVI:• OurMainprogramhasbecomesimplerandeasierto
understandandmaintain• Wecanreuseourmodel inotherapplications• Ifweneedtodochangesinthemodel,weonlydoitonceandin
oneplace!
![Page 55: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/55.jpg)
MathScriptLabVIEWMathScriptRTModule
Add-onModule forLabVIEWwherewecandotext-basedprogrammingandsimulations– verypowerful!
![Page 56: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/56.jpg)
MathScriptSimulationExample
% Simulation of discrete modelclear, clc
% Model Parametersa = 0.25;b = 2;
% Simulation ParametersTs = 0.1; %sTstop = 20; %suk = 1; % Step Responsex(1) = 0;
% Simulationfor k=1:(Tstop/Ts)
x(k+1) = (1-a*Ts).*x(k) + Ts*b*uk;end
% Plot the Simulation Resultsk=0:Ts:Tstop;plot(k,x)grid on
Students:CreateandtesttheMathScriptcode.YoushouldgetthesameresultsasintheLabVIEWExamples
CreatethefollowingcodeintheMathScript“ScriptEditor”
�̇� = −𝑎𝑥 + 𝑏𝑢
![Page 57: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/57.jpg)
MathScriptNodeStudents:TrythesameexampleinsideLabVIEWusingtheMathScriptNode
Justcopyandpastethecodefromthepreviousexample
![Page 58: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/58.jpg)
Hans-PetterHalvorsen,M.Sc.
DoyouneedmorePractice?- SelectaChallenge
![Page 59: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/59.jpg)
Students:SimulatethissystemusingLabVIEW.Plottheposition, speedandtheaccelleration.Testwithdifferentvaluesonm,kandd.
Mass-Spring-DamperSystem
http://www.techteach.no/simview/mass_spring_damper/index.php
![Page 60: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/60.jpg)
AsketchoftheAirHeaterSystem:
AirHeaterOverview
TemperatureMeasurement
AirIn
ControlSignal
Heater
AirOut
TT
AirtubeAirflow
TC
RealAirHeater
![Page 61: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/61.jpg)
InthisassignmentwearegoingtosimulateandcontrolamathematicalmodelofanAirHeatersystem.
Amathematicalmodelofthesystemcouldbe:
Usethefollowing valuesinthesimulations:
Where:
AirHeaterSimulation
Note!YoufindanexampleofhowtodoitinLabVIEWonthenextslides– buttrytosolveitbyyourself first!
![Page 62: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/62.jpg)
ImplementtheHeatermodel inaSimulationSubSystem,asshownbelow:
SeenextslideforFrontPanelexample
AirHeaterSimulationExample
![Page 63: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/63.jpg)
FrontPanelExample:
AirHeaterSimulation
FindProperPI(D)Parameters
![Page 64: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/64.jpg)
AirHeaterSimulationwithMathScript % Simulation of discrete model
clear, clc
% Model Parametersa = 0.25;b = 2;
% Simulation ParametersTs = 0.1; %sTstop = 20; %suk = 1;x(1) = 0;
% Simulationfor k=1:(Tstop/Ts)
x(k+1) = (1-a*Ts).*x(k) + Ts*b*uk;end
% Plot the Simulation Resultsk=0:Ts:Tstop;plot (k, x)grid on
AreyouabletosimulatetheAirHeatermodelusingMathScriptor/andMathScriptNode?
MathScriptSimulationExample
![Page 65: Simulation in LabVIEW - Overview](https://reader031.vdocument.in/reader031/viewer/2022012319/586ba32f1a28abb26b8ba5b0/html5/thumbnails/65.jpg)
Hans-PetterHalvorsen,M.Sc.
UniversityCollegeofSoutheastNorwaywww.usn.no
E-mail:[email protected]:http://home.hit.no/~hansha/