I'm trying to develop a control system to a quadcopter and one of my options is to use a PID controller (which I think is the most used method).

From what I've read, the commom strategy is to run a PID algorithm to each axis. My question is: how the PID output is converted to PWM signals?

I'm asking that because the three axes and the four rotors depend on each other. I mean, if I slow down a couple of rotors which are opposite to each other then the quadcopter will move down in a vertical axis. But if I speed one of them and slow down the other, the quadcopter will rotate in a different axis.

So we cannot isolate each axis and associate them with a single rotor or a pair of those. And because of that, how can a PID output (which is associated to an axis) can be converted to PWM signals to the rotors?

Is that a MIMO system?


2 Answers 2


Let's try to give a comprehensive answer and stay on topic!

As you said in your question there is one PID per axis. This means 3 PIDs in total: roll, pitch, and yaw.

Also the motors input is a PWM high-level time, typically in the 1000-2000us range. There are 4 motors input: front, back, left, and right. One subtlety of the motors is that there is a value under which the motors stop completely, for instance 1100ms.

There is another variable not mentioned in the question: the throttle.

The first step in my quadcopter project was to tune the throttle. My throttle values were between -100 and 100, so I applied the following formula to each motor: motor = 300 * throttle / 100 + 1550. The constant values are arbitrary and give us a motor value in the 1250-1850 range, other values of the same magnitude would work.

Only then do we apply the PIDs using the motor mix formula. For instance for my +4 quadcopter the formula is:

  • Front = Throttle + PitchPID - YawPID
  • Back = Throttle - PitchPID - YawPID
  • Left = Throttle + RollPID + YawPID
  • Right = Throttle - RollPID + YawPID

The PID output has no unit. Choosing the right P, I, and D constants shall give us values which can stabilise the quadcopter. One caveat is that depending on the PID values the motor input can exceed the bounds: it could go over 2000us or under 1100us (which is our example motor cut value). In order to avoid such a situation we can analyse the higher and the lower of our motors inputs and add a constant to get all the motors within bounds.

For instance if the motor mix formula gave us:

  • Front = 1900
  • Back = 1800
  • Left = 2100
  • Right = 1700

We would remove 100 from each motor and get:

  • Front = 1800
  • Back = 1700
  • Left = 2000
  • Right = 1600

This would give us motors input values within bounds and maintain the difference between motors.

As a side note you said in a comment that the thrust vs PWM input is not linear. This is true but PIDs can drive non-linear systems with more or less success. For quadcopters the consensus is that it works reasonably well :)

If anything was unclear please let me know!

Cheers, Marc.

  • $\begingroup$ Nice answer. I'm starting to understand and will read it again, but before, tell me something: when you try to tune one of the PID's, doesn't it affect the tuning of the others since they are all related? And as I asked in the end of the question: is that a MIMO system then? $\endgroup$ May 24, 2014 at 1:10
  • $\begingroup$ It is called a MIMO system indeed, but each of the 3 PIDs has an individual input and an individual output. So don't let the term MIMO confuse you: it's just 3 classic PIDs. $\endgroup$
    – marcv81
    May 24, 2014 at 21:28
  • $\begingroup$ Also because the motor mix is chosen with a reasonable understanding of the underlying model, the tuning of a PID has virtually no impact on the others. It is worth noting that because a quadcopter is symmetrical the same tuning can be used for roll and pitch. In my project I turned the pitch and roll rates with the same parameters first, and then I tuned the yaw rate. $\endgroup$
    – marcv81
    May 24, 2014 at 21:37
  • 1
    $\begingroup$ Are your example values correct? From what I've read, generally the PWM range goes from 1.0ms to 2.0ms with 1.5ms being the stop value. Also, your throttle should go from -1 to +1 so your formula work and not -100/+100. As for the system, where does the direction goes in your formula? I mean, besides the throttle, we should indicate where to go (right, front, left or back). $\endgroup$ May 28, 2014 at 4:41
  • $\begingroup$ Yes, I meant microseconds (us) instead of milliseconds (ms). Also the throttle formula has a slight mistake. I edited the original reply, thanks for pointing these out! The directions are given as PIDs inputs. A PID takes as an input a setpoint and a measured variable, and the error is calculated as setpoint - measured variable. The setpoint comes from your sticks input. $\endgroup$
    – marcv81
    May 29, 2014 at 9:26

If you slow down one couple of oppositely placed rotors in a quadcopter, it will not only reduce the vertical thrust, it will result in change of yaw.

Since what you're asking is essentially a general description of PID tuning techniques for a quadcopter, I suggest you stick to Google for the moment, including http://blog.oscarliang.net/quadcopter-pid-explained-tuning/ and http://www.thomasteisberg.com/quadcopter/

Things to note:

  • You can have more than 1 PIDs per axis
  • The usual output of PIDs are +/- values for rate of change of roll, pitch and yaw.
  • The desired change in roll, pitch or yaw is brought about by a low level controller. It converts the rate of change to a restoring torque (basically... a small increment in one motor and a corresponding small decrement in the opposite motor.)
  • Usually, roll and pitch PIDs act on two motors at a time. Yaw PID act on all fours.

You may try going through : understanding the PID controller and Quadcopter PID tuning

  • $\begingroup$ Thanks for the answer. Maybe I was not very clear in my question, but I am not trying to understand a PID controller nor a quadcopter physics. As for the situation above, I think it should change the yaw AND reduce vertical thrust since the net force (which is purely vertical if the quadcopter is well balanced) will reduce. My question is about the second and third point you said. How exaclty those rates of change in an axis are converted to changes in rotor's speed? $\endgroup$ May 22, 2014 at 16:17
  • $\begingroup$ Also, since the proppellers force are not linear in respect to the PWM input, how can a sum of PID's work well? I mean, if I have a PID to control yaw acting in all four motors, another PID to controle roll acting in a pair of motors and another onde to control pitch acting also in a pair. When I want the quadcopter to make a move which is a combination of movements, each PID will give its contribution. How those contributions will be added since it is not a linear system? $\endgroup$ May 22, 2014 at 16:20
  • $\begingroup$ PWM input vs propellor thrust is not a linear curve, but you can try a test bench like this: llamahacks.blogspot.in/2014/01/… to determine the i/p vs o/p response of your setup. You'll have to determine a working region of your PWM where the response is 'nearly' linear i.e, operate the PWM at a range where the output is almost linear. If the three PIDs work fine individually, they should also work fine when put together. $\endgroup$
    – metsburg
    May 23, 2014 at 5:21
  • $\begingroup$ You may wanna have a look at this project: github.com/agnivsen/NoobCopter for a simple implementation of PID using Arduino. This project barely launches a quadrotor into a stable upward lift (may need PID tuning)... but the implementation is simple and it serves the purpose. You may start from here and build something more robust. $\endgroup$
    – metsburg
    May 23, 2014 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.