0% found this document useful (0 votes)
15 views28 pages

ET2063 Mechatronics-Report

This document discusses analyzing the stability and time response of feedback control systems using MATLAB and Simulink. It presents the open-loop and closed-loop analysis of a system, including determining poles and plotting pole-zero maps, Bode diagrams, Nyquist plots, and root loci. The stability margins and time responses are also calculated and compared between the two tools.

Uploaded by

mahsanorion247
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views28 pages

ET2063 Mechatronics-Report

This document discusses analyzing the stability and time response of feedback control systems using MATLAB and Simulink. It presents the open-loop and closed-loop analysis of a system, including determining poles and plotting pole-zero maps, Bode diagrams, Nyquist plots, and root loci. The stability margins and time responses are also calculated and compared between the two tools.

Uploaded by

mahsanorion247
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

ET2063 Mechatronics: Lab Report

Introduction:
In this report MATLAB software has been used to perform stability and times response analysis
for feedback systems. MATLAB and the Control Toolbox has been used for producing Bode
diagrams, Nyquist diagrams, root loci, and step responses for single-input-single-output open-
loop and closed-loop linear control systems. Then Simulink used to investigate the time response
behaviour of the control system and perform a comparison of the results obtained using MATLAB.
The results obtained from both Matlab and Simulink compared and discussed in this report.

Figure1. Feedback Control System

1. Part 1: Pole-Zero Map and Open-Loop Response


Matlab Code:
%Part 1: Pole-Zero Map and Open-Loop Response
clc
clear all
close all
%part 1 codes

% Define the Laplace trasnform variable 's'


s = tf('s');

% Define the system


G1 = 1 / (s + 1); % Transfer function for G1(s)
G2 = 100 / (s^2 + 18*s + 72); % Transfer function for G2(s)
H = (0.71*s + 3.57) / (s^2 + 1.50*s + 32); % Transfer function for H(s),
% Define the gain K
K = 1;

% Compute the Open Loop Transfer Function (T_open) for K = 1


T_open = K * G1 * G2;

% Part 1.1: Determine the poles of G2


poles_G2 = pole(G2);
disp('Poles of G2:');
disp(poles_G2);

% Part 1.2: Plot the pole-zero map of G2


figure;
pzmap(G2);
title('Pole-Zero Map of G2 using pzmap');

% Part 1.3: Compute the Open Loop Transfer Function


disp('Open Loop Transfer Function (OLTF):')
disp(T_open);

% Part 1.4: Determine the poles of the obtained OLTF


poles_OLTF = pole(T_open);
disp('Poles of T_open:');
disp(poles_OLTF);

% Part 1.5: Plot the pole-zero map of the obtained OLTF


figure;
pzmap(T_open);
title('Pole-Zero Map of OLTF using pzmap');

% Part 1.6: Plot a unit step response for the first 20 seconds of the open loop
system
figure;
step(T_open, 20);
title('Unit Step Response of OLTF for First 20 Seconds');

Results:
Part1.1:
Poles of G2.
Part1.2:
Pole zero-map of G given below:

Part1.3:
Open loop transfer function:
Part1.4:
Poles of OPLF:

Part 1.5:
Pole-zero map of OLTF:
Part 1.6:
Step response of OLTF for first 20 seconds:

Homework:
1.7

The stability of a system in the Laplace domain is determined by the location of its poles. G2
has poles at -12 and -6, both in the left-half of the complex s-plane, indicating negative real
parts, hence G2 is stable. This is confirmed by the pole-zero map of G2, which shows all poles
on the negative real axis, affirming its stability.

1.8:

The Open Loop Transfer Function (OLTF) of the system is obtained by multiplying the transfer
functions of its individual components:

OLTF = K ∗ G1(s) ∗ G2(s)


1 100
=1×( )×( 2 )
𝑠+1 𝑠 + 18𝑠 + 72
Simplify the above expression:
100
𝑂𝐿𝑇𝐹 =
𝑠3 + 19𝑠 2+ 90𝑠 + 72
1.9:

The OLTF has poles at -12, -6, and -1, indicating system stability. The pole-zero map confirms
this with all poles on the left side of the s-plane, ensuring no marginal or complete instability.

1.10

The system's step response shows stable behavior without oscillations or divergence,
consistent with the stable pole locations. It resembles an overdamped system, converging
smoothly to a steady state.

1.11:

The poles' position in the left half-plane indicates system stability. Faster responses correlate
with poles farther left, while absence of poles in the imaginary or right half-plane prevents
oscillations or unbounded growth, ensuring eventual settling to a steady state. The unit step
response plot confirms system stability predicted by pole locations.

