Skip to content

Instantly share code, notes, and snippets.

@pictos
Created September 7, 2018 23:21
Show Gist options
  • Save pictos/06023cc18879f7583e0e4d36b4256f78 to your computer and use it in GitHub Desktop.
Save pictos/06023cc18879f7583e0e4d36b4256f78 to your computer and use it in GitHub Desktop.
%%
%Valores
v=[57.58
57.10
57.10
56.61
56.61
57.10
57.58
57.10
57.10
57.10
57.58
57.10
57.58
57.10
57.58
57.58
57.58
57.58
57.58
57.10
57.10
57.58
57.58
57.10
57.10
56.61
56.12
56.12
56.12
55.63
55.14
55.14
54.17
54.17
53.68
53.19
52.22
51.73
52.22
51.24
51.24
50.26
49.78
49.78
49.29
49.29
49.29
48.31
48.80
47.34
47.82
46.85
46.85
46.85
45.87
45.87
46.36
45.87
45.87
45.38
45.38
44.90
44.41
44.41
43.92
43.92
43.92
43.43
43.43
42.94
42.94
43.43
42.94
42.94
42.94
42.46
42.46
41.97
41.48
41.48
40.99
41.97
41.48
40.99
40.99
40.50
40.50
40.50
40.02
40.50
40.02
40.02
40.02
39.53
39.53
39.04
40.02
39.04
39.04
38.55
39.04
38.55
38.55
38.55
38.55
38.55
38.06
38.06
37.58
38.55
37.58
37.58
37.58
38.06
37.58
37.09
37.09
37.58
36.60
37.58
37.09
37.09
37.09
37.09
36.60
36.60
36.60
36.60
36.60
36.60
36.11
35.62
36.11
36.60
36.11
36.60
35.62
35.62
35.62
36.11
35.62
35.62
35.14
35.62
35.14
35.62
35.14
35.14
35.14
35.14
34.65
35.62
34.65
34.65
34.65
35.14
35.14
34.65
35.14
34.65
35.14
34.65
35.14
35.14
35.62
34.65
34.65
35.14
34.16
34.16
35.14
34.65
35.62
34.65
34.65
35.14
35.62
34.65
35.14
35.62
35.14
35.14
35.14
35.62
35.62
35.14
35.62
35.62
35.62
35.14
35.62
35.14
35.62
35.62
36.11
35.62
35.62
35.62
35.62
35.62
35.62
36.11
35.62
35.62
35.14
35.62
35.62
35.62
36.11
35.62
36.11
36.11
35.62
35.62
35.62
35.62
36.11
35.62
35.62
35.62
35.62
35.62
35.62
36.11
35.62
35.62
36.11
36.11
35.62
36.60
35.62
36.11
36.11
36.60
36.11
36.11
36.60
35.62
36.11
36.60
36.11
35.62
36.11
35.62
36.11
36.11
36.11
36.11
36.11
36.11
36.11
36.11
35.62
36.11
35.62
36.60
36.11
36.11
36.11
36.11
36.11
36.11
36.11
36.11
36.60
36.11
36.11
35.62
36.11
36.60
36.11
36.11
36.11
35.62
36.11
36.11
35.62
35.62
36.11
36.11
36.60
36.11
36.60
36.60
36.60
35.62
36.60
36.11
36.11
36.11
35.62
35.62
36.11
36.11
36.11
36.60
36.11
36.60
36.60
36.60
36.11
36.60
36.11
36.60
36.60
36.60
36.60
36.11
36.11
36.60
36.60
36.60
35.62
36.11
36.60
36.11
36.60
36.11
36.11
36.60
36.60
36.11
36.60
36.60
36.60
36.11
36.11
36.11
36.11
36.60
35.62
36.11
36.60
36.11
36.60
36.60
36.60
36.60
36.60
36.60
36.11
36.60
36.60
36.60
36.60
36.11
36.11
36.11
36.11
36.11
36.11];
x=[1:1:351];
%%
%Parametros
k=-21.47; % ymax - ymin = 57.58 - 36.11 (como é unitario DU = 1)
tm= 23; % tempo morto em segundos
ct= 70; % tempo morto - valor do ponto final
g=-21*tf(1,[70 1],'inputdelay',23) %utilizando valores calculados
%%
%Plotando os graficos
plot(x,v,'r')
hold on
step(g+57.58)
title('TF + dados coletados');
legend('TF+57.58','Valores coletados');
grid on
hold off
h=pade(g)
%%
%Calculo dos valores Kp,Ki e Kd
Kp=0.9*70/23;
Ki=23/0.3;
pi= tf([Kp Ki],[1 0]);
Ts=0.01;
step(feedback(pi*h,1),[0:Ts:5]);
hold on
pi_=c2d(pi,Ts,'tustin'); %esse metodo garante que o sistema continue continuo quando passa para o discreto
h_=c2d(h,Ts,'tustin');
step(feedback(pi_*h_,1),[0:Ts:5], 'r');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment