Академический Документы
Профессиональный Документы
Культура Документы
function [h]=pidmotor(kp,ki,kd)
J=3.2284E-6;
b=3.5077E-6;
K=0.0274;
R=4;
L=2.75E-6;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];
kp=kp;
ki=ki;
kd=kd;
numpid=[kd kp ki];
denpid=[1 0];
numf=conv(num,numpid);
denf=conv(den,denpid);
[af,bf,cf,df]=tf2ss(numf,denf)
sysf=ss(af,bf,cf,df)
h=feedback(sysf,1);
clear all
h=pidmotor(1.79,0,0)
t=0:0.01:0.3; % tiempo de la simulacion
step(h,t)
xlabel('Tiempo (s)')
ylabel('Posicion (rad)')
grid
af =
1.0e+007 *
-0.1455 -8.6144 0 0
0.0000 0 0 0
0 0.0000 0 0
0 0 0.0000 0
bf =
1
0
0
0
cf =
1.0e+009 *
0 0 5.5244 0
df =
a =
x1 x2 x3 x4
x1 -1.455e+006 -8.614e+007 0 0
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 0 5.524e+009 0
d =
u1
y1 0
Continuous-time model.
a =
x1 x2 x3 x4
x1 -1.455e+006 -8.614e+007 -5.524e+009 0
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 0 5.524e+009 0
d =
u1
y1 0
Continuous-time model.
Step Response
1.4
1.2
1
Posicion (rad)
0.8
0.6
0.4
0.2
0
0 0.05 0.1 0.15 0.2 0.25 0.3
Tiempo (s) (sec)
clear all
h=pidmotor(1.79,20,0)
t=0:0.001:0.3;
step(h,t)
xlabel('Tiempo (s)')
ylabel('Posicion (rad)')
grid
af =
1.0e+007 *
-0.1455 -8.6144 0 0
0.0000 0 0 0
0 0.0000 0 0
0 0 0.0000 0
bf =
1
0
0
0
cf =
1.0e+010 *
0 0 0.5524 6.1725
df =
a =
x1 x2 x3 x4
x1 -1.455e+006 -8.614e+007 0 0
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 0 5.524e+009 6.172e+010
d =
u1
y1 0
Continuous-time model.
a =
x1 x2 x3 x4
x1 -1.455e+006 -8.614e+007 -5.524e+009 -6.172e+010
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 0 5.524e+009 6.172e+010
d =
u1
y1 0
Continuous-time model.
Step Response
1.5
1
Posicion (rad)
0.5
0
0 0.05 0.1 0.15 0.2 0.25 0.3
Tiempo (s) (sec)
clear all
h=pidmotor(17,200,0.15)
t=0:0.001:0.3; % tiempo de la simulacion
step(h,t)
xlabel('Tiempo (s)')
ylabel('Posicion (rad)')
grid
af =
1.0e+007 *
-0.1455 -8.6144 0 0
0.0000 0 0 0
0 0.0000 0 0
0 0 0.0000 0
bf =
1
0
0
0
cf =
1.0e+011 *
df =
a =
x1 x2 x3 x4
x1 -1.455e+006 -8.614e+007 0 0
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 4.629e+008 5.247e+010 6.172e+011
d =
u1
y1 0
Continuous-time model.
a =
x1 x2 x3 x4
x1 -1.455e+006 -5.491e+008 -5.247e+010 -6.172e+011
x2 1 0 0 0
x3 0 1 0 0
x4 0 0 1 0
b =
u1
x1 1
x2 0
x3 0
x4 0
c =
x1 x2 x3 x4
y1 0 4.629e+008 5.247e+010 6.172e+011
d =
u1
y1 0
Continuous-time model.
Step Response
1.4
1.2
1
Posicion (rad)
0.8
0.6
0.4
0.2
0
0 0.05 0.1 0.15 0.2 0.25 0.3
Tiempo (s) (sec)
Wn
H(s)= -----------------------
S^2+2ζWnS+Wn^2
0.7
i) [0 : 0.25 : 4]rad / s
n
z=0.7
wn=[0:0.25:4]
t = [0:0.1:5];
vectomega = wn;
Y = [];
for ind = 1:length(vectomega)
d = vectomega(ind);
num = [wn.^2];
den = [1,2*d*wn,wn.^2];
y = step (num,den,t);
Y = [Y, y];
end
subplot(121)
plot (t,Y);
title ('Respuesta a un escalon unitario');
xlabel ('tiempo(seg)');
grid;
[cero,polo,constate]=tf2zp(num,den)
sis=tf(num,den);
subplot(122)
pzmap(sis)
title('Grafica de polos y ceros')
-5
Respuesta
x 10 a un escalon unitario
3 Grafica de polos y ceros
1.5
2.5
1
2
Imaginary Axis 0.5
1.5
0
1 -0.5
0.5 -1
0 -1.5
0 2 4 6 -2 -1 0 1 2
tiempo(seg) Real Axis
0.5
ii) [0 : 0.25 : 4]rad / s
n
z=0.5
wn=[0:0.25:4]
t = [0:0.1:5];
vectomega = wn;
Y = [];
for ind = 1:length(vectomega)
d = vectomega(ind);
num = [wn.^2];
den = [1,2*d*wn,wn.^2];
y = step (num,den,t);
Y = [Y, y];
end
subplot(121)
plot (t,Y);
title ('Respuesta a un escalon unitario');
xlabel ('tiempo(seg)');
grid;
[cero,polo,constate]=tf2zp(num,den)
sis=tf(num,den);
subplot(122)
pzmap(sis)
title('Grafica de polos y ceros')
-5
Respuesta
x 10 a un escalon unitario
3 Grafica de polos y ceros
1.5
2.5
1
2
0.5
Imaginary Axis
1.5
0
1 -0.5
0.5 -1
0 -1.5
0 2 4 6 -2 -1 0 1 2
tiempo(seg) Real Axis
[0 : 0.25 : 3]
iii) 2rdad / s
n
z=[0:0.25:3];
wn=2;
t = [0:0.1:5];
vectDelta = z;
num = wn^2;
Y = [];
for ind = 1:length(vectDelta) %inicia el bucle
d = vectDelta(ind); % obtenemos el numero de variables que
hay
den = [1,2*d*wn,wn^2];
y = step (num,den,t);
Y = [Y, y];
end
subplot(121)
plot (t,Y);
title ('Respuesta a un escalon unitario');
xlabel ('tiempo(seg)');
grid;
[cero,polo,constate]=tf2zp(num,den) % obtenemos los polos
ceros y
% constante de la funcion
sis=tf(num,den); % transforma en un sistema los valores
subplot(122)
pzmap(sis) % nos da el plano de polos y ceros
title('Grafica de polos y ceros')
0.8
-0.2
0.6 -0.4
0.4 -0.6
0.2 -0.8
0 -1
0 2 4 6 -15 -10 -5 0
tiempo(seg) Real Axis
[0 : 0.25 : 3]
iv) 3rad / s
n
z=[0:0.25:3];
wn=3;
t = [0:0.1:5];
vectDelta = z;
num = wn^2;
Y = [];
for ind = 1:length(vectDelta) %inicia el bucle
d = vectDelta(ind); % obtenemos el numero de variables que hay
den = [1,2*d*wn,wn^2];
y = step (num,den,t);
Y = [Y, y];
end
subplot(121)
plot (t,Y);
title ('Respuesta a un escalon unitario');
xlabel ('tiempo(seg)');
grid;
[cero,polo,constate]=tf2zp(num,den) % obtenemos los polos ceros y
% constante de la funcion
sis=tf(num,den); % transforma en un sistema los valores
subplot(122)
pzmap(sis) % nos da el plano de polos y ceros
title('Grafica de polos y ceros')
Respuesta a un escalon unitario
2 Grafica de polos y ceros
1
1.8
0.8
1.6
0.6
1.4
0.4
1.2
0.2
Imaginary Axis
1
0
0.8
-0.2
0.6 -0.4
0.4 -0.6
0.2 -0.8
0 -1
0 2 4 6 -20 -15 -10 -5 0
tiempo(seg) Real Axis
num=2600
den=[4 128 1053 1990 2600]
tt=0:0.25:10;
y=step(num,den,tt);
plot(tt,y)
grid;
title ('Respuesta de sistema');
xlabel ('tiempo (s)');
ylabel ('salida');
axis([0 10 0.9 1.15])
hold
zeta =
0.6901
Wn =
1.6114
m=2; %masa en kg
b=15; %coef de amortiguamiento en Ns/m
k=25; %coef del resorte en N/m
num=1;
den=[m b k];
Kp=300;
num=[Kp];
den=[m b k+Kp];
t=0:0.01:2;
step(num,den,t)
grid
Step Response
1.4
1.2
0.8
Amplitude
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)
m=2; %masa en kg
b=15; %coef de amortiguamiento en Ns/m
k=25; %coef del resorte en N/m
num=1;
den=[m b k];
Kp=30;
Ki=70;
num=[Kp Ki];
den=[m b k+Kp Ki];
t=0:0.01:2;
step(num,den,t)
grid
Step Response
1.4
1.2
0.8
Amplitude
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)
m=2; %masa en kg
b=15; %coef de amortiguamiento en Ns/m
k=25; %coef del resorte en N/m
num=1;
den=[m b k];
Kp=300;
Kd=10;
num=[Kd Kp];
den=[m b+Kd k+Kp];
t=0:0.01:2;
step(num,den,t)
grid
Step Response
1.4
1.2
0.8
Amplitude
0.6
0.4
0.2
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)
m=2; %masa en kg
b=15; %coef de amortiguamiento en Ns/m
k=25; %coef del resorte en N/m
num=1;
den=[m b k];
Kp=350;
Ki=300;
Kd=50;
num=[Kd Kp Ki];
den=[m b+Kd k+Kp Ki];
t=0:0.01:2;
step(num,den,t)
grid
Step Response
1
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)