def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__( self, "dvb_s_demodulator_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature omega = sample_rate / symbol_rate gain_omega = omega * omega / 4.0 freq_beta = freq_alpha * freq_alpha / 4.0 mu = 0.0 gain_mu = 0.05 omega_relative_limit = 0.005 # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = gr.fll_band_edge_cc(omega, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(omega), freq_alpha, freq_beta) self.receiver = gr.mpsk_receiver_cc(M, 0, freq_alpha, freq_beta, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_relative_limit) self.rotate = gr.multiply_const_cc(0.707 + 0.707j) self.connect(self, self.agc, self.freq_recov, self.receiver, self.rotate, self)
def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__(self, "dvb_s_demodulator_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature omega = sample_rate / symbol_rate gain_omega = omega * omega / 4.0 freq_beta = freq_alpha * freq_alpha / 4.0 mu = 0.0 gain_mu = 0.05 omega_relative_limit = 0.005 # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = digital.fll_band_edge_cc(omega, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(omega), freq_bw) self.freq_recov.set_alpha(freq_alpha) self.freq_recov.set_beta(freq_beta) self.receiver = digital.mpsk_receiver_cc(M, 0, freq_bw, fmin, fmax, mu, gain_mu, omega, gain_omega, omega_relative_limit) self.receiver.set_alpha(freq_alpha) self.receiver.set_beta(freq_beta) self.rotate = gr.multiply_const_cc(0.707 + 0.707j) self.connect(self, self.agc, self.freq_recov, self.receiver, self.rotate, self)
def __init__(self): gr.top_block.__init__(self, "CW/SSB Receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 96000 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) self.sql_lev = sql_lev = -100 self.rf_gain = rf_gain = 20 self.pass_trans = pass_trans = 600 self.pass_low = pass_low = 300 self.pass_high = pass_high = 1200 self.freq = freq = 144800000 self.af_gain = af_gain = 5 self.sat_file_name = sat_file_name = "Undefined" ################################################## # Blocks ################################################## self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_lev, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((af_gain, )) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 20.8e-6, 0.3, 1.0, 0.0) self.fcd_source_c_1 = fcd.source_c("hw:1") self.fcd_source_c_1.set_freq(freq) self.fcd_source_c_1.set_freq_corr(-10) self.band_pass_filter_0 = gr.fir_filter_ccf(2, firdes.band_pass( 1, samp_rate, pass_low, pass_high, pass_trans, firdes.WIN_HAMMING, 6.76)) self.audio_sink = audio.sink(48000, "", True) self.wavfile_sink = gr.wavfile_sink(self.sat_file_name, 1, 11025, 16) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=11025, decimation=48000, taps=None, fractional_bw=None, ) ################################################## # Connections ################################################## self.connect((self.fcd_source_c_1, 0), (self.xlating_fir_filter, 0)) self.connect((self.xlating_fir_filter, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 1)) self.connect((self.gr_complex_to_real_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.wavfile_sink, 0))
def __init__(self): gr.top_block.__init__(self, "CC1101 Burst Detector") def rx_callback(): print "Callback Fired" # Variables self.samp_rate = samp_rate = 250e3 self.f_center = f_center = 510e6 self.bandwidth = bandwidth = 125e3 self.gain = gain = 15 self.sps = sps = 2 # Blocks self.uhd_src = uhd.usrp_source( device_addr="serial=E8R10Z2B1", #cheetara stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_src.set_samp_rate(samp_rate) self.uhd_src.set_center_freq(f_center, 0) self.uhd_src.set_gain(gain, 0) self.uhd_src.set_antenna("TX/RX", 0) self.uhd_src.set_bandwidth(bandwidth, 0) self.uhd_src.set_samp_rate(self.samp_rate) self.uhd_src.set_center_freq(self.f_center, 0) self.uhd_src.set_gain(self.gain, 0) # change magic_num until abs(ratio) as close to 0 (when sending all A's) # as possible (.000X or closer) # need to solve clock synchronization self.msk_demod = level.msk_demod_cf(ti_adj=False, magic_num=.022) self.agc = gr.agc2_cc() #self.clock_sync = digital.pfb_clock_sync_ccf(sps=2,) self.costas_loop = digital.costas_loop_cc(2*3.14/100.0, 4) self.packet_receiver = level.cc1k_demod_pkts(callback=rx_callback()) self.vec_sink = gr.vector_sink_f(1) self.slicer = digital.binary_slicer_fb() self.bin_sink = gr.vector_sink_b(1) # Connections self.connect(self.uhd_src, self.agc, self.msk_demod, self.slicer, self.bin_sink) self.connect(self.msk_demod, self.vec_sink) self.connect(self.uhd_src, self.packet_receiver)
def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__( self, "dvb_s_demodulator2_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature samples_per_symbol = sample_rate / symbol_rate # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = digital.fll_band_edge_cc( samples_per_symbol, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(samples_per_symbol), # Size of the filter in taps freq_bw) self.freq_recov.set_alpha(freq_alpha) self.freq_recov.set_beta(freq_beta) # Symbol timing recovery with RRC data filter ntaps = 11 * int(samples_per_symbol * nfilts) rrc_taps = gr.firdes.root_raised_cosine(nfilts, nfilts, 1.0 / samples_per_symbol, dvb_swig.RRC_ROLLOFF_FACTOR, ntaps) self.time_recov = gr.pfb_clock_sync_ccf( samples_per_symbol, # Samples per second in the incoming signal timing_alpha, # Alpha gain of control loop rrc_taps, # The filter taps nfilts, # Number of filters in the filter bank nfilts / 2) # Initial phase to look at (or which filter to start with) self.time_recov.set_beta(timing_beta) # Perform phase / fine frequency correction using Costas PLL phase_beta = phase_alpha * phase_alpha / 4 self.phase_recov = digital.costas_loop_cc(phase_bw, M) self.phase_recov.set_alpha(phase_alpha) self.phase_recov.set_beta(phase_beta) self.connect(self, self.agc, self.freq_recov, self.time_recov, self.phase_recov, self)
def __init__(self, sample_rate, symbol_rate): gr.hier_block2.__init__(self, "dvb_s_demodulator2_cc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature samples_per_symbol = sample_rate / symbol_rate # Automatic gain control self.agc = gr.agc2_cc( 0.06, # Attack rate 0.001, # Decay rate 1, # Reference 1, # Initial gain 100) # Max gain # Frequency correction with band-edge filters FLL freq_beta = freq_alpha * freq_alpha / 4 self.freq_recov = digital.fll_band_edge_cc( samples_per_symbol, dvb_swig.RRC_ROLLOFF_FACTOR, 11 * int(samples_per_symbol), # Size of the filter in taps freq_bw) self.freq_recov.set_alpha(freq_alpha) self.freq_recov.set_beta(freq_beta) # Symbol timing recovery with RRC data filter ntaps = 11 * int(samples_per_symbol * nfilts) rrc_taps = gr.firdes.root_raised_cosine(nfilts, nfilts, 1.0 / samples_per_symbol, dvb_swig.RRC_ROLLOFF_FACTOR, ntaps) self.time_recov = gr.pfb_clock_sync_ccf( samples_per_symbol, # Samples per second in the incoming signal timing_alpha, # Alpha gain of control loop rrc_taps, # The filter taps nfilts, # Number of filters in the filter bank nfilts / 2) # Initial phase to look at (or which filter to start with) self.time_recov.set_beta(timing_beta) # Perform phase / fine frequency correction using Costas PLL phase_beta = phase_alpha * phase_alpha / 4 self.phase_recov = digital.costas_loop_cc(phase_bw, M) self.phase_recov.set_alpha(phase_alpha) self.phase_recov.set_beta(phase_beta) self.connect(self, self.agc, self.freq_recov, self.time_recov, self.phase_recov, self)
def __init__( self, parent, title='', sample_rate=1, size=(495,450), frame_rate=5, const_size=1024, mod='DBPSK'): #init gr.hier_block2.__init__( self, "const_sink", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0), ) self.sd = blks2.stream_to_vector_decimator( item_size=gr.sizeof_gr_complex, sample_rate=sample_rate, vec_rate=frame_rate, vec_len=const_size, ) self. agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.gain= gr.multiply_const_cc(utils.gain[mod]) msgq = gr.msg_queue(2) sink = gr.message_sink(gr.sizeof_gr_complex*const_size, msgq, True) #connect self.connect(self, self.agc, self.gain, self.sd, sink) #controller def setter(p, k, x): p[k] = x self.controller = pubsub() #initial update common.input_watcher(msgq, self.controller, MSG_KEY) #create window self.win = const_window( parent=parent, controller=self.controller, size=size, title=title, msg_key=MSG_KEY ) common.register_access_methods(self, self.win)
def __init__(self): gr.top_block.__init__(self, "CW/SSB Receiver") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 96000 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 48000, 5000, firdes.WIN_HAMMING, 6.76) self.sql_lev = sql_lev = -100 self.rf_gain = rf_gain = 20 self.pass_trans = pass_trans = 600 self.pass_low = pass_low = 300 self.pass_high = pass_high = 1200 self.freq = freq = 144800000 self.af_gain = af_gain = 5 ################################################## # Blocks ################################################## self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), 0, samp_rate) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_lev, 1) self.gr_multiply_const_vxx_0 = gr.multiply_const_vff((af_gain, )) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 20.8e-6, 0.3, 1.0, 0.0) self.fcd_source_c_1 = fcd.source_c("hw:1") self.fcd_source_c_1.set_freq(freq) self.fcd_source_c_1.set_freq_corr(-10) self.band_pass_filter_0 = gr.fir_filter_ccf(2, firdes.band_pass( 1, samp_rate, pass_low, pass_high, pass_trans, firdes.WIN_HAMMING, 6.76)) self.audio_sink = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.fcd_source_c_1, 0), (self.xlating_fir_filter, 0)) self.connect((self.xlating_fir_filter, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.audio_sink, 1))
def __init__(self, parent, title='', sample_rate=1, size=(495, 450), frame_rate=5, const_size=1024, mod='DBPSK'): #init gr.hier_block2.__init__( self, "const_sink", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0), ) self.sd = blks2.stream_to_vector_decimator( item_size=gr.sizeof_gr_complex, sample_rate=sample_rate, vec_rate=frame_rate, vec_len=const_size, ) self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) self.gain = gr.multiply_const_cc(utils.gain[mod]) msgq = gr.msg_queue(2) sink = gr.message_sink(gr.sizeof_gr_complex * const_size, msgq, True) #connect self.connect(self, self.agc, self.gain, self.sd, sink) #controller def setter(p, k, x): p[k] = x self.controller = pubsub() #initial update common.input_watcher(msgq, self.controller, MSG_KEY) #create window self.win = const_window(parent=parent, controller=self.controller, size=size, title=title, msg_key=MSG_KEY) common.register_access_methods(self, self.win)
def test_005(self): ''' Test the complex AGC loop (attack and decay rate inputs) ''' tb = self.tb expected_result = \ ((100.000244140625+7.2191943445432116e-07j), (0.80881959199905396+0.58764183521270752j), (0.30894950032234192+0.95084899663925171j), (-0.30895623564720154+0.95086973905563354j), (-0.80887287855148315+0.58768033981323242j), (-0.99984413385391235+5.850709250410091e-09j), (-0.80889981985092163-0.58770018815994263j), (-0.30897706747055054-0.95093393325805664j), (0.30898112058639526-0.95094609260559082j), (0.80893135070800781-0.58772283792495728j), (0.99990922212600708-8.7766354184282136e-09j), (0.80894720554351807+0.58773452043533325j), (0.30899339914321899+0.95098406076431274j), (-0.30899572372436523+0.95099133253097534j), (-0.80896598100662231+0.58774799108505249j), (-0.99994778633117676+1.4628290578855285e-08j), (-0.80897533893585205-0.58775502443313599j), (-0.30900305509567261-0.95101380348205566j), (0.30900448560714722-0.95101797580718994j), (0.80898630619049072-0.58776277303695679j), (0.99997037649154663-1.7554345532744264e-08j), (0.80899184942245483+0.58776694536209106j), (0.30900871753692627+0.95103120803833008j), (-0.30900952219963074+0.95103377103805542j), (-0.8089984655380249+0.58777159452438354j), (-0.99998390674591064+2.3406109050938539e-08j), (-0.809001624584198-0.58777409791946411j), (-0.30901208519935608-0.95104163885116577j), (0.30901262164115906-0.95104306936264038j), (0.80900543928146362-0.587776780128479j), (0.99999171495437622-2.6332081404234486e-08j), (0.80900734663009644+0.58777821063995361j), (0.30901408195495605+0.95104765892028809j), (-0.30901429057121277+0.95104855298995972j), (-0.80900967121124268+0.58777981996536255j), (-0.99999648332595825+3.2183805842578295e-08j), (-0.80901080369949341-0.58778077363967896j), (-0.30901527404785156-0.95105135440826416j), (0.30901545286178589-0.95105189085006714j), (0.80901217460632324-0.58778166770935059j), (0.99999916553497314-3.5109700036173308e-08j), (0.809012770652771+0.58778214454650879j), (0.30901595950126648+0.9510534405708313j), (-0.30901598930358887+0.95105385780334473j), (-0.80901366472244263+0.58778274059295654j), (-1.0000008344650269+4.0961388947380328e-08j), (-0.8090139627456665-0.58778303861618042j), (-0.30901634693145752-0.95105475187301636j), (0.30901640653610229-0.95105493068695068j), (0.80901449918746948-0.5877833366394043j)) sampling_freq = 100 src1 = gr.sig_source_c(sampling_freq, gr.GR_SIN_WAVE, sampling_freq * 0.10, 100) dst1 = gr.vector_sink_c() head = gr.head(gr.sizeof_gr_complex, int(5 * sampling_freq * 0.10)) agc = gr.agc2_cc(1e-2, 1e-3, 1, 1, 1000) tb.connect(src1, head) tb.connect(head, agc) tb.connect(agc, dst1) if test_output == True: tb.connect(agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc2_cc.dat")) tb.run() dst_data = dst1.data() self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 4)
def __init__(self): gr.top_block.__init__(self, "Uhd Snr Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Snr Receiver") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_snr_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = filter.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.gain = gain = 15 self.freq = freq = 520e6 self.fine_freq = fine_freq = -28400 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RX Gain"+": ")) self._gain_counter = Qwt.QwtCounter() self._gain_counter.setRange(0, 31.5, 0.5) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 31.5, 0.5) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) self._freq_counter = Qwt.QwtCounter() self._freq_counter.setRange(514e6, 526e6, 1e6) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(514e6, 526e6, 1e6) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 2,0,1,1) self._fine_freq_layout = Qt.QVBoxLayout() self._fine_freq_tool_bar = Qt.QToolBar(self) self._fine_freq_layout.addWidget(self._fine_freq_tool_bar) self._fine_freq_tool_bar.addWidget(Qt.QLabel("Fine Frequency"+": ")) self._fine_freq_counter = Qwt.QwtCounter() self._fine_freq_counter.setRange(-50e3, 50e3, 100) self._fine_freq_counter.setNumButtons(2) self._fine_freq_counter.setValue(self.fine_freq) self._fine_freq_tool_bar.addWidget(self._fine_freq_counter) self._fine_freq_counter.valueChanged.connect(self.set_fine_freq) self._fine_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fine_freq_slider.setRange(-50e3, 50e3, 100) self._fine_freq_slider.setValue(self.fine_freq) self._fine_freq_slider.setMinimumWidth(200) self._fine_freq_slider.valueChanged.connect(self.set_fine_freq) self._fine_freq_layout.addWidget(self._fine_freq_slider) self.top_grid_layout.addLayout(self._fine_freq_layout, 2,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq + fine_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 500, #size samp_rate, #bw "QT GUI Plot", #name 3 #number of inputs ) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0,0,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1,0,1,2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "QT GUI Plot", #name 2 #number of inputs ) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0,1,1,1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 0.0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_mpsk_snr_est_cc_0_1 = digital.mpsk_snr_est_cc(3, 10000, 0.001) self.digital_mpsk_snr_est_cc_0_0 = digital.mpsk_snr_est_cc(2, 10000, 0.001) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(0, 10000, 0.001) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(15, 0.010, 1, digital.constellation_qpsk().base()) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100.0, 4) ################################################## # Connections ################################################## self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_1, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.digital_mpsk_snr_est_cc_0_1, 0), (self.qtgui_time_sink_x_0_0, 2))
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-e", "--interface", type="string", default="eth0", help="select Ethernet interface, default is eth0") parser.add_option("-m", "--mac-addr", type="string", default="", help="select USRP by MAC address, default is auto-select") parser.add_option("-W", "--bw", type="float", default=1e6, help="set bandwidth of receiver [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default="2.4G", help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("--fft-size", type="int", default=2048, help="Set number of FFT bins [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options self.show_debug_info = True self.qapp = QtGui.QApplication(sys.argv) # self.u = usrp2.source_32fc(options.interface, options.mac_addr) self.u = msdd_rs.source_simple("192.168.1.20", 10000); self.conv = gr.interleaved_short_to_complex(); self._adc_rate = self.u.pull_adc_freq() self.set_bandwidth(options.bw) if options.gain is None: # if no gain was specified, use the mid-point in dB # g = self.u.gain_range() g = [0, 10] #options.gain = float(g[0]+g[1])/2 options.gain = float(0) self.set_gain(options.gain) if options.freq is None: options.freq = 2.4e9; # # if no frequency was specified, use the mid-point of the subdev # f = self.u.freq_range() # options.freq = float(f[0]+f[1])/2 self.set_frequency(options.freq) self._fftsize = options.fft_size self._freq = options.freq; self._bandwidth = 400; self.set_bandwidth(self._bandwidth); self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._freq, self._bandwidth, "USRP2 Display", True, True, False, True, False) # Set up internal amplifier self.amp = gr.multiply_const_cc(0.0) self.set_amplifier_gain(0.01) # Create a single-pole IIR filter to remove DC # but don't connect it yet self.dc_gain = 0.001 self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) self.dc_sub = gr.sub_cc() self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10); self.connect(self.u, self.conv, self.snk) #self.connect(self.u, self.conv, self.amp, self.snk) if self.show_debug_info: print "Decimation rate: ", self._decim print "Bandwidth: ", self._bandwidth # print "D'board: ", self.u.daughterboard_id() # Get the reference pointer to the SpectrumDisplayForm QWidget # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) self.main_win = main_window(self.pysink, self) self.main_win.set_frequency(self._freq) self.main_win.set_gain(self._gain) self.main_win.set_bandwidth(self._bandwidth) self.main_win.set_amplifier(self._amp_value) self.main_win.show()
def __init__(self): gr.top_block.__init__(self) amplitude = 5000 interp_rate = 256 dec_rate = 16 sw_dec = 5 num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle taps = [complex(1,1)] * num_taps matched_filt = gr.fir_filter_ccc(sw_dec, taps); agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) to_mag = gr.complex_to_mag() center = rfid.center_ff(10) omega = 5 mu = 0.25 gain_mu = 0.25 gain_omega = .25 * gain_mu * gain_mu omega_relative_limit = .05 mm = gr.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.reader = rfid.reader_f(int(128e6/interp_rate)); tag_decoder = rfid.tag_decoder_f() command_gate = rfid.command_gate_cc(12, 250, 64000000 / dec_rate / sw_dec) to_complex = gr.float_to_complex() amp = gr.multiply_const_ff(amplitude) #output the TX and RX signals only f_txout = gr.file_sink(gr.sizeof_gr_complex, 'f_txout.out'); f_rxout = gr.file_sink(gr.sizeof_gr_complex, 'f_rxout.out'); #TX # working frequency at 915 MHz by default and RX Gain of 20 freq = options.center_freq #915e6 rx_gain = options.rx_gain #20 tx = usrp.sink_c(fusb_block_size = 512, fusb_nblocks=4) tx.set_interp_rate(256) tx_subdev = (0,0) tx.set_mux(usrp.determine_tx_mux_value(tx, tx_subdev)) subdev = usrp.selected_subdev(tx, tx_subdev) subdev.set_enable(True) subdev.set_gain(subdev.gain_range()[2]) t = tx.tune(subdev.which(), subdev, freq) if not t: print "Couldn't set tx freq" #End TX #RX rx = usrp.source_c(0, dec_rate, fusb_block_size = 512, fusb_nblocks = 4) rx_subdev_spec = (1,0) rx.set_mux(usrp.determine_rx_mux_value(rx, rx_subdev_spec)) rx_subdev = usrp.selected_subdev(rx, rx_subdev_spec) rx_subdev.set_gain(rx_gain) rx_subdev.set_auto_tr(False) rx_subdev.set_enable(True) r = usrp.tune(rx, 0, rx_subdev, freq) self.rx = rx if not r: print "Couldn't set rx freq" #End RX command_gate.set_ctrl_out(self.reader.ctrl_q()) tag_decoder.set_ctrl_out(self.reader.ctrl_q()) #########Build Graph self.connect(rx, matched_filt) self.connect(matched_filt, command_gate) self.connect(command_gate, agc) self.connect(agc, to_mag) self.connect(to_mag, center, mm, tag_decoder) self.connect(tag_decoder, self.reader, amp, to_complex, tx); ################# #Output dumps for debug self.connect(rx, f_rxout); self.connect(to_complex, f_txout);
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-e", "--interface", type="string", default="eth0", help="select Ethernet interface, default is eth0") parser.add_option( "-m", "--mac-addr", type="string", default="", help="select USRP by MAC address, default is auto-select") parser.add_option("-W", "--bw", type="float", default=1e6, help="set bandwidth of receiver [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default="2.4G", help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("--fft-size", type="int", default=2048, help="Set number of FFT bins [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options self.show_debug_info = True self.qapp = QtGui.QApplication(sys.argv) # self.u = usrp2.source_32fc(options.interface, options.mac_addr) self.u = msdd_rs.source_simple("192.168.1.20", 10000) self.conv = gr.interleaved_short_to_complex() self._adc_rate = self.u.pull_adc_freq() self.set_bandwidth(options.bw) if options.gain is None: # if no gain was specified, use the mid-point in dB # g = self.u.gain_range() g = [0, 10] #options.gain = float(g[0]+g[1])/2 options.gain = float(0) self.set_gain(options.gain) if options.freq is None: options.freq = 2.4e9 # # if no frequency was specified, use the mid-point of the subdev # f = self.u.freq_range() # options.freq = float(f[0]+f[1])/2 self.set_frequency(options.freq) self._fftsize = options.fft_size self._freq = options.freq self._bandwidth = 400 self.set_bandwidth(self._bandwidth) self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, self._freq, self._bandwidth, "USRP2 Display", True, True, False, True, False) # Set up internal amplifier self.amp = gr.multiply_const_cc(0.0) self.set_amplifier_gain(0.01) # Create a single-pole IIR filter to remove DC # but don't connect it yet self.dc_gain = 0.001 self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) self.dc_sub = gr.sub_cc() self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10) self.connect(self.u, self.conv, self.snk) #self.connect(self.u, self.conv, self.amp, self.snk) if self.show_debug_info: print "Decimation rate: ", self._decim print "Bandwidth: ", self._bandwidth # print "D'board: ", self.u.daughterboard_id() # Get the reference pointer to the SpectrumDisplayForm QWidget # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) self.main_win = main_window(self.pysink, self) self.main_win.set_frequency(self._freq) self.main_win.set_gain(self._gain) self.main_win.set_bandwidth(self._bandwidth) self.main_win.set_amplifier(self._amp_value) self.main_win.show()
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, timing_alpha=_def_timing_alpha, timing_max_dev=_def_timing_max_dev, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered DQPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alphas: float @param timing_alpha: timing loop alpha gain @type timing_alpha: float @param timing_max: timing loop maximum rate deviations @type timing_max: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "dqpsk2_demod", 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._excess_bw = excess_bw self._costas_alpha = costas_alpha self._timing_alpha = timing_alpha self._timing_beta = _def_timing_beta self._timing_max_dev=timing_max_dev self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol arity = pow(2,self.bits_per_symbol()) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) #self.agc = gr.feedforward_agc_cc(16, 2.0) self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha # Allow a frequency swing of +/- half of the sample rate fmin = -0.5 fmax = 0.5 self.clock_recov = gr.costas_loop_cc(self._costas_alpha, self._costas_beta, fmax, fmin, arity) # symbol timing recovery with RRC data filter nfilts = 32 ntaps = 11 * samples_per_symbol*nfilts taps = gr.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(self._samples_per_symbol), self._excess_bw, ntaps) self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_alpha, taps, nfilts, nfilts/2, self._timing_max_dev) self.time_recov.set_beta(self._timing_beta) # Perform Differential decoding on the constellation self.diffdec = gr.diff_phasor_cc() # find closest constellation point rot = 1 rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) if self._gray_code: self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) else: self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect self.connect(self, self.agc, self.clock_recov, self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="AM Receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.offset_fine = offset_fine = 0 self.offset_coarse = offset_coarse = 0 self.freq = freq = 7200000 self.LO = LO = 0 self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.width = width = 10000 self.trans = trans = 1500 self.rx_freq = rx_freq = LO+freq+(offset_coarse+offset_fine) self.rf_gain = rf_gain = 20 self.lo_freq = lo_freq = LO self.display_selector = display_selector = 0 self.af_gain = af_gain = 1 ################################################## # Blocks ################################################## _width_sizer = wx.BoxSizer(wx.VERTICAL) self._width_text_box = forms.text_box( parent=self.GetWin(), sizer=_width_sizer, value=self.width, callback=self.set_width, label="Filter", converter=forms.float_converter(), proportion=0, ) self._width_slider = forms.slider( parent=self.GetWin(), sizer=_width_sizer, value=self.width, callback=self.set_width, minimum=2000, maximum=40000, num_steps=760, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_width_sizer, 7, 0, 1, 1) _trans_sizer = wx.BoxSizer(wx.VERTICAL) self._trans_text_box = forms.text_box( parent=self.GetWin(), sizer=_trans_sizer, value=self.trans, callback=self.set_trans, label="Trans", converter=forms.float_converter(), proportion=0, ) self._trans_slider = forms.slider( parent=self.GetWin(), sizer=_trans_sizer, value=self.trans, callback=self.set_trans, minimum=500, maximum=5000, num_steps=900, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_trans_sizer, 8, 0, 1, 1) self._rx_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label="Receive", converter=forms.float_converter(), ) self.GridAdd(self._rx_freq_static_text, 5, 3, 1, 1) _offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_fine_sizer, value=self.offset_fine, callback=self.set_offset_fine, label="Fine tune", converter=forms.float_converter(), proportion=0, ) self._offset_fine_slider = forms.slider( parent=self.GetWin(), sizer=_offset_fine_sizer, value=self.offset_fine, callback=self.set_offset_fine, minimum=-1000, maximum=1000, num_steps=400, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_fine_sizer, 6, 0, 1, 2) _offset_coarse_sizer = wx.BoxSizer(wx.VERTICAL) self._offset_coarse_text_box = forms.text_box( parent=self.GetWin(), sizer=_offset_coarse_sizer, value=self.offset_coarse, callback=self.set_offset_coarse, label="Coarse tune", converter=forms.float_converter(), proportion=0, ) self._offset_coarse_slider = forms.slider( parent=self.GetWin(), sizer=_offset_coarse_sizer, value=self.offset_coarse, callback=self.set_offset_coarse, minimum=-120000, maximum=120000, num_steps=960, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_offset_coarse_sizer, 6, 2, 1, 2) self._display_selector_chooser = forms.drop_down( parent=self.GetWin(), value=self.display_selector, callback=self.set_display_selector, label="Spectrum", choices=[0, 1], labels=['Baseband','USRP'], ) self.GridAdd(self._display_selector_chooser, 5, 0, 1, 1) _af_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._af_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, label="VOL", converter=forms.float_converter(), proportion=0, ) self._af_gain_slider = forms.slider( parent=self.GetWin(), sizer=_af_gain_sizer, value=self.af_gain, callback=self.set_af_gain, minimum=0, maximum=5, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_af_gain_sizer, 8, 1, 1, 1) self.xlating_fir_filter = gr.freq_xlating_fir_filter_ccc(1, (xlate_filter_taps), -(offset_coarse+offset_fine), samp_rate) self.rtlsdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) self.rtlsdr_source_c_0.set_sample_rate(samp_rate) self.rtlsdr_source_c_0.set_center_freq(31e6, 0) self.rtlsdr_source_c_0.set_freq_corr(0, 0) self.rtlsdr_source_c_0.set_gain_mode(0, 0) self.rtlsdr_source_c_0.set_gain(10, 0) self.rtlsdr_source_c_0.set_if_gain(24, 0) _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label="RF", converter=forms.float_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=50, num_steps=50, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 7, 1, 1, 1) self.low_pass_filter = gr.fir_filter_ccf(5, firdes.low_pass( 1, samp_rate, width/2, trans, firdes.WIN_HAMMING, 6.76)) self._lo_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.lo_freq, callback=self.set_lo_freq, label="LO", converter=forms.float_converter(), ) self.GridAdd(self._lo_freq_static_text, 5, 2, 1, 1) self.gr_multiply_const_vxx_1 = gr.multiply_const_vff((af_gain, )) self.gr_agc2_xx_0 = gr.agc2_cc(0.1, 10e-6, 0.9, 1.0, 1.0) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="USRP", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 5, 1, 1, 1) self.fftsink = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=rx_freq*display_selector, y_per_div=10, y_divs=10, ref_level=0, ref_scale=13490.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.5, title="", peak_hold=False, size=(800,300), ) self.GridAdd(self.fftsink.win, 0, 0, 5, 4) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=441, decimation=500, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=44100, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(44100, "", True) ################################################## # Connections ################################################## self.connect((self.xlating_fir_filter, 0), (self.fftsink, 0)) self.connect((self.xlating_fir_filter, 0), (self.low_pass_filter, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self.audio_sink_0, 1)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.low_pass_filter, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.rtlsdr_source_c_0, 0), (self.xlating_fir_filter, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception("Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq+frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc(sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self, constellation, samples_per_symbol=_def_samples_per_symbol, differential=_def_differential, excess_bw=_def_excess_bw, gray_coded=True, freq_bw=_def_freq_bw, timing_bw=_def_timing_bw, phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered differential generic demodulation. The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param constellation: determines the modulation type @type constellation: gnuradio.digital.gr_constellation @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param gray_coded: turn gray coding on/off @type gray_coded: bool @param freq_bw: loop filter lock-in bandwidth @type freq_bw: float @param timing_bw: timing recovery loop lock-in bandwidth @type timing_bw: float @param phase_bw: phase recovery loop bandwidth @type phase_bw: 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, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._constellation = constellation.base() self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw self._freq_bw = freq_bw self._timing_bw = timing_bw self._timing_max_dev= _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol) arity = pow(2,self.bits_per_symbol()) nfilts = 32 ntaps = 11 * int(self._samples_per_symbol*nfilts) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) # Frequency correction fll_ntaps = 55 self.freq_recov = digital_swig.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter 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, nfilts, nfilts//2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 self.receiver = digital_swig.constellation_receiver_cb( self._constellation, self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: self.diffdec = gr.diff_decoder_bb(arity) if gray_coded: self.symbol_mapper = gr.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class blocks = [self, self.agc, self.freq_recov, self.time_recov, self.receiver] if differential: blocks.append(self.diffdec) if self._constellation.apply_pre_diff_code(): blocks.append(self.symbol_mapper) blocks += [self.unpack, self] self.connect(*blocks)
def __init__(self, constellation, samples_per_symbol=_def_samples_per_symbol, differential=_def_differential, excess_bw=_def_excess_bw, gray_coded=True, freq_bw=_def_freq_bw, timing_bw=_def_timing_bw, phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered differential generic demodulation. The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param constellation: determines the modulation type @type constellation: gnuradio.digital.gr_constellation @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param gray_coded: turn gray coding on/off @type gray_coded: bool @param freq_bw: loop filter lock-in bandwidth @type freq_bw: float @param timing_bw: timing recovery loop lock-in bandwidth @type timing_bw: float @param phase_bw: phase recovery loop bandwidth @type phase_bw: 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, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._constellation = constellation.base() self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw self._freq_bw = freq_bw self._timing_bw = timing_bw self._timing_max_dev = _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol) arity = pow(2, self.bits_per_symbol()) nfilts = 32 ntaps = 11 * int(self._samples_per_symbol * nfilts) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) # Frequency correction fll_ntaps = 55 self.freq_recov = digital.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter taps = gr.firdes.root_raised_cosine(nfilts, nfilts * self._samples_per_symbol, 1.0, self._excess_bw, ntaps) self.time_recov = digital.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_bw, taps, nfilts, nfilts // 2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 self.receiver = digital.constellation_receiver_cb( self._constellation, self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: self.diffdec = digital.diff_decoder_bb(arity) if gray_coded: self.symbol_mapper = digital.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class blocks = [ self, self.agc, self.freq_recov, self.time_recov, self.receiver ] if differential: blocks.append(self.diffdec) if self._constellation.apply_pre_diff_code(): blocks.append(self.symbol_mapper) blocks += [self.unpack, self] self.connect(*blocks)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Grc Wisp Reader") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=1e6, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) amplitude = 1 interp_rate = 128 # dec_rate = 8 # sw_dec = 4 dec_rate = 16 sw_dec = 2 # num_taps = int(64000 / ( (dec_rate * 4) * 40 )) #Filter matched to 1/4 of the 40 kHz tag cycle num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle taps = [complex(1,1)] * num_taps matched_filt = gr.fir_filter_ccc(sw_dec, taps); agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) to_mag = gr.complex_to_mag() # center = rfid.center_ff(10) center = rfid.center_ff(4) omega = 5 mu = 0.25 gain_mu = 0.25 gain_omega = .25 * gain_mu * gain_mu omega_relative_limit = .05 # mm = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) mm = rfid.clock_recovery_zc_ff(4,1); self.reader = rfid.reader_f(int(128e6/interp_rate)); tag_decoder = rfid.tag_decoder_f() # command_gate = rfid.command_gate_cc(12, 250, 64000000 / dec_rate / sw_dec) command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec) to_complex = gr.float_to_complex() amp = gr.multiply_const_ff(amplitude) ################################################## # Blocks ################################################## freq = 915e6 rx_gain = 1 tx = uhd.usrp_sink( device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) print "tx: get sample rate:" print (tx.get_samp_rate()) tx.set_samp_rate(128e6/interp_rate) print "tx: get sample rate:" print (tx.get_samp_rate()) r = tx.set_center_freq(freq, 0) rx = uhd.usrp_source( device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) print "rx: get samp rate" print (rx.get_samp_rate()) r = rx.set_samp_rate(64e6/dec_rate) print "rx: get samp rate" print (rx.get_samp_rate()) r = rx.set_center_freq(freq, 0) print "rx: get gain " print (rx.get_gain_range()) r = rx.set_gain(rx_gain, 0) print "rx: get gain " print (rx.get_gain()) command_gate.set_ctrl_out(self.reader.ctrl_q()) tag_decoder.set_ctrl_out(self.reader.ctrl_q()) #########Build Graph self.connect(rx, matched_filt) self.connect(matched_filt, command_gate) self.connect(command_gate, to_mag) # self.connect(command_gate, agc) # self.connect(agc, to_mag) self.connect(to_mag, center, mm, tag_decoder) # self.connect(to_mag, center, matched_filt_tag_decode, tag_decoder) self.connect(tag_decoder, self.reader) self.connect(self.reader, amp) self.connect(amp, to_complex) self.connect(to_complex, tx)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Amaviation Agc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sql_threshold = sql_threshold = -30 self.samp_rate = samp_rate = 1000000 self.frq_offset = frq_offset = 0 self.base_frq = base_frq = 131725000 ################################################## # Blocks ################################################## _sql_threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._sql_threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, label="Squelch Threshold", converter=forms.float_converter(), proportion=0, ) self._sql_threshold_slider = forms.slider( parent=self.GetWin(), sizer=_sql_threshold_sizer, value=self.sql_threshold, callback=self.set_sql_threshold, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_sql_threshold_sizer) _frq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._frq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._frq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_frq_offset_sizer, value=self.frq_offset, callback=self.set_frq_offset, minimum=-100000, maximum=100000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_frq_offset_sizer) self._base_frq_text_box = forms.text_box( parent=self.GetWin(), value=self.base_frq, callback=self.set_base_frq, label="Base frequency", converter=forms.float_converter(), ) self.Add(self._base_frq_text_box) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rtl2832_source_0 = baz.rtl_source_c(defer_creation=True) self.rtl2832_source_0.set_verbose(True) self.rtl2832_source_0.set_vid(0x0) self.rtl2832_source_0.set_pid(0x0) self.rtl2832_source_0.set_tuner_name("") self.rtl2832_source_0.set_default_timeout(0) self.rtl2832_source_0.set_use_buffer(True) self.rtl2832_source_0.set_fir_coefficients(([])) if self.rtl2832_source_0.create() == False: raise Exception( "Failed to create RTL2832 Source: rtl2832_source_0") self.rtl2832_source_0.set_bandwidth(300000) self.rtl2832_source_0.set_sample_rate(samp_rate) self.rtl2832_source_0.set_frequency(base_frq + frq_offset) self.rtl2832_source_0.set_gain_mode("sensitive") self.rtl2832_source_0.set_auto_gain_mode(False) self.rtl2832_source_0.set_relative_gain(True) self.rtl2832_source_0.set_gain(30) self.gr_simple_squelch_cc_0 = gr.simple_squelch_cc( sql_threshold, 0.0001) self.gr_agc2_xx_0 = gr.agc2_cc(100e-3, 200e-3, 1.0, 1.0, 2.0) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_ccc( interpolation=48, decimation=1000, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=48000, audio_decim=1, audio_pass=5000, audio_stop=5500, ) self.audio_sink_0 = audio.sink(48000, "pulse", True) ################################################## # Connections ################################################## self.connect((self.rtl2832_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.gr_simple_squelch_cc_0, 0)) self.connect((self.gr_simple_squelch_cc_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.rtl2832_source_0, 0), (self.blks2_rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uhd Snr Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Uhd Snr Receiver") self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "uhd_snr_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.samp_rate = samp_rate = 1e6 self.rrc_taps = rrc_taps = filter.firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts) self.gain = gain = 15 self.freq = freq = 520e6 self.fine_freq = fine_freq = -28400 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RX Gain" + ": ")) self._gain_counter = Qwt.QwtCounter() self._gain_counter.setRange(0, 31.5, 0.5) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 31.5, 0.5) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency" + ": ")) self._freq_counter = Qwt.QwtCounter() self._freq_counter.setRange(514e6, 526e6, 1e6) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(514e6, 526e6, 1e6) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 2, 0, 1, 1) self._fine_freq_layout = Qt.QVBoxLayout() self._fine_freq_tool_bar = Qt.QToolBar(self) self._fine_freq_layout.addWidget(self._fine_freq_tool_bar) self._fine_freq_tool_bar.addWidget(Qt.QLabel("Fine Frequency" + ": ")) self._fine_freq_counter = Qwt.QwtCounter() self._fine_freq_counter.setRange(-50e3, 50e3, 100) self._fine_freq_counter.setNumButtons(2) self._fine_freq_counter.setValue(self.fine_freq) self._fine_freq_tool_bar.addWidget(self._fine_freq_counter) self._fine_freq_counter.valueChanged.connect(self.set_fine_freq) self._fine_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fine_freq_slider.setRange(-50e3, 50e3, 100) self._fine_freq_slider.setValue(self.fine_freq) self._fine_freq_slider.setMinimumWidth(200) self._fine_freq_slider.valueChanged.connect(self.set_fine_freq) self._fine_freq_layout.addWidget(self._fine_freq_slider) self.top_grid_layout.addLayout(self._fine_freq_layout, 2, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq + fine_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 500, #size samp_rate, #bw "QT GUI Plot", #name 3 #number of inputs ) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "QT GUI Plot", #name 2 #number of inputs ) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 0.0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2 * 3.14 / 100.0, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_mpsk_snr_est_cc_0_1 = digital.mpsk_snr_est_cc( 3, 10000, 0.001) self.digital_mpsk_snr_est_cc_0_0 = digital.mpsk_snr_est_cc( 2, 10000, 0.001) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc( 0, 10000, 0.001) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 15, 0.010, 1, digital.constellation_qpsk().base()) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 2 * 3.14 / 100.0, 4) ################################################## # Connections ################################################## self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.gr_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 3)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 2)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_mpsk_snr_est_cc_0_1, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.digital_mpsk_snr_est_cc_0_1, 0), (self.qtgui_time_sink_x_0_0, 2))
def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6): grc_wxgui.top_block_gui.__init__(self, title="Simple Trx") ################################################## # Parameters ################################################## self.antenna = antenna self.rx_gain = rx_gain self.vor_samp_rate = vor_samp_rate self.com_freq_1 = com_freq_1 self.gain = gain self.vor_freq_1 = vor_freq_1 ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_volume_slider = vor_volume_slider = 5 self.vor_ident = vor_ident = False self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.system_center_freq = system_center_freq = 133.9e6 self.squelch_slider = squelch_slider = -85 self.samp_rate = samp_rate = 250e3 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.correction_gain = correction_gain = 0.8 self.com_volume_slider = com_volume_slider = 1 self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.com_enable = com_enable = True self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._vor_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, label='vor_volume_slider', converter=forms.float_converter(), proportion=0, ) self._vor_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1) self._vor_ident_check_box = forms.check_box( parent=self.GetWin(), value=self.vor_ident, callback=self.set_vor_ident, label='vor_ident', true=1, false=0, ) self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._vor_freq_entry_1_text_box, 0, 1, 1, 1) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._com_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, label='com_volume_slider', converter=forms.float_converter(), proportion=0, ) self._com_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1) self._com_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1) self._com_enable_check_box = forms.check_box( parent=self.GetWin(), value=self.com_enable, callback=self.set_com_enable, label='com_enable', true=1, false=0, ) self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=12.5e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-200, maxval=200, factor=1.0, decimal_places=10, ref_level=0, sample_rate=25e3 / 2000, number_rate=15, average=True, avg_alpha=0.02, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=25e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0) self.uhd_usrp_sink_0.set_gain(25, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1) self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.low_pass_filter_3_0 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_3 = filter.fir_filter_fff( 5, firdes.low_pass(1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf( int(250e3 / 25e3), firdes.low_pass(1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex * 1) self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_add_xx_0_0_0 = gr.add_vff(1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1) self.fft_tone_to_angle_0 = fft_tone_to_angle( fft_bin=12, fft_size=2000, ) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180.0 / 3.1415, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf( channel_rate=25e3, audio_decim=am_decimation, audio_pass=11.5e3, audio_stop=12.250e3, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.band_pass_filter_0 = gr.fir_filter_fff( 2, firdes.band_pass(1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1) self.analog_sig_source_x_0_0 = analog.sig_source_f( 48000, analog.GR_COS_WAVE, 1000, 1, 0) self.adsf_0 = blocks.multiply_const_vff( (com_enable * com_volume_slider, )) self.adsf = blocks.multiply_const_vff( (vor_ident * vor_volume_slider, )) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0)) self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0)) self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0)) self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1)) self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0)) self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1)) self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0)) self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1)) self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8*2**10 self.nsps_mod = nsps_mod = 4 self.noise = noise = .1 self.freq_off = freq_off = 0 self.ebw_mod = ebw_mod = 0.35 ################################################## # Notebooks ################################################## self.n0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab1") self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab2") self.n0.AddPage(grc_wxgui.Panel(self.n0), "tab3") self.Add(self.n0) ################################################## # Controls ################################################## _nsps_mod_sizer = wx.BoxSizer(wx.VERTICAL) self._nsps_mod_text_box = forms.text_box( parent=self.GetWin(), sizer=_nsps_mod_sizer, value=self.nsps_mod, callback=self.set_nsps_mod, label="Samples per symbol for DPSK modulator", converter=forms.int_converter(), proportion=0, ) self._nsps_mod_slider = forms.slider( parent=self.GetWin(), sizer=_nsps_mod_sizer, value=self.nsps_mod, callback=self.set_nsps_mod, minimum=2, maximum=32, num_steps=31, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_nsps_mod_sizer) _noise_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, label="Noise", converter=forms.float_converter(), proportion=0, ) self._noise_slider = forms.slider( parent=self.GetWin(), sizer=_noise_sizer, value=self.noise, callback=self.set_noise, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_sizer) _freq_off_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_off_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, label="Freq Offset", converter=forms.float_converter(), proportion=0, ) self._freq_off_slider = forms.slider( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, minimum=-.5, maximum=.5, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_off_sizer) _ebw_mod_sizer = wx.BoxSizer(wx.VERTICAL) self._ebw_mod_text_box = forms.text_box( parent=self.GetWin(), sizer=_ebw_mod_sizer, value=self.ebw_mod, callback=self.set_ebw_mod, label="Excess BW for DPSK modulator", converter=forms.float_converter(), proportion=0, ) self._ebw_mod_slider = forms.slider( parent=self.GetWin(), sizer=_ebw_mod_sizer, value=self.ebw_mod, callback=self.set_ebw_mod, minimum=00.01, maximum=10.00, num_steps=10*100-1, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_ebw_mod_sizer) ################################################## # Blocks ################################################## self.blks2_dxpsk2_mod_0 = blks2.dqpsk2_mod( samples_per_symbol=nsps_mod, excess_bw=ebw_mod, gray_code=True, verbose=False, log=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, access_code="", pad_for_usrp=True, ), payload_length=0, ) self.gr_agc2_xx_0 = gr.agc2_cc(1e-1, 1e-2, 1.0, 1.0, 1e3) self.gr_channel_model_0 = gr.channel_model( noise_voltage=noise, frequency_offset=freq_off, epsilon=1.0, taps=(16.0, ), noise_seed=42, ) self.gr_throttle_1_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*nsps_mod*8) self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.n0.GetPage(1).GetWin(), title="Constellation Plot", sample_rate=samp_rate*8*nsps_mod/2, frame_rate=5, const_size=512, M=4, theta=0, alpha=0.005, fmax=0.5, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate*8/2, omega_limit=0.005, ) self.n0.GetPage(1).Add(self.wxgui_constellationsink2_0.win) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.blks2_dxpsk2_mod_0, 0)) self.connect((self.random_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.gr_throttle_1_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.blks2_dxpsk2_mod_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.gr_throttle_1_0, 0))
def test_005(self): ''' Test the complex AGC loop (attack and decay rate inputs) ''' fg = self.fg expected_result = \ ((100.000244140625+7.2191943445432116e-07j), (0.80881959199905396+0.58764183521270752j), (0.30894950032234192+0.95084899663925171j), (-0.30895623564720154+0.95086973905563354j), (-0.80887287855148315+0.58768033981323242j), (-0.99984413385391235+5.850709250410091e-09j), (-0.80889981985092163-0.58770018815994263j), (-0.30897706747055054-0.95093393325805664j), (0.30898112058639526-0.95094609260559082j), (0.80893135070800781-0.58772283792495728j), (0.99990922212600708-8.7766354184282136e-09j), (0.80894720554351807+0.58773452043533325j), (0.30899339914321899+0.95098406076431274j), (-0.30899572372436523+0.95099133253097534j), (-0.80896598100662231+0.58774799108505249j), (-0.99994778633117676+1.4628290578855285e-08j), (-0.80897533893585205-0.58775502443313599j), (-0.30900305509567261-0.95101380348205566j), (0.30900448560714722-0.95101797580718994j), (0.80898630619049072-0.58776277303695679j), (0.99997037649154663-1.7554345532744264e-08j), (0.80899184942245483+0.58776694536209106j), (0.30900871753692627+0.95103120803833008j), (-0.30900952219963074+0.95103377103805542j), (-0.8089984655380249+0.58777159452438354j), (-0.99998390674591064+2.3406109050938539e-08j), (-0.809001624584198-0.58777409791946411j), (-0.30901208519935608-0.95104163885116577j), (0.30901262164115906-0.95104306936264038j), (0.80900543928146362-0.587776780128479j), (0.99999171495437622-2.6332081404234486e-08j), (0.80900734663009644+0.58777821063995361j), (0.30901408195495605+0.95104765892028809j), (-0.30901429057121277+0.95104855298995972j), (-0.80900967121124268+0.58777981996536255j), (-0.99999648332595825+3.2183805842578295e-08j), (-0.80901080369949341-0.58778077363967896j), (-0.30901527404785156-0.95105135440826416j), (0.30901545286178589-0.95105189085006714j), (0.80901217460632324-0.58778166770935059j), (0.99999916553497314-3.5109700036173308e-08j), (0.809012770652771+0.58778214454650879j), (0.30901595950126648+0.9510534405708313j), (-0.30901598930358887+0.95105385780334473j), (-0.80901366472244263+0.58778274059295654j), (-1.0000008344650269+4.0961388947380328e-08j), (-0.8090139627456665-0.58778303861618042j), (-0.30901634693145752-0.95105475187301636j), (0.30901640653610229-0.95105493068695068j), (0.80901449918746948-0.5877833366394043j)) sampling_freq = 100 src1 = gr.sig_source_c (sampling_freq, gr.GR_SIN_WAVE, sampling_freq * 0.10, 100) dst1 = gr.vector_sink_c () head = gr.head (gr.sizeof_gr_complex, int (5*sampling_freq * 0.10)) agc = gr.agc2_cc(1e-2, 1e-3, 1, 1, 1000) fg.connect (src1, head) fg.connect (head, agc) fg.connect (agc, dst1) if test_output == True: fg.connect (agc, gr.file_sink(gr.sizeof_gr_complex, "test_agc2_cc.dat")) fg.run () dst_data = dst1.data () self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 4)
def __init__(self, agc_max=100, agc_decay=0.1, freq_offset=1000000, outfile="datafifo", bandpass_bandwidth=20, threshold_buffer=0.25, threshold_center=0.5, agc_attack=0.1, bandpass_transition_width=1000000): gr.top_block.__init__(self, "Collect") ################################################## # Parameters ################################################## self.agc_max = agc_max self.agc_decay = agc_decay self.freq_offset = freq_offset self.outfile = outfile self.bandpass_bandwidth = bandpass_bandwidth self.threshold_buffer = threshold_buffer self.threshold_center = threshold_center self.agc_attack = agc_attack self.bandpass_transition_width = bandpass_transition_width ################################################## # Variables ################################################## self.samp_rate = samp_rate = 64000000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1, ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(915000000 - freq_offset, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.gr_threshold_ff_0 = gr.threshold_ff( threshold_center - threshold_buffer, threshold_center + threshold_buffer, 0) self.gr_map_bb_0 = gr.map_bb(([48, 49])) self.gr_float_to_char_0 = gr.float_to_char() self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, outfile) self.gr_file_sink_0.set_unbuffered(False) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(agc_attack, agc_decay, 1.0, 1.0, agc_max) self.band_pass_filter_0 = gr.fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, freq_offset - bandpass_bandwidth / 2, freq_offset + bandpass_bandwidth / 2, bandpass_transition_width, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.gr_float_to_char_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_threshold_ff_0, 0), (self.gr_float_to_char_0, 0)) self.connect((self.gr_complex_to_mag_0, 0), (self.gr_threshold_ff_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_complex_to_mag_0, 0))
def __init__( self, agc_max=100, agc_decay=0.1, freq_offset=1000000, outfile="datafifo", bandpass_bandwidth=20, threshold_buffer=0.25, threshold_center=0.5, agc_attack=0.1, bandpass_transition_width=1000000, ): gr.top_block.__init__(self, "Collect") ################################################## # Parameters ################################################## self.agc_max = agc_max self.agc_decay = agc_decay self.freq_offset = freq_offset self.outfile = outfile self.bandpass_bandwidth = bandpass_bandwidth self.threshold_buffer = threshold_buffer self.threshold_center = threshold_center self.agc_attack = agc_attack self.bandpass_transition_width = bandpass_transition_width ################################################## # Variables ################################################## self.samp_rate = samp_rate = 64000000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source(device_addr="", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(915000000 - freq_offset, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.gr_threshold_ff_0 = gr.threshold_ff( threshold_center - threshold_buffer, threshold_center + threshold_buffer, 0 ) self.gr_map_bb_0 = gr.map_bb(([48, 49])) self.gr_float_to_char_0 = gr.float_to_char() self.gr_file_sink_0 = gr.file_sink(gr.sizeof_char * 1, outfile) self.gr_file_sink_0.set_unbuffered(False) self.gr_complex_to_mag_0 = gr.complex_to_mag(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(agc_attack, agc_decay, 1.0, 1.0, agc_max) self.band_pass_filter_0 = gr.fir_filter_ccf( 1, firdes.band_pass( 1, samp_rate, freq_offset - bandpass_bandwidth / 2, freq_offset + bandpass_bandwidth / 2, bandpass_transition_width, firdes.WIN_HAMMING, 6.76, ), ) ################################################## # Connections ################################################## self.connect((self.gr_float_to_char_0, 0), (self.gr_map_bb_0, 0)) self.connect((self.gr_map_bb_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.gr_threshold_ff_0, 0), (self.gr_float_to_char_0, 0)) self.connect((self.gr_complex_to_mag_0, 0), (self.gr_threshold_ff_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_complex_to_mag_0, 0))
def __init__(self, constellation, differential=_def_differential, samples_per_symbol=_def_samples_per_symbol, pre_diff_code=True, excess_bw=_def_excess_bw, freq_bw=_def_freq_bw, timing_bw=_def_timing_bw, phase_bw=_def_phase_bw, verbose=_def_verbose, log=_def_log): gr.hier_block2.__init__(self, "generic_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self._constellation = constellation self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._phase_bw = phase_bw self._freq_bw = freq_bw self._timing_bw = timing_bw self._timing_max_dev= _def_timing_max_dev self._differential = differential if self._samples_per_symbol < 2: raise TypeError, ("sbp must be >= 2, is %d" % self._samples_per_symbol) # Only apply a predifferential coding if the constellation also supports it. self.pre_diff_code = pre_diff_code and self._constellation.apply_pre_diff_code() arity = pow(2,self.bits_per_symbol()) nfilts = 32 ntaps = 11 * int(self._samples_per_symbol*nfilts) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) # Frequency correction fll_ntaps = 55 self.freq_recov = digital.fll_band_edge_cc(self._samples_per_symbol, self._excess_bw, fll_ntaps, self._freq_bw) # symbol timing recovery with RRC data filter taps = gr.firdes.root_raised_cosine(nfilts, nfilts*self._samples_per_symbol, 1.0, self._excess_bw, ntaps) self.time_recov = digital.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_bw, taps, nfilts, nfilts//2, self._timing_max_dev) fmin = -0.25 fmax = 0.25 self.receiver = digital.constellation_receiver_cb( self._constellation.base(), self._phase_bw, fmin, fmax) # Do differential decoding based on phase change of symbols if differential: self.diffdec = digital.diff_decoder_bb(arity) if self.pre_diff_code: self.symbol_mapper = digital.map_bb( mod_codes.invert_code(self._constellation.pre_diff_code())) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class blocks = [self, self.agc, self.freq_recov, self.time_recov, self.receiver] if differential: blocks.append(self.diffdec) if self.pre_diff_code: blocks.append(self.symbol_mapper) blocks += [self.unpack, self] self.connect(*blocks)
def __init__(self): gr.top_block.__init__(self) amplitude = 30000 filt_out = gr.file_sink(gr.sizeof_gr_complex, "./filt.out") filt2_out = gr.file_sink(gr.sizeof_gr_complex, "./filt2.out") ffilt_out = gr.file_sink(gr.sizeof_float, "./ffilt.out") ffilt2_out = gr.file_sink(gr.sizeof_float, "./ffilt2.out") interp_rate = 128 dec_rate = 8 sw_dec = 4 num_taps = int(64000 / ( (dec_rate * 4) * 256 )) #Filter matched to 1/4 of the 256 kHz tag cycle taps = [complex(1,1)] * num_taps matched_filt = gr.fir_filter_ccc(sw_dec, taps); agc = gr.agc2_cc(0.3, 1e-3, 1, 1, 100) to_mag = gr.complex_to_mag() center = rfid.center_ff(4) omega = 2 mu = 0.25 gain_mu = 0.25 gain_omega = .25 * gain_mu * gain_mu omega_relative_limit = .05 mm = gr.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.reader = rfid.reader_f(int(128e6/interp_rate)); tag_decoder = rfid.tag_decoder_f() command_gate = rfid.command_gate_cc(12, 60, 64000000 / dec_rate / sw_dec) to_complex = gr.float_to_complex() amp = gr.multiply_const_ff(amplitude) f_sink = gr.file_sink(gr.sizeof_gr_complex, 'f_sink.out'); f_sink2 = gr.file_sink(gr.sizeof_gr_complex, 'f_sink2.out'); #TX freq = 915e6 rx_gain = 20 tx = usrp.sink_c(fusb_block_size = 1024, fusb_nblocks=8) tx.set_interp_rate(interp_rate) tx_subdev = (0,0) tx.set_mux(usrp.determine_tx_mux_value(tx, tx_subdev)) subdev = usrp.selected_subdev(tx, tx_subdev) subdev.set_enable(True) subdev.set_gain(subdev.gain_range()[2]) t = tx.tune(subdev.which(), subdev, freq) if not t: print "Couldn't set tx freq" #End TX #RX rx = usrp.source_c(0, dec_rate, fusb_block_size = 512 * 4, fusb_nblocks = 16) rx_subdev_spec = (1,0) rx.set_mux(usrp.determine_rx_mux_value(rx, rx_subdev_spec)) rx_subdev = usrp.selected_subdev(rx, rx_subdev_spec) rx_subdev.set_gain(rx_gain) rx_subdev.set_auto_tr(False) rx_subdev.set_enable(True) r = usrp.tune(rx, 0, rx_subdev, freq) self.rx = rx if not r: print "Couldn't set rx freq" #End RX command_gate.set_ctrl_out(self.reader.ctrl_q()) tag_decoder.set_ctrl_out(self.reader.ctrl_q()) agc2 = gr.agc2_ff(0.3, 1e-3, 1, 1, 100) #########Build Graph self.connect(rx, matched_filt) self.connect(matched_filt, command_gate) self.connect(command_gate, agc) self.connect(agc, to_mag) self.connect(to_mag, center, agc2, mm, tag_decoder) self.connect(tag_decoder, self.reader, amp, to_complex, tx); ################# self.connect(matched_filt, filt_out)
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, freq_alpha=_def_freq_alpha, phase_alpha=_def_phase_alpha, timing_alpha=_def_timing_alpha, timing_max_dev=_def_timing_max_dev, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log, sync_out=False): """ Hierarchical block for RRC-filtered DQPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param freq_alpha: loop filter gain for frequency recovery @type freq_alpha: float @param phase_alpha: loop filter gain @type phase_alphas: float @param timing_alpha: timing loop alpha gain @type timing_alpha: float @param timing_max: timing loop maximum rate deviations @type timing_max: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param log: Print modualtion data to files? @type log: bool @param sync_out: Output a sync signal on :1? @type sync_out: bool """ if sync_out: io_sig_out = gr.io_signaturev( 2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) gr.hier_block2.__init__( self, "dqpsk2_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature io_sig_out) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._freq_alpha = freq_alpha self._freq_beta = 0.25 * self._freq_alpha**2 self._phase_alpha = phase_alpha self._timing_alpha = timing_alpha self._timing_beta = _def_timing_beta self._timing_max_dev = timing_max_dev self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "sbp must be >= 2, is %d" % samples_per_symbol arity = pow(2, self.bits_per_symbol()) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) #self.agc = gr.feedforward_agc_cc(16, 2.0) # Frequency correction self.freq_recov = gr.fll_band_edge_cc( self._samples_per_symbol, self._excess_bw, 11 * int(self._samples_per_symbol), self._freq_alpha, self._freq_beta) # symbol timing recovery with RRC data filter nfilts = 32 ntaps = 11 * int(samples_per_symbol * nfilts) taps = gr.firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(self._samples_per_symbol), self._excess_bw, ntaps) self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_alpha, taps, nfilts, nfilts / 2, self._timing_max_dev) self.time_recov.set_beta(self._timing_beta) # Perform phase / fine frequency correction self._phase_beta = 0.25 * self._phase_alpha * self._phase_alpha # Allow a frequency swing of +/- half of the sample rate fmin = -0.5 fmax = 0.5 self.phase_recov = gr.costas_loop_cc(self._phase_alpha, self._phase_beta, fmax, fmin, arity) # Perform Differential decoding on the constellation self.diffdec = gr.diff_phasor_cc() # find closest constellation point rot = 1 rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) if self._gray_code: self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) else: self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect self.connect(self, self.agc, self.freq_recov, self.time_recov, self.phase_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) if sync_out: self.connect(self.time_recov, (self, 1))
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, gain_mu=_def_gain_mu, mu=_def_mu, omega_relative_limit=_def_omega_relative_limit, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log): """ Hierarchical block for RRC-filtered differential BPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alphas: float @param gain_mu: for M&M block @type gain_mu: float @param mu: for M&M block @type mu: float @param omega_relative_limit: for M&M block @type omega_relative_limit: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param debug: Print modualtion data to files? @type debug: bool """ gr.hier_block2.__init__(self, "dbpsk_demod", 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._excess_bw = excess_bw self._costas_alpha = costas_alpha self._mm_gain_mu = gain_mu self._mm_mu = mu self._mm_omega_relative_limit = omega_relative_limit self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,) arity = pow(2,self.bits_per_symbol()) # Automatic gain control #scale = (1.0/16384.0) #self.pre_scaler = gr.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.feedforward_agc_cc(16, 2.0) # RRC data filter ntaps = 11 * samples_per_symbol self.rrc_taps = gr.firdes.root_raised_cosine( 1.0, # gain self._samples_per_symbol, # sampling rate 1.0, # symbol rate self._excess_bw, # excess bandwidth (roll-off factor) ntaps) self.rrc_filter=gr.interp_fir_filter_ccf(1, self.rrc_taps) # symbol clock recovery if not self._mm_gain_mu: self._mm_gain_mu = 0.1 self._mm_omega = self._samples_per_symbol self._mm_gain_omega = .25 * self._mm_gain_mu * self._mm_gain_mu self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha fmin = -0.25 fmax = 0.25 self.receiver=gr.mpsk_receiver_cc(arity, 0, self._costas_alpha, self._costas_beta, fmin, fmax, self._mm_mu, self._mm_gain_mu, self._mm_omega, self._mm_gain_omega, self._mm_omega_relative_limit) # Do differential decoding based on phase change of symbols self.diffdec = gr.diff_phasor_cc() # find closest constellation point rot = 1 rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) if self._gray_code: self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) else: self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect and Initialize base class self.connect(self, self.agc, self.rrc_filter, self.receiver, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self)
def __init__(self, antenna="TX/RX", rx_gain=30, vor_samp_rate=250e3, com_freq_1=135.275e6, gain=21, vor_freq_1=115e6): grc_wxgui.top_block_gui.__init__(self, title="Simple Trx") ################################################## # Parameters ################################################## self.antenna = antenna self.rx_gain = rx_gain self.vor_samp_rate = vor_samp_rate self.com_freq_1 = com_freq_1 self.gain = gain self.vor_freq_1 = vor_freq_1 ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_volume_slider = vor_volume_slider = 5 self.vor_ident = vor_ident = False self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6-108.00e6)/2+117.95e6 self.system_center_freq = system_center_freq = 133.9e6 self.squelch_slider = squelch_slider = -85 self.samp_rate = samp_rate = 250e3 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate/obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate/ils_decimation self.gain_slider = gain_slider = gain self.correction_gain = correction_gain = 0.8 self.com_volume_slider = com_volume_slider = 1 self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.com_enable = com_enable = True self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## _vor_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._vor_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, label='vor_volume_slider', converter=forms.float_converter(), proportion=0, ) self._vor_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_vor_volume_slider_sizer, value=self.vor_volume_slider, callback=self.set_vor_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_vor_volume_slider_sizer, 1, 4, 1, 1) self._vor_ident_check_box = forms.check_box( parent=self.GetWin(), value=self.vor_ident, callback=self.set_vor_ident, label='vor_ident', true=1, false=0, ) self.GridAdd(self._vor_ident_check_box, 0, 3, 1, 1) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._vor_freq_entry_1_text_box, 0, 1, 1, 1) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) _com_volume_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._com_volume_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, label='com_volume_slider', converter=forms.float_converter(), proportion=0, ) self._com_volume_slider_slider = forms.slider( parent=self.GetWin(), sizer=_com_volume_slider_sizer, value=self.com_volume_slider, callback=self.set_com_volume_slider, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_com_volume_slider_sizer, 1, 5, 1, 1) self._com_freq_entry_1_text_box = forms.text_box( parent=self.GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.GridAdd(self._com_freq_entry_1_text_box, 0, 0, 1, 1) self._com_enable_check_box = forms.check_box( parent=self.GetWin(), value=self.com_enable, callback=self.set_com_enable, label='com_enable', true=1, false=0, ) self.GridAdd(self._com_enable_check_box, 2, 3, 1, 1) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(3).GetWin(), title="Scope Plot", sample_rate=12.5e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-200, maxval=200, factor=1.0, decimal_places=10, ref_level=0, sample_rate=25e3/2000, number_rate=15, average=True, avg_alpha=0.02, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0_1 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=25e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_source("internal", 0) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(com_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(vor_freq_entry_1, rf_freq=system_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq(com_freq_entry_1, 0) self.uhd_usrp_sink_0.set_gain(25, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-100, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_squelch_slider_sizer, 1, 0, 1, 1) self.squelch = gr.pwr_squelch_cc(squelch_slider, 0.01, 20, False) self.openavionics_joystick_interface_0 = openavionics.joystick_interface() self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.low_pass_filter_3_0 = filter.fir_filter_fff(5, firdes.low_pass( 1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_3 = filter.fir_filter_fff(5, firdes.low_pass( 1, 25e3, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 25e3, 3e3, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff(1, firdes.low_pass( 1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.fir_filter_ccf(int(250e3/25e3), firdes.low_pass( 1, vor_samp_rate, 11e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(int(250e3/12.5e3), firdes.low_pass( 1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_sig_source_x_0 = gr.sig_source_c(25e3, gr.GR_COS_WAVE, 9960, 1, 0) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_ff(-50, 0.5, 1, False) self.gr_null_sink_0_0 = gr.null_sink(gr.sizeof_gr_complex*1) self.gr_multiply_xx_0_0_1 = gr.multiply_vff(1) self.gr_multiply_xx_0_0_0_0 = gr.multiply_vcc(1) self.gr_multiply_xx_0 = gr.multiply_vcc(1) self.gr_float_to_complex_0_0_0 = gr.float_to_complex(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.gr_agc2_xx_0_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_agc2_xx_0 = gr.agc2_cc(1, 1, 0.75, 1.0, 0.0) self.gr_add_xx_0_0_0 = gr.add_vff(1) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_slider_sizer, 1, 1, 1, 1) self.fft_tone_to_angle_0 = fft_tone_to_angle( fft_bin=12, fft_size=2000, ) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0_0_0_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((180.0/3.1415, )) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_rational_resampler_xxx_2_0 = blks2.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.blks2_am_demod_cf_0_0 = blks2.am_demod_cf( channel_rate=25e3, audio_decim=am_decimation, audio_pass=11.5e3, audio_stop=12.250e3, ) self.blks2_am_demod_cf_0 = blks2.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.band_pass_filter_0 = gr.fir_filter_fff(2, firdes.band_pass( 1, 25000, 980, 1150, 50, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice','VOR Subcarrier'], ) self.GridAdd(self._audio_select_chooser, 0, 2, 1, 1) self.analog_sig_source_x_0_0 = analog.sig_source_f(48000, analog.GR_COS_WAVE, 1000, 1, 0) self.adsf_0 = blocks.multiply_const_vff((com_enable*com_volume_slider, )) self.adsf = blocks.multiply_const_vff((vor_ident*vor_volume_slider, )) ################################################## # Connections ################################################## self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.gr_null_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.squelch, 0), (self.gr_agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.gr_agc2_xx_0, 0), (self.blks2_am_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.wxgui_fftsink2_0_1, 0)) self.connect((self.gr_agc2_xx_0_0, 0), (self.blks2_am_demod_cf_0_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.low_pass_filter_0_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.fft_tone_to_angle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fft_tone_to_angle_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.fft_tone_to_angle_0, 2), (self.blocks_null_sink_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_agc2_xx_0_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.low_pass_filter_3, 0), (self.fft_tone_to_angle_0, 0)) self.connect((self.low_pass_filter_3_0, 0), (self.fft_tone_to_angle_0, 1)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.low_pass_filter_3_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_multiply_xx_0, 0), (self.low_pass_filter_2, 0)) self.connect((self.gr_sig_source_x_0, 0), (self.gr_multiply_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.blks2_am_demod_cf_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.adsf, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.adsf, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.low_pass_filter_1, 0), (self.adsf_0, 0)) self.connect((self.adsf_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.adsf_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.adsf, 0)) self.connect((self.const_source_x_0_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 1)) self.connect((self.gr_float_to_complex_0_0_0, 0), (self.gr_multiply_xx_0_0_0_0, 0)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 1)) self.connect((self.gr_add_xx_0_0_0, 0), (self.gr_float_to_complex_0_0_0, 0)) self.connect((self.const_source_x_0_0_1, 0), (self.gr_add_xx_0_0_0, 1)) self.connect((self.gr_multiply_xx_0_0_1, 0), (self.gr_add_xx_0_0_0, 0)) self.connect((self.const_source_x_0_1, 0), (self.gr_multiply_xx_0_0_1, 1)) self.connect((self.gr_multiply_xx_0_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_rational_resampler_xxx_2_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_rational_resampler_xxx_2_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.gr_multiply_xx_0_0_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")