Lab Automation
Lab Automation
IE 0906544
Experiment 1
Introduction to SIMULINK
Objectives:
By the end of this experiment, the student should be able to:
1. Build and simulate simple system model using Simulink
2. Use Simulink test and measurement tools.
1. Introduction
Simulink is a program for simulating signals and dynamic systems. Simulink has two phases of use: model
definition and model analysis. It provides an interactive graphical environment and a customizable set of block
libraries that let you design, simulate, implement, and test a variety of time-varying systems, including
communications, controls, signal processing, video processing, and image processing.
Simulink provides toolboxes for designing, simulating, and analysing communications systems. The Simulink
enables source coding, channel coding, interleaving, analogue and digital modulation, equalization,
synchronization, and channel modelling.
A typical session starts by either defining a new model or by recalling a previously defined model, and then
proceeds to analyse that model. In order to facilitate the model definition, Simulink has a large library of
blocks. Models are created by combining proper blocks from the library and edited in the model window
principally using mouse-driven operation ( Drag and Drop ) . An important part of mastering Simulink is to
become familiar with manipulations of various model components in these windows.
After you create (or define) a model, you can analyse it either by choosing options from the Simulink menus in
the model window or by entering commands in the Matlab command window. The progress of an ongoing
simulation can be viewed while it is running, and the results can be made available in the Matlab workspace
when the simulation is complete.
Simulink is a visual programming interface designed to make modelling systems intuitive. It offers a
way to solve equations numerically using a graphical user interface, rather than requiring code.
Blocks are mathematical functions, they can have varying numbers of inputs and outputs.
Signals are lines connecting blocks, transferring values between them. Signals are different
data types, for example numbers, vectors or matrices. Signals can be labelled.
Annotations of text or images can be added to the model, and while not used in the
calculations they can make it easier for others to understand design decisions in the model.
Text Annotation
Blocks
2. The Library Browser keeps a repository of all the libraries it shows. If your library has missing
repository information, a notification bar appears above the Libraries pane when you refresh
the Library Browser. To prevent this notification from appearing again, click on Fix in the
notification bar and choose Resave libraries in SLX file format. This saves all libraries in .slx
format with Enable Repository property set to on. You can also open the Simulink Library
Browser from the MATLAB Tool strip, by clicking
the Simulink Library button. To keep the Library Browser above all other windows on your
desktop, in the toolbar, select the Stay on top button.
1. From the Simulink Library Browser toolbar, click the New Model button . An empty
model diagram figure 1.2 opens in the Simulink Editor.
Figure 1.2: Simulink New Model
where u(t) is a square wave with an amplitude of 1 and a frequency of 1 rad/sec, use an integrator
block and a gain block.
The Integrator block integrates its input x· (t) to produce x(t). Other blocks needed in this model include
a Gain block and a Sum block. To generate a square wave, use a Signal Generator block and select the
Square Wave form but change the default units to radians/sec. Again, view the output using a Scope
block. Gather the blocks and define the gain.
An important concept in this model is the loop that includes the Sum block, the Integrator block, and
the Gain block.
In this equation, x(t) is the output of the Integrator block. It is also the input to the blocks that compute
x· (t), on which it is based. This relationship is implemented using a loop.
The Scope displays x(t) at each time step. For a simulation lasting 10 seconds, the output shows in
figure 4:
Figure 1.4: The simulation result of x(t)
Example .2: Model the differential Equation (Frequency Domain- Transfer Function)
x· (t) = 2x(t) + u(t) (2)
The equation you modeled in this example can also be expressed as a transfer function. The model
uses the Transfer Fcn block, which accepts u as input and outputs x(t).
So, the block implements (s)/U(s) . If you substitute sX(s) for x· (t) in the above equation, you get
sX(s) = -2X(s) + U(s)
Solving for X(s) gives
U(s)
X(s) =
s+2
Or
The Transfer Fcn block uses parameters to specify the numerator and denominator coefficients. In
this case, the numerator is 1 and the denominator is s+2. Specify both terms as vectors of coefficients
of successively decreasing powers of s
In this case the numerator is [1] (or just 1) and the denominator is [1 2].
Exercise 2:
Use SIMULINK to generate the output of the second order differential equation above.
Automation and Automatic Control Lab
IE 0906544
Objective: The objective of this exercise will be to learn commands in MATLAB that would
be used to reduce linear systems block diagram using series, parallel and feedback
configuration.
List of Equipment/Software
Following equipment/software is required:
• MATLAB
Category Soft-Experiment
Deliverables
A complete lab report including the following:
Series configuration: If the two blocks are connected as shown below then the blocks are
said to be in series. It would like multiplying two transfer functions. The MATLAB
command for the such configuration is “series”.
Example 1: Given the transfer functions of individual blocks generate the system transfer
function of the block combinations.
The result is as shown below:
Parallel configuration: If the two blocks are connected as shown below then the blocks
are said to be in parallel. It would like adding two transfer functions.
Example 2: For the previous systems defined, modify the MATLAB commands to obtain the
overall transfer function when the two blocks are in parallel.
Feedback configuration: If the blocks are connected as shown below then the blocks are
said to be in feedback. Notice that in the feedback there is no transfer function H(s) defined.
When not specified, H(s) is unity. Such a system is said to be a unity feedback system.
The MATLAB command for implementing a feedback system is “feedback” as shown below:
When H(s) is non-unity or specified, such a system is said to be a non-unity feedback system
as shown below:
Example 3: Given a unity feedback system as shown in the figure, obtain the overall transfer
function using MATLAB:
Poles and Zeros of System: To obtain the poles and zeros of the system use the MATLAB
command “pole” and “zero” respectively as shown in example 5. You can also use MATLAB
command “pzmap” to obtain the same.
Example 5: Given a system transfer function plot the location of the system zeros and poles
using the MATLAB pole-zero map command.
For example:
Exercise 1: For the following multi-loop feedback system, get closed loop transfer function
and the corresponding pole-zero map of the system.
1 1 s2 + 1 s+1 s+1
Given G1 = ;G = ;G = ; G4 = ; H1 = ; H2 = 2;
(s + 10) 2
(s + 1) 3 (s + 4s + 4)
2
(s + 6) (s + 2)
H3= 1
Automation and Control Lab
IE 0906544
For the unit-step input, which is the derivative of unit-ramp input, the
output c(t) is
Objective: The objective of this exercise will be to study the performance characteristics of first and
second order systems using MATLAB.
List of Equipment/Software
Following equipment/software is required:
• MATLAB
Category Soft-Experiment
Deliverables
A complete lab report including the following:
An electrical RC-circuit is the simplest example of a first order system. It comprises of a resistor and
capacitor connected in series to a voltage supply as shown below on Figure 1.
E(t) Vc(t)
Figure 1: RC Circuit
If the capacitor is initially uncharged at zero voltage when the circuit is switched on, it starts to charge
due to the current ‘i' through the resistor until the voltage across it reaches the supply voltage. As soon
as this happens, the current stops flowing or decays to zero, and the circuit becomes like an open circuit.
However, if the supply voltage is removed, and the circuit is closed, the capacitor will discharge the
energy it stored again through the resistor. The time it takes the capacitor to charge depends on the time
constant of the system, which is defined as the time taken by the voltage across the capacitor to rise to
approximately 63% of the supply voltage. For a given RC-circuit, this time constant is Hence τ =RC its
magnitude depends on the values of the circuit components.
The RC circuit will always behave in this way, no matter what the values of the components. That is,
the voltage across the capacitor will never increase indefinitely. In this respect we will say that the
system is passive and because of this property it is stable.
For the RC-circuit as shown in Fig. 1, the equation governing its behavior is given by
where Vc(t) is the voltage across the capacitor, R is the resistance and C is the capacitance. The constant τ =RC is
the time constant of the system and is defined as the time required by the system output i.e. Vc(t) to rise to 63% of its
final value (which is E). Hence, the above equation (1) can be expressed in terms of the time constant as:
Where τ is time constant of the system and the system is known as the first order system. The performance measures
of a first order system are its time constant and its steady state.
Exercise 1:
a) Given the values of R and C, obtain the unit step response of the first order system.
a. R=2KΩ and C=0.01F
b. R=2.5KΩ and C=0.003F
b) Verify in each case that the calculated time constant (τ =RC) and the one measured from the figure as
63% of the final value are same.
c) Obtain the steady state value of the system.
Consider the following Mass-Spring system shown in the Figure 2. Where K is the spring constant, B
is the friction coefficient, x(t) is the displacement and F(t) is the applied force:
x(t)
M F(t)
The differential equation for the above Mass-Spring system can be derived as follows
Applying the Laplace transformation, we get
Provided that, all the initial conditions are zeros. Then the transfer function representation of the system is
given by
For which the transient output, as obtained from the Laplace transform table (Table 2.3, Textbook), is
Where 0 < ζ < 1. The transient response of the system changes for different values of damping ratio, ζ. Standard
performance measures for a second order feedback system are defined in terms of step response of a system.
Where, the response of the second order system is shown below.
The performance measures could be described as follows:
Rise Time: The time for a system to respond to a step input and attains a response equal to a percentage
of the magnitude of the input. The 0-100% rise time, Tr, measures the time to 100% of the magnitude of
the input. Alternatively, Tr1, measures the time from 10% to 90% of the response to the step input.
Peak Time: The time for a system to respond to a step input and rise to peak response.
Overshoot: The amount by which the system output response proceeds beyond the desired response. It
is calculated as
M pt − f υ
P.O.= ×100%
fυ
where MPt is the peak value of the time response, and fv is the final value of the response. Settling
Time: The time required for the system’s output to settle within a certain percentage of the input
amplitude (which is usually taken as 2%). Then, settling time, Ts, is calculated as
E(s)
R(s) Y(s)
Find the step response of the system for values of ωn = 1 and ζ = 0.1, 0.4, 0.7, 1.0 and
2.0.
ζ Rise time Peak Time % Overshoot Settling time Steady state value
0.1
0.4
0.7
1.0
2.0
Experiment 2
Performance of First order and second order systems
Data Sheet
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
Automation and Control Lab
IE 0906544
Controller: Provides excitation for the plant; Designed to control the overall system
behavior. The three-term controller: The transfer function of the PID controller looks
like the following:
KP = Proportional gain
KI = Integral gain
KD = Derivative gain
First, let's take a look at how the PID controller works in a closed-loop system using
the schematic shown above. The variable (e) represents the tracking error, the
difference between the desired input value (R) and the actual output (Y). This error
signal (e) will be sent to the PID controller, and the controller computes both the
derivative and the integral of this error signal. The signal (u) just past the controller is
now equal to the proportional gain (KP) times the magnitude of the error plus the
integral gain (KI) times the integral of the error plus the derivative gain (KD) times
the derivative of the error.
1
This signal (u) will be sent to the plant, and the new output (Y) will be obtained. This
new output (Y) will be sent back to the sensor again to find the new error signal (e).
The controller takes this new error signal and computes its derivatives and its internal
again. The process goes on and on.
Example:
The transfer function between the displacement X(s) and the input F(s) then becomes:
Let
The goal of this problem is to show you how each of Kp, Ki and Kd contributes to
obtain
2
Open-loop step response:
Proportional control:
The closed-loop transfer function of the above system with a proportional controller
is:
3
Figure 4: step response with a proportional controller at Kp=300.
Proportional-Derivative control:
The closed-loop transfer function of the given system with a PD controller is:
4
This plot shows that the derivative controller reduced both the overshoot and the
settling time, and had a small effect on the rise time and the steady-state error.
Proportional-Integral control:
Before going into a PID control, let's take a look at a PI control. For the given system,
the closed-loop transfer function with a PI control is:
We have reduced the proportional gain (Kp) because the integral controller also
reduces the rise time and increases the overshoot as the proportional controller does
(double effect). The above response shows that the integral controller eliminated the
steady-state error.
Proportional-Integral-Derivative control:
Now, let's take a look at a PID controller. The closed-loop transfer function of the
given system with a PID controller is:
5
After several trial and error runs, the gains Kp=350, Ki=300, and Kd=50 provided the
desired response. To confirm, enter the following commands to an m-file and run it in
the command window. You should get the following step response.
Figure 7: step response with a PID controller at Kp=350, Kd=5500, Ki= 300.
Now, we have obtained a closed-loop system with no overshoot, fast rise time, and no
steady state error.
The proportional controller (KP) will have the effect of reducing the rise time and will
reduce, but never eliminate, the steady state error. An integral controller (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.
6
Effect of each controller KP, KI and KD on the closed-loop system are summarized
below
Note that these corrections may not be 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 KP, KI, and KD.
Exersice:
Obtain the unit step response of Gp(s) Try PI controllers with (Kp=2, 10, 100),
and Ki=Kp/10. Investigate the unit step response in each case, compare the
results and comment.
Let Kp=100, Ki=10, and add a derivative term with (Kd=0.1, 0.9, 2).
Investigate the unit step response in each case, compare the results and
comment.
Based on your results in parts above what do you conclude as a suitable PID
controller for this process and give your justification.
7
Automation and Control Lab
Experiments 5: Introduction to Pneumatics
مشغل
An actuator is an output device for the conversion of
supply energy into useful work.
The output signal is controlled by the control system, and
the actuator responds to the control signals via the control
element.
The pneumatic actuator can be described under two
groups, linear and rotary :
Linear motion: Single-acting cylinders and Double-acting
cylinders.
•Rotary motion : Air motor, Rotary cylinders and Rotary
actuators.
Single Acting cylinders
Introduction to Pneumatics
Simulation of Single Acting and Double acting Cylinders using Automation
Studio
Introduction
In this experiment, you will study about the pneumatic circuits for the linear movement of an
actuator. More precisely, we will study about the single-acting and double acting pneumatic
cylinder.
Objectives
To learn about pneumatic power characteristics, applications, advantages and
disadvantages;
To investigate a basic pneumatic circuit.
Components Required
Automation Studio software
Discussion
Fluid power systems convert mechanical energy into fluid energy, and then convert this fluid
energy back into mechanical energy to do useful work. The fluid power devices that convert
the energy of a pressurized fluid into mechanical energy to do work are called actuators. The
two basic types of actuators are cylinders, which generate linear motion, and motors or rotary
actuators, which generate rotary motion.
Most pneumatic circuits contain a source of compressed air, a pressure control device,
conductors such as pipe or tubing, an actuator, and a directional control valve to control the
operation of the actuator. The power source comes from a motor or engine, called a prime
mover, that operates a compressor having its inlet port connected to the atmosphere. The
mechanical energy is converted into fluid power when this air is compressed. In addition to a
prime mover and a compressor, a pneumatic power source includes an air storage tank called
a receiver. The receiver stores the compressed air until this energy is needed elsewhere in the
system.
A pneumatic circuit is a fluid power circuit that uses gas to transmit power. Air is commonly
used as a gas in pneumatics because it is readily available, inexpensive, and can be returned
to the atmosphere after use.
Air is extremely compressible and elastic. It is capable of absorbing large amounts of
potential energy. These properties of compressed air make possible smooth acceleration and
deceleration and reversal of direction of mechanical motions, with relative freedom from
shock.
As a power medium, compressed air has numerous distinct advantages such as:
Easy to transport and store;
Unlimited conductive geometry;
Offers little risk of explosion or fire;
Is a very fast working medium and enables high working speed to be obtained;
Provides flexibility in the control of machines;
Provides an efficient method of multiplying force; C no return lines necessary; C
efficient and dependable.
Figure 1-2 illustrates the flow of air through a fundamental pneumatic circuit. Air is drawn
from the atmosphere by the compressor and compressed in the receiver. When the directional
control valve (DCV) is operated, air flows through the valve and to side A of the cylinder. This
causes the cylinder to extend and the air from side B is exhausted and returned to atmosphere.
Procedure:
Part 1: Single –acting Cylinder
A. Simulation of single acting cylinder using direct method.
1. Draw the pneumatic circuit diagram for direct triggering of single acting cylinder in Figure
3 using Automation Studio Software.
2. Simulate the circuit using Automation Studio Software.
Figure 1- 5: Single acting Cylinder circuit using two push Button switches.
1. Draw the pneumatic circuit diagram for direct triggering of double acting cylinder in
Figure 6 using Automation Studio Software.
2. Simulate the circuit using Automation Studio Software.
Figure 1-6: Double acting cylinder using direct method.
A.
1. Construct the pneumatic circuit in the Figure 2.
2. Fill the table below with the state of the cylinder if the stroke is return or forward
according to the states of valve 1 and valve 2 ( ON or OFF).
3. What is the logic function this circuit represents?
Figure 1
Figure 2
Figure 3
.
PLC for Pneumatic Cylinder
https://www.youtube.com/watch?v
=bXXL-0sf8gs
Solenoid Valve
Figure 1
2. With your supervisor, built the AB PLC ladder diagram in Figure 2, please notice the name
of the libraries from which you can select the components.
Figure 2
3. With your supervisor, built the AB PLC ladder diagram in Figure 3, please notice the name
of the libraries from which you can select the components.
Figure. 3
5. Rebuilt the AB PLC ladder diagram in Figure 3 by using a counter that will counts up to 10
( Figure 6) , please notice the name of the libraries from which you can select the
components.
Figure. 6
Exercise: Compare between the outputs of the different timers and the counter you have
simulated in the previous steps.
Automation and Control Lab
Experiment 8
Data Sheet: PLC for Pneumatic Circuits (2)
Figure 1
2. With your supervisor, built the AB PLC ladder diagram in Figure 2, please notice the name
of the libraries from which you can select the components.
Exercise: Compare between the outputs of the different timers and the counter you have
simulated in the previous steps.
Figure 2