Commit 9624d80e authored by medlem's avatar medlem
Browse files

Worked on feedback

parent d026dda6
Pipeline #53 failed with stage
% a = Z1
% b = Z2
% c = Z3
% d = Z4
% e = I1
% f = U1
syms a b c d e f
eqn = e == (f+b*((b*e)/(b-c-d)))/(a+b)
sole = solve(eqn, e)
......@@ -3,10 +3,10 @@ C2 = 1e-11;
L1 = 1e-5;
L2 = 1e-1;
M = 1e-6;
R1 = 1e-2;
R2 = 1e2;
%G1 = 1e2;
G1 = 1e-3;
R1 = 0;
R2 = 0;
%G1 = 1e-2;
G1 = 0;
% Time domain parameters
fs = 4e6; % Sampling frequency
......
C1 = 1e-7;
C2 = 1e-11;
L1 = 1e-5;
L2 = 1e-1;
M = 1e-6;
R1 = 0;
R2 = 0;
%G1 = 1e2;
G1 = 0;
% Over brkstreken
a = 2*(C1*C2*G1*M)-(C1*C2*G1*L2); %s^3
b = 0-(C1*C2*G1*R2)-(C1*C2); %s^2
c = 0-(C1*G1); %s^1
d = 0; %s^0
% Under brkstreken
e = (C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M); %s^4
f = (C1*C2*G1*L1*R2)+(C1*C2*L1)+(C1*C2*G1*R1*L1)-2*(C1*C2*G1*R1*M); %s^3
g = (C1*G1*L1)+(C1*C2*R1)+(C2*G1*L2)-2*(C2*G1*M); %s^2
h = (C1*G1*R1)+(C2*G1*R2)+C2; %s^1
k = G1; %s^0
HFB = tf([a b c d],[e f g h k]);
a = ((C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M)+(C1*C2*G1*M^2));
b = ((C1*C2*G1*L1*R2)+(C1*C2*G1*L2*R1)-2*(C1*C2*G1*M*R1)+(C1*C2*L1));
c = ((C1*C2*G1*R1*R2)+(C1*C2*R1)+(C1*G1*L1)+(C2*G1*L2)-2*(C2*G1*M));
d = ((C1*G1*R1)+(C2*G1*R2)+C2);
e = (G1);
f = (-1)*(C1*C2*M);
g = (-1)*(C1*G1*M);
H1 = tf([f g 0 0],[a b c d e]);
f0=1/(2*pi*(sqrt(L1*C1)));
% Time domain parameters
fs = 4e6; % Sampling frequency
dt = 1/fs; % Time resolution
T = 2*(1/f0); % Signal duration
t = 0:dt:T-dt; % Total duration
N = length(t); % Number of time samples
x2=square(2*pi*f0*t);
figure;
lsim(HFB,x2,t);
axis([0 1e-4 -10 10]);
xlabel('Seconds');
ylabel('Amplitude');
pbaspect([2 1 1]);
figure;
x81 = lab02(x8,0,1e-12);
H = feedback(H,HFB);
figure;
lsim(H,x1,t);
axis([0 1e-4 -10 10]);
xlabel('Seconds');
ylabel('Amplitude');
pbaspect([2 1 1]);
%plot(x8,t);
C1 = 1e-7;
C2 = 1e-11;
L1 = 1e-5;
L2 = 1e-1;
M = 1e-6;
R1 = 0;
R2 = 0;
%G1 = 1e-2;
G1 = 1e-6;
% Over brkstreken
a = 2*(C1*C2*G1*M)-(C1*C2*G1*L2); %s^3
b = 0-(C1*C2*G1*R2)-(C1*C2); %s^2
c = 0-(C1*G1); %s^1
d = 0; %s^0
% Under brkstreken
e = (C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M); %s^4
f = (C1*C2*G1*L1*R2)+(C1*C2*L1)+(C1*C2*G1*R1*L1)-2*(C1*C2*G1*R1*M); %s^3
g = (C1*G1*L1)+(C1*C2*R1)+(C2*G1*L2)-2*(C2*G1*M); %s^2
h = (C1*G1*R1)+(C2*G1*R2)+C2; %s^1
k = G1; %s^0
HFB = tf([a b c d],[e f g h k]);
a = ((C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M)+(C1*C2*G1*M^2));
b = ((C1*C2*G1*L1*R2)+(C1*C2*G1*L2*R1)-2*(C1*C2*G1*M*R1)+(C1*C2*L1));
c = ((C1*C2*G1*R1*R2)+(C1*C2*R1)+(C1*G1*L1)+(C2*G1*L2)-2*(C2*G1*M));
d = ((C1*G1*R1)+(C2*G1*R2)+C2);
e = (G1);
f = (-1)*(C1*C2*M);
g = (-1)*(C1*G1*M);
H1 = tf([f g 0 0],[a b c d e]);
f0=1/(2*pi*(sqrt(L1*C1)));
% Time domain parameters
fs = 4e6; % Sampling frequency
dt = 1/fs; % Time resolution
T = 1; % Signal duration
t = 0:dt:T-dt; % Total duration
N = length(t); % Number of time samples
x1 = ones(1,N);
x1(1) = 0;
H = feedback(H,HFB);
figure;
lsim(H,x1,t);
axis([0 1e-4 -10 10]);
xlabel('Seconds');
ylabel('Amplitude');
pbaspect([2 1 1]);
%plot(x8,t);
%SCHMITT TRIGGER
function [y] = lab02(x,tL,tH)
%x=rand(1,100);
%x=conv(x,ones(10,1)/10);
limit=0;
if nargin<3
disp('number of inputs arguments should be three');
end
N=length(x);
y=[length(x)];
for i=1:N
if ( limit ==0)
y(i)=0;
elseif (limit == 1)
y(i)=1;
end
if (x(i)<=tL)
limit=0;
y(i)=0;
elseif( x(i)>= tH)
limit=1;
y(i)=1;
end
end
plot(x,'r','DisplayName','plot of x','LineWidth',1.5); hold on;
plot(y,'blue','DisplayName','plot of y','LineWidth',3); hold off;
legend('show');
\ No newline at end of file
C1 = 1e-7;
C2 = 1e-11;
L1 = 1e-5;
L2 = 1e-1;
M = 1e-6;
R1 = 1e-1;
R2 = 1e1;
%G1 = 1e2;
G1 = 0;
%k =
H1 = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1);
H2 = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1);
H3 = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1);
H4 = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1);
H5 = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1);
figure;
bde1 = bodeplot(H1,H2,H3,H4,H5);
setoptions(bde1, 'FreqUnits','Hz','Grid','on');
figure;
subplot(2,1,1)
% step(H1, 1e-4); hold on;
% step(H2, 1e-4); hold on;
% step(H3, 1e-4); hold on;
step(H4, 2e-5); hold on;
% step(H5, 1e-4);
% [y1, t1] = step(H1,1e-4);
% y1 = pruneNaNWonderbar(y1);
% y1(numel(t1)) = 0;
% [y1, ~] = envelope(y1);
%
% [y2, t2] = step(H2,1e-4);
% y2 = pruneNaNWonderbar(y2);
% y2(numel(t2)) = 0;
% [y2, ~] = envelope(y2);
%
% [y3, t3] = step(H3,1e-4);
% y3 = pruneNaNWonderbar(y3);
% y3(numel(t3)) = 0;
% [y3, ~] = envelope(y3);
%
% [y4, t4] = step(H4,1e-4);
% y4 = pruneNaNWonderbar(y4);
% y4(numel(t4)) = 0;
% [y4, ~] = envelope(y4);
%
% [y5, t5] = step(H5,1e-4);
% y6 = y5;
% t6 = t5;
% y5 = pruneNaNWonderbar(y5);
% y5(numel(t5)) = 0;
% [y5, ~] = envelope(y5);
%loglog(t1, y1); hold on;
%loglog(t2, y2); hold on;
%plot(t3, y3); hold on;
%plot(t4, y4); hold on;
%plot(t5, y5); hold on;
%plot(t6, y6); hold on;
subplot(2,1,2)
impulse(H4, 2e-5);
figure;
pzmap(H4);
grid on;
function H = transfertingsak(C1, C2, L1, L2, M, R1, R2, G1)
a = ((C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M)+(C1*C2*G1*M^2));
b = ((C1*C2*G1*L1*R2)+(C1*C2*G1*L2*R1)-2*(C1*C2*G1*M*R1)+(C1*C2*L1));
c = ((C1*C2*G1*R1*R2)+(C1*C2*R1)+(C1*G1*L1)+(C2*G1*L2)-2*(C2*G1*M));
d = ((C1*G1*R1)+(C2*G1*R2)+C2);
e = (G1);
f = (-1)*(C1*C2*M);
g = (-1)*(C1*G1*M);
H = tf([f g 0 0],[a b c d e]);
H
end
function H = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1)
% Over brkstreken
a = 2*(C1*C2*G1*M)-(C1*C2*G1*L2); %s^3
b = 0-(C1*C2*G1*R2)-(C1*C2); %s^2
c = 0-(C1*G1); %s^1
d = 0; %s^0
% Under brkstreken
e = (C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M); %s^4
f = (C1*C2*G1*L1*R2)+(C1*C2*L1)+(C1*C2*G1*R1*L1)-2*(C1*C2*G1*R1*M); %s^3
g = (C1*G1*L1)+(C1*C2*R1)+(C2*G1*L2)-2*(C2*G1*M); %s^2
h = (C1*G1*R1)+(C2*G1*R2)+C2; %s^1
k = G1; %s^0
H = tf([a b c d],[e f g h k]);
H
end
function yo = pruneNaNWonderbar(y)
firstnanindex = find(isnan(y),1);
if ~isempty(firstnanindex)
y = y(1:(firstnanindex - 1));
end
firstinfindex = find(isinf(y),1);
if ~isempty(firstinfindex)
y = y(1:(firstinfindex - 1));
end
yo = y;
end
\ No newline at end of file
C1 = 1e-7;
C2 = 1e-11;
L1 = 1e-5;
L2 = 1e-1;
M = 1e-6;
R1 = 1e-1;
R2 = 1e2;
%G1 = 1e2;
G1 = 0;
%k =
H1 = transferCurrent(C1, C2, L1, L2, M, R1, R2, 1e-7);
H2 = transferCurrent(C1, C2, L1, L2, M, R1, R2, 1e-7);
H3 = transferCurrent(C1, C2, L1, L2, M, R1, R2, 1e-7);
H4 = transferCurrent(C1, C2, L1, L2, M, R1, R2, 1e7);
H5 = transferCurrent(C1, C2, L1, L2, M, R1, R2, 1e7);
figure;
bde1 = bodeplot(H1,H2,H3,H4,H5);
setoptions(bde1, 'FreqUnits','Hz','Grid','on');
figure;
subplot(2,1,1)
% step(H1, 1e-4); hold on;
% step(H2, 1e-4); hold on;
% step(H3, 1e-4); hold on;
step(H4, 2e-5); hold on;
% step(H5, 1e-4);
% [y1, t1] = step(H1,1e-4);
% y1 = pruneNaNWonderbar(y1);
% y1(numel(t1)) = 0;
% [y1, ~] = envelope(y1);
%
% [y2, t2] = step(H2,1e-4);
% y2 = pruneNaNWonderbar(y2);
% y2(numel(t2)) = 0;
% [y2, ~] = envelope(y2);
%
% [y3, t3] = step(H3,1e-4);
% y3 = pruneNaNWonderbar(y3);
% y3(numel(t3)) = 0;
% [y3, ~] = envelope(y3);
%
% [y4, t4] = step(H4,1e-4);
% y4 = pruneNaNWonderbar(y4);
% y4(numel(t4)) = 0;
% [y4, ~] = envelope(y4);
%
% [y5, t5] = step(H5,1e-4);
% y6 = y5;
% t6 = t5;
% y5 = pruneNaNWonderbar(y5);
% y5(numel(t5)) = 0;
% [y5, ~] = envelope(y5);
%loglog(t1, y1); hold on;
%loglog(t2, y2); hold on;
%plot(t3, y3); hold on;
%plot(t4, y4); hold on;
%plot(t5, y5); hold on;
%plot(t6, y6); hold on;
subplot(2,1,2)
impulse(H4, 2e-5);
figure;
pzmap(H4);
grid on;
function H = transfertingsak(C1, C2, L1, L2, M, R1, R2, G1)
a = ((C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M)+(C1*C2*G1*M^2));
b = ((C1*C2*G1*L1*R2)+(C1*C2*G1*L2*R1)-2*(C1*C2*G1*M*R1)+(C1*C2*L1));
c = ((C1*C2*G1*R1*R2)+(C1*C2*R1)+(C1*G1*L1)+(C2*G1*L2)-2*(C2*G1*M));
d = ((C1*G1*R1)+(C2*G1*R2)+C2);
e = (G1);
f = (-1)*(C1*C2*M);
g = (-1)*(C1*G1*M);
H = tf([f g 0 0],[a b c d e]);
H
end
function H = transferCurrent(C1, C2, L1, L2, M, R1, R2, G1)
% Over brkstreken
a = 2*(C1*C2*G1*M)-(C1*C2*G1*L2); %s^3
b = 0-(C1*C2*G1*R2)-(C1*C2); %s^2
c = 0-(C1*G1); %s^1
d = 0; %s^0
% Under brkstreken
e = (C1*C2*G1*L1*L2)-2*(C1*C2*G1*L1*M); %s^4
f = (C1*C2*G1*L1*R2)+(C1*C2*L1)+(C1*C2*G1*R1*L1)-2*(C1*C2*G1*R1*M); %s^3
g = (C1*G1*L1)+(C1*C2*R1)+(C2*G1*L2)-2*(C2*G1*M); %s^2
h = (C1*G1*R1)+(C2*G1*R2)+C2; %s^1
k = G1; %s^0
H = tf([a b c d],[e f g h k]);
H
end
function yo = pruneNaNWonderbar(y)
firstnanindex = find(isnan(y),1);
if ~isempty(firstnanindex)
y = y(1:(firstnanindex - 1));
end
firstinfindex = find(isinf(y),1);
if ~isempty(firstinfindex)
y = y(1:(firstinfindex - 1));
end
yo = y;
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment