estel1/it6 — comment on commit fef6ea79c9cf6710d93bb48e06b497a7d524b05a
File:  line 0
By venik:

#!/usr/bin/octave

% definitions
zeta = 0.707;
wp = 2 * pi * 50;

%Kd = 0.7 ;
%K0 = 0.6 ;
%Ki = 0.9 ;
%Kp = 0.15 ;

Kd = 0.5 ;
K0 = 0.5 ;
Ki = wp^2 / (Kd*K0) ;
Kp = 2*zeta*wp / (Kd*K0) ;

f0 = 1e3;	% 1kHz
delta_f = 0.0;
dt = 0.01;

phi = pi/2;

N = 5000;
x = zeros(N,1);
y = zeros(N,1);
e = zeros(N,1);

Int_e = 0;
Int_f = 0;
yn = 0;

omega0 = 10 ;

for k=1:N
t = (k-1) * dt;
x(k) = sin(2*pi*(f0 + delta_f)*t + phi) * yn ; ;
%x(k) = sin(omega0*t + phi) * yn ; ;
Int_f = Int_f + x(k)*dt;
e(k) = Kd * (Kp * x(k) + Ki * Int_f);
Int_e = Int_e + e(k)*dt;
y(k) = cos(2*pi*f0*t + K0 * Int_e);
%yn = cos(omega0*t + K0 * Int_e);
yn = y(k);
end % for k=1:N

plot(e(1:500))