Here, the main objective of this project was to stabilize the yaw, pitch and roll axis's of the quadrotor as by merely applying a uniform thrust signal to them together will only result in the copter being flown away or in the worst case chopping off your head. So, to get a happy ending, the system needs to be stabilized.
So the story begins with an IMU (Inertial Measurement Unit) which is used to detect the real time attitude of the quadrotor in space, the 6DOF IMU consists of an accelerometer and a gyroscope , whose values are read by an I2C protocol using a microcontroller. This sensor's data is processed and applied to a quaternion based algorithm to yield the various yaw, pitch and roll angles of the quadrotor with respect to a reference point.So now we have the current state, next a PID (Proportional Integral Derivative) algorithm is used to bring the quadrotor to the stabilized position by detecting and reducing deviations from the steady state. The most fundamental part is tuning for the PID constants Kp, Ki, Kd , which was done by the same old trial and error method, after which filtering and estimating the angle values with minimum delay can be considered as a killer. The program loop is 115Hz.The most exciting part of this project is the ability to work with the highly powerful brushless motors (and there are 4 of them) achieving rpm's >10,000.
The microcontroller used here is an ATMega 2560, due to the high EEPROM capacity (256Kb). It's PWM pins are directly connected with the ESC's, the next connection is from the IMU to the controller.
The quadrotor attitude estimation software based on processing and arduino, based on Fabio Varesano, Starlino approach: