quadopter motor control

Hi all!

my quadcopter is in such configuration:

m0 - CCW m1 - CW

m2 - CW m3 - CCW

it is set up in an X configuration

now, my PID algorithm returns values from -10 to 10 (still has to be adjusted)

the main problem is the algorithm which will apply the new PWM values to the motors
currently, I have something like this:

  motor_speed[0] = (int)output_gy + (int)output_gx + (int)output_gyaw;
  motor_speed[1] = (int)output_gy  - (int)output_gx - (int)output_gyaw;
  motor_speed[2] = (int)output_gy(-1) + (int)output_gx - (int)output_gyaw;
  motor_speed[3] = (int)output_gy(-1) - (int)output_gx + (int)output_gyaw;

  motor_speed[0] += throttle;
  motor_speed[1] += throttle;
  motor_speed[2] += throttle;
  motor_speed[3] += throttle;

this produces fine results when i told the quadcopter in the x or y axis but when i tilt it in both the X and Y axis simultaneously I get a sum (for example if throttle is 0, I get 20; output_gx + output_gy)

I could not get the right PID values no matter how hard i tried, I believe it could be due to this bug.

Now, the real question is, can someone point me in the right direction with an algorithm which will add the PID output to the motors in a correct manner?

Thanks,
Damian

What makes you think that 20 is 'wrong'?

You could divide all the values by 2. That would keep the maximum control value down to 10 but would make the maximum correction on a single axis 5. It would be the same as limiting the Output to +/-5 instead of 10.

I would keep the 20 values since your PID loops should be tuned so that they seldom (if ever) hit the control limits. If they hit the limits it means you are not correcting fast enough and should use higher limits.

Well I have tied down the quadcopter (its palm sized) and I'm trying to tune it on 1 axis. I believe that the logic is bogus as I cannot get it to stable out and I always get oscillation - slow for small values of p and fast for large values of p. Thankfully I can rotate the imu and I will try to set it up in the other mode (I forget the name). I'll get back with the results