Skip to content
OEWER Tools
Electronics

How a Drone Stays Level: Gyros, Motors and PID Loops

4 min readBy OEWER Team

A quadcopter is naturally unstable. See how four motors, motion sensors and a fast feedback loop called PID let it hover and hold its angle.

In this article
  1. Four rotors, two directions
  2. What the sensors measure
  3. The feedback loop
  4. From correction to motor speed
  5. Flight modes
  6. Summary
  7. Sources

A small quadcopter has no wings to give it stability and no tail rotor. It stays steady because a computer reads motion sensors hundreds of times a second and adjusts the speed of four motors each time. This article explains the pieces: how the motors move the drone, what the sensors measure, and the feedback loop that ties them together.

Four rotors, two directions

According to Wikipedia's article on quadcopters, two of the four rotors usually spin clockwise and two counterclockwise. When all four spin at the same speed, their twisting forces cancel, so the body does not rotate. Equal thrust from all four holds the drone in a hover or changes its altitude.

  • Yaw (turning left or right): the controller makes the clockwise pair and the counterclockwise pair produce different torque totals.
  • Pitch and roll (tilting and moving): more thrust on one rotor, or two neighbouring rotors, and less on the diagonally opposite side shifts the net thrust, so the drone tilts.
  • Climb or descend: all four rotors speed up or slow down together.

Unlike a helicopter, a quadcopter usually does not change the angle of its blades. All control comes from varying motor speed, as the same article explains. That makes the machine mechanically simple and puts the work on the electronics.

What the sensors measure

The motion sensors sit in a unit called an inertial measurement unit, or IMU. Wikipedia describes it as a device that reports a body's specific force and angular rate, combining accelerometers and gyroscopes and sometimes magnetometers.

  • Gyroscope: measures how fast the drone is rotating around each axis.
  • Accelerometer: measures acceleration, including the pull of gravity, which shows which way is down.
  • Magnetometer: senses the magnetic field and gives a heading reference.

Each sensor has a weakness. The IMU article explains that navigation with an IMU works by adding up, or integrating, measurements over time, so small errors accumulate into a growing gap between the estimate and reality, called drift. A gyroscope integrated alone drifts. To correct this, the article says a Kalman filter can combine the gyroscope's rotation rate with the gravity direction measured by the accelerometers to estimate attitude, meaning the drone's tilt. Outside references such as GPS can help correct drift too.

The same article notes that low-cost IMUs enabled the consumer drone industry. The quadcopter article places the arrival of cheap, light flight controllers, accelerometers, GPS and cameras at around 2005 to 2010.

The feedback loop

A flight controller compares what the pilot wants with what the sensors report, then corrects. Hobbyist flight-controller guides describe this with a PID controller, a standard feedback method. Wikipedia's PID article defines it as a loop that compares a setpoint (the target) with a measured value and adjusts its output to shrink the difference, called the error.

  • P, proportional: reacts to the current error. A bigger error gives a bigger correction. Alone it can leave a small steady offset.
  • I, integral: adds up the error over time, so a lingering gap keeps growing the correction until it closes.
  • D, derivative: looks at how quickly the error is changing and eases off as it closes, which reduces overshoot.

One flight-controller write-up describes a controller that maps the pilot's stick position onto the same degree scale the IMU reports, subtracts the measured angle from the desired one to get the error, and runs that through the three terms. Each term is weighted by a gain, and tuning those gains decides whether the aircraft flies slowly and smoothly or quickly and aggressively. Too much proportional gain can cause oscillation, and too much integral gain can cause overshoot.

From correction to motor speed

The controller's output is turned into signals for electronic speed controllers, which set how fast each motor spins. The exact mixing of roll, pitch, yaw and throttle into four motor commands varies between designs, and the sources used here do not cover it in detail.

Flight modes

The write-up mentions two common modes. In rate or acrobatic mode, only gyroscope feedback is used, so the drone holds a rotation speed and does not level itself. In stable mode the accelerometer, and the magnetometer if fitted, are also used, so the drone levels itself when the pilot releases the stick. In that project the bank and pitch were limited to 60 degrees in stable mode.

Summary

A quadcopter's steadiness is software, not shape. Motors give it the ability to tilt and turn, the IMU tells it how it is moving, and a PID loop running many times a second turns the difference between 'wanted' and 'measured' into small motor adjustments. When all three work together, a drone that would tumble within a second looks like it is resting on air.

Sources

This article was written with AI assistance. How we research and check our articles.

Share

Email

Keep reading