# Quadcopter Flight Controller:Why does Using gyroscope data give better results?

I have succeeded in making my first quadcopter from scratch with a readymade frame. I designed the flight controller myself with help from YMFC-3D youtube series of videos. https://www.youtube.com/watch?v=2pHdO8m6T7c

But in the process, I discovered that using the euler angles or the 'ypr' values from the MPU6050 as the feeback to the PID loop makes it super difficult to tune the quadcopter and even then it doesn't fly great.

Whereas although not intuitive to me, using the gyroscope values with a complementary filter instantly made the quad respond much better and the tuning also was not too difficult.

Let me clearly define the response in both cases.

Using ypr values:- +Always keeps overshooting or 'underreaching' +Very small range of values that can let the quad fly stable +Drastic Reactions to extreme values of P (Kp)values

Using gyro values:- +Reaction is much more stable +Tuning the PID was also simple + Even under high values of P(Kp) the quad might crash due to oscillations but not flip or react extremely

Below is a portion of the PID loop:

//gyrox_temp is the current gyroscope output

gyro_x_input=(gyro_x_input*.8)+(gyrox_temp*0.2);//complementary filter

pidrate_error_temp =gyro_x_input - setpoint;//error value for PID loop

pidrate_i_mem_roll += pidrate_i_gain_roll * pidrate_error_temp;
//integral portion

pidrate_output_roll = pidrate_p_gain_roll * pidrate_error_temp + pidrate_i_mem_roll + pidrate_d_gain_roll * (pidrate_error_temp - pidrate_last_roll_d_error);
//output of the pid loop
/pidrate_p_gain_roll-Kp
//pidrate_i_gain_roll-Ki
//pidrate_d_gain_roll-Kd
//this output is given as the pwm signal to the quad plus throttle

• Was your controller configured to adjust speed or angle? How are you processing gyro data? Can you provide a block diagram of the before and after code? As it stands, your question is very vague. Apr 29 '16 at 21:26
• Also, check the units on ypr - are you neglecting a 2*pi factor in the angles? I know it sounds silly but incorrect units on variables could cause this behavior. Apr 30 '16 at 5:56
• I added the 2*pi factor @SteveO May 1 '16 at 6:51