summaryrefslogtreecommitdiff
path: root/gr-digital
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital')
-rwxr-xr-xgr-digital/examples/example_timing.py2
-rw-r--r--gr-digital/examples/receive_path.py14
-rw-r--r--gr-digital/examples/transmit_path.py15
-rw-r--r--gr-digital/python/bpsk.py79
-rw-r--r--gr-digital/python/generic_mod_demod.py44
-rw-r--r--gr-digital/python/qam.py4
6 files changed, 115 insertions, 43 deletions
diff --git a/gr-digital/examples/example_timing.py b/gr-digital/examples/example_timing.py
index ef72d2369..fd86acfb1 100755
--- a/gr-digital/examples/example_timing.py
+++ b/gr-digital/examples/example_timing.py
@@ -42,7 +42,7 @@ class example_timing(gr.top_block):
if mode == 0:
self.clk = gr.pfb_clock_sync_ccf(sps, gain, rrc_taps_rx,
- nfilts, nfilts/2, 3.5)
+ nfilts, nfilts//2, 3.5)
self.taps = self.clk.get_taps()
self.dtaps = self.clk.get_diff_taps()
diff --git a/gr-digital/examples/receive_path.py b/gr-digital/examples/receive_path.py
index c6a26daf2..dd8eb1a0d 100644
--- a/gr-digital/examples/receive_path.py
+++ b/gr-digital/examples/receive_path.py
@@ -50,12 +50,12 @@ class receive_path(gr.hier_block2):
demod_kwargs = self._demod_class.extract_kwargs_from_options(options)
# Build the demodulator
- demodulator = self._demod_class(**demod_kwargs)
+ self.demodulator = self._demod_class(**demod_kwargs)
# Design filter to get actual channel we want
sw_decim = 1
chan_coeffs = gr.firdes.low_pass (1.0, # gain
- sw_decim * demodulator._samples_per_symbol, # sampling rate
+ sw_decim * self.samples_per_symbol(), # sampling rate
1.0, # midpoint of trans. band
0.5, # width of trans. band
gr.firdes.WIN_HANN) # filter type
@@ -63,7 +63,7 @@ class receive_path(gr.hier_block2):
# receiver
self.packet_receiver = \
- digital.demod_pkts(demodulator,
+ digital.demod_pkts(self.demodulator,
access_code=None,
callback=self._rx_callback,
threshold=-1)
@@ -90,7 +90,10 @@ class receive_path(gr.hier_block2):
return self._bitrate
def samples_per_symbol(self):
- return self._samples_per_symbol
+ return self.demodulator._samples_per_symbol
+
+ def differential(self):
+ return self.demodulator._differential
def carrier_sensed(self):
"""
@@ -139,4 +142,5 @@ class receive_path(gr.hier_block2):
print "\nReceive Path:"
print "modulation: %s" % (self._demod_class.__name__)
print "bitrate: %sb/s" % (eng_notation.num_to_str(self._bitrate))
- print "samples/symbol: %.4f" % (self._samples_per_symbol)
+ print "samples/symbol: %.4f" % (self.samples_per_symbol())
+ print "Differential: %s" % (self.differential())
diff --git a/gr-digital/examples/transmit_path.py b/gr-digital/examples/transmit_path.py
index 8ffb1e108..f22ffb327 100644
--- a/gr-digital/examples/transmit_path.py
+++ b/gr-digital/examples/transmit_path.py
@@ -44,7 +44,6 @@ class transmit_path(gr.hier_block2):
self._verbose = options.verbose
self._tx_amplitude = options.tx_amplitude # digital amplitude sent to USRP
self._bitrate = options.bitrate # desired bit rate
- self._samples_per_symbol = options.samples_per_symbol # desired samples/baud
self._modulator_class = modulator_class # the modulator_class we are using
@@ -52,9 +51,10 @@ class transmit_path(gr.hier_block2):
mod_kwargs = self._modulator_class.extract_kwargs_from_options(options)
# transmitter
- modulator = self._modulator_class(**mod_kwargs)
+ self.modulator = self._modulator_class(**mod_kwargs)
+
self.packet_transmitter = \
- digital.mod_pkts(modulator,
+ digital.mod_pkts(self.modulator,
access_code=None,
msgq_limit=4,
pad_for_usrp=True)
@@ -87,7 +87,10 @@ class transmit_path(gr.hier_block2):
return self._bitrate
def samples_per_symbol(self):
- return self._samples_per_symbol
+ return self.modulator._samples_per_symbol
+
+ def differential(self):
+ return self.modulator._differential
def add_options(normal, expert):
"""
@@ -115,5 +118,5 @@ class transmit_path(gr.hier_block2):
print "Tx amplitude %s" % (self._tx_amplitude)
print "modulation: %s" % (self._modulator_class.__name__)
print "bitrate: %sb/s" % (eng_notation.num_to_str(self._bitrate))
- print "samples/symbol: %.4f" % (self._samples_per_symbol)
-
+ print "samples/symbol: %.4f" % (self.samples_per_symbol())
+ print "Differential: %s" % (self.differential())
diff --git a/gr-digital/python/bpsk.py b/gr-digital/python/bpsk.py
index 806a5d695..58a8289a5 100644
--- a/gr-digital/python/bpsk.py
+++ b/gr-digital/python/bpsk.py
@@ -34,7 +34,7 @@ import modulation_utils2
# Default number of points in constellation.
_def_constellation_points = 2
# Whether differential coding is used.
-_def_differential = True
+_def_differential = False
# /////////////////////////////////////////////////////////////////////////////
# BPSK constellation
@@ -52,7 +52,7 @@ def bpsk_constellation(m=_def_constellation_points):
class bpsk_mod(generic_mod):
def __init__(self, constellation_points=_def_constellation_points,
- *args, **kwargs):
+ differential=False, *args, **kwargs):
"""
Hierarchical block for RRC-filtered BPSK modulation.
@@ -68,8 +68,8 @@ class bpsk_mod(generic_mod):
if constellation_points != 2:
raise ValueError('Number of constellation points must be 2 for BPSK.')
super(bpsk_mod, self).__init__(constellation=constellation,
- *args, **kwargs)
-
+ differential=differential, *args, **kwargs)
+
# /////////////////////////////////////////////////////////////////////////////
# BPSK demodulator
#
@@ -78,7 +78,7 @@ class bpsk_mod(generic_mod):
class bpsk_demod(generic_demod):
def __init__(self, constellation_points=_def_constellation_points,
- *args, **kwargs):
+ differential=False, *args, **kwargs):
"""
Hierarchical block for RRC-filtered BPSK modulation.
@@ -94,7 +94,71 @@ class bpsk_demod(generic_demod):
if constellation_points != 2:
raise ValueError('Number of constellation points must be 2 for BPSK.')
super(bpsk_demod, self).__init__(constellation=constellation,
- *args, **kwargs)
+ differential=differential, *args, **kwargs)
+
+
+
+# /////////////////////////////////////////////////////////////////////////////
+# DBPSK constellation
+# /////////////////////////////////////////////////////////////////////////////
+
+def dbpsk_constellation(m=_def_constellation_points):
+ if m != _def_constellation_points:
+ raise ValueError("DBPSK can only have 2 constellation points.")
+ return digital_swig.constellation_dbpsk()
+
+# /////////////////////////////////////////////////////////////////////////////
+# DBPSK modulator
+# /////////////////////////////////////////////////////////////////////////////
+
+class dbpsk_mod(generic_mod):
+
+ def __init__(self, constellation_points=_def_constellation_points,
+ differential=True, *args, **kwargs):
+
+ """
+ Hierarchical block for RRC-filtered DBPSK modulation.
+
+ The input is a byte stream (unsigned char) and the
+ output is the complex modulated signal at baseband.
+
+ See generic_mod block for list of parameters.
+ """
+
+ constellation_points = _def_constellation_points
+ constellation = digital_swig.constellation_bpsk()
+ if constellation_points != 2:
+ raise ValueError('Number of constellation points must be 2 for DBPSK.')
+ super(dbpsk_mod, self).__init__(constellation=constellation,
+ differential=True,
+ *args, **kwargs)
+
+# /////////////////////////////////////////////////////////////////////////////
+# DBPSK demodulator
+#
+# /////////////////////////////////////////////////////////////////////////////
+
+class dbpsk_demod(generic_demod):
+
+ def __init__(self, constellation_points=_def_constellation_points,
+ differential=True, *args, **kwargs):
+
+ """
+ Hierarchical block for RRC-filtered DBPSK modulation.
+
+ The input is a byte stream (unsigned char) and the
+ output is the complex modulated signal at baseband.
+
+ See generic_demod block for list of parameters.
+ """
+
+ constellation_points = _def_constellation_points
+ constellation = digital_swig.constellation_bpsk()
+ if constellation_points != 2:
+ raise ValueError('Number of constellation points must be 2 for DBPSK.')
+ super(dbpsk_demod, self).__init__(constellation=constellation,
+ differential=True,
+ *args, **kwargs)
#
# Add these to the mod/demod registry
@@ -102,3 +166,6 @@ class bpsk_demod(generic_demod):
modulation_utils2.add_type_1_mod('bpsk', bpsk_mod)
modulation_utils2.add_type_1_demod('bpsk', bpsk_demod)
modulation_utils2.add_type_1_constellation('bpsk', bpsk_constellation)
+modulation_utils2.add_type_1_mod('dbpsk', dbpsk_mod)
+modulation_utils2.add_type_1_demod('dbpsk', dbpsk_demod)
+modulation_utils2.add_type_1_constellation('dbpsk', dbpsk_constellation)
diff --git a/gr-digital/python/generic_mod_demod.py b/gr-digital/python/generic_mod_demod.py
index fad01fdfc..3410ab9d5 100644
--- a/gr-digital/python/generic_mod_demod.py
+++ b/gr-digital/python/generic_mod_demod.py
@@ -47,7 +47,7 @@ _def_phase_bw = 2*math.pi/100.0
# Number of points in constellation
_def_constellation_points = 16
# Whether differential coding is used.
-_def_differential = True
+_def_differential = False
def add_common_options(parser):
"""
@@ -55,10 +55,12 @@ def add_common_options(parser):
"""
parser.add_option("-p", "--constellation-points", type="int", default=_def_constellation_points,
help="set the number of constellation points (must be a power of 2 (power of 4 for QAM) [default=%default]")
- parser.add_option("", "--differential", action="store_true", dest="differential", default=True,
- help="use differential encoding [default=%default]")
- parser.add_option("", "--not-differential", action="store_false", dest="differential",
+ parser.add_option("", "--non-differential", action="store_true",
+ dest="differential", default=False,
help="do not use differential encoding [default=%default]")
+ parser.add_option("", "--differential", action="store_false",
+ dest="differential",
+ help="use differential encoding [default=False]")
parser.add_option("", "--mod-code", type="choice", choices=mod_codes.codes,
default=mod_codes.NO_CODE,
help="Select modulation code from: %s [default=%%default]"
@@ -270,17 +272,13 @@ class generic_demod(gr.hier_block2):
taps = gr.firdes.root_raised_cosine(nfilts, nfilts*self._samples_per_symbol,
1.0, self._excess_bw, ntaps)
self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol,
- self._timing_bw, taps,
+ self._timing_bw, taps,
nfilts, nfilts//2, self._timing_max_dev)
- self._phase_alpha = 0.1
- self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha
fmin = -0.25
fmax = 0.25
-
self.receiver = digital_swig.constellation_receiver_cb(
- self._constellation,
- self._phase_alpha, self._phase_beta,
+ self._constellation, self._phase_bw,
fmin, fmax)
# Do differential decoding based on phase change of symbols
@@ -326,31 +324,31 @@ class generic_demod(gr.hier_block2):
def _setup_logging(self):
print "Modulation logging turned on."
self.connect(self.agc,
- gr.file_sink(gr.sizeof_gr_complex, "rx_agc.dat"))
+ gr.file_sink(gr.sizeof_gr_complex, "rx_agc.32fc"))
self.connect((self.freq_recov, 0),
- gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.dat"))
+ gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov.32fc"))
self.connect((self.freq_recov, 1),
- gr.file_sink(gr.sizeof_float, "rx_freq_recov_freq.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_freq_recov_freq.32f"))
self.connect((self.freq_recov, 2),
- gr.file_sink(gr.sizeof_float, "rx_freq_recov_phase.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_freq_recov_phase.32f"))
self.connect((self.freq_recov, 3),
- gr.file_sink(gr.sizeof_gr_complex, "rx_freq_recov_error.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_freq_recov_error.32f"))
self.connect((self.time_recov, 0),
- gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.dat"))
+ gr.file_sink(gr.sizeof_gr_complex, "rx_time_recov.32fc"))
self.connect((self.time_recov, 1),
- gr.file_sink(gr.sizeof_float, "rx_time_recov_error.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_time_recov_error.32f"))
self.connect((self.time_recov, 2),
- gr.file_sink(gr.sizeof_float, "rx_time_recov_rate.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_time_recov_rate.32f"))
self.connect((self.time_recov, 3),
- gr.file_sink(gr.sizeof_float, "rx_time_recov_phase.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_time_recov_phase.32f"))
self.connect((self.receiver, 0),
- gr.file_sink(gr.sizeof_char, "rx_receiver.dat"))
+ gr.file_sink(gr.sizeof_char, "rx_receiver.8c"))
self.connect((self.receiver, 1),
- gr.file_sink(gr.sizeof_float, "rx_receiver_error.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_receiver_error.32f"))
self.connect((self.receiver, 2),
- gr.file_sink(gr.sizeof_float, "rx_receiver_phase.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_receiver_phase.32f"))
self.connect((self.receiver, 3),
- gr.file_sink(gr.sizeof_float, "rx_receiver_freq.dat"))
+ gr.file_sink(gr.sizeof_float, "rx_receiver_freq.32f"))
if self._differential:
self.connect(self.diffdec,
gr.file_sink(gr.sizeof_char, "rx_diffdec.dat"))
diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py
index f29291ce8..a5a2e6c2c 100644
--- a/gr-digital/python/qam.py
+++ b/gr-digital/python/qam.py
@@ -113,7 +113,7 @@ def make_differential_constellation(m, gray_coded):
return const_map
-def make_not_differential_constellation(m, gray_coded):
+def make_non_differential_constellation(m, gray_coded):
side = int(pow(m, 0.5))
if (not isinstance(m, int) or m < 4 or not is_power_of_four(m)):
raise ValueError("m must be a power of 4 integer.")
@@ -158,7 +158,7 @@ def qam_constellation(constellation_points=_def_constellation_points,
if differential:
points = make_differential_constellation(constellation_points, gray_coded)
else:
- points = make_not_differential_constellation(constellation_points, gray_coded)
+ points = make_non_differential_constellation(constellation_points, gray_coded)
side = int(sqrt(constellation_points))
width = 2.0/(side-1)
# No pre-diff code