Title: MATLAB CHAPTER 9 Simulink
1 MATLAB ??CHAPTER 9 Simulink
2Simulation Diagram
- Simulation diagram (block diagram)
- Consider the equation
- ?
- ?
- Simulation diagrams for
3Introduction to Simulink
- Type Simulink
- in the MATLAB
- Command window
- to start window.
Type simulink In the Command Window
? The Simulink Library Browser
4Introduction to Simulink
- Create a new model
- Click on the icon that resembles a clean sheet of
paper, or select New from the File menu in the
Browser.
Or
Click this icon
File ? New
5Introduction to Simulink
- ? Double-click appropriate library.
- ? See a list of blocks within that library.
- ? Click on the block name or icon.
- ? Hold the mouse button, and drag
- it to the new model window.
- ? release the button.
click, hold, drag, and release
6Introduction to Simulink
- ? Use the File menu in the model window to Open,
Close, and Save model files. - ? To print, File ? print
- ? Edit to copy, cut and paste blocks.
- ? you can also use mouse for these operations
7Introduction to Simulink
- Example
- Simulink Solution of
- Use Simulink to solve the following problem for
0 t 13. - The exact solution is
-
8Introduction to Simulink
- ? Start Simulink and open a new model window.
- ? Select and place the Sine Wave block from the
Source library.
9Introduction to Simulink
? Double-click to open the Block Parameters
window. Make sure that Amplitude 1,
Frequency 1, Phase 0, Sample time 0 Then
click OK.
10Introduction to Simulink
- ? Select and place the Gain block from the Math
Operations library. - the Block Parameters window the Gain value
10. - Note that the value 10 then appears in
the triangle. - ? Select and place the Integrator block from the
Continuous library. - Initial condition0 (because y(0)0)
-
11Introduction to Simulink
- ? Select and place the Scope block from the Sinks
library. - ? Connect each input and output port.
12Introduction to Simulink
- ? Click on the Simulation menu, and click the
Configuration Parameters item. - (If you use MATLAB 6.5 or earlier, click
Simulation parameters instead of
Configuration Parameters.) - Click on the solver tab, and enter 13 for
the stop time. - Make sure the Start time is 0.
13Introduction to Simulink
- ? Run the simulation by clicking on the
Simulation menu, - and clicking the Start item.
OR
14Introduction to Simulink
- ? After the simulation, double-click on the Scope
block .
Double-click!
15Linear State-Variable Models
- State-variable models can have more than one
input and more than on output. - Simulink has the State-space block that
represents the linear state-variable model
16Linear State-Variable Models
- Example
- Simulink Model of the Two-Mass System
- m15, m23, c14, c28, k11, and k24
- The equations of motion are
- These equations can be expressed in
state-variable form as
17Linear State-Variable Models
18Linear State-Variable Models
- Initinal conditions
- Output equation
19Linear State-Variable Models
- ?Create a new model window
- ?Select and place the Step block from the Sources
library. - Step time0, Initial and Final values 0 and
1, Sample time0
20Linear State-Variable Models
- ?Select and place the State-Space lock. Enter
A,B,C,D. Then enter initial condition.
21Linear State-Variable Models
- ?Select and place the Scope block.
- ?connect each port.
22Linear State-Variable Models
- ?experiment with different values of the Stop
time until the Scope shows that the steady-state
response has been reached. - Ex) when stop time 25
23Piecewise-Linear Models
- Closed-form solutions are not available for most
nonlinear differential equations, We must solve
such equations numerically. - Ex)
- Piecewise-linear models are actually nonlinear,
although they may appear to be linear. - Ex) a mass attached to a spring and sliding on a
horizontal surface with Coulomb friction.
24Piecewise-Linear Models
- These two equations can be expressed as the
single, nonlinear equation. - Solutions of models that contain piecewise-linear
functions are very tedious to program. However,
Simulink has built-in blocks that represent many
of the commonly-found functions such as Coulomb
friction. Therefore Simulink is especially
useful for such applications. One such block is
the Saturation block in the Discontinuities
library.
25Simulink Model of a Rocket-Propelled sled
- A rocket propelled sled
- Compute the sleds velocity v for 0t6 if v(0)
0 - The rocket thrust is 4000N and the sled mass is
450kg. - The sleds equation of motion is
26Simulink Model of a Rocket-Propelled sled
- To obtain ?(t)
- Thus the equation of motion becomes
- The solution is formally given by
27Simulink Model of a Rocket-Propelled sled
- (a) Create a Simulink model to solve this problem
for 0t10s. - (b) Now suppose that the engine angle is limited
by a mechanical stop to 60 , which is 60p/180
rad. Create a Simulink model to solve the
problem. - Solution
- (a)
- ?create ?(t) by integrating the constant
twice. - ?Constant block from the Sources library.
Constant valuepi/50. - ?Trigonometric block from the Math Operations
library. Functioncos.
28Simulink Model of a Rocket-Propelled sled
- ? Set the Stop time 10, run the simulation, and
examine the result in Scope.
29Simulink Model of a Rocket-Propelled sled
- (b)
- ?modify the model as follows.
- ?the Saturation block from the Discontinuities
library. - Upper limit 60pi/180,
- Lower limit0.
- ?mux
30Simulink Model of a Rocket-Propelled sled
T0
T?0
31The Relay Block
- The Simulink Relay block is an example of
something that is tedious to program in MATLAB
but is easy to implement in Simulink. - A graph of the logic of a relay.
- The relay switches the output between two
specified values, named On and Off in the figure.
32Model of a Relay-Controlled Motor
- The model of an armature-controlled dc motor
33Model of a Relay-Controlled Motor
- x1i, x2?
- R0.6?, L0.002H, KT0.04Nm/A, Ke0.04Vs/rad,
c0.01Nms/rad, and I610(-5)kgm2 - Suppose we have a sensor that measure the motor
speed, and we use the sensors signal to activate
a relay to switch the applied voltage v(t)
between 0 and 100V to keep the speed between 250
and 350rad/s. - SwOff250, SwOn350, Off100, On0
34Model of a Relay-Controlled Motor
- Given parameter values
- To examine the speed ? as output, we choose
35Model of a Relay-Controlled Motor
- ?Create a new Simulink model.
- ?Select and place a Step block from the Sources
library. Label it Disturbance Step. - Step time0.05, Initial and Final time0 and 3,
Sample time0 - ?Select and place a Relay block from the
Discontinuities library. - Switch-on and Switch-off points350 and 250,
- Output when on and Output when off0 and 100.
36Model of a Relay-Controlled Motor
- ?Select and place the Mux block from the signal
Routing library. - Display option to Signals.
- number of input2.
- ?Select and place the State-Space block from the
Continuous library. - enter the A,B,C,D.
- enter 00 for the initial conditoin.
- B tells 2 input, C and D tells 1 output.
37Model of a Relay-Controlled Motor
- ?Select and place the Scope block from the Sinks
library. - ?connect each port.
- ?Stop time0.1 and run the simulation. (the plot
of ?(t) in the scope.)
Note Connect signal1(first input) to the output
of the Relay block Connect signa2(second input)
to the output of the Disturbance Step
38Model of a Relay-Controlled Motor
- Relay logic scheme keeps the speed within the
desired limits of 250 and 350 before the
disturbance torque starts to act. - Speed oscillates.
- When V0, the speed decrease because back emf,
and viscous damping. - The speed drops below 250 when the disturbance
torque starts to act, because the V0. - As soon as the speed drops for the speed to
increase because the motor torque must now work
against the disturbance.
39Model of a Relay-Controlled Motor
- Speed becomes constant
- V100, the system achieves a steady-state
condition in which the motor torque equals the
sum of the disturbance torque and the viscous
damping torque. Thus the acceleration is zero.
40Model of a Relay-Controlled Motor
- ?If you want examine the current i(t), change
the matrix C to 1,0, and run the simulation
again.