DIY Quadcopter – Vibrations & gyroscope

I’m still working on my quadcopter with a DIY flight controller based on an arduino chip. After a lot of tests and mainly (to not say only) crashes I realised that my gyroscope datas were unstable, here is how i try to sort it out !

In a previous article, I explained why we need a gyroscope and an accelerometer on a quadcopter to determine its attitude (pitch, roll and maybe yaw). In this article, I will explain how to filter the raw datas coming from the gyroscope in order to use in a fusing algorithm.

yet an other crash !

yet an other crash !

Find and cancel the offset

In order to understand what is happening I wrote a code that sends raw gyro datas to my computer here is the result :


The drone was not moving so what you see is only noise. The value is supposed to be 0 on each axis. When you see this graph, you quickly realize that each axis is staying around a specific value, this is the offset. Sensors are not perfect and their zero is not the real zero.

Here is my simple solution :

    //remove offset
    gyro[0] = gyro[0] + 236;
    gyro[1] = gyro[1] - 117;
    gyro[2] = gyro[2] - 296;

The values are simply the result of an average of 500 values on each axis.

offset removed

offset removed

The result is better but we still have noise. This is a simple solution that can only apply to my sensor at this specific time. The offset can move and is different from one sensor to an other. A more complex way would be to calibrate it at the beginning of each flight.

Reducing the noise

There is noise in the reading, not only because of the sensor itself but also because there are a lot of vibrations on board ! With my tests I realized that the motors tend to change the reading from my gyroscope. This is what you can see on the next graph, when the motors are not turning there is almost no noise, however when the motors are spinning there is way more noise that needs to be filtered.

Reading from the gyroscope (blue) and power on the motor (yellow)

Reading from the gyroscope (blue) and power on the motor (yellow)

Continue reading