discretize a compensator -凯发k8网页登录
this example shows how to convert a compensator from continuous to discrete time using several discretization methods, to identify a method that yields a good match in the frequency domain.
you might design a compensator in continuous time, and then need to convert it to discrete time for a digital implementation. when you do so, you want the discretization to preserve frequency-domain characteristics that are essential to your performance and stability requirements.
in the following control system, g
is a continuous-time second-order system with a sharp resonance around 3 rad/s.
one valid controller for this system includes a notch filter in series with an integrator. create a model of this controller.
notch = tf([1,0.5,9],[1,5,9]); integ = pid(0,0.34); c = integ*notch; bodeplot(c)
the notch filter centered at 3 rad/s counteracts the effect of the resonance in g
. this configuration allows higher loop gain for a faster overall response.
discretize the compensator.
cdz = c2d(c,0.5);
the c2d
command supports several different discretization methods. since this command does not specify a method, c2d
uses the default method, zero-order hold (zoh). in the zoh method, the time-domain response of the discretized compensator matches the continuous-time response at each time step.
the discretized controller cdz
has a sample time of 0.5 s. in practice, the sample time you choose might be constrained by the system in which you implement your controller, or by the bandwidth of your control system.
compare the frequency-domain response of c
and cdz
.
bodeplot(c,cdz) legend('c','cdz');
the vertical line marks the nyquist frequency, , where is the sample time. near the nyquist frequency, the response of the discretized compensator is distorted relative to the continuous-time response. as a result, the discretized notched filter may not properly counteract the plant resonance.
to fix this, try discretizing the compensator using the tustin method and compare to the zoh result. the tustin discretization method often yields a better match in the frequency domain than the zoh method.
cdt = c2d(c,0.5,'tustin'); plotopts = bodeoptions; plotopts.ylim = {[-60,40],[-225,0]}; bodeplot(c,cdz,cdt,plotopts) legend('c','cdz','cdt')
the tustin method preserves the depth of the notch. however, the method introduces a frequency shift that is unacceptable for many applications. you can remedy the frequency shift by specifying the notch frequency as the prewarping frequency in the tustin transform.
discretize the compensator using the tustin method with frequency prewarping, and compare the results.
discopts = c2doptions('method','tustin','prewarpfrequency',3.0); cdtp = c2d(c,0.5,discopts); bodeplot(c,cdt,cdtp,plotopts) legend('c','cdt','cdtp')
to specify additional discretization options beyond the discretization method, use c2doptions
. here, the discretization options set discopts
specifies both the tustin method and the prewarp frequency. the prewarp frequency is 3.0 rad/s, the frequency of the notch in the compensator response.
using the tustin method with frequency prewarping yields a better-matching frequency response than tustin without prewarping.
see also
functions
- |