controlling of quadcopter problem

Started by nehasha187, May 09, 2012, 07:51:26 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nehasha187

anyone who has successfully completed a quadcopter..please help...i have checked every module namely,
gps, gyroscope + accelerometer, controlling individually. for controlling i am not sure what values (maximum and minimum) for raw, pitch, yaw to have a stable flight. help. its urgent

sajid6300shaikh

well there are no pre defined values for roll, pitch and yaw gain. that's why they provide a preset to adjust these according to our setup.
you need to find the values by trial and error method, on very low throttle, coz u don't want to break your props..  ;D
go according to the manual and u'll figure out..

spitfire


hyd_quads

Which board are you using? I suppose it's a standalone board, using some sized arduino (pro mini or nano?) Which firmware are you running?
Which gyros and acc? (nunchuk and WM+?) or other ITG32XX series gyros and BMA18X acc? Specify so that others can figure the sol. out.

nehasha187

Quote from: spitfire on May 09, 2012, 08:15:16 PM
Which control board are you using?
i designed the board myself according to my requirements. i am using PIC18F4520 microcontroller. In pid tuning of quadcopter, we need to set the output limits for throttle, pitch, yaw and roll and based on the tilting requirement the maximum and minimum values for all these are chosen in order to have a safe flight. with implementation of kalman filter i am able to get angles from -90 to 90 degree. i am posting my code. i am just a beginner so correct me if i have made any mistakes. thank you

#ifndef pidquadchanges
#define pidquadchanges
#define throttle 0
#define roll 1
#define pitch 2
#define yaw 3
// for yaw we apply only the user yaw
//unsigned int count; this variable stores the current time
// setpoints are data of sensors, input are data from my remote(designed according to my requirement) and output is used for setting the values of timers which are generating pwm for bldc motors

// variables used in calculating final throttle of all the motors
   #pragma udata my_section_1      //this was necessary otherwise some error was there see word file error on pid quad
   unsigned lasttime=0;
   // already defined in recievespi module   float input[6],setpoint[3],output[4];
   float error[3],dinput[3];      //output 4 as yaw is another output that is not calculated here but applied directly
   float iterm[3],lastinput[3],min[4],max[4];
   #pragma udata my_section_2
   float KP[3],KI[3],KD[3];
   float kp[4]={0,1.8,1.8,3.6},ki[4]={0,0.48,0.48,1.2},kd[4]={0,0.30,0.30,0.15};
   int sampletime=1000;   //1 sec
   float outmax[3],outmin[3];
   unsigned int d;
   unsigned inauto=0;
void compute(void);
void setoutputlimits();
void initialize(void);

void compute() // this is the comput function
{
   //if(!inauto)   return;   //manual mode and hence no pid tuning inauto needs to be connected to any pin of microcontroller
   setpoint[0]=output[0];
   d=0;
   while(d<3)
      {
      unsigned int now=count;      //here the value of count is to be assigned
      int timechange=(now-lasttime);
      if(timechange>=sampletime)
         {
         //compute all the working variable errors
         error[d]=setpoint[d]-input[d];
         iterm[d]+=(ki[d]*error[d]);
         if(iterm[d]>outmax[d]) iterm[d]=outmax[d];
         else if(iterm[d]<outmin[d]) iterm[d]=outmin[d];
         dinput[d]=(input[d]-lastinput[d]);
         //compute pid output
         output[d] = kp[d]*error[d]+iterm[d]-kd[d]*dinput[d];
         //remember some variables for the next time
         lastinput[d]=input[d];
         lasttime=now;   
         d++;      
         }
      }
      setpoint[0]=output[0];      //assigning throttle for the next time
}
be limited to min and max
{
   if(min[d] > max[d]) return;
   outmin[d] = min[d];
   outmax[d] = max[d];

   if(output[d] > outmax[d]) output[d] = outmax[d];
   else if(output[d] < outmin[d]) output[d] = outmin[d];

   if(iterm[d]> outmax[d]) iterm[d]= outmax[d];
   else if(iterm[d]< outmin[d]) iterm[d]= outmin[d];
   d++;
}
}

void setmode(int mode)
{
   char newauto = (mode == automatic);
   if(newauto && !inauto)
   {  /*we just went from manual to auto*/
      initialize();
   }
   inauto = newauto;
}

void initialize()
{
d=0;
while(d<3)
{
   lastinput[d] = input[d];
   iterm[d] = output[d];
   if(iterm[d]> outmax[d]) iterm[d]= outmax[d];
   else if(iterm[d]< outmin[d]) iterm[d]= outmin[d];
   d++;
}
}
#endif


help please

nehasha187

#5
due to budget problems i am not able to employ manetometer so my quad can change only pitch and roll not yaw. if user wants to change the yaw angle then it is directly used in calcaluting pwm for the motors.

nehasha187

Quote from: hyd_quads on May 09, 2012, 08:16:31 PM
Which board are you using? I suppose it's a standalone board, using some sized arduino (pro mini or nano?) Which firmware are you running?
Which gyros and acc? (nunchuk and WM+?) or other ITG32XX series gyros and BMA18X acc? Specify so that others can figure the sol. out.
3 axis gyroscope and accelerometer from nex-robotics and i designed the control board myself.

nehasha187


RotorZone

The ESCs accept standard servo pulse of 1-2ms.

Near 1ms the ESCs shut down and go into start up mode. Start up is slow, so you'd want to avoid going there in flight. The start up point will vary with different brands of ESCs. You could try 1.2ms as a initial value and then increase it if needed.

Most ESCs learn the high limit at power on, you should have provision for that in your code.

Other than this I don't think you need a specific limit for stable mode. I haven't worked on any quad code myself, so you could get better and faster answers if you go through code of projects like multiwii, mikrokopter, ardupilot etc. They are open source.

nehasha187

i have successfully generated pwm for the four motors and tested it as well....but that is not the issue...i am facing problem in balancing my quad..just want to know what should be the gains for roll, pitch and yaw and also what percentage of them is to be added to throttle of motors.

satyagupta

Start with 40%-50% and keep increasing or decreasing it..

Decrease or increase your pitch/roll gain until it starts oscillating, once starts decrease it back to previous value.
one stop for multirotor needs:
www.quadkopters.com

http://www.facebook.com/QuadKopters
https://www.youtube.com/user/QuadKopters
https://www.instagram.com/quadkopters