2. Part 2: Bode and Nyquist Diagram

Part2.1

Matlab Code:
% Part 2.1: Plot a Nyquist diagram of OLTF
figure;
nyquist(T_open);
title('Nyquist Diagram of OLTF');
Part2.2
Matlab Code:
% Part 2.2: Plot a Bode diagram
figure;
[mag, phase, w] = bode(T_open);
margin(T_open); % plots the Bode diagram and automatically annotates the GM and PM
2.3
Code:
% Part 2.3: using the "margin" function to determine the values of GM and PM
[GM, PM, ~, ~] = margin(T_open);
fprintf('Gain Margin (GM): %f dB\n', 20*log10(GM));
fprintf('Phase Margin (PM): %f degrees\n', PM);

% Assume that K* is the value of K for which GM is infinite (or the system just
becomes unstable)
% In practice, we would find K* by increasing K until GM just approaches 0 dB (or
1 as a magnitude)

2.4
Code:
% Part 2.4: Re-plot the Nyquist diagram with K = K*
% To compute K*, we need to find the value where the Nyquist plot crosses the -1
point
% This requires a bit more analysis which typically involves looking at the phase
plot and finding
% the gain at the phase crossover frequency (where phase = -180 degrees)

% You should replace it with your specific values or methods to compute K*


K_star = 1; % Placeholder for K*, needs to be determined through analysis
OLTF_K_star = K_star * T_open;
figure;
nyquist(OLTF_K_star);
title('Nyquist Diagram with K = K*');

% The following lines would be used to derive K_star through interactive analysis
% [mag,phase] = bode(OLTF,w);
% phase_crossover_freq = interp1(phase, w, -180, 'linear', 'extrap');
% K_star = 1 / interp1(w, mag, phase_crossover_freq, 'linear', 'extrap');
Homework:
2.5:

Comparing the Nyquist diagrams between Part 2.1 (original OLTF) and Part 2.4 (with K=K*) is
essential for stability analysis. The original plot doesn't encircle the critical point (-1,0),
indicating stability. However, when K=K* the plot nears this critical point. If it were to encircle
it, the system would become unstable. Thus K* serves as the stability boundary: the system can
handle gain increases up to K* before instability.

2.6:

The Gain Margin (GM) given in decibels (dB) can be converted to a linear scale (magnitude)
as follows:

\[ GM_{\text{linear}} = 10^{\frac{GM_{\text{dB}}}{20}} \]

Given the GM of 24.287142 dB, the calculation in magnitude would be:

\[ GM_{\text{linear}} = 10^{\frac{24.287142}{20}} \approx 17.782794 \]

Therefore, the maximum value of ( K ) that maintains system stability, denoted ( K* ),


is the reciprocal of thelinear GM:

\[ K^* = \frac{1}{GM_{\text{linear}}} \approx \frac{1}{17.782794} \approx 0.056234 \]

This value of \( K^* \) is critical because it represents the maximum gain at which the system
maintains stability.
2.7:

The Bode diagram shows a GM of 24.287142 dB and a PM of 123.663411 degrees, indicating


ample stability margin. The Nyquist plot remains stable at K=1, but approaches instability at
K=K*, confirming consistency between the two plots and providing insight into system
robustness.

2.8:

GM measures how much gain can increase before instability (0 dB), while PM indicates
additional phase lag before hitting -180 degrees. In Bode plots, GM is where phase crosses -
180 degrees and PM where gain crosses 0 dB. In Nyquist plots, GM is the distance to (-1,0)
along the negative real axis, and PM is the angle where the plot intersects the negative real
axis. Both plots assess stability based on system frequency response, with Bode showing
magnitude and phase versus frequency and Nyquist depicting complex gain traversal around
the complex plane. Despite visual differences, both plots enable determination of stability
margins and system robustness against gain and phase variations.

3. Part 3: Root Locus Diagram


Matlab Code:
%PART 3
%part 3 codes

% Define the Laplace variable 's'


s = tf('s');

% Given transfer functions for the system


G1 = 1 / (s + 1); % Transfer function for G1(s)
G2 = 100 / (s^2 + 18*s + 72); % Transfer function for G2(s)
H = (0.71*s + 3.57) / (s^2 + 1.50*s + 32); % Transfer function for H(s)

% Assuming unity feedback for G3(s)


G3 = 1;

% Open-Loop Transfer Function (OLTF)


T_open = G1 * G2 * H;

% Calculate the gain margin using the Bode plot


[GM, PM, Wcg, Wcp] = margin(T_open);

% Calculate the linear gain margin


GM_linear = 10^(19.656691 / 20);

