📄 envgui.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of envgui</title>
<meta name="keywords" content="envgui">
<meta name="description" content="ENVGUI S-function for making a simple PID GUI">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="m2html.css">
</head>
<body>
<table border=0 width="100%" cellpadding=0 cellspacing=0><tr>
<td valign=baseline bgcolor="#ffe4b0"><b>AutotunerPID Toolkit</b></td>
<td valign=baseline bgcolor="#ffe4b0" align=right><a href="butterdesign.html"><img src="b_prev.gif" alt="Previous page" border=0></a> <a href="idareas.html"><img src="b_next.gif" alt="Next Page" border=0></a></td>
</tr>
</table>
<h1>envgui</h1>
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
<div class="box"><strong>Matlab S-function for making a simple PID GUI.</strong></div>
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
<div class="box"><strong>function [sys,x0,str,ts] = envgui(t,x,u,flag,NoiseBlock,LoadDistBlock) </strong></div>
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
<div class="fragment"><pre class="comment">ENVGUI S-function for making a simple PID GUI
When the model autotunerPID.mdl is run, this S-function create a panel
designed as a console from which controlling the simulation
environment. For example a measurement noise or a step on the load
disturbance can be included.
The most interesting part of this interface is the one termed
``Comparative Analysis'' which include analysis tools for both time and
frequency domain.
The time domain analysis perform a comparison of the responses to a
step on the set-point and on the load disturbance for a PID tuned with
all the available methods.
The frequency domain analysis reports the open loop Bode diagram of the
control system together with the Bode diagram of the complementary
sensitivity and the sensitivity function.
Everything started looking at PENDAN, an S-function for making pendulum
animation
Author: William Spinelli (wspinell@elet.polimi.it)
Copyright 2004 W.Spinelli
$Revision: 1.0 $ $Date: 2004/02/27 12:00:00 $</pre></div>
<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(matlabicon.gif)">
<li><a href="bodePIDcompare.html" class="code" title="function bodePIDcompare(num,den,tau)">bodePIDcompare</a> BODEPIDCOMPARE Comparison of Bode Diagrams with different autotuning</li><li><a href="stepPIDcompare.html" class="code" title="function stepPIDcompare(num,den,tau)">stepPIDcompare</a> STEPPIDCOMPARE Comparison of step response on setpoint and load</li></ul>
This function is called by:
<ul style="list-style-image:url(matlabicon.gif)">
</ul>
<!-- crossreference -->
<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
<ul style="list-style-image:url(matlabicon.gif)">
<li><a href="#_sub1" class="code">function [sys,x0,str,ts] = mdlInitializeSizes(NoiseBlock,LoadDistBlock)</a></li><li><a href="#_sub2" class="code">function sys = mdlUpdate(t,x,u)</a></li><li><a href="#_sub3" class="code">function LocalDeleteBlock</a></li><li><a href="#_sub4" class="code">function LocalClose</a></li><li><a href="#_sub5" class="code">function LocalDeleteFigure</a></li><li><a href="#_sub6" class="code">function LocalNoise</a></li><li><a href="#_sub7" class="code">function LocalNoiseParam</a></li><li><a href="#_sub8" class="code">function LocalDist</a></li><li><a href="#_sub9" class="code">function LocalDistParam</a></li><li><a href="#_sub10" class="code">function LocalStepPID</a></li><li><a href="#_sub11" class="code">function LocalBodePID</a></li><li><a href="#_sub12" class="code">function LocalHlp</a></li><li><a href="#_sub13" class="code">function LocalEnvSets(time,ud,u)</a></li><li><a href="#_sub14" class="code">function LocalEnvInit(NoiseBlock,LoadDistBlock)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [sys,x0,str,ts] = envgui(t,x,u,flag,NoiseBlock,LoadDistBlock)</a>
0002 <span class="comment">%ENVGUI S-function for making a simple PID GUI</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% When the model autotunerPID.mdl is run, this S-function create a panel</span>
0005 <span class="comment">% designed as a console from which controlling the simulation</span>
0006 <span class="comment">% environment. For example a measurement noise or a step on the load</span>
0007 <span class="comment">% disturbance can be included.</span>
0008 <span class="comment">% The most interesting part of this interface is the one termed</span>
0009 <span class="comment">% ``Comparative Analysis'' which include analysis tools for both time and</span>
0010 <span class="comment">% frequency domain.</span>
0011 <span class="comment">% The time domain analysis perform a comparison of the responses to a</span>
0012 <span class="comment">% step on the set-point and on the load disturbance for a PID tuned with</span>
0013 <span class="comment">% all the available methods.</span>
0014 <span class="comment">% The frequency domain analysis reports the open loop Bode diagram of the</span>
0015 <span class="comment">% control system together with the Bode diagram of the complementary</span>
0016 <span class="comment">% sensitivity and the sensitivity function.</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% Everything started looking at PENDAN, an S-function for making pendulum</span>
0019 <span class="comment">% animation</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% Author: William Spinelli (wspinell@elet.polimi.it)</span>
0022 <span class="comment">% Copyright 2004 W.Spinelli</span>
0023 <span class="comment">% $Revision: 1.0 $ $Date: 2004/02/27 12:00:00 $</span>
0024
0025 <span class="comment">% Plots every major integration step, but has no states of its own</span>
0026 <span class="keyword">switch</span> flag,
0027
0028 <span class="comment">% Initialization</span>
0029 <span class="keyword">case</span> 0,
0030 [sys,x0,str,ts] = <a href="#_sub1" class="code" title="subfunction [sys,x0,str,ts] = mdlInitializeSizes(NoiseBlock,LoadDistBlock)">mdlInitializeSizes</a>(NoiseBlock,LoadDistBlock);
0031 <span class="comment">% Update</span>
0032 <span class="keyword">case</span> 2,
0033 sys = <a href="#_sub2" class="code" title="subfunction sys = mdlUpdate(t,x,u)">mdlUpdate</a>(t,x,u);
0034 <span class="comment">% Unused flags</span>
0035 <span class="keyword">case</span> { 1, 3, 4, 9 },
0036 sys = [];
0037 <span class="comment">% DeleteBlock</span>
0038 <span class="keyword">case</span> <span class="string">'DeleteBlock'</span>,
0039 <a href="#_sub3" class="code" title="subfunction LocalDeleteBlock">LocalDeleteBlock</a>
0040 <span class="comment">% DeleteFigure</span>
0041 <span class="keyword">case</span> <span class="string">'DeleteFigure'</span>,
0042 <a href="#_sub5" class="code" title="subfunction LocalDeleteFigure">LocalDeleteFigure</a>
0043 <span class="comment">% Close</span>
0044 <span class="keyword">case</span> <span class="string">'Close'</span>,
0045 <a href="#_sub4" class="code" title="subfunction LocalClose">LocalClose</a>
0046 <span class="comment">% Noise</span>
0047 <span class="keyword">case</span> <span class="string">'Noise'</span>,
0048 <a href="#_sub6" class="code" title="subfunction LocalNoise">LocalNoise</a>
0049 <span class="comment">% NoiseParam</span>
0050 <span class="keyword">case</span> <span class="string">'NoiseParam'</span>,
0051 <a href="#_sub7" class="code" title="subfunction LocalNoiseParam">LocalNoiseParam</a>
0052 <span class="comment">% Dist</span>
0053 <span class="keyword">case</span> <span class="string">'Dist'</span>,
0054 <a href="#_sub8" class="code" title="subfunction LocalDist">LocalDist</a>
0055 <span class="comment">% DistParam</span>
0056 <span class="keyword">case</span> <span class="string">'DistParam'</span>,
0057 <a href="#_sub9" class="code" title="subfunction LocalDistParam">LocalDistParam</a>
0058 <span class="comment">% StepPID</span>
0059 <span class="keyword">case</span> <span class="string">'StepPID'</span>,
0060 <a href="#_sub10" class="code" title="subfunction LocalStepPID">LocalStepPID</a>
0061 <span class="comment">% BodePID</span>
0062 <span class="keyword">case</span> <span class="string">'BodePID'</span>,
0063 <a href="#_sub11" class="code" title="subfunction LocalBodePID">LocalBodePID</a>
0064 <span class="comment">% Help</span>
0065 <span class="keyword">case</span> <span class="string">'Hlp'</span>,
0066 <a href="#_sub12" class="code" title="subfunction LocalHlp">LocalHlp</a>
0067 <span class="comment">% Unexpected flags</span>
0068 <span class="keyword">otherwise</span>
0069 error([<span class="string">'Unhandled flag = '</span>,num2str(flag)]);
0070 <span class="keyword">end</span>
0071 <span class="comment">% end envgui</span>
0072
0073 <span class="comment">%=============================================================================</span>
0074 <span class="comment">% mdlInitializeSizes</span>
0075 <span class="comment">% Return the sizes, initial conditions, and sample times for the S-function.</span>
0076 <span class="comment">%=============================================================================</span>
0077 <a name="_sub1" href="#_subfunctions" class="code">function [sys,x0,str,ts] = mdlInitializeSizes(NoiseBlock,LoadDistBlock)</a>
0078 <span class="comment">% initialize parameters (setpoint)</span>
0079 set_param(get_param([get_param(gcs,<span class="string">'Parent'</span>) <span class="string">'/'</span> NoiseBlock],<span class="string">'Handle'</span>),<span class="keyword">...</span>
0080 <span class="string">'Variance'</span>,<span class="string">'0'</span>);
0081 set_param(get_param([get_param(gcs,<span class="string">'Parent'</span>) <span class="string">'/'</span> LoadDistBlock],<span class="string">'Handle'</span>),<span class="keyword">...</span>
0082 <span class="string">'Value'</span>,<span class="string">'0'</span>);
0083
0084 <span class="comment">% set up S-function</span>
0085 sizes = simsizes;
0086
0087 sizes.NumContStates = 0;
0088 sizes.NumDiscStates = 0;
0089 sizes.NumOutputs = 0;
0090 sizes.NumInputs = 0;
0091 sizes.DirFeedthrough = 0;
0092 sizes.NumSampleTimes = 1;
0093
0094 sys = simsizes(sizes);
0095
0096 x0 = [];
0097 str = [];
0098 ts = [0.1 0];
0099
0100 <a href="#_sub14" class="code" title="subfunction LocalEnvInit(NoiseBlock,LoadDistBlock)">LocalEnvInit</a>(NoiseBlock,LoadDistBlock);
0101 <span class="comment">% end mdlInitializeSizes</span>
0102
0103
0104 <span class="comment">%=============================================================================</span>
0105 <span class="comment">% mdlUpdate</span>
0106 <span class="comment">% Update the Environment Control GUI animation.</span>
0107 <span class="comment">%=============================================================================</span>
0108 <a name="_sub2" href="#_subfunctions" class="code">function sys = mdlUpdate(t,x,u)</a>
0109 fig = get_param(gcbh,<span class="string">'UserData'</span>);
0110 <span class="keyword">if</span> ishandle(fig),
0111 <span class="keyword">if</span> strcmp(get(fig,<span class="string">'Visible'</span>),<span class="string">'on'</span>),
0112 ud = get(fig,<span class="string">'UserData'</span>);
0113 <a href="#_sub13" class="code" title="subfunction LocalEnvSets(time,ud,u)">LocalEnvSets</a>(t,ud,u);
0114 <span class="keyword">end</span>
0115 <span class="keyword">end</span>
0116 sys = [];
0117 <span class="comment">% end mdlUpdate</span>
0118
0119
0120 <span class="comment">%=============================================================================</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -