Module rpps.sync.agc

Automatic Gain Control

R = reference level

x[n] = input signal a[n] = AGC output z[n] = controlled output |z[n]| = sqrt(zI2 + zQ2) = |a[n-1] * x[n]| e[n] = R - |a[n-1]x[n]| a[n] = a[n-1] + μ * e[n] a[n] = (1-μB) * a[n-1] + μ * R a[n] = { a[0] - R/B }(1 - μB)*n + R/B z[n] = R/B * B = R

Classes

class AGC2 (target, mu)
Expand source code
class AGC2(_AGC):
    __slots__ = ("agc")
    def __init__(self, target, mu):
        super().__init__(target)
        # self.mu = mu
        self.agc = AGC_log(target, mu)

    def _run(self, sample):
        self.agc._run(sample)
        self.agc._run(sample)
        self.gain = self.agc.gain
        self.err = self.agc.err

Ancestors

  • rpps.sync.agc._AGC

Instance variables

var agc
Expand source code
class AGC2(_AGC):
    __slots__ = ("agc")
    def __init__(self, target, mu):
        super().__init__(target)
        # self.mu = mu
        self.agc = AGC_log(target, mu)

    def _run(self, sample):
        self.agc._run(sample)
        self.agc._run(sample)
        self.gain = self.agc.gain
        self.err = self.agc.err
class AGC_lin (target, mu)
Expand source code
class AGC_lin(_AGC):
    __slots__ = ("mu")
    def __init__(self, target, mu):
        super().__init__(target)
        self.mu = mu

    def _run(self, sample):
        pwr = np.abs(sample)
        self.err = self.target - self.gain*pwr
        self.gain += self.mu*self.err

Ancestors

  • rpps.sync.agc._AGC

Instance variables

var mu
Expand source code
class AGC_lin(_AGC):
    __slots__ = ("mu")
    def __init__(self, target, mu):
        super().__init__(target)
        self.mu = mu

    def _run(self, sample):
        pwr = np.abs(sample)
        self.err = self.target - self.gain*pwr
        self.gain += self.mu*self.err
class AGC_log (target, mu)
Expand source code
class AGC_log(_AGC):
    __slots__ = ("mu")
    def __init__(self, target, mu):
        super().__init__(target)
        self.mu = mu
        self.gain = 1.0

    def _run(self, sample):
        pwr = np.abs(sample)
        self.err = np.log(self.target) - np.log(abs(self.gain*pwr))
        self.gain = np.exp(np.log(self.gain) + self.mu*self.err)

Ancestors

  • rpps.sync.agc._AGC

Instance variables

var mu
Expand source code
class AGC_log(_AGC):
    __slots__ = ("mu")
    def __init__(self, target, mu):
        super().__init__(target)
        self.mu = mu
        self.gain = 1.0

    def _run(self, sample):
        pwr = np.abs(sample)
        self.err = np.log(self.target) - np.log(abs(self.gain*pwr))
        self.gain = np.exp(np.log(self.gain) + self.mu*self.err)