simple matlab simulation of a quadrotor with pid controller

it is my final project. am working on position control of a quadrotor with pid controller in matlab.there are some problems in my matlab codes.I think the algorithm of pid controller is wrong and also i can not adjust the rotor speeds when i want to move quadrotor along only x-axis or y-axis.Actually i can control it on z-axis. I want to move quadrotor along z-axis first and then x-axis and finally y-axis.Could you inform me about the whole algorithm as soon as possible. I attached the matlab-codes, the codes are written to move quadrotor along x-axis.

Views: 1792

Reply to This

Replies to This Discussion

For some reason I cannot get the attached code file. See error message below:


Access Denied
You don't have permission to access "http://api.ning.com/files/hLt2Ui-AgwWXpiwJ9lekR8qGp1KnVBDSYG-t7zyYW91mi*6H*QlF2oGdYR93E30P7wfrgGPzfsSenHMcBn2vRA__/xaxis.rar" on this server.

Reference #18.504503f.1295506375.4dc791cc

I am sorry about that but i could not get the file as well so i decided to post codes directly. thanks zigmond...

 

clc;

clear all;

close all;

 

global   kp_x ki_x kd_x Intgr_x G perror_x  distance_x ;

time=input('time=');

distance_x=input('distance_x=');

 

kp_x=input('kp_x=');

kd_x=input('kd_x=');

ki_x=input('ki_x=');

Intgr_x=0;

syms A1 A2 A3 A4 U1 U2 U3 U4

baslangic=[0 0 0 0 0 0 0 0 0 0 0 0];

 

for i=1:((time/0.2)+1)

 

    z(i,:)=baslangic;

    [t,x]=ode23('position_qdrt2_x',[0,0.2],[baslangic(1),baslangic(2),baslangic(3),baslangic(4),baslangic(5),baslangic(6),baslangic(7),baslangic(8),baslangic(9),baslangic(10),baslangic(11),baslangic(12)]);

    a=size(x);

    baslangic=[x(a(1),1),x(a(1),2),x(a(1),3),x(a(1),4),x(a(1),5),x(a(1),6),x(a(1),7),x(a(1),8),x(a(1),9),x(a(1),10),x(a(1),11),x(a(1),12)];

 

end

 

function xdot=position_qdrt2_x(t,x)
    global  G perror_x kp_x kd_x ki_x Intgr_x distance_x ;
   
   
    perror_x=(distance_x-x(1))/0.2;       %x(1)-displacement on x-axis%
   
    Intgr_x=Intgr_x+0.2*perror_x;
   
    G=(kp_x*perror_x)+(kd_x*(x(2)))+ki_x*Intgr_x;  %x(2)-derivative of the x(1)%

%rotor speeds A1 A2 A3 A4%
    A1=212.61-0.001*G;
    A2=212.61;
    A3=212.61+0.001*G;
    A4=212.61;
   
    b=54.2*10^-6;
    d=1.1*10^-6;
   
    U1=b*(A1^2+A2^2+A3^2+A4^2);
    U2=b*(A4^2-A2^2);
    U3=b*(A3^2-A1^2);
    U4=d*(A2^2+A4^2-A1^2-A3^2);
    B=A2+A4-A1-A3;
   
m=1;
g=9.8;
l=0.48;
Ix=8.1*10^-3;
Iy=8.1*10^-3;
Iz=14.2*10^-3;
Jr=71.88*10^-6;
y1=((cos(x(7))*sin(x(9))*cos(x(11))+sin(x(7))*sin(x(11)))*(U1/m));
y2=((cos(x(7))*sin(x(9))*sin(x(11))-sin(x(7))*cos(x(11)))*(U1/m));
y3=-g+(cos(x(7))*cos(x(9)))*(U1/m);
y4=x(12)*x(10)*((Iy-Iz)/Ix)-(Jr/Ix)*x(10)*B+((l*U2)/Ix);
y5=x(12)*x(8)*((Iz-Ix)/Iy)+(Jr/Iy)*x(8)*B+((l*U3)/Iy);
y6=x(10)*x(8)*((Ix-Iy)/Iz)+((l*U4)/Iz);
 
xdot=[x(2);y1;x(4);y2;x(6);y3;x(8);y4;x(10);y5;x(12);y6];
 

hello,

 my name is cherazed,and i am a student in  the university of technologie option automatic, and i need 

matlab code of a quadrotor with pid controller please help me.

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service