Monday, February 14, 2011

GNU Radio modulation

Looking at gnuradio-examples/python/digital/tx_voice.py....

self.txpath = usrp_transmit_path.usrp_transmit_path(modulator_class, options)

Leads me to usrp_transimit_path.py, which sets some USRP sink options, then passes the work to transmit_path.py.

The options passed to transmit_path.py include:

  • verbose
  • tx_amplitude
  • bitrate
  • samples_per_symbol

...and then the 'modulator class':

self._modulator_class = modulator_class

    # Get mod_kwargs
    mod_kwargs = \
        self._modulator_class.extract_kwargs_from_options(options)
    
    # transmitter
    modulator = self._modulator_class(**mod_kwargs)
    self.packet_transmitter = \
        blks2.mod_pkts(modulator,
                       access_code=None,
                       msgq_limit=4,
                       pad_for_usrp=True)

Then you connect the 'packet_transmitter', amplitude, and transmit path together.

self.connect(self.packet_transmitter, self.amp, self)

    ...

def send_pkt(self, payload='', eof=False):
    """
    Calls the transmitter method to send a packet
    """
    return self.packet_transmitter.send_pkt(payload, eof)

gnuradio-3.3.0/gnuradio-core/src/python/gnuradio/blks2impl/pkt.py: blks2.mod_pkts


class mod_pkts gets passed an instance of a modulator class (gr_block of heir_block2). It then simply connects a packet input block (gr_message_source(sizeof char, msgq_limit):

self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
    self.connect(self._pkt_input, self._modulator, self)



Modulation classes (tx_voice.py):

from gnuradio import gr, gru, modulation_utils
...
mods = modulation_utils.type_1_mods()
...
    for mod in mods.values():
        mod.add_options(expert_grp)
...
# pass it down: tx_voice.py -> usrp_transmit_path.py -> transmit_path.py -> pkt.py
tb = my_top_block(mods[options.modulation], options)

This particular example generated packets from a message queue attached to a voice coder:

from gnuradio.vocoder import gsm_full_rate
...
voice_coder = gsm_full_rate.encode_sp()

The corresponding C++ block, gsm_fr_encode_sp, has a simple work function:

for (int i = 0; i < noutput_items; i++){
    gsm_encode (d_gsm, const_cast(in), out);
    in += GSM_SAMPLES_PER_FRAME;
    out += sizeof (gsm_frame);
  }

This references C code which does the GSM (de/en)coding.



Here are the modulators available in tx_voice.py:

gnuradio.blks2impl.cpm.cpm_mod
gnuradio.blks2impl.d8psk.d8psk_mod
gnuradio.blks2impl.qam8.qam8_mod
gnuradio.blks2impl.dbpsk.dbpsk_mod
gnuradio.blks2impl.dqpsk.dqpsk_mod
gnuradio.blks2impl.gmsk.gmsk_mod

Implemented as separate Python files in gnuradio-core/src/python/gnuradio/blks2impl. The other blks2 folder ties it all together.

No comments:

Post a Comment