2
# Copyright 2008 Free Software Foundation, Inc.
4
# This file is part of GNU Radio
6
# GNU Radio is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3, or (at your option)
11
# GNU Radio is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with GNU Radio; see the file COPYING. If not, write to
18
# the Free Software Foundation, Inc., 51 Franklin Street,
19
# Boston, MA 02110-1301, USA.
22
##################################################
24
##################################################
27
from gnuradio import gr, blks2
28
from pubsub import pubsub
29
from constants import *
31
##################################################
32
# Constellation sink block (wrapper for old wxgui)
33
##################################################
34
class const_sink_c(gr.hier_block2):
36
A constellation block with a gui window.
44
size=const_window.DEFAULT_WIN_SIZE,
45
frame_rate=const_window.DEFAULT_FRAME_RATE,
46
const_size=const_window.DEFAULT_CONST_SIZE,
58
gr.hier_block2.__init__(
61
gr.io_signature(1, 1, gr.sizeof_gr_complex),
62
gr.io_signature(0, 0, 0),
65
sd = blks2.stream_to_vector_decimator(
66
item_size=gr.sizeof_gr_complex,
67
sample_rate=sample_rate,
71
beta = .25*alpha**2 #redundant, will be updated
73
gain_omega = .25*gain_mu**2 #redundant, will be updated
74
omega = 1 #set_sample_rate will update this
75
# Costas frequency/phase recovery loop
76
# Critically damped 2nd order PLL
77
self._costas = gr.costas_loop_cc(alpha, beta, fmax, fmin, M)
78
# Timing recovery loop
79
# Critically damped 2nd order DLL
80
self._retime = gr.clock_recovery_mm_cc(omega, gain_omega, mu, gain_mu, omega_limit)
81
#sync = gr.mpsk_receiver_cc(
94
agc = gr.feedforward_agc_cc(16, 1)
95
msgq = gr.msg_queue(2)
96
sink = gr.message_sink(gr.sizeof_gr_complex*const_size, msgq, True)
98
self.connect(self, self._costas, self._retime, agc, sd, sink)
100
def setter(p, k, x): p[k] = x
101
self.controller = pubsub()
102
self.controller.subscribe(ALPHA_KEY, self._costas.set_alpha)
103
self.controller.publish(ALPHA_KEY, self._costas.alpha)
104
self.controller.subscribe(BETA_KEY, self._costas.set_beta)
105
self.controller.publish(BETA_KEY, self._costas.beta)
106
self.controller.subscribe(GAIN_MU_KEY, self._retime.set_gain_mu)
107
self.controller.publish(GAIN_MU_KEY, self._retime.gain_mu)
108
self.controller.subscribe(OMEGA_KEY, self._retime.set_omega)
109
self.controller.publish(OMEGA_KEY, self._retime.omega)
110
self.controller.subscribe(GAIN_OMEGA_KEY, self._retime.set_gain_omega)
111
self.controller.publish(GAIN_OMEGA_KEY, self._retime.gain_omega)
112
self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
113
self.controller.subscribe(SAMPLE_RATE_KEY, lambda x: setter(self.controller, OMEGA_KEY, float(x)/symbol_rate))
114
self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
116
self.controller[SAMPLE_RATE_KEY] = sample_rate
118
common.input_watcher(msgq, self.controller, MSG_KEY)
120
self.win = const_window.const_window(
122
controller=self.controller,
128
gain_mu_key=GAIN_MU_KEY,
129
gain_omega_key=GAIN_OMEGA_KEY,
131
sample_rate_key=SAMPLE_RATE_KEY,
133
common.register_access_methods(self, self.win)