How to adjust receiver gains to avoid saturation and quantization noise to optimise post digital processing? I am using a Hack RF One as SDR and the software GNU Radio to receive and process signals emitted from a drone. Given that the drone is moving and is emitting signals from a wide zone, received signal strengths vary dramatically : if the signal is too large, it over-ranges the ADC input and if the signal is too small, it gets lost in the converter's quantization noise. 

At the reception, I have three different gains : RF gain, IF gain and BB gain. RF gain can be set to 0 or 14dB, IF gain from 0 to 40dB by 8dB steps and BB gain from 0 to 62dB by 2dB steps. At the transmission, I keep the transmitting power constant.

For now, my algorithm to manage the different values of gains is the following : Every x seconds, I look at the received digitised signal peak-to-peak value $V_{pp}$ (I take the maximum value V_pp for real or imaginary received signal) and I try to maintain this value into a range such that $V_{pp,lim1} &lt; V_{pp} &lt; V_{pp,lim2}$ , to avoid quantization noise and saturation. To do so, I simply increase or decrease the gain in function of the value $V_{pp}$, starting with IF and BB gains to finish with the amplifying RF gain.

The problem is the following : My algorithm is not optimised. Given that the possible changing steps are not linear and different for every type of gain (14dB for RF, 8dB for IF and 2dB for BB), I sometimes fall into situations where my gains are continuously changing between two situations and do not manage to stabilise even if I keep the distance constant between emitter and receiver.

The question is : how can I manage to have the more constant output amplitude so that my dynamic range is optimised for the ADC?

Constraints :


Gain steps restricted : 14dB for RF (0 or 14dB), 8dB for IF (from 0 to 40dB) and 2dB for BB (from 0 to 62dB)
Order of changing gains : "Increase or decrease the IF and baseband gain controls roughly equally to find the best settings for your situation. Turn on the RF amp if you need help picking up weak signals" (source : https://github.com/mossmann/hackrf/wiki/FAQ )
To avoid quantization or limit cycle oscillations, you can add hysteresis to your AGC decision loop (a form of "debouncing").