📄 learningpid.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"><html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>Learning PID Tuning II: Stability Margin</title> <meta name="generator" content="MATLAB 7.5"> <meta name="date" content="2008-02-05"> <meta name="m-file" content="learningpid"><style>body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. */ p,h1,h2,div.content div { max-width: 600px; /* Hack for IE6 */ width: auto !important; width: 600px;}pre.codeinput { background: #EEEEEE; padding: 10px;}@media print { pre.codeinput {word-wrap:break-word; width:100%;}} span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.codeoutput { color: #666666; padding: 10px;}pre.error { color: red;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;} </style></head> <body> <div class="content"> <h1>Learning PID Tuning II: Stability Margin</h1> <introduction> <p>The PID controller is the most widely used controller in various engineering systems. However, appropriately tuning a PID controller is not an easy task althrough it has only three parameters at most. The difficulty particially comes from some comfilict requirements of control system performance and partially is due to complicated impacts of PID parameters on control performance. This submission provides the second tutorial on PID tuning using the stability margin. </p> </introduction> <h2>Contents</h2> <div> <ul> <li><a href="#1">Ziegler-Nichols Tuning Rule</a></li> <li><a href="#2">Determine the Ultimate Gain and Period</a></li> <li><a href="#3">Example: PI controller for a first-order plus time-delay system</a></li> <li><a href="#4">Closed-loop step response</a></li> <li><a href="#5">Closed-loop performance comparison</a></li> <li><a href="#6">Conclusion</a></li> </ul> </div> <h2>Ziegler-Nichols Tuning Rule<a name="1"></a></h2> <p>Ziegler-Nichols tuning rule was the first such effort to provide a practical approach to tune a PID controller. According to the rule, a PID controller is tuned by firstly setting it to the P-only mode but adjusting the gain to make the control system in continuous oscillation. The corresponding gain is referred to as the ultimate gain (Ku) and the oscillation period is termed as the ultimated period (Pu). Then, the PID controller parameters are determined from Ku and Pu using the Ziegler-Nichols tuning table. </p> <p><html> <table border=1> <tr><td>Controller</td><td>Kc</td><td>Ti</td><td>Td</td></tr> <tr><td>P</td><td> Ku / 2 </td><td> </td><td> </td></tr> <tr><td>PI</td><td> Ku / 2.2 </td><td> Pu / 1.2 </td><td> </td></tr> <tr><td>PID</td><td> Ku / 1.7 </td><td> Pu / 2 </td><td> Pu / 8 </td></tr> </table> </html> </p> <h2>Determine the Ultimate Gain and Period<a name="2"></a></h2> <p>The key step of the Ziegler-Nichols tuning approach is to determine the untimate gain and period. However, to determine the ultimate gain and period experimentally is time comsuming. Since the continuous oscillation mode correcponds to the critical stable condition, for linear systems, such a condition can be easily determined through stability margins. Other tools, such as the Routh criterion and the Evans root locus, cannot deal with a time-delay directly. </p> <p>Let the plant have gain margin Gm at crossover frequency Wcg. This equivalent to connect with a unit gain controller. Therefore, if the controller gain increases by Gm, then the system will oscillate at frequency Wcg. Therefore, Ku and Pu can be determined from Gm and Wcg as follows: </p> <p><img vspace="5" hspace="5" src="learningpid_eq1339.png"> </p> <p>or</p> <p><img vspace="5" hspace="5" src="learningpid_eq105252.png"> </p> <p><img vspace="5" hspace="5" src="learningpid_eq14982.png"> </p> <h2>Example: PI controller for a first-order plus time-delay system<a name="3"></a></h2> <p>The plant has a unit gain, time constant 10 and time delay 2</p><pre class="codeinput">T=10;dt=2;G=tf(1,[T 1]);G.InputDelay=dt;<span class="comment">% use the Ziegler-Nichols PID design tool</span>[k,ku,pu]=znpidtuning(G,2);<span class="comment">% verify Ku and Pu using step response of G*ku in 5 periods</span>step(feedback(ss(G*ku),1),5*pu)</pre><img vspace="5" hspace="5" src="learningpid_01.png"> <h2>Closed-loop step response<a name="4"></a></h2> <p>the PI controller transfer function</p><pre class="codeinput">C=k.kc*(1+tf(1,[k.ti 0]));<span class="comment">% get the closed-loop model in state space form since MATLAB/Control Toolbox</span><span class="comment">% support time-delay only in state-space form.</span>H=minreal(feedback(ss(G*C),1));<span class="comment">% closed-loop step response</span>step(H)</pre><img vspace="5" hspace="5" src="learningpid_02.png"> <h2>Closed-loop performance comparison<a name="5"></a></h2> <p>The above result is compared with the PI controller tuned based on the <a href="http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16661&objectType=FILE">Process Reaction Curve Appraoch.</a> The PI parameters from this approach are as follows: </p><pre class="codeinput">kc=0.9*T/(1*dt);ti=3.33*dt;C1=kc*(1+tf(1,[ti 0]));H1=minreal(feedback(ss(G*C1),1));holdstep(H1)gridlegend(<span class="string">'stability margin approach'</span>,<span class="string">'process reaction curve appraoch'</span>)</pre><pre class="codeoutput">Current plot held</pre><img vspace="5" hspace="5" src="learningpid_03.png"> <h2>Conclusion<a name="6"></a></h2> <p>For this particular example, the stability margin based tuning results a smaller overshooting but slightly slower response.</p> <p class="footer"><br> Published with MATLAB® 7.5<br></p> </div> <!--##### SOURCE BEGIN #####%% Learning PID Tuning II: Stability Margin
% The PID controller is the most widely used controller in various
% engineering systems. However, appropriately tuning a PID controller is
% not an easy task althrough it has only three parameters at most. The
% difficulty particially comes from some comfilict requirements of control
% system performance and partially is due to complicated impacts of PID
% parameters on control performance. This submission provides the second
% tutorial on PID tuning using the stability margin.
%
%% Ziegler-Nichols Tuning Rule
% Ziegler-Nichols tuning rule was the first such effort to provide a
% practical approach to tune a PID controller. According to the rule, a PID
% controller is tuned by firstly setting it to the P-only mode but adjusting
% the gain to make the control system in continuous oscillation. The
% corresponding gain is referred to as the ultimate gain (Ku) and the
% oscillation period is termed as the ultimated period (Pu). Then, the PID
% controller parameters are determined from Ku and Pu using the
% Ziegler-Nichols tuning table.
%
% <html>
% <table border=1>
% <tr><td>Controller</td><td>Kc</td><td>Ti</td><td>Td</td></tr>
% <tr><td>P</td><td> Ku / 2 </td><td> </td><td> </td></tr>
% <tr><td>PI</td><td> Ku / 2.2 </td><td> Pu / 1.2 </td><td> </td></tr>
% <tr><td>PID</td><td> Ku / 1.7 </td><td> Pu / 2 </td><td> Pu / 8 </td></tr>
% </table>
% </html>
%
%% Determine the Ultimate Gain and Period
% The key step of the Ziegler-Nichols tuning approach is to determine the
% untimate gain and period. However, to determine the ultimate gain and
% period experimentally is time comsuming. Since the continuous oscillation
% mode correcponds to the critical stable condition, for linear systems,
% such a condition can be easily determined through stability margins.
% Other tools, such as the Routh criterion and the Evans root locus, cannot
% deal with a time-delay directly.
%
% Let the plant have gain margin Gm at crossover frequency Wcg. This
% equivalent to connect with a unit gain controller. Therefore, if the
% controller gain increases by Gm, then the system will oscillate at
% frequency Wcg. Therefore, Ku and Pu can be determined from Gm and Wcg as
% follows:
%
% $$K_u=G_m$$
%
% or
%
% $$20\log_{10}(K_u) = G_m (dB)\,\, \Rightarrow\,\, K_u=10^{Gm/20}$$
%
% $$P_u=\frac{2\pi}{\omega_{cg}}$$
%
%% Example: PI controller for a first-order plus time-delay system
% The plant has a unit gain, time constant 10 and time delay 2
T=10;
dt=2;
G=tf(1,[T 1]);
G.InputDelay=dt;
% use the Ziegler-Nichols PID design tool
[k,ku,pu]=znpidtuning(G,2);
% verify Ku and Pu using step response of G*ku in 5 periods
step(feedback(ss(G*ku),1),5*pu)
%% Closed-loop step response
% the PI controller transfer function
C=k.kc*(1+tf(1,[k.ti 0]));
% get the closed-loop model in state space form since MATLAB/Control Toolbox
% support time-delay only in state-space form.
H=minreal(feedback(ss(G*C),1));
% closed-loop step response
step(H)
%% Closed-loop performance comparison
% The above result is compared with the PI controller tuned based on the
% <http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=16661&objectType=FILE Process Reaction Curve Appraoch.>
% The PI parameters from this approach are as follows:
kc=0.9*T/(1*dt);
ti=3.33*dt;
C1=kc*(1+tf(1,[ti 0]));
H1=minreal(feedback(ss(G*C1),1));
hold
step(H1)
grid
legend('stability margin approach','process reaction curve appraoch')
%% Conclusion
% For this particular example, the stability margin based tuning results a
% smaller overshooting but slightly slower response.
##### SOURCE END #####--> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -