clear all clc close all % For the process P=25/(s^2+15*s+50), design a digital controller by emulation % of a continuous design in order to satisfy the given requirments. % plant to be controlled s=tf('s'); P=25/(s^2+15*s+50); %%%% REQUIREMENTS %%%%%%%%%%%%%%%%%% % 1. error at steady state (e_inf) =0 wrt a step reference signal => % include an integrator in the open loop function (a pole in the origin) % 2. relative error at steady state (e_inf_r) <=0.05 wrt to disturbs. % in the range [0.01 0.1] rad/s => |F(jw)|>=1/0.05=20 in that range, i.e |F(jw)|>=26dB % 3. no overshoot => zita_c>0.6 phase_margin>60 degrees % (first order approx. of the closed loop system) % 4. ta5<=1 sec; ta5=3*tau, tau=1/wc <=> 3/wc<=1 <=> wc>=3 % Delta_ph: phase decrease due to discretization, i.e. wc*Ts/2, % then with wc=3, Delta_ph is about 9 degrees Ts=0.1; wc=3; Delta_ph=wc*Ts/2*180/pi; % use an integral controller, increase the integral gain in order to satisfy % the second requirement, i.e. |F(jw)|>=26dB for w in [0.01 0.1] % integral gain ki ki=6; C1=ki/s; % open loop function with C1 F1=C1*P; % evaluate the cross. freq. and phase margin figure, margin(F1) grid on % the cross. freq. of F1 is close to the desired wc, % but it is needed to increase the phase margin % introduce a zero in s=-3, then the tf of the controller is given by C2 C2=C1*(s/3+1); % define the open loop function with C2 F2=C2*P; % evaluate the cross. freq. and phase margin figure, margin(F2) grid on % compare F1 and F2 figure bode(F1,F2) hold on grid on legend % % evaluate the continuous closed loop system for the two cases (C1 and C2) W1=feedback(F1,1); W2=feedback(F2,1); figure hold on grid on step(W1,W2) legend % implement the digital controller D1 = c2d(C2, Ts, 'tustin'); % Discretize using Tustin's method % anti-aliasing filter - a pole at frequency wf such that wf>wc ws=2*pi/Ts; % sampling freq. wf=ws/2.1; % frequency of the pole of anti-aliasing filter Fa=1/(s/wf+1); scheme_exam_IA_25_Feb_2025