### Zero-PIDs Tuner for Multirotors

This topic is about PID auto tuning algorithm that can tune your Quadcopter from PIDs ZERO as a start value.

Introduction

Adjusting PIDs is a problem for many of Quadcopter’ pilots, it would be nice to get your quadcopter to adjust PIDs for itself. I made some investigation in this area, and found many complex algorithms that are related to Adaptive PIDs, and Fuzzy Logic. Although my background is engineering but I don’t like complex math when you can make simple solutions :)

I started with multiwii version 2.3, I chose it because its code is not that complex, while it has many GUI tools and debug facilities to trace, and it has one of the largest community that can test and verify the results. Anyway I have developed a new mode that I called G_TUNE, which enables quadcopter to calculate flyable PIDs values for ACRO mode. i.e. PIDs for GYRO.

How to Use

G_Tune mode starts by resetting all Gyro' PIDs for Roll, Pitch & Yaw to Zero’s.  Then pilot needs to takeoff !!  yes it will take off as the algorithm will start instantly to correct errors and update PIDs parameters accordingly. Pilot should try not to make aggressive maneuvers. That is because the error in multiwii is calculated as (RC_Stick - Gyroreading) as stick position acts as rotation speed target i.e. the target rpm, so moving stick suddenly generates false errors.

The algorithm mainly works as our human eye. what you do is that if you find your quad tilt you give thrust to motor to adjust this tilt.

Below is the state machine for the new mode.

1- As we can see from above state diagram, You need to disarm your quadcopter, then you switch to G_Tune mode. once you do that all PIDs will be Zero and you can test that by switch back to ACRO mode again and try to fly "be careful as you have no control because all PIDs are ZERO"

2- You can then switch back to G_TUNE the arm your quadcopter. Try to fly carefully, do not make aggressive moves, your quadcopter should fly reasonably stable.

3- Now switch to GYRO mode in AIR to stop updating the values. dont try to land first.

4- Now fly again in ACRO mode and this time it will fly.

The algorithm was able to generate the following PIDs values for ACRO mode:

Both values in the two screen shots flythe quadcopter

Caution

1- This is a test mode that I tested only on my quadcopter with Simonk ESC, 10x4.5 props and Turnigy 1100 KV. It should work on other configuration, but I have not try it myself.

2- Moving ELE & ALE sticks just before changing from G_TUNE to ACRO mode could corrupt the values, so please try to fly as stable as possible and switch to ACRO while sticks are almost released for best results.

3- Switching back from GYRO to G_Tune mode in AIR could be dangerous -however the correction is very fast and it normally works- because PIDs are reset to ZEROs in AIR.

I have some thoughts about how you could guess the D-term.

You are a skilled pilot which means you can tune in Acro mode ;) . I can only fly in Angle mode.

• I am tuning Multiwii v2.3 PID of GYRo. Actually the P & I only.

• Developer

Hi MHefny,

Nice job! Can you put up a diagram of the PID loops you are tuning in the Multi Wii. I suspect they are using a different system to the Arducopter code. I would also be interested in hearing more about exactly how you adjust the pid parameters based the gyro measurements.

Thanks for posting!!

• Great! I look forward to publishing of your algorithm. And for sure going to be one of the first tester :).

• sure it works on v2.3 and can be compiled on any multiwii board.

I am still working on the algorithm before publishing it.

• Very interesting!

Is it possible to try you G_TUNE mode on AIO Flight Controller with multiwii version 2.3? If yes how? :)

• Thanks :)

• Pretty amazing! Great work.