module4

module4 - clg; echo on

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clg; echo on %--------------------------------------------------------- % % Dept. of Electrical & Computer Eng. % University of California, Santa Barbara. % % ECE 147 A: Feedback Control Systems % % module4: Bode methods & loopshaping % % ------------------------------------------------- % The first example will show how to check the gain and % phase margins of a given loop. Consider the % following system; P = nd2sys(1,[1,2,1,0]); w = logspace(-1,2,150); P_w = frsp(P,w); % A Bode plot is first shown. Unity gain and -180 degrees % phase are also plotted for reference. subplot(221); vplot('liv,lm',P_w,'-',1,'--') title('P(s): Bode plot') xlabel('freq: rad/sec') ylabel('magnitude') subplot(223); vplot('liv,p',P_w,'-',-1-eps*j,'--') % -eps*j resolves +-180 ambiguity title('P(s): Bode plot') xlabel('freq: rad/sec') ylabel('phase') % And also a Nyquist plot, with the -1 point indicated. subplot(222); axis('square'); vplot('nyq',P_w,'-',-1,'*') axis([-2,2,-2,2]); title('P(s): Nyquist') xlabel('real') ylabel('imaginary') grid; axis('normal'); axis; % meta mod4fig1 pause % press any key to continue. % Now we would like to find the frequencies where the magnitude % is equal to one and the phase is equal to -180 degrees. Note % that it only crosses the negative real axis once and only goes % through the -180 degree point once. % The Matlab find function can be used to locate the closest % frequency value to the points we are looking for. [data,pointer,freqs] = vunpck(P_w); % get the data gindx = find(abs(data) < 1); % indices for |P(jw)| < 1 gw = freqs(gindx(1)); % frequency of a gain < 1 pindx = find(angle(data) > 0); % find where it wraps around pw = freqs(pindx(1)); % first wrapped frequency. GM = 1/abs(var2con(xtract(P_w,pw))) % actual gain margin 10*log10(GM) % margin in dBs PM = pi + angle(var2con(xtract(P_w,gw))) % in radians PM*360/(2*pi) % margin in degrees % Note that these are only approximations and depend on % the resolution with which we have calculated the % frequency response. pause % press any key to continue % ================================================ % Now consider the satellite example. This can be modeled % as a double integrator. % P(s) = (1/m)/s^2 m = 1.111; % satellite mass P = nd2sys(1/m,[1,0,0]); w = logspace(-2,2,200); % frequency vector. P_w = frsp(P,w); % Now examine the Bode and Nyquist plots of the system. clg; subplot(221); vplot('liv,lm',P_w,'-',1,'--') title('P(s): Bode plot') xlabel('freq: rad/sec') ylabel('magnitude') subplot(223); vplot('liv,p',P_w,'-',-1-eps*j,'--') % -eps*j resolves +-180 ambiguity title('P(s): Bode plot') xlabel('freq: rad/sec') ylabel('phase') % And also a Nyquist plot, with the -1 point indicated....
View Full Document

Page1 / 13

module4 - clg; echo on

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online