1 # post detection agc processing
3 # Imagine that the usual gnuradio copyright stuff is right here.
5 # This agc strategy is copied more or less verbatim from
6 # weaver_isb_am1_usrp3.py by cswiger.
10 # Then modified in a variety of ways.
12 # There doesn't appear to be a way to hook multiple blocks to the
13 # input port when building a hier block like this. Thus the
17 # Power is estimated by squaring the input.
18 # Low pass filter using a 1 pole iir.
19 # The time constant can be tweaked by changing the taps.
20 # Currently there is no implementation to change this while operating
21 # a potentially useful addition.
22 # The log block turns this into dB
23 # gain adjusts the agc authority.
27 from gnuradio import gr, gru
29 class agc( gr.hier_block ):
30 def __init__( self, fg ):
31 self.split = gr.multiply_const_ff( 1 )
32 self.sqr = gr.multiply_ff( )
33 self.int0 = gr.iir_filter_ffd( [.004, 0], [0, .999] )
34 self.offs = gr.add_const_ff( -30 )
35 self.gain = gr.multiply_const_ff( 70 )
36 self.log = gr.nlog10_ff( 10, 1 )
37 self.agc = gr.divide_ff( )
39 fg.connect( self.split, ( self.agc, 0 ) )
40 fg.connect( self.split, ( self.sqr, 0 ) )
41 fg.connect( self.split, ( self.sqr, 1 ) )
42 fg.connect( self.sqr, self.int0 )
43 fg.connect( self.int0, self.log )
44 fg.connect( self.log, self.offs )
45 fg.connect( self.offs, self.gain )
46 fg.connect( self.gain, ( self.agc, 1 ) )
48 gr.hier_block.__init__( self, fg, self.split, self.agc )