Re: AGC

More interestingly, I’m using complex_to_mag to demodulate a 32K sps
baseband channel as AM, then filtering/decimating the resulting audio.

If I set the AGC reference value (second parameter) to anything above
0.2 (including the default 1.0), the audio comes out distorted. It
sounds like clipping.

For a reference value, of say, 0.5, complex_to_mag should be outputting
peaks at |0.5+0.5j| which is ~0.71.

I don’t have the agc code in front of me, but the definition of the
setpoint in important. Assuming you make the setpoint 1, and that the
agc is setting the average (of either I or Q) to the setpoint, the
amplitude will go from 0 to 2, since this is AM. You will need to
subtract 1 so that you get a signal of +/- 1 for the audio sink.

Matt

Matt E. wrote:

I don’t have the agc code in front of me, but the definition
of the setpoint in important. Assuming you make the setpoint 1,
and that the agc is setting the average (of either I or Q) to
the setpoint, the amplitude will go from 0 to 2, since this is AM.
You will need to subtract 1 so that you get a signal of +/- 1 for
the audio sink.

From gri_agc_cc.h:

gr_complex scale (gr_complex input){
gr_complex output = input * _gain;
_gain += (_reference -
sqrt(output.real()*output.real()+output.imag()*output.imag())) * _rate;

}

or _gain += reference - |output| * _rate

This looks like then that _gain would asymptotically approach a point
where the RMS output value (not average value) would equal the reference
value.

Is that the case? My brain can’t seem to wrap around simple concepts
today.

Time to learn gr.wxgui and scopesink …

-Johnathan

Johnathan C. wrote:

Matt E. wrote:

I don’t have the agc code in front of me, but the definition
of the setpoint in important. Assuming you make the setpoint 1,
and that the agc is setting the average (of either I or Q) to
the setpoint, the amplitude will go from 0 to 2, since this is AM.
You will need to subtract 1 so that you get a signal of +/- 1 for
the audio sink.

Is that the case? My brain can’t seem to wrap around simple concepts today.

Matt, you’re completely right. Just adding a gr.add_const_ff(-1.0) to
the pipeline cleared it up and let the prior AGC stage operate at it’s
default reference of 1.0:

Convert baseband AGC’d (ref. val. 1.0) AM channel to audio floats

class am_demod(gr.hier_block):
def init(self, fg):
MAG = gr.complex_to_mag()
DCR = gr.add_const_ff(-1.0)
fg.connect(MAG, DCR)
gr.hier_block.init(self, fg, MAG, DCR)

-Johnathan