ZN Close Loop Tuning of a Quadrocopter

Tuning Experiment

This is a short note on the use of a close-loop tuning technique due to Zeigler and Nichols (ZN) [Wikipedia] for obtaining coeficients for the PID loops on the Quadrocopter (QC) specifically for pitch and roll. This has been a personal research exercise for information only. I do not wish to actively encourage others to use this technque. I have implemented ZN open-loop tuning on other aircraft where the PID coefficients may be obtained in flight although well clear of the ground and I may explore this for the quadrocopter.

In essence the technique involves using proportional gain only which is increased until the aircraft commences a stable oscillation around the axis of interest. This so called ultimate gain is noted along with the period of the oscillation from which the PID coefficients may be computed directly. Importantly the technique does not require any knowledge at all of the mass of the aircraft, its dimensions or the various associated rotational inertias; it is quite general.

Needless to say the procedure is potentially DANGEROUS and should only be undertaken if you are appropriately qualified and is entirely AT YOUR OWN RISK. With some more conventional aircraft the experimentation can be undertaken in the air which I have done. In the case of the QC in flight testing is not feasible for pitch and roll as will be seen and must be undertaken on the bench. To do this the QC must be physicallly restrained so that it can rotate around one axis only. The QC must also be sufficiently well clear of the ground to avoid ground effect which may increase the frequency of oscillation dramatically.

In the attached video the roll axis was chosen for tuning. The QC is securely pinned at each end of the pitch axis with roll limited to 90 degrees. The gain is increased until stable oscillation is obtained at 35. At a gain of 37 the oscillation is clearly divergent that is its amplitude continues to increase. With the ultimate gain now obtained the period of oscillation was determined offline by analysing the video. In the case of my QC the period was found to be 0.33Sec.

In a discrete time domain controller the integral term includes multiplication by the sampling interval and often rescaled for integer arithmetic. In the case of UAVP/UAVX the coefficient entered into UAVPSet is NOT the ZN obtained coefficient but a rescaled value. For other quadrocopters where floating point is used the scaling may be done at run time; see Discrete Implentation and Pseudocode in Wikipedia article.

For example UAVP rescales the integral terms by 16 and so if, for a PI controller, Ki was computed as 57.3 and the sampling interval ("Impulse time") was 3mS then the Ki entered through UAVPSet for Ki would be:

57.3*16*0.003 = 2.75 or 3

It was subsequently discovered that there is an additional 4mS delay in UAVP over above the Impulse-time setting of 3mS making the sampling interval 7mS! The Integral term was then re-computed as 6 aligning closely with gains others have obtained empirically.

So in UAVPSet the coefficients, as entered, are specific to a particular UAVPSet Impuse-time although it is common to change this while also changing the PID coefficients without fully realising the ramifications.

There is a spreadsheet for UAVP.

Thanks to OMM for his questions which prompted me to improve the description of the UAVP/UAVPSet specific scaling.

The movie shows the tuning process and illustrates the potential DANGER.

 

The same tuning process may also be used for yaw and altitude control and could be conducted more safely in flight.

G.K. Egan

Flying

Top | Home

Copyright © G.K. & S.P. Egan - All rights reserved. Last updated March, 2016.