|
From: | Martin Spears |
Subject: | RE: gr-dsd help needed |
Date: | Wed, 23 Sep 2020 11:49:01 +0000 |
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # SPDX-License-Identifier: GPL-3.0 # # GNU Radio Python Flow Graph # Title: DSD # GNU Radio version: 3.8.1.0 from distutils.version import StrictVersion if __name__ == '__main__': import ctypes import sys if sys.platform.startswith('linux'): try: x11 = ctypes.cdll.LoadLibrary('libX11.so') x11.XInitThreads() except: print("Warning: failed to XInitThreads()") from PyQt5 import Qt from gnuradio import qtgui from gnuradio.filter import firdes import sip from gnuradio import fosphor from gnuradio.fft import window from gnuradio import analog import math from gnuradio import audio from gnuradio import blocks from gnuradio import filter from gnuradio import gr import sys import signal from argparse import ArgumentParser from gnuradio.eng_arg import eng_float, intx from gnuradio import eng_notation from gnuradio.qtgui import Range, RangeWidget import dsd import osmosdr import time from gnuradio import qtgui class DSD(gr.top_block, Qt.QWidget): def __init__(self): gr.top_block.__init__(self, "DSD") Qt.QWidget.__init__(self) self.setWindowTitle("DSD") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass 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", "DSD") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.vol = vol = 40 self.trans = trans = 2000 self.squelch = squelch = -95 self.samp_rate = samp_rate = 1.92e6 self.offset = offset = 0 self.gain = gain = 30 self.freq = freq = 170175000 self.down_rate = down_rate = 256e3 self.dmod = dmod = -1.92 self.cutoff = cutoff = 12500 self.corr = corr = 0 self.audio_dec = audio_dec = 2 ################################################## # Blocks ################################################## self._vol_range = Range(0, 100, 1, 40, 200) self._vol_win = RangeWidget(self._vol_range, self.set_vol, 'volume', "counter_slider", float) self.top_grid_layout.addWidget(self._vol_win) self._squelch_range = Range(-100, 0, 5, -95, 200) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, 'squelch', "counter_slider", float) self.top_grid_layout.addWidget(self._squelch_win) self._gain_range = Range(1, 70, 1, 30, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win) self._freq_range = Range(70e6, 900e6, 1e5, 170175000, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win) self._dmod_range = Range(-5, 5, .01, -1.92, 200) self._dmod_win = RangeWidget(self._dmod_range, self.set_dmod, 'Q-Demod', "counter_slider", float) self.top_grid_layout.addWidget(self._dmod_win) self._trans_range = Range(100, 8000, 50, 2000, 200) self._trans_win = RangeWidget(self._trans_range, self.set_trans, 'transition', "counter_slider", float) self.top_grid_layout.addWidget(self._trans_win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=24000, decimation=8000, taps=None, fractional_bw=None) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'uhd' ) self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq -offset, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('RX2', 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 40, firdes.low_pass( 1, samp_rate, 122500, 2000, firdes.WIN_HAMMING, 6.76)) self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_0.set_fft_window(firdes.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_0.set_frequency_range(freq, 200000) self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_win) self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,3) self._cutoff_range = Range(12500, 250000, 500, 12500, 200) self._cutoff_win = RangeWidget(self._cutoff_range, self.set_cutoff, 'cutoff', "counter_slider", float) self.top_grid_layout.addWidget(self._cutoff_win) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(vol/100) self.audio_sink_0 = audio.sink(8000, '', True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -20000, 1, 0, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(dmod) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.fosphor_qt_sink_c_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) def closeEvent(self, event): self.settings = Qt.QSettings("GNU Radio", "DSD") self.settings.setValue("geometry", self.saveGeometry()) event.accept() def get_vol(self): return self.vol def set_vol(self, vol): self.vol = vol self.blocks_multiply_const_vxx_0_0.set_k(self.vol/100) def get_trans(self): return self.trans def set_trans(self, trans): self.trans = trans def get_squelch(self): return self.squelch def set_squelch(self, squelch): self.squelch = squelch self.analog_simple_squelch_cc_0.set_threshold(self.squelch) def get_samp_rate(self): return self.samp_rate def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate) self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 122500, 2000, firdes.WIN_HAMMING, 6.76)) self.osmosdr_source_0.set_sample_rate(self.samp_rate) self.qtgui_freq_sink_x_1.set_frequency_range(self.freq, self.samp_rate) def get_offset(self): return self.offset def set_offset(self, offset): self.offset = offset self.osmosdr_source_0.set_center_freq(self.freq -self.offset, 0) def get_gain(self): return self.gain def set_gain(self, gain): self.gain = gain self.osmosdr_source_0.set_gain(self.gain, 0) def get_freq(self): return self.freq def set_freq(self, freq): self.freq = freq self.fosphor_qt_sink_c_0.set_frequency_range(self.freq, 200000) self.osmosdr_source_0.set_center_freq(self.freq -self.offset, 0) self.qtgui_freq_sink_x_1.set_frequency_range(self.freq, self.samp_rate) def get_down_rate(self): return self.down_rate def set_down_rate(self, down_rate): self.down_rate = down_rate def get_dmod(self): return self.dmod def set_dmod(self, dmod): self.dmod = dmod self.analog_quadrature_demod_cf_0.set_gain(self.dmod) def get_cutoff(self): return self.cutoff def set_cutoff(self, cutoff): self.cutoff = cutoff def get_corr(self): return self.corr def set_corr(self, corr): self.corr = corr self.osmosdr_source_0.set_freq_corr(self.corr, 0) def get_audio_dec(self): return self.audio_dec def set_audio_dec(self, audio_dec): self.audio_dec = audio_dec def main(top_block_cls=DSD, options=None): if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): style = gr.prefs().get_string('qtgui', 'style', 'raster') Qt.QApplication.setGraphicsSystem(style) qapp = Qt.QApplication(sys.argv) tb = top_block_cls() tb.start() tb.show() def sig_handler(sig=None, frame=None): Qt.QApplication.quit() signal.signal(signal.SIGINT, sig_handler) signal.signal(signal.SIGTERM, sig_handler) timer = Qt.QTimer() timer.start(500) timer.timeout.connect(lambda: None) def quitting(): tb.stop() tb.wait() qapp.aboutToQuit.connect(quitting) qapp.exec_() if __name__ == '__main__': main() Martin Spears VE3AGS From: Martin Spears I have tested this again and again. I cannot get audio out of the did block. I will post the .py in the morning. I just need a direction Sent from my BlackBerry — the most secure mobile device — via the Bell Network
I will add a sink between the did and rational resampler and test again. Other then that does the flow graph look correct. I am using a B210 UHD Sent from my BlackBerry — the most secure mobile device — via the Bell Network
Is it possible the output rate of your DSD block isn't actually as high |
gr-dsd block flow graph.png
Description: gr-dsd block flow graph.png
[Prev in Thread] | Current Thread | [Next in Thread] |