control//feedback control//PID controller//PID tuning//relay autotuning
Relay autotuning is a method for tuning a PID controller in which the controller is replaced for a few cycles by an on-off relay, so that the loop settles into a small, controlled oscillation near its critical frequency, from which the ultimate gain and period are read and the gains computed; proposed by Karl Johan Åström and Tore Hägglund in 1984, it is the autotune button of many industrial controllers. It measures the same two numbers as the Ziegler-Nichols method without ever pushing the plant towards instability with a gain.
Relay autotuning is a method for tuning a PID controller in which the controller is replaced for a few cycles by an on-off relay, so that the loop settles into a small, controlled oscillation near its critical frequency, from which the ultimate gain and period are read and the gains computed; proposed by Karl Johan Åström and Tore Hägglund in 1984, it is the autotune button of many industrial controllers. It measures the same two numbers as the Ziegler-Nichols method without ever pushing the plant towards instability with a gain.
The relay switches the command between two levels ±d\pm d±d around its working value each time the error changes sign. The plant, which filters out the sharp edges, answers with a nearly sinusoidal oscillation of amplitude aaa, and that oscillation sits where the loop's lag is 180 degrees, the critical frequency. Its period is the ultimate period PuP_uPu, and the ultimate gain follows from the amplitudes:
Ku≈4dπa,K_u\approx\frac{4d}{\pi a},Ku≈πa4d,
since the first harmonic of a square wave of height ddd has amplitude 4d/π4d/\pi4d/π. With those two numbers any rule (Ziegler-Nichols, or a softer one aimed at a chosen phase margin) gives the PID. The operator chooses ddd, and with it how much the process moves during the test: a degree or two on a furnace, a few percent of flow.
The crudest controller becomes the instrument for tuning the finest.
The relay test is an identification experiment that measures exactly the datum stability depends on, the frequency where the loop accumulates 180 degrees of lag and the gain there, with an amplitude the operator fixes in advance.
It is safe because the oscillation limits itself. A relay's effective gain falls as the amplitude grows, so the cycle settles at the amplitude where the loop is exactly critical instead of growing (limit cycle, on-off control).
Noise needs a little hysteresis in the relay, or it switches on every noise spike; the band shifts the measured frequency slightly and is accounted for in the formulas.
It measures one point of the frequency response and no more. A load disturbance during the test, or a plant that passes harmonics instead of filtering them, corrupts the estimate, and a slow plant still needs a few full periods; model-based rules from a step test, such as the SIMC rules, are the alternative when a step is easier to arrange than an oscillation.
Drone autopilots apply the same idea of a small deliberate excitation in flight: ArduPilot and PX4 autotune modes shake the attitude with small manoeuvres, fit a simple model and compute gains, identification in miniature (system identification).