clear all clc close all % define the plant to be controlled s=tf('s'); P=1/s/(s+1); % or using tf function P1=tf(1,[1 1 0]); %% requirments % - error null in the case of step disturbance --> open loop function % with one integrator (pole in the origin) % - s% <= 15% (phase_margin >= 50°) % - ta5% <= 300 ms (w_c >= 20 rad/s) % - Ts = 30 ms (delay at w_c, in terms of phase, about -wc*Ts/2=-17°) % define the sampling time Ts=0.03; % the sampling angular frequency w_s=2*pi/Ts; % define the open-loop function C=1; F=C*P; % evaluate the margins figure, margin(F) grid on % define C1 in order to get w_c=20 rad/s: need an increase of the magnitude % of F1 in w_c of about 50dB and of the phase of F1 in w_c equal to 50+17 degrees (the latter taking % into account the delay introduced by ZOH) C1=20*(s+1)/(s/50+1); % add a zero in -1 and a pole at high frequency (-50) for realizable devise F1=C1*P; figure margin(F1) grid on % discret equivalent tf by using Tustin D1=c2d(C1,Ts,'tustin'); % anti-aliasing filter - a pole at frequency w_f such that w_f>w_c w_f=w_s/2.1; Fa=1/(s/w_f+1); % open the schemes (analog, digital and digital with anti-aliasing filter) implemented in Simulink feedback_control_scheme_analog_vs_digital