Control System Lab Programs
Control System Lab Programs
In control systems, block diagram reduction is a technique to simplify the complex systems
into a single transfer function. Here, we'll manually reduce the blocks step-by-step,
assuming a generic case with a few blocks in series and parallel, and feedback loops.
Let's consider a simple example where you have two blocks in series, a feedback loop,
and a parallel connection:
• Block 1 (𝐺1 ) and Block 2 (𝐺2 ) in series.
• Feedback loop with feedback element H.
• Block 3 (𝐺3 ) in parallel to the series combination of (𝐺1 ) and (𝐺2 ).
The general approach is:
• Reduce series blocks: 𝐺𝑠𝑒𝑟𝑖𝑒𝑠 = 𝐺1 × 𝐺2
• Handle feedback loop for any block G is 𝐺𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘 = 𝐺𝑠𝑒𝑟𝑖𝑒𝑠 /(1 + 𝐺𝑠𝑒𝑟𝑖𝑒𝑠 𝐻)
• Combine parallel blocks: 𝐺𝑝𝑎𝑟𝑎𝑙𝑙𝑒𝑙 = 𝐺𝑠𝑒𝑟𝑖𝑒𝑠 + 𝐺3
MATLAB Code:
% Define the transfer functions for each block
% For example, let's assume G1(s) = 1/(s+1), G2(s) = 2/(s+2), G3(s) = 3/(s+3),
H(s) = 1/(s+4)
s = tf('s');
G1 = 1/(s + 1);
G2 = 2/(s + 2);
G3 = 3/(s + 3);
H = 1/(s + 4);
Output:
>> p1
Reduction of Series Block
G_series =
2
-------------
s^2 + 3 s + 2
G_feedback =
2 s^3 + 14 s^2 + 28 s + 16
------------------------------------------
s^5 + 10 s^4 + 37 s^3 + 66 s^2 + 58 s + 20
G_parallel =
Explanation:
• 𝒕𝒇(′𝒔′) initializes the transfer function in terms of 𝑠 (Laplace transform variable).
• The transfer functions for 𝐺1, 𝐺2, 𝐺3 and 𝐻 are defined as simple first-order systems
for illustration.
• 𝑮_𝒔𝒆𝒓𝒊𝒆𝒔 is calculated by multiplying 𝑮𝟏 and 𝑮𝟐.
• 𝑮_𝒇𝒆𝒆𝒅𝒃𝒂𝒄𝒌 is calculated considering the negative feedback loop using the formula
𝐺
.
1+𝐺𝐻
• Finally, 𝑮_𝒑𝒂𝒓𝒂𝒍𝒍𝒆𝒍 combines 𝑮_𝒇𝒆𝒆𝒅𝒃𝒂𝒄𝒌 and 𝑮𝟑 in parallel (addition of transfer
functions).
• 𝒅𝒊𝒔𝒑 function is used to display the overall transfer function.
2. Implement Signal Flow graph to obtain transfer function a control system.
The Mason's Gain Formula is commonly used to calculate the overall transfer function of a
system represented by a signal flow graph. This formula takes into account all forward paths,
loops, and combinations of non-touching loops.
Here's a simple MATLAB code that illustrates the use of Mason's Gain Formula for a generic
signal flow graph with a few paths and loops. Let's consider a graph with:
MATLAB Code:
% Define the transfer functions of the forward paths and loops
% Let's assume symbolic variables for general representation
close all;
clear all;
clc;
s = tf('s'); % Define the Laplace transform variable
% Forward paths
P1 = 1/(s + 1); % Path 1
P2 = 2/(s + 2); % Path 2
% Loops
L1 = -1/(s + 3); % Loop 1 (negative sign for feedback loop)
L2 = -1/(s + 4); % Loop 2 (negative sign for feedback loop)
% Non-touching loops
L12 = L1 * L2; % Product of loop 1 and loop 2
% Calculate Delta (1 - sum of all individual loop gains + sum of products of all
non-touching loops)
Delta = 1 - (L1 + L2) + L12;
% For Path 2, Delta2 excludes all loops touching Path 2 (none in this simple
example)
Delta2 = 1 - (L1 + L2); % No loops touch Path 2
TF =
3 s^9 + 94 s^8 + 1293 s^7 + 10243 s^6 + 51460 s^5 + 169827 s^4
+ 367528 s^3 + 501696 s^2 + 390528 s + 131328
------------------------------------------------------------
s^10 + 33 s^9 + 484 s^8 + 4150 s^7 + 23005 s^6 + 85993 s^5 +
219006 s^4 + 374080 s^3 + 408384 s^2 + 255744 s + 69120
Explanation:
• Symbolic Definitions: The transfer functions (P1, P2, L1, L2) represent paths and
loops. Modify these based on your graph.
• Delta Calculation: Delta considers all loops and combinations of non-touching
loops. Here, it includes the individual loops and their product because they are non-
touching.
• Path Deltas: Delta1 and Delta2 are computed for each path. They are adjusted based
on loops that do not touch the specific path, though in this simple example, all loops
are considered non-touching.
• Mason's Gain Formula: The overall transfer function TF is computed by weighing
paths with their respective Delta values and normalizing by the global Delta.
3. Simulation of poles and zeros of a transfer function.
Poles and zeros are fundamental concepts in the study of systems and control theory,
particularly within the context of linear time-invariant (LTI) systems. They play a crucial role
in understanding and designing systems in engineering and science, especially in the areas of
signal processing, control systems, and electronics. Here’s a basic overview:
Zeros
• Definition: Zeros of a transfer function are the values of the Laplace transform variable
𝑠s (or 𝑧z in the z-domain for digital systems) that make the transfer function equal to
zero. In other words, they are the roots of the numerator polynomial in the transfer
function's ratio.
• Impact on System Behavior: Zeros dictate the frequency components that the system
attenuates. A zero at a particular frequency means the system output will have minimal
or no response at that frequency, effectively 'canceling' inputs at that frequency.
Poles
• Definition: Poles of a transfer function are the values of 𝑠s that make the transfer
function approach infinity. These are the roots of the denominator polynomial of the
transfer function.
• Impact on System Behavior: Poles determine the stability and the dynamic response
of the system. The location of poles in the complex plane directly influences the
system’s transient and steady-state behavior. For instance:
• Real Poles: Influence the rate of exponential decay or growth.
• Complex Poles: Contribute to oscillatory components, with the real part
dictating the exponential decay/growth rate and the imaginary part dictating the
oscillation frequency.
Pole-Zero Map
• A pole-zero map is a graphical representation in the complex plane showing the
locations of poles (often marked with 'x') and zeros (often marked with 'o'). This map
is crucial for analyzing the system's behavior just by visually inspecting the locations
of these features relative to the imaginary and real axes.
Practical Implications
• Control System Design: Poles and zeros are used to specify and adjust the performance
and stability of a control system using techniques like pole placement and zero
cancellation.
• Filter Design: In signal processing, the placement of poles and zeros defines the
characteristics of filters, such as passbands, stopbands, and the sharpness of the filter
response.
Understanding poles and zeros provides deep insights into the system's performance without
solving the complete differential equations that describe the system. This knowledge is
fundamental for the design and analysis of any system modelled by differential or difference
equations.
MATLAB Code:
% Define the Laplace transform variable s
s = tf('s');
Output:
>> p3
Poles of the transfer function:
-3.0000 + 0.0000i
-0.5000 + 1.3229i
-0.5000 - 1.3229i
Explanation:
• Transfer Function Definition: The numerator and denominator are defined using
polynomial expressions of s, where s is the Laplace transform variable. Here, a second-
order polynomial is used for the numerator and a third-order polynomial for the
denominator.
• Transfer Function Creation: G is the transfer function created from the defined
numerator and denominator.
• Pole and Zero Calculation: The pole(G) and zero(G) functions are used to find the
poles and zeros of the transfer function G.
• Displaying Results: The poles and zeros are displayed in the MATLAB command
window.
• Plotting: The pzmap function plots the poles (marked with 'x') and zeros (marked with
'o') on the complex plane, providing a visual representation of the dynamics of the
system.
4. Implement time response specification of a second order Under damped System,
for different damping factors.
For a second order underdamped system, the time response specifications such as peak
time, settling time, and overshoot depend heavily on the system's damping ratio (𝜁) and
natural frequency (𝜔𝑛 ). In control theory, the characteristic equation of a second-order
system is given by:
𝜔𝑛 2
𝑇(𝑆) =
𝑆 2 + 2𝜁𝜔𝑛 𝑆 + 𝜔𝑛 2
Where:
𝜔𝑛 - the natural frequency
𝜁- the damping ratio
To simulate and visualize the time response for different damping factors, the MATLAB
code below sets up a range of damping ratios, computes the response to a step input for
each, and plots these responses.
MATLAB Code:
% Define the natural frequency
wn = 5; % Example natural frequency
Output:
Explanation:
• Natural Frequency and Damping Ratios: We've defined a constant natural frequency
(𝜔𝑛 = 5) and an array of damping ratios for typical underdamped responses.
• Time Vector: A time vector t is defined for simulating the step responses from 0 to 5
seconds.
• Simulation Loop: For each damping ratio in the zetas array, the transfer function sys
is defined with current zeta value, and the step response is computed using
𝒔𝒕𝒆𝒑(𝒔𝒚𝒔, 𝒕).
• Plotting: Each response is plotted on the same graph with labels indicating different
damping ratios. This helps in visualizing how the response changes with varying
damping ratios.
5. Implement frequency response of a second order System.
To implement the frequency response of a second-order system in MATLAB, you'll typically
examine both the magnitude and phase of the system's response over a range of frequencies.
The basic form of a second-order system's transfer function can be written as:
𝜔𝑛 2
𝑇(𝑆) = 2
𝑆 + 2𝜁𝜔𝑛 𝑆 + 𝜔𝑛 2
Where:
𝜔𝑛 - the natural frequency
𝜁- the damping ratio
MATLAB Code:
% Define the natural frequency and damping ratio
clear all;
close all;
clc;
wn = 2; % Example natural frequency
zeta = 0.5; % Example damping ratio
where:
• 𝑇𝑙𝑒𝑎𝑑 is the time constant for the lead component, typically less than 1.
• 𝑇𝑙𝑎𝑔 is the time constant for the lag component, typically greater than 1.
MATLAB Code:
% Define the time constants for the lead and lag components
T_lead = 0.1; % Lead time constant
T_lag = 10; % Lag time constant
Explanation:
• Transfer Function Definition: The numerator num represents the lead component and
the denominator den represents the lag component. The compensator's transfer function
is defined by these.
• Frequency Range: The logspace function generates frequencies on a logarithmic scale
appropriate for frequency response analysis, ranging from 0.01 to 100 rad/s.
• Bode Function: bode calculates the frequency response (magnitude and phase) over
the specified frequency range.
• Data Conversion: The magnitude is converted from linear scale to decibels for easier
interpretation, and the phase is converted from radians to degrees.
• Plotting: Using semilogx, both magnitude and phase responses are plotted on
logarithmic x-axes. The first subplot shows the magnitude response, and the second
shows the phase response.
7. Analyze the stability of the given system using Routh stability criterion.
Routh Stability Criterion
1. Construction of Routh Array: The Routh array is built from the coefficients of the
characteristic equation of a system. This equation typically results from setting the
denominator of the system's transfer function to zero, representing the system's poles.
2. Sign Changes in the First Column: The stability of the system is assessed by
examining the first column of the Routh array. Stability is determined based on the
number of sign changes in this column from top to bottom.
3. Rule for Stability:
• Stable System: If there are no sign changes in the first column of the Routh
array, all the poles of the system lie in the left-half of the s-plane (i.e., they all
have negative real parts). This indicates a stable system.
• Unstable System: Any sign changes in the first column indicate that there are
poles in the right-half of the s-plane (positive real parts). The number of sign
changes corresponds to the number of poles in the right-half plane, which
indicates an unstable system.
Practical Implications
The importance of the number of sign changes can be summarized as follows:
• Zero Sign Changes: The system is stable; all responses will eventually settle without
sustained oscillations or divergence.
• One or More Sign Changes: The system is unstable; responses may diverge or
oscillate indefinitely, depending on the nature and location of the poles.
The Routh stability criterion is particularly useful because it can provide stability information
without having to explicitly solve for the roots of the characteristic equation, making it a
powerful tool in control system analysis and design.
MATLAB Code:
% Define the coefficients of the characteristic polynomial
% Example: s^4 + 3s^3 + 3s^2 + s + 2
clear all;
close all;
clc;
coefficients = [1, 3, 3, 1, 2];
if sign_changes > 0
disp('The system is unstable.');
else
disp('The system is stable.');
end
Output:
Routh Array:
1.0000 3.0000 2.0000
3.0000 1.0000 0
-2.6667 -2.0000 0
1.2500 0 0
2.0000 0 0
% Coefficients of the denominator are combined from s, (s+5), (s+6), and (s^2 + 2s
+ 2)
denominator = conv([1 0], [1 5]); % Multiply (s)(s+5)
denominator = conv(denominator, [1 6]); % Multiply previous result by (s+6)
denominator = conv(denominator, [1 2 2]); % Finally, multiply by (s^2 + 2s + 2)
% Adding grid to help in analyzing the damping ratio and natural frequency
grid on;
Output:
Explanation:
• Numerator and Denominator: The numerator is straightforward as it's just 𝑠+3s+3.
The denominator is constructed by multiplying out the factors of 𝑠s, 𝑠+5s+5, 𝑠+6s+6,
and the quadratic polynomial 𝑠2+2𝑠+2s2+2s+2. The conv function is used to multiply
these polynomials sequentially.
• Transfer Function: The tf function creates the transfer function from the given
numerator and denominator.
• Root Locus Plot: The rlocus function plots the root locus of the system. This plot will
show how the system's poles migrate in the complex plane as a parameter (typically a
gain) is varied.
• Grid: Enabling the grid on the plot can be helpful for better visual interpretation of the
damping ratio and natural frequency characteristics.
9. Analyse the stability of the given system using Bode plots.
Bode Plots
Bode plots are a fundamental tool in control theory and systems engineering, used to analyze
the frequency response of linear time-invariant (LTI) systems. A Bode plot is a graphical
representation that describes how the gain (magnitude) and phase of the system response
change across a range of frequencies. These plots are composed of two graphs:
1. Magnitude Plot: Shows the gain of the system in decibels (dB) versus frequency
(usually on a logarithmic scale). This plot helps in understanding how different
frequencies are amplified or attenuated by the system.
2. Phase Plot: Shows the phase shift introduced by the system as a function of frequency,
measured in degrees. This plot indicates how the phase of the output signal is shifted
relative to the input signal across different frequencies.
Stability Analysis Using Bode Plots
Stability analysis using Bode plots revolves around two key concepts: Gain Margin and Phase
Margin.
• Gain Margin: It refers to the amount of gain increase required to make the closed-loop
system unstable. A system is typically analyzed for stability at the frequency where the
phase shift is -180 degrees (the point where a system with unity feedback would ideally
have a phase shift of 0 degrees). The gain margin is measured in dB and is calculated
as the difference between 0 dB and the actual gain at this phase crossover frequency. A
positive gain margin indicates that the system can tolerate a certain increase in gain
before becoming unstable.
• Phase Margin: It is a measure of how much additional phase lag at the gain crossover
frequency (the frequency where the gain is 1 or 0 dB) is required to bring the system to
the verge of instability. The phase margin is the amount of additional phase delay that
would lead to a phase shift of -180 degrees at the gain crossover frequency. A positive
phase margin means that there is still some phase delay reserve left before the system
reaches an oscillatory instability.
Rules for Stability:
1. Phase Margin Rule:
• A positive phase margin typically indicates a stable system. More specifically,
phase margins of greater than 45 degrees are generally considered good for
stability, implying a well-damped response.
• A zero or negative phase margin indicates that the system is marginally stable
or unstable, respectively, as it suggests that the phase delay has reached or
exceeded the critical -180 degrees at the unity gain frequency.
2. Gain Margin Rule:
• A positive gain margin means the system gain must be increased by this margin
to reach instability, indicating a stable system.
• A zero or negative gain margin means the system is already at or past the point
of potential instability at the frequency where the phase is -180 degrees.
Practical Application
These margins are crucial in the design and analysis of feedback control systems. They help in
designing controllers that ensure sufficient robustness to parameter variations and external
disturbances. Bode plots, therefore, not only provide insight into the frequency response
characteristics but also fundamentally assist in assessing and enhancing system stability.
MATLAB Code:
% Define the coefficients of the numerator and the denominator of the transfer
function
% G(s) = 10(s + 20) / (s * (s + 100) * (s^2 + 5s + 100))
numerator = [10 200]; % Coefficients of the numerator (10s + 200)
denominator = conv([1 0], [1 100]); % Multiply s and (s + 100)
denominator = conv(denominator, [1 5 100]); % Multiply by (s^2 + 5s + 100)
Output:
>> p9
Gain Margin: 293.7324 dB
Phase Margin: 89.9885 degrees
Gain Crossover Frequency: 11.1001 rad/s
Phase Crossover Frequency: 0.02 rad/s
The system is stable as it has positive gain and phase
margins.
Explanation:
• Plot Setup: Magnitude and phase plots are generated using data from the bode function.
• Margin Calculation: The margin function calculates gain and phase margins along
with their respective crossover frequencies.
• Annotations: The crossover points are marked and annotated directly on the Bode
plots. The text function positions descriptions next to these points, which helps to easily
identify and interpret them.
10. Analyse the stability of the given system using Nyquist plot.
The Nyquist plot is a powerful graphical tool used in control engineering to determine the
stability of a feedback system. This method is based on the Nyquist stability criterion, which
involves plotting the complex frequency response 𝐺(𝑗𝜔)𝐻(𝑗𝜔) of an open-loop transfer
function 𝐺(𝑠)𝐻(𝑠) in the complex plane.
Fundamental Concepts:
1. Nyquist Plot:
• A Nyquist plot represents the frequency response of the system's open-loop transfer
function plotted over a range of frequencies from −∞ 𝑡𝑜 + ∞. In practice, due to
symmetry properties of real rational functions, the plot is often constructed only from
0 𝑡𝑜 + ∞ and mirrored.
• The plot is a parametric plot of the complex values 𝐺(𝑗𝜔)𝐻(𝑗𝜔), where 𝐺(𝑠) is the
forward path transfer function, and 𝐻(𝑠) is the feedback path transfer function.
2. Critical Point (−𝟏, 𝟎𝒋):
• The Nyquist plot revolves around the point −1 + 0𝑗 on the complex plane. This point
is significant because it represents the condition where the closed-loop system poles
transition from the left half of the s-plane (stable) to the right half (unstable).
Nyquist Stability Criterion:
The Nyquist stability criterion relates the number of times the plot encircles the critical point
−1,0𝑗 to the number of poles of 𝐺(𝑠)𝐻(𝑠) in the right half of the s-plane. The rules are:
1. Encirclement Counting:
• Count the number of times the Nyquist plot encircles the critical point −1,0𝑗.
• Direction Matters: Counterclockwise encirclements indicate a tendency toward
stability, while clockwise encirclements indicate potential instability.
2. Zero Encirclements:
• If the plot does not encircle −1,0𝑗 and there are no open-loop poles in the right-half
plane (RHP), the system is stable.
3. Encirclements and Poles:
• Let Z be the number of zeros of 1 + 𝐺(𝑠)𝐻(𝑠) in the RHP (equivalent to closed-loop
system poles in the RHP).
• Let P be the number of poles of 𝐺(𝑠)𝐻(𝑠) in the RHP.
• Let N be the net number of counterclockwise encirclements of −1,0𝑗.
• According to the Nyquist criterion, 𝑍 = 𝑁 + 𝑃. A stable system has 𝑍 = 0.
Stability Analysis:
Stable System:
• The system is stable if the Nyquist plot does not encircle −1,0𝑗 and 𝑃 = 0 (no open-
loop poles in the RHP), or if 𝑁 + 𝑃 = 0.
Unstable System:
• The system is unstable if 𝑁 + 𝑃 ≠ 0. This indicates that the closed-loop response has
poles in the RHP.
Practical Implementation:
When applying the Nyquist criterion, it's crucial to also consider the phase and gain margins,
as they provide additional insight into the robustness of system stability. The Nyquist plot is
particularly useful for systems where the root locus might be insufficient to clearly determine
stability, especially in cases involving complex conjugate pole pairs or multiple feedback loops.
MATLAB Code:
% Define the coefficients of the numerator and the denominator of the transfer
function
% G(s) = 90 / (s^2 + 9s + 8)
clear all;
close all;
clc;
numerator = 90; % Numerator coefficient
denominator = [1 9 8]; % Coefficients of the denominator (s^2 + 9s + 8)
Output:
>> p10
Winding number around (-1,0): 0
The system is stable.
Explanation:
• Transfer Function: The function is defined using constants for the numerator and
polynomial coefficients for the denominator.
• Nyquist Plot: The real (re) and imaginary (im) parts of the Nyquist plot are generated
using the nyquist function. These values are plotted along with their mirror images
(since the frequency response is symmetric about the real axis).
• Critical Point: The critical point −1+0𝑗−1+0j is marked to help visually check for
encirclements that indicate instability.
• Winding Number Calculation: The winding number is calculated by analysing the
change in angle around the critical point. This number indicates the number of
counterclockwise encirclements of −1+0j.
• Stability Check: The stability is determined based on the Nyquist stability criterion. If
the winding number equals the negative of the number of unstable poles (RHP poles),
the system is stable.
11. Obtain the time response from state model of a system.
The time response of a system in state-space representation is a fundamental concept in control
theory and systems engineering, providing insights into how the system behaves dynamically
in response to different inputs. The state-space model offers a compact and versatile way to
describe and analyze linear systems, especially for systems with multiple inputs and outputs.
Here’s a detailed theoretical background:
State-Space Representation
State-Space Equations: The state-space representation of a system involves two equations:
1. State Equation: 𝑥˙(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡)
Where:
• 𝑥(𝑡) is the state vector (n-dimensional),
• 𝑥˙(𝑡) is the derivative of the state vector with respect to time,
• 𝐴 is the system matrix (𝑛 × 𝑛),
• 𝐵 is the input matrix (𝑛 × 𝑚),
• 𝑢(𝑡) is the input vector (m-dimensional).
2. Output Equation: 𝑦(𝑡) = 𝐶𝑥(𝑡) + 𝐷𝑢(𝑡)
Where:
• y(t) is the output vector (p-dimensional),
• C is the output matrix (𝑝 × 𝑛),
• D is the feedthrough (or direct transmission) matrix (𝑝 × 𝑚).
These equations together describe the dynamics of a system in terms of matrices that relate the
system’s current state, its inputs, and its outputs.
Types of Time Responses
There are two primary types of time responses to consider:
1. Transient Response:
• This part of the response describes how the state variables of a system
transition from their initial conditions to a steady state.
• Key characteristics of the transient response include rise time, settling time,
overshoot, and time to peak.
2. Steady-State Response:
• Once the transient effects have decayed, the steady-state response is what
remains. It describes the long-term behavior of the system when subjected
to a continuous or steady input.
• For linear systems, the steady-state response to sinusoidal inputs is
particularly important and can be predicted by solving the system equations
in the frequency domain.
MATLAB Code:
% Define the state-space matrices
A = [-1 0; 0 -2]; % System matrix
B = [1; 0]; % Input matrix
C = [1 1]; % Output matrix
D = [0]; % Feedthrough matrix
Output:
Explanation:
• State-Space Matrices: As before, the matrices A, B, C, and D describe the system.
Modify these to reflect the system you are analysing.
• State-Space Model: The ss function creates the state-space object.
• Time Vector and Input Signal: The t vector specifies the simulation time, and u
defines the input signal over this time. In this case, it’s a sine wave, but you can
replace u with any vector of input values you wish to simulate.
• Simulate Time Response: The lsim function is used to simulate the system
response to the arbitrary input 𝑢u. This function is ideal for scenarios where the
input is not a simple step but varies with time.
• Plotting: The output 𝑦y of the system in response to the input is plotted against
time.
12. Implement PI and PD Controllers.
Proportional-Integral (PI) Controllers
A Proportional-Integral (PI) controller combines proportional control and integral action to
provide both immediate and accumulative corrective actions to the control system. This type
of controller is particularly effective in eliminating steady-state errors without increasing the
response time or causing the system to be overly reactive.
Theory and Benefits:
• Proportional Control (P): This component of the PI controller produces an output that
is proportional to the current error value. The proportional gain (Kp) determines the
ratio of output response to the error signal. A high Kp increases the system's
responsiveness but can also lead to system instability and increased oscillation.
• Integral Control (I): This component integrates the error over time, resulting in the
output that is proportional to both the magnitude and the duration of the error. The
integral action accelerates the movement of the process towards the setpoint and
eliminates the residual steady-state error that occurs with a pure proportional controller.
The integral gain (Ki) affects how quickly the accumulated error is corrected.
Implementation Considerations:
• PI controllers are widely used when the system needs to eliminate steady-state errors,
which is common in absence of disturbances.
• Care must be taken with the integral part to prevent integral windup, which can occur
when the controller accumulates a significant error during periods when the actuator is
saturated.
Proportional-Derivative (PD) Controllers
A Proportional-Derivative (PD) controller combines proportional control with a derivative
action. The derivative part predicts system behavior and thus improves the stability and speed
of the response.
Theory and Benefits:
• Proportional Control (P): As with the PI controller, the proportional part depends on
the proportional gain (Kp), which dictates how much the output will respond to the
current error.
• Derivative Control (D): This component produces an output based on the rate of
change of the error, providing a way to anticipate future errors. This feature of the PD
controller makes it effective in dealing with systems where a high degree of damping
is required. The derivative gain (Kd) controls the extent to which this anticipation
affects the controller output.
Implementation Considerations:
• PD controllers do not address steady-state errors but are useful in applications requiring
improved transient response and system stability.
• The derivative term is sensitive to noise in the error signal, thus, it is often filtered to
avoid high-frequency noise amplification.
MATLAB Code for PI Controller:
% Define the plant transfer function
Plant = tf(1, [1, 3, 2]);
% Sampling time
Ts = 0.01;
% Discretize the plant with the same sampling time as the controller
Plant_d = c2d(Plant, Ts, 'zoh');
% Controller parameters
Kp = 5; % Proportional gain
Ki = 1; % Integral gain
Output:
MATLAB Code for PD Controller:
% Define the plant transfer function
Plant = tf(1, [1, 10, 20]);
% PD Controller parameters
Kp = 2; % Proportional gain
Kd = 0.5; % Derivative gain
PD_Controller = tf([Kd Kp], [1]); % Transfer function of PD Controller
Output:
Explanation:
• System Model: Both scripts begin by defining a plant transfer function, Plant. The
example plant used here is a second-order system with a transfer function 1𝑠2 + 10𝑠 +
20.
• Controller Definitions:
• PI Controller: The PI controller is represented by Kps+Ki. It is implemented in
MATLAB as a transfer function where Kp is the proportional gain and Ki is the
integral gain.
• PD Controller: The PD controller is described by Kp+Kds. This is represented
as a transfer function in MATLAB where Kd is the derivative gain and Kp is
the proportional gain.
• Feedback and Response:
• The feedback function is used to form a unity feedback closed-loop system. The
product of the controller and the plant is fed into the feedback loop.
• The step function simulates the step response of the closed-loop systems,
displaying how the system output responds to a step input over time.