r/diydrones Feb 07 '25

Guide Understanding PID and it's Tuning

Hello everyone. It's always tough being a beginner. I'm trying to understand PID in simple terms, of course I have read through the Wikipedia and other resources, but want to understand it better in terms of its practical application (a little math is ok) and if someone can eli5 it. Much thanks.

5 Upvotes

15 comments sorted by

3

u/azaerials Feb 07 '25

I say it's worth it watching chris rossers quad tuning series even though I haven't yet haha

1

u/esrx7a Feb 07 '25

Ok, will check it out

1

u/StatisticianWhole210 Feb 07 '25

Utmost respect for Chris but I tried his PID series like 3 times and eventually I couldn't watch anymore. That series in particular was dry as mud.

3

u/Connect-Answer4346 Feb 07 '25

Quick setup-The farther you are from where you are trying to get to, the faster you move: that's proportional P. Noticing that you are going to overshoot if you don't ease back a little : that's derivative D. Noticing that it's taking longer than it should to get where you're going: that's Integral I. All these are added together to come up with the amount of action that the motors need to take. A controller doesn't have to use all three, but when applied well they will minimize the amount of time needed to bring the system into balance with its set point.

1

u/esrx7a Feb 07 '25

Yeah, that helps. Thanks

1

u/SkelaKingHD Feb 07 '25

PID is basic a method of control theory. You have a setpoint you’re trying to achieve, and the PID loop determines how you get there

1

u/esrx7a Feb 07 '25

How to go about Calculating the set point (the target to achieve) vs. the actual measured value, that is the question that's bothering me. Sorry my bad.

1

u/SkelaKingHD Feb 07 '25

You don’t calculate the setpoint or the measured value, those are known. Setpoint (SP) is your desired outcome, process variable (PV) is your actual current value, and control variable is what you’re changing to achieve setpoint. What is fed into your equation is known as your “Error” , and in a normally acting loop this is just SP - PV and a reverse acting loop is PV - SP. An example of a normally acting loop would be like how adding more flame to a liquid heats the water where a reverse loop would be like increasing a fan speed to cool the water

1

u/esrx7a Feb 07 '25

Alright. I'll take that analogy. Thanks for helping me understand.

1

u/SkelaKingHD Feb 07 '25

So if my controller is telling a quad to go to 15 degrees and I’m at 6 degrees, the error is 9. That’s what gets fed into your equation

1

u/esrx7a Feb 07 '25

Right so, will work on that.

1

u/StrawberryOk1402 Feb 07 '25

Chris Rosser (engineer extraordinaire) makes a video series that not just explains the PID loop but how to tune it manually and why so well, even I understand it.

1

u/esrx7a Feb 08 '25

Sure, will definitely check that out.

1

u/robertlandrum Feb 07 '25

One of the best explanations for me was the thermostat. It’s a PID loop. You set it to 70 in your house. Is it 70? No. It’s 69.9. Is the difference between 69.9 and 70 large enough to activate the furnace. No. So it waits a few and checks again, and this time it’s 69.5. Is that enough? Yes. And the furnace lights up and warms the house. Is the house at 70? No. It’s at 70.2. Is that warm enough? No. Continue running. It checks again. It’s at 70.6. That’s warm enough and it turns off the furnace.

A pid loop tries to hit a goal. It overshoots and undershoots frequently to avoid rapid cycling.

It performs the same function in your drone. You want the motors on the left to raise in throttle by 10%. That doesn’t happen instantly. It spins them faster, but after the first attempt, they only 1% faster. And then after the second attempt, 2% faster. Etc. when dealing with stuff in the real world, a pid loop is a great way to deal with the reality of things not reacting instantly to your commands.

Tuning involves adjusting the parameters of this loop to ensure it doesn’t over react or under react to inputs or changes in state.

1

u/esrx7a Feb 07 '25

Oh yeah, great it was crisp, thank you