Flight modes:
Horizon + Baro
Angle + Baro
The Barometer sensor is used to detect the altitude of your multirotor aircraft and is used for altitude hold mode. As the barometer sensor is not very precise and is quite noisy, detection of small up and down movements is impossible.
So small up and down movements are detected by the accelerometer Z axis. Combination of these two sensors gives good altitude hold.PID settings for ALT works like this:
P – Is how much the multirotor should rely on the barometer sensor. The higher the value is the stronger the multirotor relys on the Barometer reading.
I – Is used to compensate for drift caused by battery voltage drop during the flight. The higher the value is more the multirotor will react to voltage drops ( or other varying factors over time).
D – Is how strong the multirotor should react to data from the accelerometer Z axis. It is used to react to small up and down movements that the barometer cannot accurately sense. The higher the value is the stronger the multirotor will react to small altitude changes.
Tuning:
We need to start from settings the Accelerometer.
1. So set the P and I to 0
2. Start to play with D value only. To high D may cause yoyo effect (up and down oscillations). With to low D copter will be not able to react strong/fast enough to hold altitude. Your goal here is to set D to the value when copter don’t oscillate up and down and also holds altitude quite well for a not very long period of time. Copter will not hold altitude perfectly at this point during long periods. It will slowly drift up or down, but altitude should be quite stable in short periods.
3. Start to increase P to the point where copter holds altitude over long time period. If the value is to small the copter will drift slowly up and down. If the value is to high yoyo effect may appear. Goal here is to set it to the point where copter holds altitude for quite some time. Copter will still go slowly down due to battery voltage drop over time.
4. “I” is used to compensate the voltage drop. So start to increase the “I” value slowly until you get a perfect position hold during a very long time.
Now your altitude hold should be good enough.