diff options
Diffstat (limited to 'gnuradio-examples/python/hier/dect')
-rw-r--r-- | gnuradio-examples/python/hier/dect/Makefile.am | 28 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/dect/README | 46 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/dect/dect_receiver.py | 81 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/dect/gmsk2.py | 278 | ||||
-rwxr-xr-x | gnuradio-examples/python/hier/dect/usrp_dect.py | 62 | ||||
-rw-r--r-- | gnuradio-examples/python/hier/dect/usrp_source.py | 124 |
6 files changed, 0 insertions, 619 deletions
diff --git a/gnuradio-examples/python/hier/dect/Makefile.am b/gnuradio-examples/python/hier/dect/Makefile.am deleted file mode 100644 index 5ab1589aea..0000000000 --- a/gnuradio-examples/python/hier/dect/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -EXTRA_DIST = \ - README \ - dect_receiver.py \ - usrp_source.py \ - usrp_dect.py - -MOSTLYCLEANFILES = *.pyc *~ diff --git a/gnuradio-examples/python/hier/dect/README b/gnuradio-examples/python/hier/dect/README deleted file mode 100644 index c8853f185b..0000000000 --- a/gnuradio-examples/python/hier/dect/README +++ /dev/null @@ -1,46 +0,0 @@ -This directory contains a work in progress service monitor for DECT -digital cordless phone base stations and handsets. - - -Status ------- - -2007 Apr 27 - Converted to new hier_block2 format -2007 Apr 03 - Development on hold. -2007 Feb 11 - Added GMSK demodulation and option to log to file -2007 Feb 10 - Able to tune and log filtered baseband to file - - -Files ------ - -usrp_dect.py - DECT receiver application - -dect_receiver.py - Top-level hierarchical block (new type) implementing - receiver - -usrp_source.py - Hierarchical block (new type) implementing a USRP - complex source, with convenience functions for tuning, - gain, decimation, etc. - -gmsk2.py - Hierarchical block (new type) implementing GMSK - modulation and demodulation. This will eventually go - into the core blksimpl directory - -DECT Modulation Details ------------------------ - -In the US, the FCC has allocated four carrier frequencies for DECT usage: - -Channel Frequency -------- --------- - 1 1921.536 MHz - 2 1923.264 MHz - 3 1924.992 MHz - 4 1926.720 MHz - -These are spaced at 1.728 MHz intervals. - -The DECT PHY uses GMSK with a 0.5 bandwidth-time product at 1.152 Msym/sec, -for an occupied bandwidth (99% power) of 1.186 MHz (1.03 x symbol rate.) - diff --git a/gnuradio-examples/python/hier/dect/dect_receiver.py b/gnuradio-examples/python/hier/dect/dect_receiver.py deleted file mode 100644 index 80ea93794a..0000000000 --- a/gnuradio-examples/python/hier/dect/dect_receiver.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, optfir -from usrp_source import usrp_source_c -from gmsk2 import gmsk2_demod - -_dect_symbol_rate = 1.152e6 -_dect_occupied_bandwidth = _dect_symbol_rate * 1.03 # BT=0.5 -_dect_channel_bandwidth = 1.728e6 - -# Top-level hierarchical block that implements DECT demodulation and -# decoding. -class dect_receiver(gr.top_block): - def __init__(self, options): - gr.top_block.__init__(self, "dect_receiver") - self._options = options - - # Need greater than 2 samples per symbol. This makes a decimation - # rate of 26 and a samples per symbol of 2.136752 - if_rate = 2.461538e6 - self._usrp = usrp_source_c(which=0, - subdev_spec=options.rx_subdev_spec, - if_rate=if_rate, - gain=options.gain, - freq=options.freq, - calibration=options.calibration, - verbose=options.verbose) - - # Filter baseband to 1.186 MHz passband, 1.728 MHz stopband - chan_taps = optfir.low_pass(1.0, # Gain - if_rate, # Sample rate - _dect_occupied_bandwidth/2, # One sided modulation bandwidth - _dect_channel_bandwidth/2, # One sided channel bandwidth - 1.0, # Passband ripple (db) - 60) # Stopband attenuation (db) - if self._options.verbose: - print "Channel filter has", len(chan_taps), "taps" - self._channel_filter = gr.freq_xlating_fir_filter_ccf(1, # Decimation rate - chan_taps, # Filter taps - 0.0, # Offset frequency - if_rate) # Sample rate - - self._demod = gmsk2_demod(samples_per_symbol=if_rate/_dect_symbol_rate, - verbose=options.verbose) - - self._sink = gr.null_sink(gr.sizeof_char) - self.connect(self._usrp, self._channel_filter, self._demod, self._sink) - - # Log baseband to file if requested - if options.log_baseband is not None: - if options.verbose: - print "Logging baseband to file", options.log_baseband - self.baseband_log = gr.file_sink(gr.sizeof_gr_complex, options.log_baseband) - self.connect(self._channel_filter, self.baseband_log) - - # Log demodulator output to file if requested - if options.log_demod is not None: - if options.verbose: - print "Logging demodulator to file", options.log_demod - self.demod_log = gr.file_sink(gr.sizeof_char, options.log_demod) - self.connect(self._demod, self.demod_log) diff --git a/gnuradio-examples/python/hier/dect/gmsk2.py b/gnuradio-examples/python/hier/dect/gmsk2.py deleted file mode 100644 index f26c566552..0000000000 --- a/gnuradio-examples/python/hier/dect/gmsk2.py +++ /dev/null @@ -1,278 +0,0 @@ -# -# GMSK modulation and demodulation. -# -# -# Copyright 2005,2006,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# See gnuradio-examples/python/digital for examples - -from gnuradio import gr -from gnuradio import modulation_utils -from math import pi -import numpy -from pprint import pprint -import inspect - -# default values (used in __init__ and add_options) -_def_samples_per_symbol = 2 -_def_bt = 0.35 -_def_verbose = False -_def_log = False - -_def_gain_mu = 0.05 -_def_mu = 0.5 -_def_freq_error = 0.0 -_def_omega_relative_limit = 0.005 - - -# ///////////////////////////////////////////////////////////////////////////// -# GMSK modulator -# ///////////////////////////////////////////////////////////////////////////// - -class gmsk2_mod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - bt=_def_bt, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - modulation. - - The input is a byte stream (unsigned char) and the - output is the complex modulated signal at baseband. - - @param samples_per_symbol: samples per baud >= 2 - @type samples_per_symbol: integer - @param bt: Gaussian filter bandwidth * symbol time - @type bt: float - @param verbose: Print information about modulator? - @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool - """ - gr.hier_block2.__init__(self, - "gmsk2_mod", # Block typename - gr.io_signature(1,1,gr.sizeof_char), # Input signature - gr.io_signature(1,1,gr.sizeof_gr_complex)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._bt = bt - - if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2: - raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,)) - - ntaps = 4 * samples_per_symbol # up to 3 bits in filter at once - sensitivity = (pi / 2) / samples_per_symbol # phase change per bit = pi / 2 - - # Turn it into NRZ data. - self.nrz = gr.bytes_to_syms() - - # Form Gaussian filter - # Generate Gaussian response (Needs to be convolved with window below). - self.gaussian_taps = gr.firdes.gaussian( - 1, # gain - samples_per_symbol, # symbol_rate - bt, # bandwidth * symbol time - ntaps # number of taps - ) - - self.sqwave = (1,) * samples_per_symbol # rectangular window - self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave)) - self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps) - - # FM modulation - self.fmmod = gr.frequency_modulator_fc(sensitivity) - - if verbose: - self._print_verbage() - - self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self) - - if log: - self._setup_logging() - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "Gaussian filter bt = %.2f" % self._bt - - - def _setup_logging(self): - print "Modulation logging turned on." - self.connect(self.nrz, gr.file_sink(gr.sizeof_float, "nrz.dat")) - self.connect(self.gaussian_filter, gr.file_sink(gr.sizeof_float, "gaussian_filter.dat")) - self.connect(self.fmmod, gr.file_sink(gr.sizeof_gr_complex, "fmmod.dat")) - - def add_options(parser): - """ - Adds GMSK modulation-specific options to the standard parser - """ - parser.add_option("", "--bt", type="float", default=_def_bt, - help="set bandwidth-time product [default=%default] (GMSK)") - add_options=staticmethod(add_options) - - # FIXME: figure out what has to change for gr.hier_block2 version - #def extract_kwargs_from_options(options): - # """ - # Given command line options, create dictionary suitable for passing to __init__ - # """ - # return modulation_utils.extract_kwargs_from_options(gmsk_mod.__init__, - # ('self', 'fg'), options) - #extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - - -# ///////////////////////////////////////////////////////////////////////////// -# GMSK demodulator -# ///////////////////////////////////////////////////////////////////////////// - -class gmsk2_demod(gr.hier_block2): - - def __init__(self, - samples_per_symbol=_def_samples_per_symbol, - gain_mu=_def_gain_mu, - mu=_def_mu, - omega_relative_limit=_def_omega_relative_limit, - freq_error=_def_freq_error, - verbose=_def_verbose, - log=_def_log): - """ - Hierarchical block for Gaussian Minimum Shift Key (GMSK) - demodulation. - - The input is the complex modulated signal at baseband. - The output is a stream of bits packed 1 bit per byte (the LSB) - - @param samples_per_symbol: samples per baud - @type samples_per_symbol: integer - @param verbose: Print information about modulator? - @type verbose: bool - @param log: Print modualtion data to files? - @type log: bool - - Clock recovery parameters. These all have reasonble defaults. - - @param gain_mu: controls rate of mu adjustment - @type gain_mu: float - @param mu: fractional delay [0.0, 1.0] - @type mu: float - @param omega_relative_limit: sets max variation in omega - @type omega_relative_limit: float, typically 0.000200 (200 ppm) - @param freq_error: bit rate error as a fraction - @param float - """ - - gr.hier_block2.__init__(self, - "gmsk2_demod", # Block typename - gr.io_signature(1,1,gr.sizeof_gr_complex), # Input signature - gr.io_signature(1,1,gr.sizeof_char)) # Output signature - - self._samples_per_symbol = samples_per_symbol - self._gain_mu = gain_mu - self._mu = mu - self._omega_relative_limit = omega_relative_limit - self._freq_error = freq_error - - if samples_per_symbol < 2: - raise TypeError, "samples_per_symbol >= 2, is %f" % samples_per_symbol - - self._omega = samples_per_symbol*(1+self._freq_error) - - self._gain_omega = .25 * self._gain_mu * self._gain_mu # critically damped - - # Demodulate FM - sensitivity = (pi / 2) / samples_per_symbol - self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity) - - # the clock recovery block tracks the symbol clock and resamples as needed. - # the output of the block is a stream of soft symbols (float) - self.clock_recovery = gr.clock_recovery_mm_ff(self._omega, self._gain_omega, - self._mu, self._gain_mu, - self._omega_relative_limit) - - # slice the floats at 0, outputting 1 bit (the LSB of the output byte) per sample - self.slicer = gr.binary_slicer_fb() - - if verbose: - self._print_verbage() - - self.connect(self, self.fmdemod, self.clock_recovery, self.slicer, self) - - if log: - self._setup_logging() - - def samples_per_symbol(self): - return self._samples_per_symbol - - def bits_per_symbol(self=None): # staticmethod that's also callable on an instance - return 1 - bits_per_symbol = staticmethod(bits_per_symbol) # make it a static method. - - def _print_verbage(self): - print "bits per symbol = %d" % self.bits_per_symbol() - print "M&M clock recovery omega = %f" % self._omega - print "M&M clock recovery gain mu = %f" % self._gain_mu - print "M&M clock recovery mu = %f" % self._mu - print "M&M clock recovery omega rel. limit = %f" % self._omega_relative_limit - print "frequency error = %f" % self._freq_error - - - def _setup_logging(self): - print "Demodulation logging turned on." - self.connect(fmdemod, gr.file_sink(gr.sizeof_float, "fmdemod.dat")) - self.connect(clock_recovery, gr.file_sink(gr.sizeof_float, "clock_recovery.dat")) - self.connect(slicer, gr.file_sink(gr.sizeof_char, "slicer.dat")) - - def add_options(parser): - """ - Adds GMSK demodulation-specific options to the standard parser - """ - parser.add_option("", "--gain-mu", type="float", default=_def_gain_mu, - help="M&M clock recovery gain mu [default=%default] (GMSK/PSK)") - parser.add_option("", "--mu", type="float", default=_def_mu, - help="M&M clock recovery mu [default=%default] (GMSK/PSK)") - parser.add_option("", "--omega-relative-limit", type="float", default=_def_omega_relative_limit, - help="M&M clock recovery omega relative limit [default=%default] (GMSK/PSK)") - parser.add_option("", "--freq-error", type="float", default=_def_freq_error, - help="M&M clock recovery frequency error [default=%default] (GMSK)") - add_options=staticmethod(add_options) - - # FIXME: figure out what this is for gr.hier_block2 version - #def extract_kwargs_from_options(options): - # """ - # Given command line options, create dictionary suitable for passing to __init__ - # """ - # return modulation_utils.extract_kwargs_from_options(gmsk_demod.__init__, - # ('self', 'fg'), options) - #extract_kwargs_from_options=staticmethod(extract_kwargs_from_options) - -# -# Add these to the mod/demod registry -# -modulation_utils.add_type_1_mod('gmsk2', gmsk2_mod) -modulation_utils.add_type_1_demod('gmsk2', gmsk2_demod) diff --git a/gnuradio-examples/python/hier/dect/usrp_dect.py b/gnuradio-examples/python/hier/dect/usrp_dect.py deleted file mode 100755 index 27259d8127..0000000000 --- a/gnuradio-examples/python/hier/dect/usrp_dect.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser -from dect_receiver import dect_receiver -import sys - -def main(): - parser = OptionParser(option_class=eng_option) - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("", "--calibration", type="eng_float", default=0.0, - help="set frequency calibration offset to FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-v", "--verbose", action="store_true", default=False, - help="print extra debugging info") - parser.add_option("", "--log-baseband", default=None, - help="log filtered baseband to file") - parser.add_option("", "--log-demod", default=None, - help="log demodulator output to file") - (options, args) = parser.parse_args() - - if len(sys.argv) == 1 or len(args) != 0: - parser.print_help() - sys.exit(1) - - # Create an instance of a hierarchical block - top_block = dect_receiver(options) - - try: - # Run forever - top_block.run() - except KeyboardInterrupt: - # Ctrl-C exits - pass - -if __name__ == '__main__': - main () diff --git a/gnuradio-examples/python/hier/dect/usrp_source.py b/gnuradio-examples/python/hier/dect/usrp_source.py deleted file mode 100644 index 6a779840f2..0000000000 --- a/gnuradio-examples/python/hier/dect/usrp_source.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, usrp, eng_notation -n2s = eng_notation.num_to_str - -# Hierarchical block implementing a USRP source for complex floats, -# with convenience functions for gain, tune, decimation, etc. -# -class usrp_source_c(gr.hier_block2): - """ - Create a USRP source object supplying complex floats. - """ - def __init__(self, which=0, subdev_spec=None, gain=None, if_rate=None, - freq=0.0, calibration=0.0, verbose=False): - # Call hierarchical block constructor - gr.hier_block2.__init__(self, - "usrp_source_c", # Block typename - gr.io_signature(0,0,0), # Input signature - gr.io_signature(1,1,gr.sizeof_gr_complex)) # Output signature - - self._verbose = verbose - self._u = usrp.source_c(which) - if self._verbose: - print 'ADC sample rate is', n2s(self._u.adc_rate()), "sps" - self.set_subdev(subdev_spec) - self.set_if_rate(if_rate) - self.set_gain(gain) - self.set_calibration(calibration) - self.tune(freq) - self.connect(self._u, self) - - def set_subdev(self, subdev_spec): - if subdev_spec is None: - subdev_spec = self.pick_subdevice() - self._subdev = usrp.selected_subdev(self._u, subdev_spec) - self._u.set_mux(usrp.determine_rx_mux_value(self._u, subdev_spec)) - if self._verbose: - print 'RX using', self._subdev.name(), 'daughterboard' - - def pick_subdevice(self): - """ - The user didn't specify a subdevice. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if self._u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if self._u.db[1][0].dbid() >= 0: - return (1, 0) - return (0, 0) - - def set_if_rate(self, if_rate): - # If no IF rate specified, set to maximum decimation - if if_rate is None: - self._decim = 256 - else: - self._decim = int(self._u.adc_rate()/if_rate) - - self._u.set_decim_rate(self._decim) - self._if_rate = self._u.adc_rate()/self._decim - - if self._verbose: - print "USRP decimation rate is", self._decim - print "USRP IF rate is", n2s(self._if_rate), "sps" - - def set_gain(self, gain): - # If no gain specified, set to midrange - if gain is None: - g = self._subdev.gain_range() - gain = (g[0]+g[1])/2.0 - self._gain = gain - self._subdev.set_gain(self._gain) - - def set_calibration(self, calibration): - self._cal = calibration - if self._verbose: - print "Using frequency calibration offset of", n2s(calibration), "Hz" - - def tune(self, freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @type: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - self._tune_result = usrp.tune(self._u, 0, self._subdev, freq+self._cal) - if self._tune_result: - if self._verbose: - print "Baseband frequency is", n2s(self._tune_result.baseband_freq), "Hz" - print "DXC frequency is", n2s(self._tune_result.dxc_freq), "Hz" - print "Center frequency is", n2s(freq), "Hz" - print "Residual frequency is", n2s(self._tune_result.residual_freq), "Hz" - return True - - return False - -if __name__ == '__main__': - src = usrp_source_c(verbose=True) |