Process for Compensator in Altitude Hold
A lag controller is basically an amplifier whose input is proportional of the present error, that is the difference between the current altitude and the target altitude



With low amplification the trouble is the lack of response as long the error is small.

With great amplification we have an overshoot effect with continuous oscillation around the target altitude.

The best simple low cost compensator consists of an PID

Please refer to this website:

https://en.m.wikipedia.org/wiki/PID_controller

The PID has 3 adjustable inputs:


A proportional input « P » somehow similar to a lag amplifier
An integral input « I » that is proportional to the error but also to the duration of the error, therefore an error as small it may be will be corrected with time and will decay
A derivative input »D » which is proportional to the slope of the error that is the error evolution, therefore it has a predictive value. Therefore the D input will neutralize the tendency of an error to appear or to increase.




The adjustment is done by small steps, 

-you start by setting to minima the I and D inputs, and set the P input to get the best non overshooting response.

-In order to reduce the remaining error with the previous adjustment you increase the I input by steps and verifying you don’t get overshoots

-In order to avoid drifting error you act on the D input, increase the input so that you obtain a little overshoot that you correct by reducing the I input.

Trial and error adjustments could be useful