710 likes | 847 Vues
Engr/Math/Physics 25. Chp10: SimuLink-1. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. Learning Goals. Implement Mathematical Operations in MATLAB using SimuLink InterConnected Functional Blocks
E N D
Engr/Math/Physics 25 Chp10: SimuLink-1 Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
Learning Goals • Implement Mathematical Operations in MATLAB using SimuLinkInterConnected 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
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.
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 3rd year courses on Electrical, or Dynamic Mechanical, Systems-Control
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
Prob 10.2 Solution (book typo) • Use FEEDBACK to Find y(t) for ODE Time For WhtBd Demo
Fire Up Simulink Library Browser SimuLink-1
Open “Model” Window/File SimuLink-2
The “Untitled” Model” Window SimuLink-3
SimuLink-4 Select “Sources” Library Drag SineWave icon to Model Window
SimuLink-5 No ChangesNeeded DoubleClick SineWave icon to Open Block-Parameters Dialog Box
SimuLink-6 Select “Math Ops” Library Drag Gain icon to Model Window
SimuLink-7 Set Gainto 10 DoubleClick Gain icon to Open Block-Parameters Dialog Box
SimuLink-8 • Select Continous Library • Drag Integrator Block to Model Window • 2X-Click the Icon to Open the DiaLog Box • Set the IC to Zero Set IC to Zero
SimuLink-9 • Select “Sinks”Library • Drag Scope Block to Model Window
SimuLink-10 Turns to Cross when Clik’d • Connect The Block OutPuts & InPuts
SimuLink-11 • Open the Config Parameters Dialog Box • Set 13s Stop-Time
SimuLink-12 • Start Simulation • Opens the Scope Display • Wait for “Bell” to Sound • 2X Click Scope • Clik Binoc’s to AutoScale
SimuLink-13 • Simulation Result
Export Simulation to WorkSpace for Plotting Add/Subtract icons EX 10.2-1 (1) • 2X-Clik “To WorkSpace” icon SIGNALROUTING SOURCES Library SINKS Library
Export Result EX 10.2-1 (2) • Plot the Result >> plot(y(:,1),y(:,2)), xlabel('t'), ylabel('y'), grid
SimuLink Model for EX 10.2-3 (1) (with a few mods) • Thus Simulate • Integrating, Find • Then The Model • Note that the variables are NOT Separable • y is on BOTH sides
EX 10.2-3 (2) → Model Parameters Chg to 2
EX 10.2-3 (5) → OutPut Summary ODE Parameters Changed plot(y_of_t(:,1), y_of_t(:,2)),grid
Naming SimuLink Blocks • Double-Click on the BlockName PlaceHolder • Type in a DESCRIPTIVE Name
EX 10.4-1 (1) • The SimuLink Model • 10s Simulation • 100s Simulation
Caveat: Hidden Functions • Many math Functions do NOT have their own block. Instead they “Hide” in a PullDown menu in another icon. • ExamineSome of These. Time For Live Demo
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
Sin to Cos by PullDown • 2X clik the “sin” icon to Reveal PullDown
Sin to Cos by PullDown • Clik on Cos • Changes Icon to the Cos Function • That was easy • Run Sin & Cos
All Done for Today Running aHouseFurnace • One THERM is a unit of heating equal to 100,000 BTU.
Engr/Math/Physics 25 Appendix Time For Live Demo Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
ThermoStat Control of Bldg Temp Problem 10.15 • The Governing ODE • Also Solve-For, and Plot, T(t) for Given Parameters • Where did this Eqn Come from?
RELAY Block Relay Switch output between two constants Library → Discontinuities Prob 10.15 (1) • Relay Parameters
T-Stat Temp Gain Gain Multiply the input by a constant Library → Math Operations Prob 10.15 (2) • Parameter for Case-1 • For Case-2 will change Gain to 40 • Fnce Gain
Ambient Temperature Model Sine Wave Generate a sine wave Library → Sources Prob 10.15 (3) • The Input Parameters for Bias Amplitude Frequency
Sin Fcn Parameters Prob 10.15 (4) • The Summing Node • Sum Add or subtract inputs • Library → Math Operations
Sum Parameters Prob 10.15 (6) • COPY the R*qm Gain Block in Model Space and change Parameters • 1/RC Gain Block • 0.5 per HR
Now the LaPlace Integrator Integrator Integrate a signal Library → Continuous Prob 10.15 (7) • Integ Parameters
MUX (Many-to-One) for Ta and T Mux Combine several input signals into a vector or bus output signal Library → Signal Routing Prob 10.15 (8) • MUX Parameters for
Use ToWorkSpace to Send Ta & T to WorkSpace for Plotting To Workspace Write data to the workspace Library → Sinks Prob 10.15 (9) • The ToWorkSpace Parameters
Connect the Dots Be sure to Include FeedBack Link to the ThermoStat Prob 10.15 (10) • Scope Added for Diagnostic PurposesBack Link to the ThermoStat
Compare Cases Prob 10.15 (11) • Small Furnace • Large Furnace
Prob 10.15a (12) – Small Fnce % plot(tout, simout), xlabel('t (Hr)'), ylabel('T (°F)'), grid Unstable Inside Temp
Prob 10.15a (13) – Large Fnce STABLEInsideTemp