summaryrefslogtreecommitdiff
path: root/gr-digital/python
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python')
-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
3 files changed, 96 insertions, 31 deletions
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