fixed-凯发k8网页登录
this example uses the hinfstruct
command to tune a fixed-structure controller subject to constraints.
introduction
the hinfstruct
command extends classical synthesis (see hinfsyn
) to fixed-structure control systems. this command is meant for users already comfortable with the hinfsyn
workflow. if you are unfamiliar with synthesis or find augmented plants and weighting functions intimidating, use systune
and looptune
instead. see tune control systems using systune for the systune
counterpart of this example.
plant model
this example uses a 9th-order model of the head-disk assembly (hda) in a hard-disk drive. this model captures the first few flexible modes in the hda.
load hinfstruct_demo g bode(g), grid
we use the feedback loop shown below to position the head on the correct track. this control structure consists of a pi controller and a low-pass filter in the return path. the head position y
should track a step change r
with a response time of about one millisecond, little or no overshoot, and no steady-state error.
figure 1: control structure
tunable elements
there are two tunable elements in the control structure of figure 1: the pi controller and the low-pass filter
use the tunablepid
class to parameterize the pi block and specify the filter as a transfer function depending on a tunable real parameter .
c0 = tunablepid('c','pi'); % tunable pi a = realp('a',1); % filter coefficient f0 = tf(a,[1 a]); % filter parameterized by a
loop shaping design
loop shaping is a frequency-domain technique for enforcing requirements on response speed, control bandwidth, roll-off, and steady state error. the idea is to specify a target gain profile or "loop shape" for the open-loop response . a reasonable loop shape for this application should have integral action and a crossover frequency of about 1000 rad/s (the reciprocal of the desired response time of 0.001 seconds). this suggests the following loop shape:
wc = 1000; % target crossover s = tf('s'); ls = (1 0.001*s/wc)/(0.001 s/wc); bodemag(ls,{1e1,1e5}), grid, title('target loop shape')
note that we chose a bi-proper, bi-stable realization to avoid technical difficulties with marginally stable poles and improper inverses. in order to tune and with hinfstruct
, we must turn this target loop shape into constraints on the closed-loop gains. a systematic way to go about this is to instrument the feedback loop as follows:
add a measurement noise signal
n
use the target loop shape
ls
and its reciprocal to filter the error signale
and the white noise sourcenw
.
figure 2: closed-loop formulation
if denotes the closed-loop transfer function from (r,nw)
to (y,ew)
, the gain constraint
secures the following desirable properties:
at low frequency (w
ls at high frequency (w>wc), the open-loop gain stays below the gain specified by
ls
the closed-loop system has adequate stability margins
the closed-loop step response has small overshoot.
we can therefore focus on tuning and to enforce .
specifying the control structure in matlab
in matlab, you can use the connect
command to model by connecting the fixed and tunable components according to the block diagram of figure 2:
% label the block i/os wn = 1/ls; wn.u = 'nw'; wn.y = 'n'; we = ls; we.u = 'e'; we.y = 'ew'; c0.u = 'e'; c0.y = 'u'; f0.u = 'yn'; f0.y = 'yf'; % specify summing junctions sum1 = sumblk('e = r - yf'); sum2 = sumblk('yn = y n'); % connect the blocks together t0 = connect(g,wn,we,c0,f0,sum1,sum2,{'r','nw'},{'y','ew'});
these commands construct a generalized state-space model t0
of . this model depends on the tunable blocks c
and a
:
t0.blocks
ans = struct with fields:
c: [1x1 tunablepid]
a: [1x1 realp]
note that t0
captures the following "standard form" of the block diagram of figure 2 where the tunable components are separated from the fixed dynamics.
figure 3: standard form for disk-drive loop shaping
tuning the controller gains
we are now ready to use hinfstruct
to tune the pi controller and filter for the control architecture of figure 1. to mitigate the risk of local minima, run three optimizations, two of which are started from randomized initial values for c0
and f0
.
rng('default') opt = hinfstructoptions('display','final','randomstart',5); t = hinfstruct(t0,opt);
final: peak gain = 3.88, iterations = 67 final: peak gain = 597, iterations = 185 some closed-loop poles are marginally stable (decay rate near 1e-07) final: peak gain = 597, iterations = 161 some closed-loop poles are marginally stable (decay rate near 1e-07) final: peak gain = 3.88, iterations = 66 final: peak gain = 1.56, iterations = 102 final: peak gain = 1.56, iterations = 96
the best closed-loop gain is 1.56, so the constraint is nearly satisfied. the hinfstruct
command returns the tuned closed-loop transfer . use showtunable
to see the tuned values of and the filter coefficient :
showtunable(t)
c = 1 kp ki * --- s with kp = 0.000846, ki = 0.0103 name: c continuous-time pi controller in parallel form. ----------------------------------- a = 5.49e 03
use getblockvalue
to get the tuned value of and use getvalue
to evaluate the filter for the tuned value of :
c = getblockvalue(t,'c'); f = getvalue(f0,t.blocks); % propagate tuned parameters from t to f tf(f)
ans = from input "yn" to output "yf": 5486 -------- s 5486 continuous-time transfer function.
to validate the design, plot the open-loop response l=f*g*c
and compare with the target loop shape ls
:
bode(ls,'r--',g*c*f,'b',{1e1,1e6}), grid, title('open-loop response'), legend('target','actual')
the 0db crossover frequency and overall loop shape are as expected. the stability margins can be read off the plot by right-clicking and selecting the characteristics menu. this design has 24db gain margin and 81 degrees phase margin. plot the closed-loop step response from reference r
to position y
:
step(feedback(g*c,f)), grid, title('closed-loop response')
while the response has no overshoot, there is some residual wobble due to the first resonant peaks in g
. you might consider adding a notch filter in the forward path to remove the influence of these modes.
tuning the controller gains from simulink
suppose you used this to represent the control structure. if you have simulink control design installed, you can tune the controller gains from this simulink model as follows. first mark the signals r,e,y,n
as linear analysis points in the simulink model.
then create an instance of the sltuner
interface and mark the simulink blocks c
and f
as tunable:
st0 = sltuner('rct_diskdrive',{'c','f'});
since the filter has a special structure, explicitly specify how to parameterize the f
block:
a = realp('a',1); % filter coefficient setblockparam(st0,'f',tf(a,[1 a]));
finally, use getiotransfer
to derive a tunable model of the closed-loop transfer function (see figure 2)
% compute tunable model of closed-loop transfer (r,n) -> (y,e) t0 = getiotransfer(st0,{'r','n'},{'y','e'}); % add weighting functions in n and e channels t0 = blkdiag(1,ls) * t0 * blkdiag(1,1/ls);
you are now ready to tune the controller gains with hinfstruct
:
rng(0) opt = hinfstructoptions('display','final','randomstart',5); t = hinfstruct(t0,opt);
final: peak gain = 3.88, iterations = 69 final: peak gain = 597, iterations = 178 some closed-loop poles are marginally stable (decay rate near 1e-07) final: peak gain = 597, iterations = 166 some closed-loop poles are marginally stable (decay rate near 1e-07) final: peak gain = 3.88, iterations = 68 final: peak gain = 1.56, iterations = 97 final: peak gain = 1.56, iterations = 84
verify that you obtain the same tuned values as with the matlab approach:
showtunable(t)
c = 1 kp ki * --- s with kp = 0.000846, ki = 0.0103 name: c continuous-time pi controller in parallel form. ----------------------------------- a = 5.49e 03