updated uhd-tetra_demod.py and cqpsk.py for GNU Radio v3.74 compatibility

This commit is contained in:
Mike Jameson 2014-08-25 14:33:49 +01:00
parent 6430bdeb5f
commit 5429a1e3ab
2 changed files with 29 additions and 27 deletions

View file

@ -27,7 +27,8 @@
differential PI/4 CQPSK modulation and demodulation. differential PI/4 CQPSK modulation and demodulation.
""" """
from gnuradio import gr, gru from gnuradio import gr, gru, blocks, analog, filter, digital
from gnuradio.filter import firdes
from math import pi, sqrt from math import pi, sqrt
#import psk #import psk
import cmath import cmath
@ -110,14 +111,14 @@ class cqpsk_mod(gr.hier_block2):
self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity]) self.chunks2symbols = gr.chunks_to_symbols_bc(psk.constellation[arity])
# pulse shaping filter # pulse shaping filter
self.rrc_taps = gr.firdes.root_raised_cosine( self.rrc_taps = firdes.root_raised_cosine(
self._samples_per_symbol, # gain (sps since we're interpolating by sps) self._samples_per_symbol, # gain (sps since we're interpolating by sps)
self._samples_per_symbol, # sampling rate self._samples_per_symbol, # sampling rate
1.0, # symbol rate 1.0, # symbol rate
self._excess_bw, # excess bandwidth (roll-off factor) self._excess_bw, # excess bandwidth (roll-off factor)
ntaps) ntaps)
self.rrc_filter = gr.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps) self.rrc_filter = filter.interp_fir_filter_ccf(self._samples_per_symbol, self.rrc_taps)
if verbose: if verbose:
self._print_verbage() self._print_verbage()
@ -145,15 +146,15 @@ class cqpsk_mod(gr.hier_block2):
def _setup_logging(self): def _setup_logging(self):
print "Modulation logging turned on." print "Modulation logging turned on."
self.connect(self.bytes2chunks, self.connect(self.bytes2chunks,
gr.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat")) blocks.file_sink(gr.sizeof_char, "tx_bytes2chunks.dat"))
self.connect(self.symbol_mapper, self.connect(self.symbol_mapper,
gr.file_sink(gr.sizeof_char, "tx_graycoder.dat")) blocks.file_sink(gr.sizeof_char, "tx_graycoder.dat"))
self.connect(self.diffenc, self.connect(self.diffenc,
gr.file_sink(gr.sizeof_char, "tx_diffenc.dat")) blocks.file_sink(gr.sizeof_char, "tx_diffenc.dat"))
self.connect(self.chunks2symbols, self.connect(self.chunks2symbols,
gr.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat")) blocks.file_sink(gr.sizeof_gr_complex, "tx_chunks2symbols.dat"))
self.connect(self.rrc_filter, self.connect(self.rrc_filter,
gr.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat")) blocks.file_sink(gr.sizeof_gr_complex, "tx_rrc_filter.dat"))
def add_options(parser): def add_options(parser):
""" """
@ -238,19 +239,19 @@ class cqpsk_demod(gr.hier_block2):
# Automatic gain control # Automatic gain control
scale = (1.0/16384.0) scale = (1.0/16384.0)
self.pre_scaler = gr.multiply_const_cc(scale) # scale the signal from full-range to +-1 self.pre_scaler = blocks.multiply_const_cc(scale) # scale the signal from full-range to +-1
#self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) #self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100)
self.agc = gr.feedforward_agc_cc(16, 2.0) self.agc = analog.feedforward_agc_cc(16, 2.0)
# RRC data filter # RRC data filter
ntaps = 11 * samples_per_symbol ntaps = 11 * samples_per_symbol
self.rrc_taps = gr.firdes.root_raised_cosine( self.rrc_taps = firdes.root_raised_cosine(
1.0, # gain 1.0, # gain
self._samples_per_symbol, # sampling rate self._samples_per_symbol, # sampling rate
1.0, # symbol rate 1.0, # symbol rate
self._excess_bw, # excess bandwidth (roll-off factor) self._excess_bw, # excess bandwidth (roll-off factor)
ntaps) ntaps)
self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps) self.rrc_filter=filter.interp_fir_filter_ccf(1, self.rrc_taps)
if not self._mm_gain_mu: if not self._mm_gain_mu:
sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15} sbs_to_mm = {2: 0.050, 3: 0.075, 4: 0.11, 5: 0.125, 6: 0.15, 7: 0.15}
@ -281,13 +282,13 @@ class cqpsk_demod(gr.hier_block2):
self.receiver.set_beta(self._costas_beta) self.receiver.set_beta(self._costas_beta)
# Perform Differential decoding on the constellation # Perform Differential decoding on the constellation
self.diffdec = gr.diff_phasor_cc() self.diffdec = digital.diff_phasor_cc()
# take angle of the difference (in radians) # take angle of the difference (in radians)
self.to_float = gr.complex_to_arg() self.to_float = blocks.complex_to_arg()
# convert from radians such that signal is in -3/-1/+1/+3 # convert from radians such that signal is in -3/-1/+1/+3
self.rescale = gr.multiply_const_ff( 1 / (pi / 4) ) self.rescale = blocks.multiply_const_ff( 1 / (pi / 4) )
if verbose: if verbose:
self._print_verbage() self._print_verbage()
@ -322,19 +323,19 @@ class cqpsk_demod(gr.hier_block2):
def _setup_logging(self): def _setup_logging(self):
print "Modulation logging turned on." print "Modulation logging turned on."
self.connect(self.pre_scaler, self.connect(self.pre_scaler,
gr.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat")) blocks.file_sink(gr.sizeof_gr_complex, "rx_prescaler.dat"))
self.connect(self.agc, self.connect(self.agc,
gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat")) blocks.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
self.connect(self.rrc_filter, self.connect(self.rrc_filter,
gr.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat")) blocks.file_sink(gr.sizeof_gr_complex, "rx_rrc_filter.dat"))
self.connect(self.receiver, self.connect(self.receiver,
gr.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat")) blocks.file_sink(gr.sizeof_gr_complex, "rx_receiver.dat"))
self.connect(self.diffdec, self.connect(self.diffdec,
gr.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat")) blocks.file_sink(gr.sizeof_gr_complex, "rx_diffdec.dat"))
self.connect(self.to_float, self.connect(self.to_float,
gr.file_sink(gr.sizeof_float, "rx_to_float.dat")) blocks.file_sink(gr.sizeof_float, "rx_to_float.dat"))
self.connect(self.rescale, self.connect(self.rescale,
gr.file_sink(gr.sizeof_float, "rx_rescale.dat")) blocks.file_sink(gr.sizeof_float, "rx_rescale.dat"))
def add_options(parser): def add_options(parser):
""" """

View file

@ -2,8 +2,9 @@
import sys import sys
import math import math
from gnuradio import gr, gru, audio, eng_notation, blks2, optfir from gnuradio import gr, gru, audio, eng_notation, filter, blocks
from gnuradio import uhd from gnuradio import uhd
from gnuradio.filter import firdes
from gnuradio.eng_option import eng_option from gnuradio.eng_option import eng_option
from optparse import OptionParser from optparse import OptionParser
@ -63,9 +64,9 @@ class my_top_block(gr.top_block):
sys.stderr.write('Failed to set center frequency\n') sys.stderr.write('Failed to set center frequency\n')
raise SystemExit, 1 raise SystemExit, 1
channel_taps = gr.firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, gr.firdes.WIN_HANN) channel_taps = firdes.low_pass(1.0, sample_rate, options.low_pass, options.low_pass * 0.1, firdes.WIN_HANN)
FILTER = gr.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate) FILTER = filter.freq_xlating_fir_filter_ccf(1, channel_taps, options.calibration, sample_rate)
sys.stderr.write("sample rate: %d\n" %(sample_rate)) sys.stderr.write("sample rate: %d\n" %(sample_rate))
@ -78,11 +79,11 @@ class my_top_block(gr.top_block):
log=options.log, log=options.log,
verbose=options.verbose) verbose=options.verbose)
OUT = gr.file_sink(gr.sizeof_float, options.output_file) OUT = blocks.file_sink(gr.sizeof_float, options.output_file)
r = float(sample_rate) / float(new_sample_rate) r = float(sample_rate) / float(new_sample_rate)
INTERPOLATOR = gr.fractional_interpolator_cc(0, r) INTERPOLATOR = filter.fractional_interpolator_cc(0, r)
self.connect(self._u, FILTER, INTERPOLATOR, DEMOD, OUT) self.connect(self._u, FILTER, INTERPOLATOR, DEMOD, OUT)