Helicopter Pendulum Is PID-licious

If you’ve ever tried to tune a PID system, you have probably encountered equal parts overwhelming math and black magic folk wisdom. Or maybe you just let the autotune take over. If you really want to get some good intuition for motion control algorithms, PID included, nothing beats a little hands-on experimentation.

To get you started, [Clovis] wrote in with his budget propeller-based PID demo platform (Portuguese, translated shockingly well here).

The basic setup is a potentiometer glued to a barbecue skewer with a mini-quadcopter motor and rotor on the end of it. A microcontroller reads the voltage and PWMs the propeller through a MOSFET. The goal is to have the pendulum hover stably in midair, controlled by whatever algorithms you can dream up on the controller. [Clovis]’ video demonstrates on-off and PID control of the fan. Adding a few more potentiometers (one for P, I, and D?) would make hands-on tweaking even more interactive.

In all, it’s a system that will only set you back a few bucks, but can teach you more than you’d learn in a month in college. Chances are good that you’re not going to have exactly the same brand of sardine can on hand that he did, but some improvisation is called for here.

If you don’t know why you’d like to master open-loop closed-loop control algorithms, here’s one of the best advertisements that we’ve seen in a long time. But you don’t have to start out with hand-wound hundred-dollar motors, or precisely machined bits. As [Clovis] demonstrates, you can make do with a busted quadcopter and whatever you find in your kitchen.

23 thoughts on “Helicopter Pendulum Is PID-licious

      1. I wonder why the Google page translator did such a good job on the text of the page, but the auto-translated close caption on YouTube failed so miserably. YouTube is part of Google, of course. The Translate people need to help out the YouTube people.

        “The gringos are shaking.” :)

      2. Sorry, all I get from the translation is that Tony belucci and pet boy will go-go wash off on October 20 at Nile Javari and his boyfriend will control a lot of biomass int the ocean… Not very helpful and definitely not shockingly well translated unless the content creator was on acid…

  1. Nitpick: Since PWM is being controlled by a potentiometer attached to the output, this would be a closed-loop control algorithm. An open-loop control would be one without the potentiometer to provide feedback.

  2. That is the setup designed for the 4 Weeks MIT MOOC 6.302.0x Introduction to Feedback Control Theory. Was live January this year, now renamed to “6.302.0x Introduction to Control System Design – A First Look” as an archived course.

    It’s an very basic introductory level course. There they teach you step-by-step how to build all this and to program the controller. Anyone interested should take a look at the archived course and don’t be scared by the math since only the most basic you already know from HS is all what is needed.

    1. I have seen that very briefly in the “introduction to aerospace engineering ” a month ago (and yes, That’s where the idea came from), and didn’t know it was fully featured in another course. Anyway, the way I do my stuff is “look at the end result and try to do it myself from the scratch “, so it May have elements from that course but Just look at my original Arduino code and you Will notice what I Just said

      1. Didn’t try to imply anything negative, just liked the course and found very easy to follow so wanted to recommend it to anyone interested to learn building a PID the same as you did. :)

  3. It would be cool to see this switch between PID and bang-bang control and add data out to a plot of angle versus time. One could do a really nice demo. It is nice as it is, but what are we comparing it to?

  4. Always cool seeing closed-loop control systems in action!

    It looks to me like the pot that the pendulum is connected to has a lot of friction, which may be contributing to the rather large overshoot in both directions. That, or the PID settings could be a lot better. It’s hard to tell because he didn’t demonstrate the response to disturbances in the on-off mode.

  5. So I haven’t read the code Clovis uses, but this is not the best teaching or learning setup for a PID. Why? If you’ve programmed robots, especially flying robot, you’ll know that controlling the *position* in this setup needs 2 PIDs or one and a half at least. In practice you can fully control the velocity (angular rate) of the arm with a single PID. You’ll need another closed loop controller on top of the velocity controller for smooth position control, to get a behavior that doesn’t overshoot in either direction. I said one and a half because some of the P, I and D values may be 0 in the second controller.

    1. By the way I don’t know if there’s a scientific name for such stacked PID controller, I call them PIDD (with further Ds if necessary). The velocity is the derivative of position and the derivate of the velocity is the second derivative of position, so basically this ends up being a single Proportional, Integral, Derivative, Second Derivative-and-so-on controller.

  6. I’ve lifted the pid control from the Marlin 3D printer firmware a year ago, used it to create a precisely controlled heated surface using a pic mcu and converted it to use integer calculations. I’ve learned a lot tuning the pid values by hand. The animated gif on wikipedia gives a good general visualization what each variable does to the system.

    The thing that I didn’t expect was that the sampljng and control frequency plays a large part in finding the pid values. Outputting the resulting data as csv through the serial port helped a great deal to graph the temperature and see what’s going on.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.