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.
? 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.
Click this icon
Or 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
- E.g.
- 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. - Double-click to open the Block Parameters
window. - Make sure Amplitude 1, Frequency 1, Phase
0, Sample time 0 - Then click OK.
9Introduction 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)
-
10Introduction to Simulink
- ? Select and place the Scope block from the Sinks
library. - ? connect each input and output port.
11Introduction to Simulink
- ? click on the Simulation menu, and click the
Configuration Parameters item. - click on the solver tab, and enter 13 for
the stop time. - Make sure the Start time is 0.
- (matlab 6.5 click Simulation parameters)
matlab 6.5 Simulation parameters
12Introduction to Simulink
- ? Run the simulation by clicking on the
Simulation menu, - and clicking the Start item.
13Introduction to Simulink
- ? After the simulation, double-click on the Scope
block .
Double-click!
14Linear 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 - E.g.
- Simulink Model of the Two-Mass System
15Linear State-Variable Models
- m15, m23, c14, c28, k11, and k24
- The eq. of motion are
- These equations can be expressed in
state-variable form as
16Linear State-Variable Models
- Vector matrix form
- Initinal condition
17Linear State-Variable Models
- Solution
- ?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
18Linear State-Variable Models
- ?Select and place the State-Space lock. Enter
A,B,C,D. Then enter initial condition. - ?Select and place the Scope block.
- ?connect each port.
19Linear 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
steady-state
20Piecewise-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.
21Piecewise-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.
22Simulink 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
23Simulink Model of a Rocket-Propelled sled
- To obtain ?(t)
- Thus the equation of motion becomes
- The solution is formally given by
24Simulink 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.
25Simulink Model of a Rocket-Propelled sled
- ? Set the Stop time 10, run the simulation, and
examine the result in Scope. - (b)
- ?modify the model as follows.
- ?the Saturation block from the Discontinuities
library. - Upper limit 60pi/180,
- Lower limit0.
- ?mux
mux
Generate the solution when the engine angle ?0.
26Simulink Model of a Rocket-Propelled sled
T0
T?0
27The 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.
28Model of a Relay-Controlled Motor
- The model of an armature-controlled dc motor
29Model 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
30Model of a Relay-Controlled Motor
- Given parameter values
- To examine the speed ? as output, we choose
31Model 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.
32Model 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.
33Model 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.) - ?If you want examine the current i(t), change
the matrix C to 1,0, and run the simulation
again.
Note Connect signal1(first input) to the output
of the Relay block Connect signa2(second input)
to the output of the Disturbance Step
34Model 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.
35Model 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.
Change the matrix C1,0 Current i(t)