Taming the Skies with PID

PID controller Simple explanation with a Quadcopter as example.

Estimated read time: 1:20

    AI is evolving every day. Don't fall behind.

    Join 50,000+ readers learning how to use AI in just 5 minutes daily.

    Completely free, unsubscribe at any time.

    Summary

    In this enlightening video by Pratik Phadte, the concept of a PID controller is explained using a quadcopter as a practical example. The video breaks down the components of a PID controller—Proportional, Integral, and Derivative controls—into simple terms without delving into complex mathematics. Through a hands-on demonstration, viewers learn how to adjust PID values for optimal quadcopter stability, witnessing the effects of oscillation, steady-state error, and damping. With an entertaining narrative, Pratik explores trial-and-error methods for tuning PID values, providing valuable insights for both beginners and enthusiasts in drone technology.

      Highlights

      • Explaining PID controllers with a fun quadcopter demonstration! 🚁
      • Simplifying the theory: no heavy math, just intuitive diagrams. 🗒️
      • Understanding a P controller's role and its limitations like oscillations and steady-state errors. 📉
      • Discover how D controllers help dampen oscillations for smoother quadcopter flight. 🌬️
      • Learn how I controllers tackle steady-state errors by integrating previous errors. 📈
      • Engage in trial-and-error with PID tuning for hands-on learning and fun experimentation! ⚙️
      • Pratik's playful yet informative approach makes learning about PID engaging and accessible. 🎥

      Key Takeaways

      • Learn the basics of PID controllers through a simple demo! 🤖
      • Discover the role of Proportional, Integral, and Derivative controls in quadcopter stability. 🔄
      • Witness the impact of oscillations and steady-state errors on drone performance. 🌀
      • Explore practical tips on tuning PID values for better control. 🎛️
      • Get inspired to try out PID tuning on your own drone projects! 🚁

      Overview

      Pratik Phadte takes us on an insightful journey into the world of PID controllers using a compelling and easy-to-follow quadcopter example. He cleverly explains the PID components - Proportional, Integral, and Derivative - without the need for complex math, focusing on practical understanding. Pratik's use of diagrams and straightforward explanations help demystify how these controls can stabilize quadcopter flights.

        Throughout the video, we see Pratik experimenting with PID tuning using his quadcopter setup. His methodical trial-and-error approach is both educational and fun, demonstrating real-time how tuning affects the drone's stability. The adjustments show the necessity of balancing the pid components to combat issues like oscillation and steady-state error, which are common in drone flight.

          This video serves as a perfect introduction for anyone interested in mastering the art of PID tuning, especially in drone applications. By the end, viewers are not only informed but also inspired to experiment with their own drones. Pratik's engaging style and the practical insights offered make learning about PID controllers both fun and rewarding.

            PID controller Simple explanation with a Quadcopter as example. Transcription

            • 00:00 - 00:30 [Music] so in this video we are going to see a p ID controller with a demonstration on a card copter so before we start this let's just quickly cover some small Theory there won't be any mathematics involved in this I'll just draw a bunch of figures and I think you'll be good to go so it consists of three things that proportionally integral and derivative
            • 00:30 - 01:00 so the first part we'll talk about is the proportional so for the P controller let's say your controller just consists of a proportional controller you have a response on your y on your y AIS and time on your x-axis now as time goes you let's say your desired value was Zero then you increase your throttle joystick or your movement joystick and it increases to some value so this is your
            • 01:00 - 01:30 response that you want the system to follow okay this is actually the input you're giving okay and the output of the P controller would be somewhat like this okay so note that this was your input and this is the output that you get of a p controller now there are quite a bit of interesting things we can see is that it uh increases up to the
            • 01:30 - 02:00 value it doesn't quite touch it and then it goes below and then sort of oscillates so this oscillation happens is because of the Practical of the system like it has inertia right if it's moving from one place to another it will try to come back and forth because of the inertia so this is a bit of oscillations you can see in a p controller and one thing you can see is this never quite reaches the ideal State now this could be because of external factors such as wind pressure or something else so this is one thing we
            • 02:00 - 02:30 need to worry about so there is a steady state error in AP controller so one thing is a steady state error other is oscillations so now let's try to solve the problem of oscillations we don't want oscillations so what we'll do we'll add a d controller so let's talk about a PD controller so it is just proportional and a derivative controller so I'm going to draw the same thing this's time here and there's a response here and this is the
            • 02:30 - 03:00 desired input okay this is the in input and now we have the output of the PD controller to be something like this so it is solving the problem of your oscillation so a d controller also called a damping controller it sort of damps the oscillation so this is what we're going to see in the on the actual presentation on the Drone okay so this is about the damping and uh as you can see we have have not solved uh stady
            • 03:00 - 03:30 straight error problem till now so in order to solve that problem we have like an integral controller okay so in this integral controller is the same thing again so your response and your time in in an integral controller what would happen is your output would be somewhat like this so you solve the problem of steady state by overcoming the steady state error now this is p
            • 03:30 - 04:00 controller not just a pi controller it's a p controll because you don't have the oscillations as well now the best thing about this is that an i an integral controller it sort of like adds the errors from the past so here you can see that there was some error in the past so this error it adds over time each time cycle and then it gives a response to counteract that error so that's the beauty of an integral control it just integrates over time whatever the error
            • 04:00 - 04:30 that you have it just adds it and gives a response to that whereas a DC controller if there's a sharp change in error it will sort of reduce it so a differentiation of a changing quantity gives you some value but of a constant it is zero so it try to make the Zero by different like the controller its main purpose is to damp out the oscillations so now this is the basics of A P controller uh how do we you know put it in a system so there are bunch of libraries on our you know or you can
            • 04:30 - 05:00 even create your code for it so I have the everything in the GitHub we'll move to the demo now but before we move to the demo you should know that for p d and I there are some gains so we adjust those gains in order to you know get a good response on a system now those gains could be found by trial and error there are some automated processes uh which are uh to be done in a good environment in a simulated environment uh but for now let's just do trial and error we are doing our physical system
            • 05:00 - 05:30 so trial and error would be good so let's move on towards the physical setup now so the setup is uh quite like this it looks like I'm grilling the Drone uh but uh it is it is very well uh it is it is a good way to experiment and I got this idea from my friend who's also into drones his name is monoj konar you can check him on YouTube I'll leave a link so uh this is what uh his idea was to get like for the pit and roll values so
            • 05:30 - 06:00 by the way these are pitch this is a ro axis so anyways the values should be same for pitch and roll because they are like in the similar plane and uh that's what we are going to do we are going to test our P values I'm going to explain you the proportional integral and differential by using this setup so this is again the same flight controller the espw flight controller drone and uh we're going to uh through Wi-Fi we're going to send data to the Drone from this uh web page so right now whatever I
            • 06:00 - 06:30 type here will be pushed onto the Drone okay and uh I can select the gain value so right now everything the pitch and roll gain have set to zero similarly I have set to Zero D have set to zero we will not discuss about the yawing because that access is not accessible right now the time cycle this is nothing but how much time it takes for one calculation to be done one PID calculation So currently let's just keep everything zero and let's see
            • 06:30 - 07:00 what exactly the C copter responds to so for me for you to just see this is like very less friction right now so we'll try with a we try increasing the throttle and see how it goes so I'm going to turn on my uh RC so if you can see this so ideally it should not do anything think like it should behave like this so I'm
            • 07:00 - 07:30 going to slowly increase the throttle and you can see that it is not giving me any sort of resistance while I leave it it is just free falling so the controller is not acting right now even if I increase the throttle there seems to be no no change so let's slowly increase the P value so right now I will
            • 07:30 - 08:00 I'm increase the so I'm increasing the P value by let's say 0.5 and this flushes it so 0.5 value has been put uh now let's try throttling it
            • 08:00 - 08:30 so there is some resistance I can feel it like it is not easily falling you can hear the motor speed increase the other side uh this side to push it up see it is not Free Falling like it used to Okay so I think we need to get more P
            • 08:30 - 09:00 value so let's keep it one right now I'm going to submit to one okay so let's see how it goes when you put one value okay so value has been entered okay so this is Qui okay but still it
            • 09:00 - 09:30 is still is not able to overcome so I think one is also less so let's increase one I'm going to try with 1.5 and we have flushed 1.5 into it so now I think it should work very
            • 09:30 - 10:00 well yeah so it is sort of stable but here you can see the magic of the integral not being there it is sort of like a tilt right if it would be integral controller the Tilt would overcome and there is the oscillation here like if I it is not sort of getting the correct result but if I pull it down
            • 10:00 - 10:30 it is the value also is not that great I would say so we'll increase a little more till we get like a decent result okay so let's put the Throttle Down
            • 10:30 - 11:00 so I have put the P value to two right now and we see how it is going okay there is a bit of unstability you can see that it overshoots okay there is that tilt you can see and uh
            • 11:00 - 11:30 it isort of okay still some oscillation you can see the oscillation sort of happening like goes back and forth with the D controller it will be stable so this is quite decent okay so let's keep the value two
            • 11:30 - 12:00 that seems okay you know that is like a decent value okay now it should not be good so I think 1 something between 1.5 and 1 two so two so you settle on the value of 1.75 uh this will be our last value
            • 12:00 - 12:30 oscillations are there we try to limit
            • 12:30 - 13:00 the we'll first try the D thing and then we'll try with the I thing because uh the oscillation is quite half haard like what if it gets cut or it it it might damage the system so first we'll try to reduce the oscillations so here on the D side I'm going to start uh this is I
            • 13:00 - 13:30 just tried earlier so I know these values so I'm going to try with like 0.44 let's see what this thing does and U you just have to find through trial and error so for your system this might be different but nevertheless U this is a learning video for p and I'm going to show you what the damping does so we have entered all the values
            • 13:30 - 14:00 so you see that the damping has reduced earlier it was damping quite still it is oscillating a little I think it is because we can increase the damping de part so we'll try to inre
            • 14:00 - 14:30 so I've almost doubled the differential again now let's see the result
            • 14:30 - 15:00 so this is quite better than earlier I think I think the p is the issue the P gain we have set more I try to reduce the P gain and see the response because as I increase the throttle the ation areed a lot so what
            • 15:00 - 15:30 I'll do is I decrease the p g I think 1 4 would be 1.2 would be something fantastic okay so 1.2 and now let's see the result
            • 15:30 - 16:00 yeah now the result is quite good there is still some so this is much better than the earlier result and uh you just have to look at it and wiing it uh there is some error here and there I
            • 16:00 - 16:30 think it's because of the I integral part uh but nevertheless it looks decent so we'll now do the last part that is the integral so I don't quite know what's the best value for this but if I keep 0.1 we'll see what what's happening and I
            • 16:30 - 17:00 think B is also good we'll just increase it by let's say more okay so let's feed these values um and I think this should be
            • 17:00 - 17:30 maybe I value I might have set I might have set it more so
            • 17:30 - 18:00 so I've not found like the best optimum value for I but uh I think this PD controller itself should work pretty decently uh let's see with this just a
            • 18:00 - 18:30 so it gives like a it gives like an almost okay result uh we have to check it how how it
            • 18:30 - 19:00 flies so that time some changes would be required but for a demonstration purpose I think you get the idea that a p controller would be like just for a proper output response a d controller would be to damping it or would be damping it and ey controller was would be for the final change so ey controller would be a really good if uh you just try it in an actual flight instead of an instead instead of a setup like this because here this joint also adds to the
            • 19:00 - 19:30 error right because it sort of messes up the throttle stick uh because of the throttle if I increase the throttle it lifts this and that that that may cause some issue with the actual system so I have some values that I'll I'll try
            • 19:30 - 20:00 for
            • 20:00 - 20:30 [Applause] so this is giving like some oscillations are there but you can see it auto correct and then try to recover from that phas but you can see the damping is quite slow like it is not abrupt so this is how you can like understand and P I hope this video was
            • 20:30 - 21:00 useful in that terms and then similar thing you can let me just this off so similar thing you can do with your try to experiment with this time cycle as well uh like you have to select an Optimum time cycle such that it matches the frequency of your C copter and uh other than that uh this is it like um let me know what you think in the comments uh I've been wanting to do this video just for like P explanation
            • 21:00 - 21:30 purpose because I didn't find many good uh videos demonstrating that although there is one from J Brooking I'll leave a link in the description so you can check this project it's open source on my GitHub you can just download it put it uh make your own esp22 Cod copter and just check uh P tuning so that's about it uh thank you for watching have a fantastic day ahead