% Calculate K* = reciprocal of the linear Gain Margin


K_star = 1 / GM_linear;

% Part 3.1: Plot the root locus diagram


figure;
rlocus(T_open);
title('Root Locus of the System');

% Part 3.2: Automatically find and plot the gain margin on the root locus diagram
% We find the gain at which the phase of the system is -180 degrees, which is the
phase crossover frequency Wcg
% Then we compute the gain at which the system becomes marginally stable using the
gain margin

% We use the computed K_star to get the root locations on the root locus
[roots, gain] = rlocus(T_open, K_star);
[~, minIdx] = min(abs(gain - K_star)); % Find the index of the gain closest to
K_star

% Mark the point on the root locus where K = K_star


hold on;
plot(real(roots(minIdx)), imag(roots(minIdx)), 'rx', 'MarkerSize', 10, 'LineWidth',
2);
hold off;

% Display the gain margin value


disp(['The Gain Margin (K*) on the root locus is approximately: ',
num2str(K_star)]);

3.1 and 3.2:


Homework:
3.3:
The root locus diagram illustrates the trajectory of closed-loop transfer function poles as the gain
K varies from 0 to infinity. Key features include:

1. Starting Points: Poles begin at the poles of the open-loop transfer function (OLTF),
typically at K=0.

2. Paths: Poles move along defined paths with increasing K, depicting changes in system
dynamics. Ideally, for stability, poles should remain in the left half of the s-plane.

3. End Points: Paths terminate at open-loop system zeros or extend to infinity if poles
exceed zeros.

3.4:

Crossing into the right half of the s-plane in root locus branches signals potential instability.
In the provided diagram, as k increases, poles approach the imaginary axis, with one eventually
crossing at the red "X," marking the instability threshold. Preceding this, pole behaviour reflects
changes in the system's transient response with increasing K

Conclusion:

Theoretical analysis from the root locus indicates that as the system gain K reaches 0.10403, it
becomes marginally stable, with further increases leading to instability. The coherence
between the Bode plot and root locus reinforces the stability assessment's reliability. In
practical controller design, maintaining a safety margin below this critical gain ensures stable
operation, even in the face of model uncertainties and external disturbances.

4. Part 4: Closed-Loop Response


Matlab Code:
%PART 4
% Define the Laplace variable 's'
s = tf('s');

% Define the system transfer functions based on given parameters


G1 = 1 / (s + 1); % Transfer function G1(s)
G2 = 100 / (s^2 + 18*s + 72); % Transfer function G2(s)
H = (0.71*s + 3.57) / (s^2 + 1.50*s + 32); % Transfer function H(s), as provided
K = 1; % Gain K as given in Part 4.1

% Open-Loop Transfer Function (OLTF) with gain K


T_open = K * G1 * G2; % G(s) without feedback for the OLTF

% 4.1 Compute the Closed Loop Transfer Function (CLTF)


CLTF = feedback(T_open * H, 1); % Closed-loop system with unity feedback
% Now let's compute the poles and zeros of the CLTF, plot its pole-zero map, and
step response.

% 4.2 Determine the poles and zeros of the CLTF


poles_CLTF = pole(CLTF); % Poles of the CLTF
zeros_CLTF = zero(CLTF); % Zeros of the CLTF

% Display the poles and zeros in the command window


disp('Poles of the CLTF:');
disp(poles_CLTF);
disp('Zeros of the CLTF:');
disp(zeros_CLTF);

% 4.3 Plot the pole-zero map of the CLTF


figure;
pzmap(CLTF);
title('Pole-Zero Map of CLTF');

% 4.4 Plot the unit step response of the CLTF


figure;
step(CLTF, 20); % Plot for the first 20 seconds
title('Unit Step Response of CLTF');

4.1
Closed loop transfer function:

4.2:
Poles and zeros of Closed loop transfer function:
4.3:
Pole zero map of CLTF

4.4:
Step response:
Homework:
4.5:

To derive the CLTF \( G_{closed}(s) \), you need to combine the individual transfer functions
\( G_1(s) \),
\( G_2(s) \), and \( H(s) \) into a single expression and apply the feedback formula.

Given:

\[ G_1(s) = \frac{1}{s + 1} \]

\[ G_2(s) = \frac{100}{s^2 + 18s + 72} ]

\[ H(s) = \frac{0.71s + 3.57}{s^2 + 1.50s + 32} ]

The CLTF for a negative feedback system with \( K = 1 \) and unity feedback \( G_3(s) = 1 \)
is given by:

\[ G_{closed}(s) = \frac{G_1(s) \cdot G_2(s) \cdot K}{1 + G_1(s) \cdot G_2(s) \cdot H(s)} \]

