# Process for Compensator in Altitude Hold

Trying to understand autopilots on a technical level. When making an altitude controller there is a compensator Gc that is used to acquire a Pitchcommand which is passed to an attitude controller (the attitude controller uses a PID loop which I understand). What is the process of creating that compensator? I've read that a PI compensator is less reliable and more complex than a lag compensator. But as a rough approximation (still trying to figure it out) of what needs to be done for a lag compensator you need to have a linearization of the aircraft model, apply root locus, adjust poles, and acquire a transfer function. If anybody could specify what would need to be done (correcting my missing/incorrect understanding) that would be very appreciated.

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

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