ArduCopter Automatic PID Tuning - BRAVE TESTERS ONLY

DISCLAIMER: This could be dangerous and might crash your copter.

OK! I made some new changes to the autotuning algorithm and I have tested it again in the simulator. I think this is ready for some real world testing from some VERY BRAVE users, or some simulation testing. Unfortunately I do not own a quad and my octo is out of commission until Tuesday, or I would be testing this right now outside.




First, here is what is new:

1. The amount of change applied to the P gain scales down with each iteration. This allows for quicker acquisition and better resolution of your Pretty Good Gain

2. If the tuning logic moved the P gain in the wrong direction it will revert to the best P gain that had been found and use that as the new launching point which should save some iterations

How to use it:

1. Replace the files in your ArduCopter 2.2b2 code base with the files that I have included in the .zip.

2. Upload the code to your board and test in the simulator so that you can get a feel for how it works (follow the same steps below for setup starting at step 5)

3. Update the config file to disable the HIL setting or change your frame type, etc...

4. Re-upload the code for live flight IF YOU DARE

5. Connect the APM to the Mission Planner.

6. Go to the configuration tab and manually set the CH7_OPTION to 8 as seen below and click "Write Params"


7. Set your Integral (I) gains for pitch and roll to zero and click "Write Params"

8. Bring the copter to a hover and flip CH7 to the high position to activate the auto tuning mode

9. Roll to the right or left and quickly return the stick to the center position. (Repeat this step at least 5 times)

10. Deactivate auto tuning mode by flipping CH7 to the low position

11. Reactivate auto tuning mode by flipping CH7 to the high position

12. Pitch the copter forward or back and quickly return the stick to the center position. (Repeat this step at least 5 times)

13. Deactivate auto tuning mode by flipping CH7 to the low position

14. Go to the configuration tab of the Mission planner and click "Refresh Params" to see your new tuned P gains

15. Write those values down.

The idea of steps 9 and 12 is to introduce a wobble and let the copter try to even itself out. Don't go too aggressive with your pitch or roll... again its just to introduce a disturbance.


My videos are in 1080p so that you will be able to read whats on the screen.


Questions, comments, discussion is welcome and encouraged!

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • Great stuff Adam, let us know as soon as the code's ready, i have a bit of testing time on my hands this week.


    I've been playing with the coptercontrol autotune today to try and get some ideas, can't get it working yet though :/

  • Developer

    Well, I tested the autotuning for real today with decent results. however, I realized that I had made a critical error when deciding which PI gains to tune. I wrote this to tune the stab pi gains when really the rate pi gains are much more important. I am refactoring my code right now to tune the rate gains instead. I think fundamentally this is sound though. As far as the stab gains are concerned, they tuned properly during today's flight.

  • Developer

    Fixed the arming issue I had yesterday. I must have screwed something up by connecting those outputs wrong. Today is way too windy to test autotuning for the first time here in Milwaukee, WI. We have some better weather coming tomorrow and the following day. Expect a video then.

  • Developer

    I tried re-calibrating the radio... no luck. Also, I should clarify that the P values come to +/- .01 and the I values are within +/- .003

  • Developer

    Well guys, I did some additional testing in the simulator today and I am very pleased with the P and I tuning. It consistently arrives at near the same values (+/- .01). I got up the courage to test it live with my large octo, but when I got there I immediately had issues. Turns out I had connected the PPM outputs in reverse order on the board (8 to 1, 7 to 2, etc...) and my ESCs let out continuous beeping. So I corrected that issue in the field and rebooted. When it rebooted everything looked good with a nice connection via my xbee to the MP, but I was not able to arm my octo. When I looked in the planner the stick PPM values were coming through just fine but it would not arm. I am hoping to get that issue resolved and try again tomorrow. Bottom line is that you all should have a video of this tuning system in action soon. I am really disappointed about today though :-/

  • Developer

    Wow fantastic! Nice work Adam!

  • @adam welcome to land if living
  • Developer

    My dev machine is back up and running. I should have some new results and videos for everyone soon.

  • @adam that is a pity that your machine gave up on you. BTW i have tried FMS a bit, but gave up on it, i managed to get my Aerosim on Friday, still getting to grips with it. I have used Xplanes for HIL. Hope you would get ur macbookpro fixed soon

  • Developer

    Had really good results today with the Integral gain. My development machine just crapped out on me.... LCD panel is fried. I should have it replaced tomorrow. I will be posting a new zip with many improvements. Also, i should have a real life test Tuesday with a video to show you guys how it works out!

    Here is my sad macbook :-(


This reply was deleted.