Substituting the given \( G_1(s) \), \( G_2(s) \), and \( H(s) \) into the formula, you would
simplify the expressionto its lowest terms to find the pole-zero representation.

4.6:

System stability is determined by the poles' positions:

• All poles of the CLTF are in the left-half of the s-plane, essential for stability in LTI
systems.

• No poles are on the right-half of the s-plane or on the imaginary axis, affirming
stability.

• The pole-zero map displays a symmetric pair of complex poles, indicating


oscillatory modes in the system's response.

4.7:

Examining the step response of the CLTF reveals:

• The system achieves steady state without oscillations, showcasing effective


damping despite complex poles, which might have induced oscillations.

• There's no overshoot, and the response settles rapidly, indicating adequately


negative real parts of complex poles to dampen oscillations.
• A minor steady-state error is noticeable, quantifiable and addressable through
additional control design refinement.

Conclusion:

Theoretical analysis and MATLAB outputs confirm a stable closed-loop system with well-
damped step response at K=1 featuring minimal steady-state error. For detailed derivations
of the CLTF, software like "MS Equation Tools" can provide clear step-by-step illustrations.

5.Part 5: Closed loop system response for K=K*, 0.5K*

Matlab Code:
%PART 5
% part 5 codes

% Define the Laplace variable 's'


s = tf('s');

% Given transfer functions for the system


G1 = 1 / (s + 1); % Transfer function for G1(s)
G2 = 100 / (s^2 + 18*s + 72); % Transfer function for G2(s)
H = (0.71*s + 3.57) / (s^2 + 1.50*s + 32); % Transfer function for H(s), as provided

% Gain values from earlier parts


K_star = 0.104032; % Gain at which system becomes marginally stable

% Part 5.1: CLTF with K=K*


K = K_star;
CLTF_K_star = feedback(K*G1*G2*H, 1);

% Determine poles and zeros


poles_CLTF_K_star = pole(CLTF_K_star);
zeros_CLTF_K_star = zero(CLTF_K_star);

% Part 5.2: Pole-zero map with K=K*


figure;
pzmap(CLTF_K_star);
title('Pole-Zero Map of CLTF with K=K*');

% Part 5.3: Step response with K=K*


figure;
step(CLTF_K_star, 20);
title('Step Response of CLTF with K=K*');

% Part 5.4: CLTF with K=0.5*K*


K = 0.5*K_star;
CLTF_half_K_star = feedback(K*G1*G2*H, 1);

% Determine poles and zeros


poles_CLTF_half_K_star = pole(CLTF_half_K_star);
zeros_CLTF_half_K_star = zero(CLTF_half_K_star);

% Part 5.5: Pole-zero map with K=0.5*K*


figure;
pzmap(CLTF_half_K_star);
title('Pole-Zero Map of CLTF with K=0.5*K*');

% Part 5.6: Step response with K=0.5*K*


figure;
step(CLTF_half_K_star, 20);
title('Step Response of CLTF with K=0.5*K*');

% Display the poles and zeros for each case in the command window
disp('Poles of the CLTF with K=K*:');
disp(poles_CLTF_K_star);

disp('Zeros of the CLTF with K=K*:');


disp(zeros_CLTF_K_star);

disp('Poles of the CLTF with K=0.5*K*:');


disp(poles_CLTF_half_K_star);

disp('Zeros of the CLTF with K=0.5*K*:');


disp(zeros_CLTF_half_K_star);

5.1:
CLTF K*:

Poles and zeros of CLTF_K*


5.2:
Pole-zero map of CLTF with K=K*

5.3:
Step response of CLTF with K=K*
5.4:
CLTF at 0.5*K*:

5.5:
Pole-zero map of CLTF with K=0.5K*
5.5
Step response of CLTF with K=0.5K

Homewrok:
5.7:

At K=K*, all poles of the CLTF are in the left-half of the s-plane, indicating stability. Three poles
are at negative real values, while two are complex conjugate with negative real parts,
suggesting a stable response potentially with oscillations.

5.8:

The step response at K=K* exhibits:

• An initial peak response, typical with complex poles, followed by settling without
significant oscillations, indicating system stability.

• The final value theorem enables prediction of a low steady-state error based on the
transfer function.

5.9:

The poles of the CLTF at K=0.5K* closely resemble those at K = K* all situated in the left-half of
the s-plane, confirming system stability even at reduced gain.
5.10:
The step response at k=0.5k* indicates:

• Quick attainment of steady state with no overshoot, reflecting stable and well-damped
response.

• Slightly faster settling compared to K = K* due to reduced gain.

