Professional Documents
Culture Documents
MATLAB, which stands for MATrix LABoratory, is a technical computing environment for
high-performance numeric computation and visualization.
1. Start Matlab and then the Simulink environment by typing simulink to the matlab
prompter.
Z.K.Nagy Page 1 of 9
Simulink for Control
3. You can construct your block diagram by drag-and-dropping the appropriate blocks from
the main Simulink widow. Some of the most commonly used blocks:
From the “Continuous” blocks (double click on the “Continuous” button) you can use the
typical blocks to construct dynamic systems (e.g. transfer function, time delay, etc.).
Transfer function
Time delay
From the “Sink” we often use the “Scope” block to plot the results.
Plot signal
Z.K.Nagy Page 2 of 9
Simulink for Control
From the “Sources” the “Step” function is used to simulate step changes in the input:
Select “Sources”
“Step” block
From the “Signal Routing” blocks the “Mux” block is often used to concatenate signals into a
“bus” e.g. for plotting multiple signals in “Scope”.
“Mux” block
The “Math Operations” set of blocks provides the usual mathematical operations:
Addition
Z.K.Nagy Page 3 of 9
Simulink for Control
E2 – Step 1. Start the Simulink environment by typing “simulink” to the matlab prompter.
E2 – Step 2. Open a new simulink mode from the File New Model
E2 – Step 3. Drag and drop the blocks below from the Simulink windows into the model
window (select “transfer function” from the “Continuous” group; “Step” from
“Sources”; “Scope” from “Sinks”, “Mux” from “Signal Routing”, etc.)
E2 – Step 4. Double click the blocks the set up different first order transfer functions.
Observe the effect of gain and time constant on the dynamic response of the
system.
(A)
(B)
(C)
E2 – Step 6. INDIVIDUAL EXERCISE – Simulate various first, second and higher order
transfer functions:
1 1 1 1
(a) ; (b) 3 2
; (c) 3 2
; (d); 2
0.1s 1 s s s 1 s 2s 2s 1 s s 1
s 1 s 1 2s 2 3s 1
(e); ; (g) ; (e)
s2 s 1 s2 s 1 s 3 2s 2 2s 1
Z.K.Nagy Page 4 of 9
Simulink for Control
E1 – Step 1. Start the Simulink environment by typing “simulink” to the matlab prompter.
E1 – Step 2. Open a new simulink mode from the File New Model
E1 – Step 3. Drag and drop the blocks below from the Simulink windows into the model
window
E1 – Step 4. Double click the blocks the set up different second order transfer functions.
Define one overdamped, one critically damped and one under damped system.
Z.K.Nagy Page 5 of 9
Simulink for Control
E1 – Step 6. Set the simulation time to 30 sec from the menu “Simulation”
“Configuration parameters”
E1 – Step 7. Simulate the process by pressing the “Run” button and then show the results
by double clicking on the “Scope” block:
Run simulation
Autoscale figure
E1 – Step 8. INDIVIDUAL EXERCISE – Change the form of the transfer function to simulate
(i) an unstable behaviour and (ii) a system at the limit of instability (with sustained
oscillations).
Z.K.Nagy Page 6 of 9
Simulink for Control
EXERCISE 3. Simulate time response of higher order transfer functions based on lower
order transfer function modes
If the poles and zeros of a TF are given a complex transfer function can be simulated as the
combination of the lower order transfer functions, which can be obtained from the poles and
zeros. For example the transfer function below, has the poles -1 and -2 and a zero of 3. By
constructing the block diagram below, show that the series of TFs based on the basic modes
given by the zeros and poles have an identical response with the original TF.
1
G(s ) 2
s 3s 2
By constructing and simulating the block diagram below show that the time response of a
linear (first order system) to a sinusoidal input is a sinusoidal signal with the same frequency
and smaller amplitude. Verify that the amplitude of the output signal decreases when the
frequency of the input signal increases or the time constant of the system increases.
INDIVIDUAL EXERCISE – Analyze the time response of the second order system given
below to an sinusoidal input signal. Show that if the frequency of the input signal equals the
natural frequency of the system the system becomes unstable, whereas for frequencies smaller
or larger than the natural frequency the system is stable. Show that at frequencies close to the
natural frequency the system is stable but exhibits oscillations with amplified amplitude.
1
G(s ) 2
s 1
Z.K.Nagy Page 7 of 9
Simulink for Control
6
Gp (s )
(2s 1)(4s 1)(6s 1)
Tune a PID controller using a practical method and the Ziegler-Nichols tuning rules. The
method is often used in industry because it does not require knowing the process transfer
function.
Zoom buttons
Ultimate period
E5 – Step 4. Determine from the figure the ultimate period (Tu). Use the zoom buttons in the
figure window and obtain the ultimate period (the
time interval for one entire oscillation).
E5 – Step 5. With the ultimate gain and period
determined at steps 3 and 5 compute the parameters
of a PID controller using the ZN tuning rules.
Z.K.Nagy Page 8 of 9
Simulink for Control
EXERCISE 6. PID controller tuning using the Process Reaction Curve based Ziegler
Nichols approximate model approach.
Consider the same system as in EXERCISE 5. We will apply the approximate model based
ZN techniques for the PID controller tuning. According to this approach (see lecture on Topic
13) first an approximate FOPTD representation of the process is identified based on the
process reaction curve and then the PID controller parameters are obtained using the
appropriate ZN tuning rules.
E6 – Step 2. Open the model and change the gain, time constant and time-delays of the
approximate model to obtain a response which is as close as possible to the original process
response. After each change simulate the two systems by pressing the run Button.
E6 – Step 3. Use the effective time constant, effective gain and effective time delay obtained in
Step 2 (which provides the best approximations of the original third order system) and
calculate the PID controller parameters using the ZN tuning rules (lecture – Topic 13, slide
25)
E6 – Step 4. Use the calculated tuning parameters in the block diagram from Exercise 5 to
simulate the closed loop response. Compare the tuning parameters obtained in this case with
those resulted in Exercise 5. Compare the closed loop performance in the two cases.
Z.K.Nagy Page 9 of 9