Advice about PID tuning

Firmware/software/electronics/mechanics
Post Reply
Yaro
Member
Posts: 31
Joined: Wed May 20, 2015 11:28 am

Advice about PID tuning

Post by Yaro »

Hi all,

I'm going to calibrate PID but I'm not sure about how to do this. I need to fix drone in position and start to perform test with increasing values. I've found a guide in this forum that tells to set all PID(kp,ki,kd) to 0 and then start with a single R or P or Y to calibrate.
About fixing drone, I should fix it with more gravity at bottom? (so it will not go upsidedown when motors are off)
And about thrust, how much thrust should I apply when I performing tuning? (about 25%? much higher like when it taking off from ground(about 60-70%) or more?)

Also, I've found that I can nullify R, P or Y inside crazyflie code with TUNE_ROLL, TUNE_PITCH and TUNE_YAW and also I can also nullify sending R, P or Y from my controller(in case I accidentally move them). Are this options necessary if I set all PIDs to 0?

Thank you.
theseankelly
Expert
Posts: 153
Joined: Mon Dec 28, 2015 3:23 pm
Contact:

Re: Advice about PID tuning

Post by theseankelly »

Hey Yaro

I've been doing a lot of learning on this subject lately. Here's a forum post where I shared a few videos of my crazyflie on a string and the resulting PID changes:

viewtopic.php?f=6&t=1978

And here are some good resources I've found about PID tuning in general:
http://aeroquad.com/showwiki.php?title=PID-Tuning
https://oscarliang.com/quadcopter-pid-explained-tuning/
http://open-txu.org/home/special-intere ... id-tuning/

And a post specific to crazyflie (this is probably the post you're talking about that you found)
viewtopic.php?f=6&t=192

Now, my thoughts on your questions:
1) No, don't worry about gravity for the sake of keeping it upright on the string. You should have your crazyflie set up exactly how you expect it to be set up when you're flying. In fact, orientation should have no effect on the performance of a well tuned PID -- if the copter is upside down when you start, it should be no problem to flip it back over with the sticks. I think a few of my videos show it starting upside down.

2) Thrust -- I usually did about 50%, which isn't quite enough to hover. Higher would be fine too. The main point is you want it in a good midrange to give the PIDs 'headroom' to lower and raise thrust without hitting 100% or 0%.

3) You must nullify them with TUNE_ROLL. The PIDs react to external forces in addition to Tx input. So, even if your controller is sending zeros, the PID will still try to compensate if it detects movement on any axis you aren't tuning, which will affect your ability to tune a single axis.

4) I suppose yes, setting all the PIDs you aren't tuning to zero will have the same affect as the TUNE_ROLL #defines. I just find it more straight forward to set the #define for this purpose.
http://www.thejumperwire.com
Tips, tutorials, and science about DIY electronics, drones, and embedded software.
Post Reply