CEN456 Notes
CEN456 Notes
CEN 456
Digital Control Lab.
Version II
Contents:
References:
- MATLAB ver.6.5. The math Works. Inc.
- SIMULINK 3. : Dynamic system simulation for MATLAB. The Math Works, Inc.
- Kuo, B. C. “ Digital control systems”, P. H., 1997.
- Franklin, G. F. , Powell, J. D. and Workman, M. L. “ Digital control of dynamic
systems” Addison-Wesley, 1996.
- Dorf, R. C. and Bishop, R. H. “ Modern control systems” Addison-Wesley, 1998
Simulation With
MATLAB & SIMULINK
1- Introduction to SIMULINK
SIMULINK (formally SIMULAB) is a software package for modeling, simulating and
analyzing dynamical systems and is an extension of MATLAB. SIMULINK differs from
MATLAB in that it has a windows-based (using block diagrams) graphical user interface. It
also adds much functionality to MATLAB.
It supports linear and nonlinear systems, modeled in continuous time, sampled time, or a
hybrid of the two. Systems can be also multi-rate, i.e., have different parts that are sampled or
updated at different rates.
For modeling, a graphical user interface (GUI) is used for building models as block diagrams,
using click-and-drag mouse operations. With this interface, you can draw the models just as
you would with pencil and paper (or as most textbooks depict them). This is a far from
previous simulation packages that require you to formulate differential equations and
difference library of sinks, sources, linear and nonlinear components, and connectors. You can
also customize and create your own blocks.
Models are hierarchical, so you can build models using both top-down and bottom-up
approaches. You can view the system at a high-level, then double-click on blocks to go down
through the levels to see increasing levels of model details. This approach provides insight into
how a model is organized and how its parts interact.
After you define a model, you can simulate it, using a choice of integration methods, either
from the SIMULINK menus or by entering commands in MATLAB’s command window. The
menus are particularly convenient for interactive work, while the command-line approach is
very useful for running a batch of simulations (for example, if you are doing Monte Carlo
simulations or want to sweep a parameter across a range of values). Using scopes and other
display blocks, you can see the simulation results while the simulation is running. In addition,
you can change parameters and immediately see what happens, for “what if” exploration. The
simulation results can be put in the MATLAB workspace for post processing and visualization.
Model analysis tools include linearization and trimming tools, which can be accessed from the
MATLAB command line, plus the many tools in MATLAB and its application toolboxes. And
because MATLAB and SIMULINK are integrated, you can simulate, analyze, and revise your
models in either environment at any point.
This tutorial presents some basic steps in using SIMULINK.
Most of the block types that you need to build a block diagram are already available in this
library. All you need to do is to pick the blocks you need, connect them together and set their
parameters. The main block look like:
1
Constant
Signal Step Ramp Sine Wave Repeating Discrete Pulse Pulse Chirp Signal
Generator Sequence Generator Generator
12:34 [T,U]
untitled.mat
Clock
Digital Clock From Uniform Random Band-Limited
From File Random
Workspace Number White Noise
Number
0 simout STOP
untitled.mat
Scope XY Graph Display To File To Workspace Stop Simulation
Abs TrigonometricMath Rounding MinMax Product Combinatorial Logical Relational Sign Rate LimiterSaturation
Function Function Function Logic Operator Operator
f(u)
Quantizer Coulomb & Backlash Dead Zone Look-Up Look-Up Memory Transport Variable
Hit Fcn
Viscous Friction Table Table (2-D) Delay Transport Delay
Crossing
MATLAB
Function system Solve
f (z) z
f(z) = 0
MATLAB Fcn S-Function Switch Relay
Manual Switch Algebraic Constraint
Multiport
Switch
A new window will appear on the screen. You will be constructing your model in this window.
Also in this window the constructed model is simulated. A screenshot of a typical working
(model) window that looks like one shown below:
Now you may begin to construct your model. To become familarized with the structure and the
environment of Simulink, you are encouraged to explore the toolboxes and scan their contents.
You may not know what they are all about but prehaps you could catch on the organization of
these toolboxes according to the category. For instant, you may see Control System Toolbox to
consist of the Linear Time Invariant (LTI) system library and the MATLAB functions can be
found under Function and Tables of the Simulink main toolbox. A good way to learn Simulink
(and MATLAB or computer programs/packages in general) is to practice and explore. Making
mistakes and know how to correct the mistakes is also a way to learn.
A simple model is used here to introduce some basic features of Simulink. Follow the steps
below to construct a simple model.
STEP 1: CREATING BLOCKS: Open (Expand) the Simulink toolbox by clicking on the + sign
infront of the Simulink entry in the Simulink Library Browser. Further expand Sources sub-
library. You should see a Sine Wave entry in the list of sources as show in the screenshot
below.
Mouse action: Click on the Sine Wave block to select and drag it to the model Window as
shown:
Now you have established a source of your model. In similar fashion, create additional blocks
in your model window.
NOTE: It is advisable that you save your model at some point early on so that if your PC
crashes (runing MATLAB under Linux OS is much more stable!) you don' t loose so much
time to reconstruct your model.
I am going to save this model under the filename: "simexample1". To save a model, go to the
pulldown File menu in the model window and select Save As. A extension named ".mdl" will
be automatically appended to the filename (just enter the filename). Simulink will recognize
file with .mdl extension as a simulation model (similar to how MATLAB recognizes files with
the extension .m as an MFile).
Continue to build your model by adding more components (or blocks) to your model window.
We' ll continue to add a scope from Sinks library, an Integrator block from Continuous library,
and a Mux block from Signals & Systems library. Once all the blocks are dragged over to the
model window, you would have a window that looks like one shown below.
You may remove a block that you don' t want by clicking on the block to turn it to the select
mode (with four squares at the corners) and use the DEL key or keys combination CTRL-X
(control key and X key at the same time) to remove the block. For example, say that I want to
change my mind and want to use repeating pattern or sequence as the source instead of sine
wave. I simply select the Sine Wave block and do a CTRL-X to remove it then do a click-n-
drag on the Repeating Sequence block.
Note that if the derivative of the signal can be obtained using the Derivative block instead of
the Integrator block. The result would be
as expected.
The above steps demonstrated some basic functions and structure of Simulink. It is strongly
recommended that you take some time to explore the toolboxes and familiarize yourself with
the parameters associated with each block. To view/edit the parameters, simply double click on
the block of interest.
Annotations
To add an annotation to your model, place the cursor at an unoccupied area in your model
window and double click on the left mouse button. A small rectangular area will appear with a
cursor prompting for your input.
To delete an annotation, hold down the SHIFT key while selecting the annotation, then press
the DELETE or BACKSPACE key. You may also change font type and color from the
FORMAT menu.
Some Examples
Example 1. Simulation of an Equation.
In this example we will use Simulink to model an equation. Consider the equation given by:
where the displacement x is a function of time t, frequency w, phase angle ϕ, and amplitude A.
In this example the values for these parameters are set as follows: frequency=5 rad/sec;
phase=pi/2;A=2.
1. From Simulink'
s library drag the following blocks to the model window
Figure E1-1
3. Double click on the blocks and enter the appropriate values as prompted by the pop-up
dialog windows. Note that the cosine function can be selected from the pull-down
menu in the pop-up window. In the arrangement shown above, the input signal (a ramp
function) is to be displayed along with the output (displacement) via the use of the mux
tool as demonstrated earlier in this tutorial. To view the plots, double click on the
scope.
4. Make sure all blocks are connected correctly then run the simulation (CTRL+T). You
may need to select the Autoscale button on the scope display window to obtain a
better display of the plots.
You may find the sinusoidal plots to be a bit "jaggy". You may want to improve the
resolution of the displayed plot by redefining the Max Step Side value ("auto" is set a
default value) in Simulation Parameters window (with keystrokes CTRL+E in the model
window). Just for fun, you may want to experiement with different choice of solver.
ODE45 is a default choice. You are encouraged to learn more about the solver methods by
checking out the help files in Matlab command window. For instance, help ODE45 for
parameters in non-stiff differential equations.
This example has demonstrated the use Simulink with built-in mathematical functions and
other supporting toolboxes to simulate an equation. The same output/result can also be
obtained with the following set of instructions entered in Matlab command window:
>>t=(0:.01:10);A=2;phi=pi/2;omega=5;
>>xt=A*cos(omega*t+phi);
>> plot(t,xt);grid
Consider a mass-spring-dashpot system as shown in Figure E2-1. The mathematical model for
this system is described by:
m x + c x + k x = f (t ) (2)
where m is the equivalent mass of the system, c is the damping ratio, k is the spring stiffness,
and f(t) is the forcing function in the x-direction. Where m is the equivalent mass of the system,
c is the damping ratio, k is the spring stiffness, and f(t) is the forcing function in the x-
direction.
In Simulink, create a new model window (CTRL+N) and drag the following blocks from the
Simulink library window
S
T
E
P
1
Blocks to be Where located in Simulink
dragged to the library browser
model window
Step Sources
Gain Math
Sum Math
Integrator Continuous
Scope Sinks
To Workspace Sinks
SBy re-arrange Eqn 2 to yield an expression for the acceleration term as:
T
E 1
P x(t ) = ( f (t ) − c x − k x ) (3)
m
2 Based on Eqn 3, we connect the blocks in the diagram as shown in Figure E2-2. Use
CTRL+F and CTRL+R to flip and rotate the blocks as necessary (select the block first
then execute the key sequence). Note that you can use CTRL+right mouse button to
create branches of the connecting lines. Don' t worry about the parameter values and the
signs for these blocks at this point as we'
ll take care of this in STEP 3. Just get them
connected first.
Figure E2-2
SEnter the values of the parameters for each block. In this example, we will set m = 2.0;
Tc=0.7; k=1. You are encouraged to try different values and observe the system' s
Eresponse to step input.
PTo show that you may obtain different form of output, I included another block (in
addition to the scope block) called "simout". This block can be found in the Sinks
3group from the Simulink Library browser. The output from this block is used in Matlab
workspace. To illustrate how this block works, I will select a name for the output called
"simout" as the variable name in the block' s parameter setting (double click on the
"simput" block to bring up the parameter dialog window). In additon, I will need a time
array from the simulation. This can be specifed as a parameter in the Simulation
Parameter window (CTRL+E) under the Workspace I/O tab as shown in Figure E2-3.
Figure E2-3
SRun the simulation by clicking on the button (alternately you may use keyboard
Tcommand CTRL+T ). The screenshot of the output from the Scope block is show in
EFigure E2-3.
P
Figure E2-3
That's it! You have successfully modeled and simulated a second-order under-damped
dynamic system. To exam different responses, please feel free to change different
values for m, c, and k in the gain blocks.
To see how you can use the output from the "simout" block (by the way, you may
name the block whatever you wish), go to Matlab Command window and type:
>> who
You should receive an echo from Matlab listing the following variables: "simout" and
"time" (and perhaps others variables in the current workspace memory).
Now, you may create a plot of the system response identical to that shown in the Scope
output. The command for creating this plot is:
>>plot(time,simout);grid
Note that the outout format used in the example above is matrix type. The output sent
to workspace can be used for further analysis and storage in ascii format. Output to
workspace allows more options in plot presentation and further data analysis as the
arrays are in ascii format.
Example 3. Using the same system presented in Example 2, we will simulate the response
using transfer function block (frequency domain). This example will illustrate an alternate
approach to one shown above.
S
T
In a new Simulink model window, drag the following blocks from the Simulink library
E
window: Step (from Sources), Transfer Function (from Continuous), Scope (from
P
Sinks), and Save File to Workspace (from Sinks).
1
SArrange the blocks as shown in Figure E3-1 below.
T
E
P
Figure E3-1
Figure E3-2
Double click on the Save Output To A File block to open the dialog window as shown
in Figure E3-3. In the Filename box specify the path and the name of the file you wish
to save. The saved file will be in .MAT format (yes, it' s in binary format! So don' t try
to read it). You will be able to load this file to Matlab workspace later on. Make sure to
remember where you save the file to. In this example, I' ll put the file in my D drive
under "temp" directory and name the file "example3out.mat". You may choose other
convenient location on your computer.
In the Variable name box, enter a name of your choice. Here I name the variable
"simout".
Leave other parameters in defaut settings unless you wish to obtain more plot points by
changing the Sample Time setting.
Figure E3-3
SRun the simulation by clicking on the button (alternately you may use keyboard
Tcommand CTRL+T ). The screenshot of the output from the Scope block is show in
EFigure E3-4.
P
Figure E3-4
Now by comparing Figure E2-3 and Figure E3-4 you will see that the reponses are
identical. No surprise here since Figure E3-1 effectively performs the same simulation
as thatcarried out in Figure E2-2, only with fewer number of blocks!
Use the load command to "import" the save *.mat file generated from the simulation.
Note: In this example, I set the path to the directory where the file "example3out.mat"
is saved. If you do not set the path in Matlab, you have to specify the full path in the
load command,e.g.,
>>load D:/temp/example3out.mat .
You may want to verify the loading by asking Matlab to list all of the variables in the
current workspace:
>> who
If the loading is successful, you should see the variable you specified earlier listed the
current workspace. In this example, Matlab echos:
To generate a plot of the step input response from the simulation, simply use the plot
command on "simout" matrix. For this example, the following command produces the
>> plot(simout(1,:),simout(2,:));grid
Figure E3-5
Example 4: Consider the double integrator system G(s), which is open, loop unstable. To
stabilize this plant, we use a lead compensator, K(s), as shown in figure 1.
K(s) G(s)
1 s +1
with: G ( s) = ; K ( s) = 10 .
s 2
s+5
Our goal is to obtain the step response of this system. We will use nine objects in this diagram:
two transfer functions, one summing junction, one gain, one clock (time), one input source
(step), and three objects for viewing the output and the control signal.
Input source elements are located in the SOURCES library. Double click this library to open
its window and note its contents. We are interested in the step fcn source. To select this block,
put the mouse cursor on it, click and hold the mouse while you drag the object into your
working window.
The transfer function, summing junction and gain blocks are located in the linear library. Open
the linear library (by double clicking on it). Drag the transfer fcn block into your working
window. Repeat this step for the second transfer function; also drag the sum and the gain.
Close the linear library.
The simulation output and the control signal are obtained using the sinks library. Open this
library and you will see that there are six objects available. The scope acts as an oscilloscope
and gives you a live display of any signal during the simulation. To Workspace block passes
the output vectors to the MATLAB workspace as matrices. This allows you to analyze and plot
your data using MATLAB. The To file block passes the data to a file and saves then under a
given name. Drag three workspace blocks to your working window. Close the sinks library.
You should have now nine blocks in your working window. The next step after block selecting
is setting the block parameters. If you double click on any block a window open to show the
parameters of that block. The window displays brief information on that block. A help option
is also available for more detailed information. Most blocks have default parameters that can
be changed.
Open one of the transfer function block (double click on it). There are two fill-in boxes for
Numerator and Denominator. Enter [1 1] and [1 5] in these boxes respectively. Select ok. Open
the second function and enter [1] and [1 0 0] and select ok. Open the gain block and enter 10
and select ok. Open the sum block and enter +- for the list of signs. If the summing element
has more than two inputs, simply enter all their signs. The block will expand to accommodate
all the inputs.
Open the step fnc block. There are three fill-in boxes. The step time is the initial starting time
for the step function (enter 0). Enter the initial value and the final value (0 and 1) respectively.
Open the To workspace blocks, enter different variable names y for the output, u for the
control signal and t for the time.
The final step in model building is connecting the blocks. All blocks, with the exception of
sources and sinks blocks have at least one angle bracket (>) pointing out of them. This is their
output port. They also an angle bracket pointing toward them, which is their input port. The
sources blocks have no inputs, so they only have output ports. Similarly, the sinks blocks only
have input ports. Multiples input port blocks (e.g sum or Mux blocks) have more than one
input port.
To connect two blocks, click on the output port of one block, drag the mouse to the input port
of the other block, and release the mouse button. The angle brackets will disappear, and a line
(with an arrowhead) will be drawn, making the connection. As you move the mouse up or
down, the line will be drawn in multiples of 45 degrees. To draw a line at any angle, hold the
right and the left buttons together while you drag the mouse. Use the above procedure to
connect all the blocks of you working window.
The block diagram is complete now.
t
Clock To Workspace
s+1 1
10 y
Step s+5 s2
Sum Gain To Workspace1
Transfer Fcn Transfer Fcn1
To Workspace2
You can embellish it by going to the style menu and change the screen color, background
color, fonts drop shadows around blocks, etc.. If you click the title of a block, it will be
highlighted and you can type in a new name. From the option menu, you can also flip and
rotate the blocks.
The final step is simulation. This is done from the Simulation menu. There are two items to
choose. You can either select Start to start the simulation, or you can set the simulation
parameters to open the seven integration algorithms. For linear system choose Linsim and for
nonlinear system choose ODE45( Dormand-Prince). Enter 0 for the start time, 10 for stop time,
0.001 for relative error, 0.1 for the minimum step size, and 0.1 for the maximum step size.
Select ok to leave the dialog box.
Now select start from the simulation menu. You will hear a beep when the simulation is
finished. To view the results of this simulation, you type MATLAB’s statements below:
the ouput-response
1.5
0.5
0
0 1 2 3 4 5 6 7 8 9 10
-5
0 1 2 3 4 5 6 7 8 9 10
Time(s)
In this part, we use commands both from Matlab and from the Control Systems Toolbox, as
well as some commands/functions, which we wrote ourselves. For more information on
writing Matlab functions, see the function page.
Command Description
Abs Absolute value
acker Compute the K matrix to place the poles of A-BK, see also place
Axis Set the scale of the current plot, see also plot, figure
Bode Draw the Bode plot, see also logspace, margin, nyquist1
c2dm Continuous system to discrete system
clf Clear figure (use clg in Matlab 3.5)
Conv Convolution (useful for multiplying polynomials), see also deconv
Ctrb The controllability matrix, see also obsv
deconv Deconvolution and polynomial division, see also conv
det Find the determinant of a matrix
dimpulse Impulse response of discrete-time linear systems, see also dstep
Dlqr Linear-quadratic regulator design for discrete-time systems, see also lqr
Dlsim Simulation of discrete-time linear systems, see also lsim
Dstep Step response of discrete-time linear systems, see also stairs
eig Compute the eigenvalues of a matrix
eps Matlab'
s numerical tolerance
feedback Feedback connection of two systems.
figure Create a new figure or redefine the current figure, see also subplot, axis
for For, next loop
format Number format (significant digits, exponents)
function Create function m-files
grid Draw the grid lines on the current plot
Gtext Add a piece of text to the current plot, see also text
help HELP!
hold Hold the current graph, see also figure
if Conditionally execute statements
Imag Return the imaginary part of a complex number, see also real
impulse Impulse response of continuous-time linear systems, see also step, lsim, dlsim
input Prompt for user input
1- Exercises
Exercise No2: Analyze the response (plot x(t)) of the system described by the equation:
.
x = −x + x 2
Hint: The system is stable with respect to origin if x(0) < 1 .
x = − 1 + sin 2 ( x) x . ( )
and plot the solution of this nonlinear differential equation with x(0)=10.
Hint: Use just one Integrator block and just one Fcn block.
Exercise No 4: The level control of a Tank may be done by two-position controller (use rely).
In this case a very easy model is the following:
Where h(t) is the Tank level and href is the reference level. Analyze the behavior of the
system, for different values of Umax and Umin (10,-10; 10,0; 5,-5) and for different values of
ε(0.01;0.1 ;0.2), both with respect to time and in the phase plane. Plot h(t) and u(t) for
different values of ε.
Hint: Use the relay block.
Exercise No5: Using MATLAB and SMULINK, plot the unit step response for the systems
represented by:
s+3 s + 2.5 s + 2.1
a- G1 ( s) = b- G2 ( s) = c- G3 ( s) =
(
(s + 2) s 2 + 3s + 10 ) (
(s + 2) s 2 + 3s + 10 ) (
(s + 2) s 2 + 3s + 10 )
s + 2.01 s +1
d- G4 ( s) = e- G5 ( s) =
(
(s + 2) s 2 + 3s + 10 ) (
(s + 2) s 2 + 3s + 10 ).
• From the plot determine %OS, Ts, Tr and Tp.
• Find (use ≠ formula) %OS, Ts, Tr and Tp for the system (d).
• Find the response that is close to the system represented by (d)? Comment?
Exercise No.6: Using MATLAB, sketch the root locus and find the range of stability for the
unit feedback systems:
a- G1( s) =
k (s + 3)
b- G2 ( s) =
(
k s 2 − 2s + 2 )
(s + 1)(s + 2)(s + 3) s (s + 2 )(s + 2 )
In the marginally stable case, find (by hand) the frequency of oscillation and all poles of the
system?
Exercise No.7 Consider the temperature control system for a chemical process:
Chemical heat
Process
Amplifier Actuator and valve
Desired Temperatue
1 0.7
PID K Temperature
s+0.4 s2 +1.7s+0.25
Step PID Controller Gain Transfer Fcn2 To Workspace
Transfer Fcn1
Temperature Sensor
0.5
s+0.5
The uncompensated system is operating with a rise time approximately the same as a
second order system with a peak time of seconds?? and 5% overshoot. There is also
considerable steady state error. Design a PID controller so that the compensated system
will have a rise time approximately equivalent to a second order system with a peak time 8
seconds and 5% overshoot and zero steady state error for a step input.
Exercise No 8: Use the Routh-Hurwitz criterion and the unity feedback of the system
modeled by:
K
G (s) =
s(s + 2 )(s + 4 )(s + 6 )
• Find the range of K for stability ( 0< K < Kmax).
• Find the value of K for marginal stability.
• Find the actual location of the closed loop poles when the system is marginally
stable.
• Plot the response of the closed loop system when K=Kmax/2 and K=Kmax.
where M is the mass, b is the damper, k is spring, x (t) is the position of the cart
and F(t) is the force applied to the system.
System 2:
- Mathematical model: If the inertia of the wheels is neglected, and it’s assumed that
the friction is opposing the motion of the car, then using Newton’s law, the model of
this system is:
mv+bv = u
where: m=1000kg; b=50 Nsec/m and u=500N.
y=v
NB: When you adjust the integral gain Ki, we suggest to start with a small value since large Ki
most likely unstabilizes the response.
Set the frequency of the sine wave to 10Hz and vary the sampling period of the zero Order
Hold from Ts=0.1s , 0.2s, 0.3s, 0.4, 0.5s.
Plot the response for each sampling period and comment the results?
Hint: simulation is from 0 to 2s.
+ D(s) G(s)
-
1 s+2
Where G ( s) = and D( s) = 70 .
s (s + 1) s + 10
1. Analyze the open loop system (without controller)
2. Plot the step response and determine the performance achieved by the controller in
closed loop (%OS, Tr, Ts , ess).
3. Find a Digital* controller D(z) to implement the lead compensator D(s). Use the
sample rate 20Hz and 40 Hz.
4. Compare the step responses of the digitally controlled system with the step
response of continuous controlled system.
u (k + 1) − u (k )
*Hint: Use Euler’s method to approximate the continuous controller u ≈ and
Ts
de e(k + 1) − e( k )
≈ where Ts is the sampling period.
dt Ts
4- Control of DC Motor
A common actuator used in control systems is DC motor. The electric circuit of the
armature and the free body diagram of the rotor are shown in the following figure:
Design requirement:
Position Control: Speed Control:
- Settling time less than 2s. -Settling time less than 40ms
- Overshoot less than 5%. - Overshoot less than 16%
- No steady state error. - No steady state error
a- If the position θ is the output and the voltage V is the input, find the transfer function.
b- Use the second Ziegler-Nichols tuning method to design a continuous PID controller.
c- If the speed θ is the output and the voltage V is the input, find the transfer function.
d- Design a continuous P controller to have 10% of overshoot.
e- Use the Bilinear transformation to design a digital controller from the continuous
controller obtained in (b and d). Discuss the instability phenomena and how you can
compensate it.
f- Compare all results (control signal and the output response by using SIMULINK).
Change the control parameters (b & d) to achieve the performance specified to position
control and speed control.
Note: The second method of Ziegler and Nichols tuning of P.I.D regulators is based on
evaluating the system at the limit of stability. The proportional gain is increased until you
observe oscillations, that is, until the system becomes marginally stable. The corresponding
gain Ku (ultimate gain) and the period of oscillation Tu (ultimate period) are determined
from the response.
Then for the continuous system, the controller parameters are taken:
Kp= 0.6 Ku; Ti=0.5 Tu and Td=0.125 Tu , and the transfer function of the PID controller
is :
1
D ( s ) = K p (1 + + Td s) .
Ti s
Mathematical model:
The dynamic equation of motion of the cart in the horizontal direction is given by:
The second equation of motion, i.e sum of the torques, is given by:
As the global system is nonlinear, this set of equations should be linearized about θ ≈ π + φ ,
where φ represents a small change in the pendulum’s position.
For this section, we will assume that the system starts at equilibrium point, and experiences an
impulse force F=1N. The pendulum should return to its upright position within 5 seconds, and
never move more than 0.05 rad away from the vertical. Thus, the design requirements for this
system are:
- Settling time less than 5 seconds
- Pendulum angle never more than 0.05 rad from the vertical.
b- Draw the system’s response to an impulse force applied to the cart. Create
the MATLAB m. file for the linear system and use SIMULINK for the
nonlinear system. Comment the result.
The control of this problem is a little different than the standard control problems, since
you are trying to control the pendulum’s position, witch should return to the vertical after the
initial disturbance. The reference signal you are taking should be zero. The force applied to the
cart can be added as an impulse disturbance. The schematic for this problem should look like
the following:
y ( s)
c- Find the transfer function closed loop system ( ).
F ( s)
d- Determine the PID controller D(s) to meet the design requirements. Draw
the response of the closed loop system by MATLAB statements.
e- Implement the above controller in closed loop with the nonlinear system by
using SIMULINK. Draw the position of the pendulum and the control signal
u(t).
g- Assume that the closed-loop bandwidth frequencies are around 1 rad/sec for
both cart and pendulum. Let the sampling time to be 1/100. Determine a
Digital controller that maintains the specified performance. Draw the
position θ(t) of the linear system (MATLAB statements) and of the
nonlinear system (SIMULINK).
h- Use the TUSTIN Transformation to design the digital controller from the
analog controller obtained in (d). Draw the position θ(t) of the linear system
(MATLAB statements) and of the nonlinear system (SIMULINK).
Part II
HARD EXPERIMENTS
Introduction :
The objective of any automation is to be able to efficiently and reliably control the behavior of
the process.. Temperature systems are widely used in real life as in industrial applications,
domestic domain (home, office) , medical and biological process engineering
Since a model is a mathematical relation that describes the behavior of the process and
forecasts the reaction to the system to certain environmental influence. The dynamic model of
the temperature process can be described by the transfer function:
K
G ( s) = e −L s
1+τ s
where K is the DC gain defined as the ratio of output voltage to input voltage.
y (∞ )
K=
u (∞ )
τ : time constant when the output reaches 63% of the final value.
L : velocity lag (time delay) as shown in Figure below:
A- Transient Response:
Experimentation Instructions:
- Set-up the experimental arrangement according to the plug-in diagram shown in Figure
1
- Set the flap to 2-division scale and the motor potentiometer to 2 div.
- Connect the Cassy Interface to temperature process as shown in Figure 1 :
Y X C B
CASSY
C should be connected to X
Figure .1
Different steps:
Switch on the computer:
1-C:\CBC-8-2\start
2- Ok
3- Set up/ Disturbance Var…/ Channel X / Quiescent level=0 and Disturbance level = set point
(8V)
4- Time scale / Screen Sweep 120
5-Operation / Step responses.
To print the Figure: File / print.
From the transient response deduce the transfer function of the temperature system.
Identify the steady state gain, the time constant and time delay.
Use the SIMULINK package to check the behavior of the temperature process model
(transfer function).
B- Two-position controller:
The previous experiment emphasized the basic concepts of the temperature process. This
experiment will introduce the idea of closed loop control. The only control objective that we
will try to meet is maintaining the output temperature at a reference value (just like the way
our heaters at home work).
There are many controllers that could be used to perform the task. They differ in
simplicity and configuration.
In this part, the two-position controller is introduced as the regulator. This controller will
recognize only two states and will have only two actions: On or OFF.
Figure 2.
The controller that we will study can have hysteresis effects, by examining the block
diagram, we can easily deduce that:
e(t) = r(t) – y(t)
If there is no switching hesteresis (h = 0), the two stales of the controller are:
e>0 u : ON
e<0 u : OFF
However, if there is switching hysertersis h, the two states:
e>h u : ON
e<h u : OFF
B-1 Simulation:
- According to the block diagram given in figure 2, use the two-position controller
(Relay in Simulink) with the hysteresis (0, ±0.5 and ±2) and the reference U=6V. Plot
the output and control signal. Deduce the frequency of the control signal. Comment
your results.
B-2 Experiment:
Connect the cassy interface to the two-position controller (X) and then to the temperature
process (sensor). Connect the feedback path from the output (sensor) to the input of the
controller (-).
1) Setting fan potentiometer to 2-scale division and the flap to 2-scale.
2) Set the reference to 6 V.
3) Repeat the question B-1 by using the Leybold two-position controller.
4) Plot the control signal and deduce the frequency of the control signal.
5) Discuss the effects of the hysteresis on the output and control signal.
6) Compare the experimental and simulation results.
NB. Always allow the system to level down to room temperature before starting.
C- PID- Controller:
So far, a simple control technique has been evaluated: the two-position control. This part will
introduce another type of controller; which is called PID (Proportional, Integral and
Derivative). This control approach is one of the oldest and most popular techniques used in the
industry, because it is simple and effective.
Figure 3 shows a block diagram of this control.
+ e PID u G(s)
Output
Reference (r) Temperature (y)
Figure 3
Output response
10
Ref
9 Output
0
0 20 40 60 80 100 120
Time(s)
A linearized quantitative version of this model can be obtained with an open-loop experiment,
by using the following procedure:
1. With the plant in open loop, take the plant manually to a normal operation point.
Assume that the plant output settles at y (t ) = y 0 for a constant input u (t ) = u 0 .
2. At an initial time t 0 , apply a step change to the plant input, from u 0 to u ∞ (this should
be in the range 10 to 20 % of full scale).
3. Record the plant output until it settles to the new operating point. Assume that you
obtain the curve shown in figure **. This curve is known the process reaction curve.
In this figure m.s.t stands for maximum slope tangent.
4. Compute the parameters model as follows:
y − y0
K= ∞ ; L = t1 − t 0 and τ = t 2 − t1 .
u∞ − u0
Use the figure obtained in part A to calculate the transfer function by the strategy given
above.
By using this transfer function, Simulate the output response (SIMULINK) and
compare the result with the figure obtained in part A.
The model obtained (transfer function) can be used to derive various tuning methods for PID
controllers. Cohen and Coon proposed one of these methods. The suggested parameters are
shown in table 1.
Kp Tr Td
P τ L
1+
KL 3τ
PI τ L 30 τ + 3 L
0.9 + L
KL 12 τ 9τ + 20 L
PID τ 4 L 32 τ + 6 L 4τ L
+ L
K L 3 4τ 13τ + 8 L 11τ + 2 L
Kp de(t )
u PID = K p e(t ) + e(s ) ds + K p Td
Tr dt
Simulate the model obtained in closed loop with PID deduced from Cohen and
Coon method. Comment your results.
Experiment:
The connection for this experiment is given below Figure 4:
- Set the flap and ventilation pot to div 2.
- The PID deduced from Cohen and Coon method will be implemented.
Different steps:
Switch on the computer:
1-C:\ CBC-8-2\start
2- Ok
3- Set up/ Disturbance Var …/ Channel X / Quiescent level=0 and Disturbance level= set
point(6V)
U (s) KI KD s2 + KP s + KI
. = Kp + + KDs =
E (s) s s
- Kp = proportional gain.
- KI = integral gain.
- KD = derivative gain.
Therefore the PID generates a control action u(t) as a function of the error e(t) given by:
de(t )
u (t ) = K p e(t ) + K D + K I e(τ ) dτ
dt
where Kp , KI, and KD are chosen depending on the process to be controlled.
By trial and error try to chose Kp, KI and Kd to provide the best possible performance for the
temperature process. Note that you have to use the table given in the next page.
Experiment:
The connection for this experiment is given below Figure 4:
- Set the flap and ventilation pot to div 2.
Different steps:
Switch on the computer:
1-C:\ CBC-8-2\start
2- Ok
3- Set up/ Disturbance Var …/ Channel X / Quiescent level=0 and Disturbance level= set
point(6V)
4- Time scale/ Screen Sweep 120,
5- Controller Type / PID (Parallel Configuration),
6- Parameter (set parameter values of Kp, Kd and KI),
5-Operation / Snap shot,
To print the Figure: File / print
Y X C B
CASSY
C should be connected to X
Figure 4
Plot and evaluate the response in terms of speed, steady state error, overshoot ect…
Effect of KP,KI,and KD :
A proportional controller (Kp) will have the effect of reducing the rise time and will
reduce ,but never eliminate, the steady-state error. An integral control (Ki) will have the effect
of eliminating the steady-state error, but it may make the transient response worse . A
derivative control (Kd) will have the effect of increasing the stability of the system, reducing
the overshoot, and improving the transient response. Effects of each of controllers Kp, Kd, and
Ki on a closed-loop system are summarized in the table shown below:
Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent
of each other. In fact, changing one, of these variables can change the effect of the other two.
For this reason, the table should only be used as a reference when you are determining the
values for Ki, Kp and Kd.
SIMULATION: Check the behavior of the temperature model (Transfer function) closed by
the previous PID controller. Comment your results.
A-Transient response:
Arrange the experimentation devices according to the connecting diagram given in figure 5:
- The input voltage = 8V, the time scale=120s and pot=6.
- Recording the transient behavior with the following adjustments:
a. The submersible tube (sensor) in the first position:
i. Slide 0 in position 1 &5,
ii. Slide 0 in position 1 &4.
b. The submersible tube in the second position:
i. Slide 4 in position 2 and slide 0 in position 5,
ii. Slide 4 (use 2nd aperture from below, close all others) in position 3 and
slide 0 in position 1 &5.
c. The submersible tube in the first position:
i. Slide 2 in position 5, Slide 0 in position 1,
ii. Slide 1 in position 5, slide 4 (use the 2nd aperture from below and close
all others) in position 3 and slide 0 in position 1.
d. The submersible tube in the second position:
i. Slide 2 in position 5, Slide 0 in position 1,
ii. Slide 1 in position 5, slide 4 (use the 2nd aperture from below and close
all others) in position 3 and slide 0 in position 1.
Figure 5
Evaluation:
- For each case, find the transfer function of the open loop system.
- Discuss the effect of the position of slides and sensor on the transient response of
system.
Given these informations, the mass balance of the tank can be written as:
d (ρ A h )
= ρ Qin − ρ Qout
dt
Since there is no heating effect, density can be assumed constant. Also, since the tank is
cylindrical, it has constant cross-section area. Therefore, the differential equation (*) becomes:
ρ A dh dh
= ρ Qin − ρ Qout or A = Qin − Qout
dt dt
Note that the flow out Qout, is determined by the pressure exerted by the liquid, and it is
given by: Qout = k h .
B- Two-position controller
1- SIMULATION:
For each transfer function given above, use the two-position controller (see par B-1 in the
previous experiment) with hysteresis (0 , ±0.5, and ±2) in closed loop with water level
model.
Plot the output and the control signal.
Comment your results.
2- EXPERIMENT:
For the case A-3-b, connect the Leybold two-position controller to the water level system.
Two-position Process
Controller Amp. Sensor
X C B
Cassy Interface.
Plot The response and the control signal for the hysteresis (0 , ±0.5, and ±2).
Discuss the effects on the output and the control signal action. Compare the experimental
and simulation results.
3-a Experimentation:
Connecting Diagram:
CASSY - SYSTEM
C Controller Y Process
C Amp. Sensor
B
X B
Figure 8.
In the case 3-b, design a PID controller to maintain the level of the water around 80%. The
objectives to be met are:
- Fast response,
- Small steady state error,
- Little or no oscillation (Note: Oscillation destroy the pump in the long run!).
By trial to changing the effect of KP , KI and KD to provide the “Best” possible
performance for the Water level . Plot the final response and the reference input.
Plot the final response, the control signal and the reference input.
3-b SIMULATION:
- Use the SIMULINK to check the behavior of the Water Process model closed by
previous PID controller.
- Plot the level, the control signal and the reference input.
- Compare the experimental and simulation response.
Introduction:
The MIC957 Traffic Lights Model is a working mimic diagram of the traffic and
pedestrian control lamp signals at a crossroads with one pedestrian crossing. It is designed to
be controlled by any of a range of microcomputers for the purpose of providing exercises in
the use of computer to monitor and control objects.
In this experiment, three exercises presented start at the simplest possible level, while the third
imposes a requirement for a degree of logical thinking.
System Description:
MIC957 Traffic Lights Modeling, which there is some buttons and set of, colored
lamp(figure 9):
• Three lamps for north –south.
• Three lamps for east –west.
• Two lamps for pedestrian crossing.
• These lamps are controlled by one bit of a single 8 bits output port as in the
Table [1].
• Five pushbuttons that may be passed to simulate the detection of vehicle by any
of four traffic sensors as shown below.
Figure 9.
Table [1]:
Experimentation Instructions:
1-All sequences:
Fill the sub-sequences (address) in the table given below by using the data given in
table 1. Write a C program that alters all these sequences.
Table [2]:
It is required to allow vehicles to travel alternatively along the north south and east west
roads. If however a pedestrian processes the request button by the crossing, the normal
sequence should proceed until the south road lights return to read and the pedestrian crossing
should change to green and back to red before the normal sequence is assumed as shown in
Table [2]. Finally write and test a program, which implements your algorithm.
In this exercise all input signals will be used. Let us call them requests. It is required to control
the traffic lights according to the following rules:
1- Every change in the lights must follow one of the sub-sequences 0 to 3, 4 to 7 or 8 to
11 listed in the table 2, subject to control by the requests received as follows.
2- A light, one it is at green, will remain so at least for normal period stated in the table 2.
Thereafter, it will remain green unless or until a request has been received for some
other light.
3- If requests are received for both of the other lights, then they will be served according
to the sequence of table 2.
4- Every request must be stored until it is cancelled. Cancellation takes place then the
corresponding light goes green. Further requests for a light that is already green are
ignored.
5- And West request are treated as equivalent, North and South requests are treated as
equivalent.
4- PC Temperature Controller
Introduction:
The MIC 955 computer application module is designed for practical exercises in the use of a
microcomputer in:
1- Digital temperature measurement control of electrical power formation of simple
closed control loop.
2- The MIC 955 is one of the Feedback MICA series of modules and interfaces for
computer applications.
3- Interfaces for computer Applications. Modules in the range may be used in conjunction
with a variety of computers for which MIC940 series interfaces are available.
The MIC955 module comprises a panel carrying a heated strip of black anodized aluminum
and a cooling fan. The strip carries two resistors, which serves as a heater, and etched platinum
strip resistor, which serves as a temperature sensor. Associated electronics are mounted on the
printed wiring board at the back.
The heater resistor are supplied with power controlled by the microcomputer’s output port,
buffered by a power amplifier, whose output may be monitored at the heater monitor socket on
the panel.
The cooling fan may be controlled in either of two ways, selected by a three-position
‘programmed – off- manual’. In the programmed condition power to the motor is switched on
or off by another bit (B5) of the computer’s output port, again acting through a buffer
amplifier. In the manual condition a variable resistor whose knob is labeled “Blower speed”
may control the blower speed. The maximum fan speed in this condition is less than the
maximum under program control, this is by design.
The temperature sensor is connected in a DC bridge circuit. Its output is amplified and the
amplifier output is balanced to zero at 0’C, the sensitivity being 20mV/C at the temperature
monitor’s socket on the panel. The analogue signal is connected to analogue-to-digital (ADC)
converter in this module, so that a digital signal is made available to the associated
microcomputer. The ADC operates when instructed to do so by a computer signal via an
output port, it then places an 8 bits number on the input port so that the computer may read the
number, which is a measure of the temperature at the sensor.
Technical Data:
The module uses the following power supplies: +12V at about 1.2 A -12V a few mA.
Black: 0V common
Red: +12V,
Orange: +5V if required,
Blue: -12V.
Block – Diagram
A0
Port A A1
Port and bit allocations for communication between the microcomputer and the module are as
follows:
Table 3:
Bit Port A, Input Port B, Output
0 (LSB) ADC output, bit 0 (LSB)
1 ADC output, bit 1
2 ADC output, bit 2
3 ADC output, bit 3
4 ADC output, bit 4
5 ADC output, bit 5 Fan Command (On=1,Off=0)
6 ADC output, bit 6 Heater Command (On=1,Off=0)
7 (MSB) ADC output, bit 7 (MSB) Start ADC command
Note: In order to trigger ADC, bit 7 of port B must be given a negative pulse, which may be
generated by the binary sequence 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 .
Objective:
This experiment is required to cycle the temperature between limits, which are specified by
entries from the keyboard, using the heater to raise the temperature and the fan when the temperature is
to be lowered. The temperature should be displayed.
Thus, the data requirements include the two temperature limits, the data handled and the
signals, which control the heater and fan. In detail therefore the data is:
• Input:
High temperature limit to be entered from keyboard low temperature limit to be
entered from keyboard ADC data byte read by the microcomputer' s input port.
• Output:
ADC trigger bit [B7] (most significant bit of MIC955 control byte, Port B), the heater
switch bit [B6] port B .The fan switch bit [B5] port B.
When the temperature is superior to the maximum, the fan turn ON and heater turn OFF
until the temperature decreases to minimum then the heater turn ON and the fan turn off.
If the temperature is between maximum and minimum, then both the fan and the heater are
switched on.
Program Algorithm:
START
Initialize ports
Read Temperature
T>Max
Heater OFF
Fan ON
T<Min
Annex –1:
Program structure:
To initialize the port A as input to the PC and port B as the output, use:
OUTPORTB (0x0303, 0x99);
The address of the port A is 0x0300;
The address of the port B is: 0x0301,
Acquisition statements:
- To input data from port A: INPORTB (0x0300).
- To output data XX to port B OUTPORTB (0x0301, XX).
Library:
# include <dos.h>
# include <conio.h>
# include <stdio.h>
# include < bios.h>
main()
{
Data declarations: int x j i, char y, z[10]={……,…..,….,…..,..}
Initializations: j=0 ; i=2,
Outportb (0x0303, 0x99);
Clrscd( );
Printf(“\ …………”);
X=atoi(gets(y));
While ( bioskey(1)==0)
{……
…
…
…
}
}.
To trigger the ADC :
outportb(0x0301,k|0x80);
delay(100);
outportb(0x0301,k&0x7f);
delay(100);
outportb(0x0301,k|0x80);
delay(100);
Objectives:
1. To investigate the motor characteristic and determine the transfer function of the motor.
2. To implement Two-position and PID controller to improve the steady state
performance.
Apparatus:
1. DC servo system,
2. Personnel computer,
3. Cassy data acquisition system,
4. Printer.
Theoretical background:
Direct-Current (DC) motors are one of the most widely used prime movers in industry
today. Years ago a majority of small servomotors used for control purposes were of the AC
variety. In reality, AC motors are more difficult to control, especially for position control, and
their characteristic are quite nonlinear, which makes the analytical task more difficult. DC
motors, on the other hand, are more expensive, because of the brushes and commutators, and
variable-flux DC motors are suitable only for certain types of control applications.
The DC motor is basically a torque transducer that converts electric energy into mechanical
energy. The torque developed on the motor shaft is directly proportional to the field flux and
the armature current. The relationship is given by:
Tm = K m Φ i a
where Tm is the torque (Nm), Φ is the magnetic flux (Webers), ia is the armature current (A)
and Km is a proportional constant.
eb = K m Φ Ω m
where eb denotes the back-emf (V), and Ωm is the shaft velocity (rad/s) of the motor.
Starting with the control input voltage V(t), the cause and effect equations for the motor
circuit are:
d i a (t ) 1 R 1
= V (t ) − i a (t ) − eb (t )
dt L L L
Tm = K i i a (t )
dθ(t )
eb (t ) = K b = K b Ω(t )
dt
d 2 θ(t ) 1 1 B dθ(t )
2
= Tm (t ) − TL (t ) −
dt J J J dt
where TL represents a load frictional torque.
The transfer function between the motor displacements θ(t) and the input voltage V(t) is:
θ( s ) Ki
=
V ( s ) L J s + (R J + B L ) s 2 + (K b K i + R B ) s
3
and between the speed Ω(t) and the input voltage V(t) :
Ω( s ) Ki
=
V ( s ) L J s + ( R J + B L ) s + (K b K i + R B )
2
Note that, if the armature current inductance is neglected (L → 0), the transfer function
becomes:
Ω( s ) Ki Km
= =
V ( s ) R J s + K b K i + R B 1 + Tm s
Ki RJ
where K m = and Tm = .
Kb Ki + R B Kb Ki + R B
This is a first order system.
DC Tach
X Motor o
Amp
Cassy C
System
B
Fig.2
1-a Experiment:
1- Mount the servo amplifier, power supply and motor on the base board as shown
in figure 2. and 3.
2- Set the input from the data acquisition system as a step of 8 V.
3- Connect the output from the tacho to the input channel (B) of the data
acquisition system.
4- Switch the power on and observe the output.
5- Apply the load and observe the output.
6- In each case, determine the time constant of the motor.
7- Discuss the effect of the load on the transient response.
8- Determine the transfer function of the DC motor (unload case only).
1-b Simulink:
Check the behavior of the DC motor (transfer function) and compare it with the
response obtained in experiment part.
Fig.3
In this part, two controller configurations are chosen: Two position controller and PID
controller.
X + Two Tach
- Position Amp o
Cassy C Controller
System
B
Fig.4
2-a-1 Experiment:
1- Connect the two positions controller to DC motor,
2- Connect the feedback path from the output (tacho) to the input of the controller.
3- Set the reference to 8V
4- Set the switching hysteresis to h = 0,
5- Plot the response Ω(t). Comment?
6- Deduce the applied control signal V(t)
7- Repeat the experiment with hysteresis h = ±0.5,
8- Repeat the experiment with hysteresis h = ±2.
Experiment evaluation:
Discuss the difference between the performance obtained in open loop and in
closed loop with two position controller (for different value of h)
Deduce the effect of the hysteresis on the output and on the control signal.
2-a-2 Simulation:
Check the behavior of the DC motor closed by Two-position controller with different
values of hysterisis (0, ± 0.5 and ±2). Compare the performance and comment the result.
Ki
G ( s) = K p e(t ) + + KD s
s
The controller provides a proportional term (P), an integral action (I) and a derivative term (D).
The equation for the output in time domain is:
de(t )
u (t ) = K p e(t ) + K I e(τ) dτ + K D
dt
Many industrial processes are controlled using PID controllers. The popularity of PID
controllers can be attributed partly to their good performance in wide range of operating
condition and portly to their functional simplicity, which allows engineers to operate them in a
simple, straightforward manner.
2-b-1 Experiments:
Arrange the experiment according to the block diagram shown in figure 5.
Steps for PID controller:
Switch on the computer,
1-C:\CBC-8-2\start
2- Ok
3- Controller type / PID(Parallel configuration),
4- Set up/ Disturbance Var…/ Channel X / Quiescent level=0 and Disturbance level = set point
(8V)
5- Time scale / screen sweep 10
6- Parameters
7- Operation / snapshot.
8- To print the figure: File / print
By trial and error select the optimal value of Kp, KI and KD that achieve desired performance.
Plot the output, reference signal and the control signal.
Deduce the effect of Kp, KI and KD on the response.
Evaluate the performance in terms of speed, steady state error, overshoot etc…
2-b-2 Simulation:
Check the behavior of the DC motor closed by PID controller with parameters obtained
in the experiment part. Compare the performance and comment the result.
Fig.5
Introduction:
Water level processes are very common in the industrial applications such as
chemical or power plants. This experiment will focus on the transient
characteristic of the water level system. Precisely, setup will be explored leading
to a better understanding of the capabilities of the system (analysis and
mathematical representation of the system).
Experiment Instructions:
1. Connect the open loop water level experiment as shown in the following
figure:
2. Connect the water level system with the profi-cassy in order to plot the
input and output signals (channel A: input, channel B: output).
3. Open Cassy-lab software, Start => Programs => Cassy lab.
4. Using Cassy lab software, Record the transient behavior for the
following 2 cases:
1. Case 1:
1. Start with Reference voltage = 5 V until you reach a steady
state.
2. Record the time required to achieve this state, name it T.
2. Case 2:
1- Start with Reference voltage = 5 V.
2- At t T s decrease it to 2 V.
3- At t 2T s increase it to 8 V.
Simulation:
Using SIMULINK, plot the open loop response of your input and compare it
with the figure obtained from the real experiment.
The experiment in part A has dealt with open loop response. In practice, a desired
performance of any process is usually achieved through closed-loop
configuration (feedback).
Figure 1 and 2 shows the difference between open loop closed-loop
configurations.
Input
Voltage
+ Level Indicator
Reference Error Controller U system
(PID)
-
This part will introduce another type of controller; which is called PID
(Proportional, Integral and Derivative). This control approach is one of the oldest
and most popular techniques used in the industry, because it is simple and
effective. In this experiment we will study how to use PID controller in the water
level system. Also obtain a better response in term of Rise Time, Overshoot,
Settling Time and Steady-State Error. After that we will see how SIMULINK can
be helped to achieve our requirement.
Closed-Loop Performance:
There are many types of controllers that can be used. In this par of experiment,
the most basic control system will be introduced and studied (PID).
The transfer function of the PID controller is given by:
U(s) K K S² + KP S + KI 1
= KP + I + KDS = D = KP 1+ + TDS
E(s) s s Ti s Wh
ere:
KP = proportional gain.
KI = integral gain.
KD = derivative gain.
We select them in order to obtain good response.
A proportional controller (KP) will have the effect of reducing the rise time and
will reduced but never eliminate the steady state error. An integral control (KI)
will have the effect of eliminating the steady state error, but it may make the
transient response worse. A derivative control (KD) will have the effect of
increasing the stability of the system, reducing the overshoot, and improving the
transient response.
When you are designing a PID controller for a given system, follow the steps
shown below to obtain a desired response:
Experiment:
You job is to design a PID controller to maintain the level of the water around 5
V (50%).
The objective to be met:
1. Fast response.
2. No steady state error.
3. Little or no oscillation (Note: Oscillation destroys the pump in the long
run).
Change the values of Kp, Ki (Ti), Kd (Td) to provide the best possible
performance for the water level. Plot the final response, the control signal and the
reference input.
Try to use the same value as 1 for PID controller. Compare results obtained from
both 1 and 2.
Simulation:
Using SIMULINK, plot the closed loop response as well as the control signal
with PID controller (using your obtained values from Hardware PID controller)
of your input and compare it with the figure obtained from the real experiment.