Ashaya KC asked . 2025-01-15

How to PID tuning to meet conditions for settling time and overshoot

PID tuning to meet conditions for settling time and overshoot while a stable system with minimum peak time and zero velocity error.

So I am trying to find the gain values for a PI control system that would give me a settling time not exceeding 6 seconds, and an maximum overshoot not going over 5% while ensuring that the peaktime is the lowest it can be, and that the system is stable, and also has zero velocity error.
I have written the following code. Starting with a kp and ki value of 1 each, I get a system that gives desirable overshoot and settling time, but I am wondering if the peaktime can be even lower while still having settling time <= 6 and overshoot <= 5.
I am using the following toolboxes: Control System Toolbox
Questions
  1. Using the rlocus function, I have also shown that the real parts of the poles are negative, so this demonstrates that my system is stable right?
  2. Also am I using Lsim correctly to determine if velocity error is zero? The resultant graph has a gray line showing the time response, and a blue line that is parallel to it. This means zero velocity error right?
  3. What is the best way to fine-tune the gain values kp and ki to minimize peak time while ensuring the above conditions are still met?
I would like to use matlab only and no simulink for this please.
 
clc
clear all


% plant transfer function
G = tf([1], [0.5 1.5 1]) 

kp = 1
ki = 1
% PI controller
C = tf([kp ki], [1 0])

% closed loop transfer function
T = feedback(C*G, 1)
rlocus(T)
% Find the poles
poles = pole(T)

% step response
figure;
step(T);
title('Step Response');
grid on;

% Step analysis
info = stepinfo(T)

% Ramp Input
t = 0:0.01:10;
ramp = t;

% System response to ramp
figure;
lsim(T, ramp, t);
title('Ramp Response')
legend
grid on

 

pid tuning , control system , proportional gain , integral gain , settling time , overshoot

Expert Answer

Prashant Kumar answered . 2025-01-18 01:11:19

Here is the solution using pidtune(). There is no direct way to input the desired settling time and overshoot percentage; however, you can enter the desired phase margin. This has been a concern for me in MATLAB for many years. Nevertheless, based on the desired overshoot percentage, you can apply the formula from your lecture notes to determine the desired phase margin.

 

%% The Plant
Gp  = tf([1], [0.5 1.5 1])
Gp =
 
           1
  -------------------
  0.5 s^2 + 1.5 s + 1
 
Continuous-time transfer function.
%% Using pidtune
Pm  = 68.2;     % desired Phase Margin
opt = pidtuneOptions('PhaseMargin', Pm, 'DesignFocus', 'balanced');
[Gc, info] = pidtune(Gp, 'pidf', opt)
Gc =
 
             1            s    
  Kp + Ki * --- + Kd * --------
             s          Tf*s+1 

  with Kp = 2.02, Ki = 1.87, Kd = 0.489, Tf = 0.00619
 
Continuous-time PIDF controller in parallel form.
info = struct with fields:
                Stable: 1
    CrossoverFrequency: 1.4142
           PhaseMargin: 72.6977
%% Closed-loop system
Gcl  = feedback(Gc*Gp, 1)
Gcl =
 
             81.01 s^2 + 328.2 s + 302.2
  -------------------------------------------------
  0.5 s^4 + 82.31 s^3 + 324.4 s^2 + 489.8 s + 302.2
 
Continuous-time transfer function.
S    = stepinfo(Gcl)
S = struct with fields:
         RiseTime: 1.1479
    TransientTime: 3.6131
     SettlingTime: 3.6131
      SettlingMin: 0.9088
      SettlingMax: 1.0499
        Overshoot: 4.9883
       Undershoot: 0
             Peak: 1.0499
         PeakTime: 2.3938
step(Gcl), grid on, grid minor
xline(S.SettlingTime,    '--', sprintf('Settling Time: %.3f s', S.SettlingTime), 'color', '#7F7F7F', 'LabelVerticalAlignment', 'bottom')
yline(1+S.Overshoot/100, '--', sprintf('Overshoot: %.3f %%',    S.Overshoot),    'color', '#7F7F7F', 'LabelVerticalAlignment', 'top')


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.