• Stable behavior observed for both k values, with desirable characteristics of absence of
overshoot and quick settling time. Further discussion is warranted to align these findings
with specific system requirements and performance metrics.

6.Part 6: Steady-State Error (SSE)


Matlab Code:
%PART 6
% 6.1
% Define the transfer function for G(s)
s = tf('s');
G_s = 100 / (s^2 + 18*s + 72); % G2(s) from the system

% Define the H(s) transfer function from the given H* value


H_s = (0.71*s + 3.57) / (s^2 + 1.5*s + 32);

% Calculate K* (for marginal stability)


K_star = 0.104032; % Value from part 2.6

% Define K for the calculation of SSE


K = 0.5 * K_star;

% Closed-loop transfer function for the given K


G_closed = feedback(K*G_s, H_s);

% Steady-State Error (SSE) Calculation for a unit step input


SSE = stepinfo(G_closed).SettlingMin - 1; % MATLAB's stepinfo function gives the
steady state value

% Display the SSE


fprintf('The Steady-State Error (SSE) with K = 0.5 * K* is: %f\n', SSE);

6.1:
Steady state Error:
Homework:
6.3:

In control theory, the steady-state error (SSE) reflects how closely a system approaches its
desired output after transients have diminished. For step inputs, we aim for the output to reach
the step magnitude as time approaches infinity, yielding zero steady-state error. SSE depends
on system type and input type.

7.Part 7: SIMULINK Models


7.1
Open loop Simulink model:

Step response:
7.2
Step response For first 20 seconds:

7.3:
Closed loop system:

Step Response:

7.4:
Closed loop step response for first 20 sec:

Homework:
7.5
1. Open-Loop vs. Closed-Loop Responses:

• Open-loop: Often unstable or slow to reach steady state.

• Closed-loop: With feedback, shows improved stability and faster response.

2. Discrepancies Between Simulations and Theory:

• Due to model simplifications, assumptions, or numerical methods.

• Modeling errors or linearization assumptions may contribute.

3. Influence of Feedback:

• Feedback affects stability and performance.


• Positive feedback may induce instability, while negative feedback stabilizes and
enhances response.

4. Stability Assessment:

• Open-loop: Poles in right half of s-plane indicate instability.

• Closed-loop: Feedback can stabilize previously unstable systems.

5. Performance Evaluation:

• Closed-loop systems demonstrate better overshoot, rise time, and settling time
due to feedback correction.

6. Summary:

• Feedback improves system dynamics, enhancing stability and performance.

• Conclusion emphasizes feedback's effectiveness in achieving desired system


behavior.

8. Part 8: LTI Viewer

Matlab Code:
%PART 8

% Define system transfer functions


numG = [0 0 0 100]; % Placeholder for actual G(s) numerator coefficients
denG = [1 18 72]; % Placeholder for actual G(s) denominator coefficients

numH = [0.71 3.57]; % Placeholder for actual H(s) numerator coefficients


denH = [1 1.5 32]; % Placeholder for actual H(s) denominator coefficients

% Create transfer function objects


G = tf(numG, denG);
H = tf(numH, denH);

% Define OLTF and CLTF for different K values


K1 = 1;
K_star = 0.10403; % Given K* value
K_half_star = 0.5 * K_star;

T_open = G * H; % Open-loop transfer function


CLTF_K1 = feedback(K1*T_open, 1); % CLTF with K = 1
CLTF_Kstar = feedback(K_star*T_open, 1); % CLTF with K = K*
CLTF_Khalf_star = feedback(K_half_star*T_open, 1); % CLTF with K = 0.5*K*

% Plot Nyquist diagrams


ltiview('nyquist', T_open, CLTF_K1, CLTF_Kstar, CLTF_Khalf_star);

% Plot step responses


ltiview('step', T_open, CLTF_K1, CLTF_Kstar, CLTF_Khalf_star);
8.1
Nyquist Diagram:
8.2:
Step Response:

Homework:

8.3:

The open-loop system exhibits a notable overshoot of approximately 65.94%, suggesting


oscillatory tendencies and potential instability without feedback. Introducing feedback with
K=1 marginally reduces overshoot, but the system remains relatively aggressive. Optimal
k(K=K*) better manages overshoot and enhances response stability. Further reducing 0.5*K
maintains overshoot levels but affirms that less aggressive control (lower k) stabilizes the
response.

8.4:

To improve performance, balancing response speed and overshoot is key. Using a PID
controller allows for finer tuning, while filters target frequency domain instability. Analyzing
the root locus plot helps find optimal gain settings. Lead/lag compensators refine rise and
settling time

You might also like