ET2063 Mechatronics-Report
ET2063 Mechatronics-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.
% 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:
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.
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)
% 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}} \]
This value of \( K^* \) is critical because it represents the maximum gain at which the system
maintains stability.
2.7:
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.
% 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
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.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} \]
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:
• 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.
4.7:
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.
Matlab Code:
%PART 5
% part 5 codes
% 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);
5.1:
CLTF 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:
• 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.
• 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.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.
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:
3. Influence of Feedback:
4. Stability Assessment:
5. Performance Evaluation:
• Closed-loop systems demonstrate better overshoot, rise time, and settling time
due to feedback correction.
6. Summary:
Matlab Code:
%PART 8
Homework:
8.3:
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