ENGR-25_Lec-25_SimuLink-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Engr/Math/Physics 25 Chp10: SimuLink-1
ENGR-25_Lec-25_SimuLink-1.ppt 2 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Learning Goals Implement Mathematical Operations in MATLAB using SimuLink InterConnected Functional Blocks Employ FeedBack in the SimuLink Environment to numerically Solve ODEs Create Simulations of Dynamic Control Systems using SimuLink Block Models Export Simulation result to MATLAB WorkSpace for Further Analysis
ENGR-25_Lec-25_SimuLink-1.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods What is SIMULINK? SIMULINK is a tool for modeling, analyzing, and simulating a wide variety of physical & mathematical systems, including those with nonlinear elements and those which make use of continuous and discrete time Applications Can be found in Dynamic Control Systems, Signal Processing, Communications, and other time-varying systems.
ENGR-25_Lec-25_SimuLink-1.ppt 4 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods More on SimuLink SimuLink is a Graphical Environment where Math Operations are represented by BLOCK Icons Allows for FEEDBACK of Control Vars Since SimuLink is used to Analyze Dynamic (time-varying) Systems, there are many References to the Variable, ‘s‘ s follows from LaPlace Transforms –Studied in 3 rd year courses on Electrical, or Dynamic Mechanical, Systems-Control
ENGR-25_Lec-25_SimuLink-1.ppt 5 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink Some More Since LaPlace Transforms, and Dynamic-System Control Theory are beyond the scope of this Class, we will learn SimuLink by example The Least intuitive Concept Employed will be FEEDBACK The LaPlace Transform
ENGR-25_Lec-25_SimuLink-1.ppt 6 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.2 Solution (book typo) Use FEEDBACK to Find y(t) for ODE
ENGR-25_Lec-25_SimuLink-1.ppt 7 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-1 Fire Up Simulink Library Browser
ENGR-25_Lec-25_SimuLink-1.ppt 8 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-2 Open “Model” Window/File
ENGR-25_Lec-25_SimuLink-1.ppt 9 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-3 The “Untitled” Model” Window
ENGR-25_Lec-25_SimuLink-1.ppt 10 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-4 Select “Sources” Library Drag SineWave icon to Model Window
ENGR-25_Lec-25_SimuLink-1.ppt 11 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-5 DoubleClick SineWave icon to Open Block- Parameters Dialog Box No Changes Needed
ENGR-25_Lec-25_SimuLink-1.ppt 12 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-6 Select “Math Ops” Library Drag Gain icon to Model Window
ENGR-25_Lec-25_SimuLink-1.ppt 13 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-7 DoubleClick Gain icon to Open Block-Parameters Dialog Box Set Gain to 10
ENGR-25_Lec-25_SimuLink-1.ppt 14 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-8 Set IC to Zero Select Continous Library Drag Integrator Block to Model Window 2X-Click the Icon to Open the DiaLog Box Set the IC to Zero
ENGR-25_Lec-25_SimuLink-1.ppt 15 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-9 Select “Sinks”Library Drag Scope Block to Model Window
ENGR-25_Lec-25_SimuLink-1.ppt 16 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-10 CConnect The Block OutPuts & InPuts Turns to Cross when Clik’d
ENGR-25_Lec-25_SimuLink-1.ppt 17 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-11 Open the Config Parameters Dialog Box Set 13s Stop-Time
ENGR-25_Lec-25_SimuLink-1.ppt 18 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-12 Start Simulation Opens the Scope Display Wait for “Bell” to Sound 2X Click Scope Clik Binoc’s to AutoScale
ENGR-25_Lec-25_SimuLink-1.ppt 19 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink-13 Simulation Result
ENGR-25_Lec-25_SimuLink-1.ppt 20 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (1) Export Simulation to WorkSpace for Plotting Add/Subtract icons 2X-Clik “To WorkSpace” icon SINKS Library SOURCES Library SIGNAL ROUTING
ENGR-25_Lec-25_SimuLink-1.ppt 21 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (2) Export Result Plot the Result >> plot(y(:,1),y(:,2)), xlabel('t'), ylabel('y'), grid
ENGR-25_Lec-25_SimuLink-1.ppt 22 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (1) (with a few mods) SimuLink Model for Thus Simulate Integrating, Find Note that the variables are NOT Separable y is on BOTH sides Then The Model
ENGR-25_Lec-25_SimuLink-1.ppt 23 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (2) → Model Parameters Chg to 2
ENGR-25_Lec-25_SimuLink-1.ppt 24 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods (3) → Scope Result (IC=2)
ENGR-25_Lec-25_SimuLink-1.ppt 25 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods (4) → Scope Result (IC=0)
ENGR-25_Lec-25_SimuLink-1.ppt 26 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (5) → OutPut Summary plot(y_of_t(:,1), y_of_t(:,2)),grid ODE Parameters Changed
ENGR-25_Lec-25_SimuLink-1.ppt 27 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (6) → Misc
ENGR-25_Lec-25_SimuLink-1.ppt 28 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink Help
ENGR-25_Lec-25_SimuLink-1.ppt 29 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink Help 3 Choices
ENGR-25_Lec-25_SimuLink-1.ppt 30 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Naming SimuLink Blocks Double-Click on the BlockName PlaceHolder Type in a DESCRIPTIVE Name
ENGR-25_Lec-25_SimuLink-1.ppt 31 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX (1) 10s Simulation 100s Simulation The SimuLink Model
ENGR-25_Lec-25_SimuLink-1.ppt 32 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Caveat: Hidden Functions Many math Functions do NOT have their own block. Instead they “Hide” in a PullDown menu in another icon. Examine Some of These.
ENGR-25_Lec-25_SimuLink-1.ppt 33 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods TRIG Function Pull Down Box On MATH OPRERATIONS can find SIN but not COS or TAN They are HIDDEN in the “TRIG” icon which just happens to have the label SIN –All the other Major Trig Function reside in this block on a pull Down menu Start with Change the Lower Function to COS
ENGR-25_Lec-25_SimuLink-1.ppt 34 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Sin to Cos by PullDown 2X clik the “sin” icon to Reveal PullDown
ENGR-25_Lec-25_SimuLink-1.ppt 35 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Sin to Cos by PullDown Clik on Cos Changes Icon to the Cos Function That was easy Run Sin & Cos
ENGR-25_Lec-25_SimuLink-1.ppt 36 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods All Done for Today Running a House Furnace OOne THERM is a unit of heating equal to 100,000 BTU.
ENGR-25_Lec-25_SimuLink-1.ppt 37 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer Engr/Math/Physics 25 Appendix
ENGR-25_Lec-25_SimuLink-1.ppt 38 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem ThermoStat Control of Bldg Temp TThe Governing ODE AAlso Solve-For, and Plot, T(t) for Given Parameters WWhere did this Eqn Come from?
ENGR-25_Lec-25_SimuLink-1.ppt 39 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (1) RELAY Block Relay Switch output between two constants Library → Discontinuities Relay Parameters
ENGR-25_Lec-25_SimuLink-1.ppt 40 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (2) T-Stat Temp Gain Gain Multiply the input by a constant Library → Math Operations For Case-2 will change Gain to 40 Fnce Gain Parameter for Case-1
ENGR-25_Lec-25_SimuLink-1.ppt 41 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (3) Ambient Temperature Model Sine Wave Generate a sine wave Library → Sources The Input Parameters for Bias Amplitude Frequency
ENGR-25_Lec-25_SimuLink-1.ppt 42 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (4) Sin Fcn Parameters The Summing Node Sum Add or subtract inputs Library → Math Operations
ENGR-25_Lec-25_SimuLink-1.ppt 43 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (6) Sum Parameters 1/RC Gain Block 0.5 per HR COPY the R*qm Gain Block in Model Space and change Parameters
ENGR-25_Lec-25_SimuLink-1.ppt 44 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (7) Now the LaPlace Integrator Integrator Integrate a signal Library → Continuous Integ Parameters
ENGR-25_Lec-25_SimuLink-1.ppt 45 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (8) MUX (Many-to-One) for Ta and T Mux Combine several input signals into a vector or bus output signal Library → Signal Routing MUX Parameters for
ENGR-25_Lec-25_SimuLink-1.ppt 46 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (9) Use ToWorkSpace to Send Ta & T to WorkSpace for Plotting To Workspace Write data to the workspace Library → Sinks The ToWorkSpace Parameters
ENGR-25_Lec-25_SimuLink-1.ppt 47 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (10) Connect the Dots Be sure to Include FeedBack Link to the ThermoStat Scope Added for Diagnostic PurposesBack Link to the ThermoStat
ENGR-25_Lec-25_SimuLink-1.ppt 48 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob (11) Compare Cases Small Furnace Large Furnace
ENGR-25_Lec-25_SimuLink-1.ppt 49 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.15a (12) – Small Fnce % plot(tout, simout), xlabel('t (Hr)'), ylabel('T (°F)'), grid Unstable Inside Temp
ENGR-25_Lec-25_SimuLink-1.ppt 50 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.15a (13) – Large Fnce STABLE Inside Temp
ENGR-25_Lec-25_SimuLink-1.ppt 51 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.15b (14) Part (B) → For Stable Temp Control Find Energy Used The Modify Previous Model Separate Gain Blok R*qm to gain Access to qm Scale qm to get scale comparable to T(t) Copy & Modify Bloks Gain Integrator
ENGR-25_Lec-25_SimuLink-1.ppt 52 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.15b (15) The Energy Integrator Model
ENGR-25_Lec-25_SimuLink-1.ppt 53 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.15b (16) – Energy Use Daily Use = BTU/Day = Therm/Day → 21.7 ¢/Day But This Fnce is Microscopic; My Fnce rating is 80 kBTU/Hr
ENGR-25_Lec-25_SimuLink-1.ppt 54 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 10.2
ENGR-25_Lec-25_SimuLink-1.ppt 55 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 10.2
ENGR-25_Lec-25_SimuLink-1.ppt 56 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods 10.2
ENGR-25_Lec-25_SimuLink-1.ppt 57 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Prob 10.2
ENGR-25_Lec-25_SimuLink-1.ppt 58 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink ↔ ODE45
ENGR-25_Lec-25_SimuLink-1.ppt 59 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
ENGR-25_Lec-25_SimuLink-1.ppt 60 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods SimuLink ↔ ODE45
ENGR-25_Lec-25_SimuLink-1.ppt 61 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem
ENGR-25_Lec-25_SimuLink-1.ppt 62 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem
ENGR-25_Lec-25_SimuLink-1.ppt 63 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Problem
ENGR-25_Lec-25_SimuLink-1.ppt 64 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
ENGR-25_Lec-25_SimuLink-1.ppt 65 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods P10.2 with various forcing fcns
ENGR-25_Lec-25_SimuLink-1.ppt 66 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods mck Exmpl (1) 2X Mass, Spring, Damper System HHow Do x 1 & x 2 respond to the SUDDEN Application of a UNIT Pull (1lb or 1N)? C1C1 C2C2 x1x1 x2x2 f (Pull Force) k1k1 k2k2
ENGR-25_Lec-25_SimuLink-1.ppt 67 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX mck (2) m 1 = 5 m 2 = 3 c 1 = 4 c 2 = 8 k 1 = 1 k 2 = 2 C1C1 C2C2 x1x1 x2x2 f (Pull Force) k1k1 k2k2
ENGR-25_Lec-25_SimuLink-1.ppt 68 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX mck (3) 2X Mass, Spring, Damper System Set Simulation Time and check by 2X click Scope
ENGR-25_Lec-25_SimuLink-1.ppt 69 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX mck (4) Simulation Time = 10s Auto Scaling the Axes Positions have NOT Yet Stabilized Try 100s StopTime
ENGR-25_Lec-25_SimuLink-1.ppt 70 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods EX mck (5) StopTime = 100s Stabilizes after about 25s Use 25s for Stop Final Offsets x 1 = 1.0 x 2 = 1.25
ENGR-25_Lec-25_SimuLink-1.ppt 71 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods P10.2 with various forcing fcns