From ce8d54eb40cda500f9b5a75f503e1a1235d862af Mon Sep 17 00:00:00 2001 From: Manolis Surligas Date: Wed, 12 Oct 2016 21:22:48 +0300 Subject: [PATCH] Improve the generic FM demodulator The FM demodulator now supports a variaty of hardware setups and saves the WAV file for further processing. A set of command line arguments can control most of the flowgraph internals, such as the wav file name and storage path e.t.c. TODO: Check the settings for all the available hardware --- apps/CMakeLists.txt | 1 + apps/flowgraphs/fm_demod.grc | 552 +++++++++++----------- apps/flowgraphs/satnogs_fm_demod.py | 258 ++++++++++ apps/flowgraphs/upsat_transceiver_cli.grc | 16 +- apps/flowgraphs/upsat_transceiver_cli.py | 31 +- python/CMakeLists.txt | 1 + python/__init__.py | 1 + python/dsp_settings.py | 31 ++ 8 files changed, 597 insertions(+), 294 deletions(-) create mode 100755 apps/flowgraphs/satnogs_fm_demod.py create mode 100644 python/dsp_settings.py diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 26a9f2c..da2c642 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -22,5 +22,6 @@ include(GrPython) GR_PYTHON_INSTALL( PROGRAMS flowgraphs/upsat_transceiver_cli.py + flowgraphs/satnogs_fm_demod.py DESTINATION bin ) diff --git a/apps/flowgraphs/fm_demod.grc b/apps/flowgraphs/fm_demod.grc index ed84873..a5a4d96 100644 --- a/apps/flowgraphs/fm_demod.grc +++ b/apps/flowgraphs/fm_demod.grc @@ -1,12 +1,12 @@ - + Thu May 5 00:22:45 2016 options author - + Manolis Surligas (surligas@gmail.com) window_size @@ -22,7 +22,7 @@ description - + A generic FM demodulation block _enabled @@ -46,7 +46,7 @@ id - fm_demod + satnogs_fm_demod max_nouts @@ -78,7 +78,7 @@ title - + FM Generic Demodulation @@ -93,7 +93,7 @@ _coordinate - (480, 21) + (568, 508) _rotation @@ -109,14 +109,12 @@ - variable_qtgui_range + variable comment - - - - value - 0.9 + Decimation factor +for the RX after the +SDR received samples _enabled @@ -124,11 +122,7 @@ _coordinate - (1048, 249) - - - gui_hint - + (336, 612) _rotation @@ -139,36 +133,8 @@ audio_gain - label - Audio Gain - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 0 - - - step - 0.01 - - - stop - 8 - - - rangeType - float - - - widget - counter_slider + value + satnogs.fm_demod_settings[rx_sdr_device]['audio_gain'] @@ -183,7 +149,7 @@ _coordinate - (480, 93) + (568, 580) _rotation @@ -212,7 +178,7 @@ SDR received samples _coordinate - (232, 21) + (192, 612) _rotation @@ -224,161 +190,7 @@ SDR received samples value - 10 - - - - variable_qtgui_range - - comment - - - - value - 100e6 - - - _enabled - True - - - _coordinate - (1048, 24) - - - gui_hint - - - - _rotation - 0 - - - id - freq - - - label - RX Frequency - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 92e6 - - - step - 100e3 - - - stop - 105e6 - - - rangeType - float - - - widget - counter_slider - - - - variable_qtgui_range - - comment - - - - value - 10 - - - _enabled - True - - - _coordinate - (1048, 137) - - - gui_hint - - - - _rotation - 0 - - - id - gain - - - label - RX RF Gain - - - min_len - 200 - - - orient - Qt.Horizontal - - - start - 0 - - - step - 0.5 - - - stop - 40 - - - rangeType - float - - - widget - counter_slider - - - - variable - - comment - To avoid the SDR carrier at the DC -we shift the LO a little further - - - _enabled - True - - - _coordinate - (832, 18) - - - _rotation - 0 - - - id - lo_offset - - - value - 100e3 + satnogs.fm_demod_settings[rx_sdr_device]['decimation_rx'] @@ -393,7 +205,7 @@ we shift the LO a little further _coordinate - (360, 21) + (432, 476) _rotation @@ -412,7 +224,8 @@ we shift the LO a little further variable comment - + SDR device +TX sampling rate _enabled @@ -420,7 +233,7 @@ we shift the LO a little further _coordinate - (8, 160) + (192, 484) _rotation @@ -432,7 +245,7 @@ we shift the LO a little further value - 10e6 + satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] @@ -455,7 +268,7 @@ we shift the LO a little further _coordinate - (664, 18) + (560, 648) _rotation @@ -502,7 +315,7 @@ we shift the LO a little further _enabled - 1 + 0 freq @@ -510,7 +323,7 @@ we shift the LO a little further _coordinate - (296, 192) + (312, 24) _rotation @@ -569,7 +382,7 @@ we shift the LO a little further _coordinate - (712, 501) + (736, 292) _rotation @@ -592,53 +405,6 @@ we shift the LO a little further quadrature_rate - - audio_sink - - alias - - - - comment - - - - affinity - - - - device_name - - - - _enabled - 1 - - - _coordinate - (776, 668) - - - _rotation - 180 - - - id - audio_sink_0 - - - num_inputs - 1 - - - ok_to_block - True - - - samp_rate - audio_samp_rate - - blocks_multiply_const_vxx @@ -663,7 +429,7 @@ we shift the LO a little further _coordinate - (968, 668) + (976, 444) _rotation @@ -706,11 +472,11 @@ we shift the LO a little further _enabled - 1 + 0 _coordinate - (568, 264) + (568, 64) _rotation @@ -741,6 +507,96 @@ we shift the LO a little further 1 + + blocks_wavfile_sink + + bits_per_sample + 16 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + file_path + + + _coordinate + (800, 428) + + + _rotation + 180 + + + id + blocks_wavfile_sink_0 + + + nchan + 1 + + + samp_rate + audio_samp_rate + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (64, 620) + + + _rotation + 0 + + + id + file_path + + + label + + + + short_id + + + + type + string + + + value + test.wav + + freq_xlating_fir_filter_xxx @@ -769,7 +625,7 @@ we shift the LO a little further _coordinate - (496, 487) + (520, 280) _rotation @@ -800,6 +656,50 @@ we shift the LO a little further ccc + + parameter + + alias + + + + comment + To avoid the SDR carrier at the DC +we shift the LO a little further + + + _enabled + True + + + _coordinate + (328, 476) + + + _rotation + 0 + + + id + lo_offset + + + label + + + + short_id + + + + type + eng_float + + + value + 100e3 + + osmosdr_source @@ -808,11 +708,11 @@ we shift the LO a little further ant0 - + satnogs.hw_rx_settings[rx_sdr_device]['antenna'] bb_gain0 - 20 + satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'] bw0 @@ -828,7 +728,7 @@ we shift the LO a little further freq0 - freq - lo_offset + rx_freq - lo_offset gain_mode0 @@ -836,7 +736,7 @@ we shift the LO a little further if_gain0 - 20 + satnogs.hw_rx_settings[rx_sdr_device]['if_gain'] iq_balance_mode0 @@ -844,7 +744,7 @@ we shift the LO a little further gain0 - gain + satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'] ant10 @@ -2096,7 +1996,7 @@ we shift the LO a little further args - + satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'] _enabled @@ -2104,7 +2004,7 @@ we shift the LO a little further _coordinate - (104, 229) + (24, 256) _rotation @@ -2227,7 +2127,7 @@ we shift the LO a little further _coordinate - (904, 487) + (944, 288) _rotation @@ -2280,6 +2180,10 @@ we shift the LO a little further average 1.0 + + axislabels + True + bw samp_rate_rx @@ -2306,7 +2210,7 @@ we shift the LO a little further _enabled - 1 + 0 fftsize @@ -2314,7 +2218,7 @@ we shift the LO a little further _coordinate - (896, 262) + (792, 28) gui_hint @@ -2548,6 +2452,10 @@ we shift the LO a little further wintype firdes.WIN_BLACKMAN_hARRIS + + label + Relative Gain + ymax 10 @@ -2556,6 +2464,96 @@ we shift the LO a little further ymin -140 + + units + dB + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (64, 724) + + + _rotation + 0 + + + id + rx_freq + + + label + + + + short_id + + + + type + eng_float + + + value + 100e6 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (64, 484) + + + _rotation + 0 + + + id + rx_sdr_device + + + label + + + + short_id + + + + type + string + + + value + usrpb200 + satnogs_doppler_correction_cc @@ -2581,7 +2579,7 @@ we shift the LO a little further _coordinate - (280, 464) + (304, 256) _rotation @@ -2605,7 +2603,7 @@ we shift the LO a little further target_freq - freq + rx_freq @@ -2628,7 +2626,7 @@ we shift the LO a little further _coordinate - (24, 446) + (24, 164) _rotation @@ -2673,7 +2671,7 @@ we shift the LO a little further blocks_multiply_const_vxx_0 - audio_sink_0 + blocks_wavfile_sink_0 0 0 diff --git a/apps/flowgraphs/satnogs_fm_demod.py b/apps/flowgraphs/satnogs_fm_demod.py new file mode 100755 index 0000000..3eccf05 --- /dev/null +++ b/apps/flowgraphs/satnogs_fm_demod.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: FM Generic Demodulation +# Author: Manolis Surligas (surligas@gmail.com) +# Description: A generic FM demodulation block +# Generated: Wed Oct 12 21:16:27 2016 +################################################## + +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 PyQt4 import Qt +from gnuradio import analog +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from gnuradio.filter import pfb +from optparse import OptionParser +import osmosdr +import satnogs +import sys +import time + + +class satnogs_fm_demod(gr.top_block, Qt.QWidget): + + def __init__(self, file_path="test.wav", lo_offset=100e3, rx_freq=100e6, rx_sdr_device="usrpb200"): + gr.top_block.__init__(self, "FM Generic Demodulation") + Qt.QWidget.__init__(self) + self.setWindowTitle("FM Generic Demodulation") + 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", "satnogs_fm_demod") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + ################################################## + # Parameters + ################################################## + self.file_path = file_path + self.lo_offset = lo_offset + self.rx_freq = rx_freq + self.rx_sdr_device = rx_sdr_device + + ################################################## + # Variables + ################################################## + self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] + self.decimation_rx = decimation_rx = satnogs.fm_demod_settings[rx_sdr_device]['decimation_rx'] + + self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76) + + self.quadrature_rate = quadrature_rate = samp_rate_rx / decimation_rx + self.audio_samp_rate = audio_samp_rate = 44100 + self.audio_gain = audio_gain = satnogs.fm_demod_settings[rx_sdr_device]['audio_gain'] + self.audio_decimation = audio_decimation = 2 + + ################################################## + # Blocks + ################################################## + self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", 4532, 1500) + self.satnogs_doppler_correction_cc_0 = satnogs.doppler_correction_cc(rx_freq, samp_rate_rx, 1000) + self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff( + audio_samp_rate / (quadrature_rate * 1.0 / audio_decimation), + taps=(firdes.low_pass_2(32, 32, 0.8, 0.1, 100)), + flt_size=32) + self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) + + self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.hw_rx_settings[rx_sdr_device]['dev_arg'] ) + self.osmosdr_source_0.set_sample_rate(samp_rate_rx) + self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) + self.osmosdr_source_0.set_freq_corr(0, 0) + self.osmosdr_source_0.set_dc_offset_mode(0, 0) + self.osmosdr_source_0.set_iq_balance_mode(0, 0) + self.osmosdr_source_0.set_gain_mode(False, 0) + self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[rx_sdr_device]['rf_gain'], 0) + self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[rx_sdr_device]['if_gain'], 0) + self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[rx_sdr_device]['bb_gain'], 0) + self.osmosdr_source_0.set_antenna(satnogs.hw_rx_settings[rx_sdr_device]['antenna'], 0) + self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) + + self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decimation_rx, (taps), lo_offset, samp_rate_rx) + self.blocks_wavfile_sink_0 = blocks.wavfile_sink(file_path, 1, audio_samp_rate, 16) + self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((audio_gain, )) + self.analog_wfm_rcv_0 = analog.wfm_rcv( + quad_rate=quadrature_rate, + audio_decimation=audio_decimation, + ) + + ################################################## + # Connections + ################################################## + self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_correction_cc_0, 'freq')) + self.connect((self.analog_wfm_rcv_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) + self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) + self.connect((self.osmosdr_source_0, 0), (self.satnogs_doppler_correction_cc_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) + self.connect((self.satnogs_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "satnogs_fm_demod") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_file_path(self): + return self.file_path + + def set_file_path(self, file_path): + self.file_path = file_path + self.blocks_wavfile_sink_0.open(self.file_path) + + def get_lo_offset(self): + return self.lo_offset + + def set_lo_offset(self, lo_offset): + self.lo_offset = lo_offset + self.osmosdr_source_0.set_center_freq(self.rx_freq - self.lo_offset, 0) + self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.lo_offset) + + def get_rx_freq(self): + return self.rx_freq + + def set_rx_freq(self, rx_freq): + self.rx_freq = rx_freq + self.osmosdr_source_0.set_center_freq(self.rx_freq - self.lo_offset, 0) + + def get_rx_sdr_device(self): + return self.rx_sdr_device + + def set_rx_sdr_device(self, rx_sdr_device): + self.rx_sdr_device = rx_sdr_device + self.set_samp_rate_rx(satnogs.hw_rx_settings[self.rx_sdr_device]['samp_rate']) + self.set_decimation_rx(satnogs.fm_demod_settings[self.rx_sdr_device]['decimation_rx']) + self.set_audio_gain(satnogs.fm_demod_settings[self.rx_sdr_device]['audio_gain']) + self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['rf_gain'], 0) + self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['if_gain'], 0) + self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['bb_gain'], 0) + self.osmosdr_source_0.set_antenna(satnogs.hw_rx_settings[self.rx_sdr_device]['antenna'], 0) + + def get_samp_rate_rx(self): + return self.samp_rate_rx + + def set_samp_rate_rx(self, samp_rate_rx): + self.samp_rate_rx = samp_rate_rx + self.set_quadrature_rate(self.samp_rate_rx / self.decimation_rx) + self.osmosdr_source_0.set_sample_rate(self.samp_rate_rx) + self.osmosdr_source_0.set_bandwidth(self.samp_rate_rx, 0) + + def get_decimation_rx(self): + return self.decimation_rx + + def set_decimation_rx(self, decimation_rx): + self.decimation_rx = decimation_rx + self.set_quadrature_rate(self.samp_rate_rx / self.decimation_rx) + + def get_taps(self): + return self.taps + + def set_taps(self, taps): + self.taps = taps + self.freq_xlating_fir_filter_xxx_0.set_taps((self.taps)) + + def get_quadrature_rate(self): + return self.quadrature_rate + + def set_quadrature_rate(self, quadrature_rate): + self.quadrature_rate = quadrature_rate + self.pfb_arb_resampler_xxx_0.set_rate(self.audio_samp_rate / (self.quadrature_rate * 1.0 / self.audio_decimation)) + + def get_audio_samp_rate(self): + return self.audio_samp_rate + + def set_audio_samp_rate(self, audio_samp_rate): + self.audio_samp_rate = audio_samp_rate + self.pfb_arb_resampler_xxx_0.set_rate(self.audio_samp_rate / (self.quadrature_rate * 1.0 / self.audio_decimation)) + + def get_audio_gain(self): + return self.audio_gain + + def set_audio_gain(self, audio_gain): + self.audio_gain = audio_gain + self.blocks_multiply_const_vxx_0.set_k((self.audio_gain, )) + + def get_audio_decimation(self): + return self.audio_decimation + + def set_audio_decimation(self, audio_decimation): + self.audio_decimation = audio_decimation + self.pfb_arb_resampler_xxx_0.set_rate(self.audio_samp_rate / (self.quadrature_rate * 1.0 / self.audio_decimation)) + + +def argument_parser(): + description = 'A generic FM demodulation block' + parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description) + parser.add_option( + "", "--file-path", dest="file_path", type="string", default="test.wav", + help="Set file_path [default=%default]") + parser.add_option( + "", "--lo-offset", dest="lo_offset", type="eng_float", default=eng_notation.num_to_str(100e3), + help="Set lo_offset [default=%default]") + parser.add_option( + "", "--rx-freq", dest="rx_freq", type="eng_float", default=eng_notation.num_to_str(100e6), + help="Set rx_freq [default=%default]") + parser.add_option( + "", "--rx-sdr-device", dest="rx_sdr_device", type="string", default="usrpb200", + help="Set rx_sdr_device [default=%default]") + return parser + + +def main(top_block_cls=satnogs_fm_demod, options=None): + if options is None: + options, _ = argument_parser().parse_args() + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls(file_path=options.file_path, lo_offset=options.lo_offset, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device) + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main() diff --git a/apps/flowgraphs/upsat_transceiver_cli.grc b/apps/flowgraphs/upsat_transceiver_cli.grc index fe92a65..09d37b8 100644 --- a/apps/flowgraphs/upsat_transceiver_cli.grc +++ b/apps/flowgraphs/upsat_transceiver_cli.grc @@ -1,5 +1,5 @@ - + Fri Jul 1 17:53:00 2016 @@ -78,7 +78,7 @@ title - + UPSat Tranceiver @@ -3676,6 +3676,10 @@ we shift the LO a little further average 1.0 + + axislabels + True + bw samp_rate_rx/decimation_rx @@ -3944,6 +3948,10 @@ we shift the LO a little further wintype firdes.WIN_BLACKMAN_hARRIS + + label + Relative Gain + ymax 0 @@ -3952,6 +3960,10 @@ we shift the LO a little further ymin -140 + + units + dB + parameter diff --git a/apps/flowgraphs/upsat_transceiver_cli.py b/apps/flowgraphs/upsat_transceiver_cli.py index e566cbe..de55623 100755 --- a/apps/flowgraphs/upsat_transceiver_cli.py +++ b/apps/flowgraphs/upsat_transceiver_cli.py @@ -2,10 +2,10 @@ # -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph -# Title: Upsat Transceiver Cli +# Title: UPSat Tranceiver # Author: Manolis Surligas (surligas@gmail.com) # Description: SATNOGS transceiver for UPSAT satellite -# Generated: Sun Aug 14 22:13:27 2016 +# Generated: Wed Oct 12 20:16:02 2016 ################################################## from gnuradio import analog @@ -28,7 +28,7 @@ import time class upsat_transceiver_cli(gr.top_block): def __init__(self, bind_addr="0.0.0.0", dest_addr="127.0.0.1", lo_offset=100e3, recv_port=16886, rx_sdr_device="usrpb200", send_port=5022, tx_sdr_device="usrpb200", wod_port=5023): - gr.top_block.__init__(self, "Upsat Transceiver Cli") + gr.top_block.__init__(self, "UPSat Tranceiver") ################################################## # Parameters @@ -150,10 +150,10 @@ class upsat_transceiver_cli(gr.top_block): def set_lo_offset(self, lo_offset): self.lo_offset = lo_offset - self.analog_sig_source_x_0.set_frequency(self.lo_offset ) - self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.lo_offset) - self.osmosdr_sink_0.set_center_freq(self.tx_frequency - self.lo_offset, 0) self.osmosdr_source_0.set_center_freq(self.rx_frequency - self.lo_offset, 0) + self.osmosdr_sink_0.set_center_freq(self.tx_frequency - self.lo_offset, 0) + self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.lo_offset) + self.analog_sig_source_x_0.set_frequency(self.lo_offset ) def get_recv_port(self): return self.recv_port @@ -166,8 +166,8 @@ class upsat_transceiver_cli(gr.top_block): def set_rx_sdr_device(self, rx_sdr_device): self.rx_sdr_device = rx_sdr_device - self.set_samp_rate_rx(satnogs.hw_rx_settings[self.rx_sdr_device]['samp_rate']) self.set_samp_rate_tx(satnogs.hw_tx_settings[self.rx_sdr_device]['samp_rate']) + self.set_samp_rate_rx(satnogs.hw_rx_settings[self.rx_sdr_device]['samp_rate']) self.osmosdr_source_0.set_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['rf_gain'], 0) self.osmosdr_source_0.set_if_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['if_gain'], 0) self.osmosdr_source_0.set_bb_gain(satnogs.hw_rx_settings[self.rx_sdr_device]['bb_gain'], 0) @@ -200,10 +200,10 @@ class upsat_transceiver_cli(gr.top_block): def set_samples_per_symbol_tx(self, samples_per_symbol_tx): self.samples_per_symbol_tx = samples_per_symbol_tx - self.set_gaussian_taps(filter.firdes.gaussian(1.0, self.samples_per_symbol_tx, 1.0, 4*self.samples_per_symbol_tx)) self.set_sq_wave((1.0, ) * self.samples_per_symbol_tx) - self.analog_frequency_modulator_fc_0.set_sensitivity((math.pi*self.modulation_index_uplink) / self.samples_per_symbol_tx) self.pfb_arb_resampler_xxx_0.set_rate(self.samp_rate_tx / (self.baud_rate_uplink * self.samples_per_symbol_tx)) + self.set_gaussian_taps(filter.firdes.gaussian(1.0, self.samples_per_symbol_tx, 1.0, 4*self.samples_per_symbol_tx)) + self.analog_frequency_modulator_fc_0.set_sensitivity((math.pi*self.modulation_index_uplink) / self.samples_per_symbol_tx) def get_sq_wave(self): return self.sq_wave @@ -233,8 +233,8 @@ class upsat_transceiver_cli(gr.top_block): def set_deviation(self, deviation): self.deviation = deviation - self.set_modulation_index_downlink(self.deviation / (self.baud_rate_downlink / 2.0)) self.set_modulation_index_uplink(self.deviation / (self.baud_rate_uplink / 2.0)) + self.set_modulation_index_downlink(self.deviation / (self.baud_rate_downlink / 2.0)) def get_decimation_rx(self): return self.decimation_rx @@ -257,8 +257,8 @@ class upsat_transceiver_cli(gr.top_block): def set_baud_rate_downlink(self, baud_rate_downlink): self.baud_rate_downlink = baud_rate_downlink self.set_modulation_index_downlink(self.deviation / (self.baud_rate_downlink / 2.0)) - self.analog_quadrature_demod_cf_0_0.set_gain(((self.first_stage_samp_rate_rx) / self.baud_rate_downlink)/(math.pi*self.modulation_index_downlink)) self.digital_clock_recovery_mm_xx_0.set_omega(self.first_stage_samp_rate_rx/self.baud_rate_downlink) + self.analog_quadrature_demod_cf_0_0.set_gain(((self.first_stage_samp_rate_rx) / self.baud_rate_downlink)/(math.pi*self.modulation_index_downlink)) def get_tx_frequency(self): return self.tx_frequency @@ -279,10 +279,10 @@ class upsat_transceiver_cli(gr.top_block): def set_samp_rate_tx(self, samp_rate_tx): self.samp_rate_tx = samp_rate_tx - self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate_tx) + self.pfb_arb_resampler_xxx_0.set_rate(self.samp_rate_tx / (self.baud_rate_uplink * self.samples_per_symbol_tx)) self.osmosdr_sink_0.set_sample_rate(self.samp_rate_tx) self.osmosdr_sink_0.set_bandwidth(self.samp_rate_tx, 0) - self.pfb_arb_resampler_xxx_0.set_rate(self.samp_rate_tx / (self.baud_rate_uplink * self.samples_per_symbol_tx)) + self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate_tx) def get_rx_frequency(self): return self.rx_frequency @@ -317,12 +317,13 @@ class upsat_transceiver_cli(gr.top_block): def set_first_stage_samp_rate_rx(self, first_stage_samp_rate_rx): self.first_stage_samp_rate_rx = first_stage_samp_rate_rx - self.analog_quadrature_demod_cf_0_0.set_gain(((self.first_stage_samp_rate_rx) / self.baud_rate_downlink)/(math.pi*self.modulation_index_downlink)) self.digital_clock_recovery_mm_xx_0.set_omega(self.first_stage_samp_rate_rx/self.baud_rate_downlink) + self.analog_quadrature_demod_cf_0_0.set_gain(((self.first_stage_samp_rate_rx) / self.baud_rate_downlink)/(math.pi*self.modulation_index_downlink)) def argument_parser(): - parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + description = 'SATNOGS transceiver for UPSAT satellite' + parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description) parser.add_option( "", "--bind-addr", dest="bind_addr", type="string", default="0.0.0.0", help="Set bind_addr [default=%default]") diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 62ef720..92177f4 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -31,6 +31,7 @@ endif() GR_PYTHON_INSTALL( FILES __init__.py + dsp_settings.py hw_settings.py satnogs_upsat_transmitter.py DESTINATION ${GR_PYTHON_DIR}/satnogs diff --git a/python/__init__.py b/python/__init__.py index 6950aa0..80199ba 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -27,6 +27,7 @@ description here (python/__init__.py). try: # this might fail if the module is python-only from satnogs_swig import * + from dsp_settings import * from hw_settings import * from satnogs_upsat_transmitter import * except ImportError: diff --git a/python/dsp_settings.py b/python/dsp_settings.py new file mode 100644 index 0000000..52911c0 --- /dev/null +++ b/python/dsp_settings.py @@ -0,0 +1,31 @@ +#! /usr/bin/python +# +# gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module +# +# Copyright (C) 2016, Libre Space Foundation +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# + +#=============================================================================== +# This file provides a variaty of settings for the flowgraphs +# based on the hardware SDR device that they are using +#=============================================================================== + +fm_demod_settings = {'usrpb200' : {'decimation_rx' : 5, 'audio_gain' : 0.9}, + 'usrp2' : {'decimation_rx' : 5, 'audio_gain' : 0.9}, + 'airspy' : {'decimation_rx' : 10, 'audio_gain' : 0.9}, + 'hackrf' : {'decimation_rx' : 5, 'audio_gain' : 0.9}, + 'rtlsdr' : {'decimation_rx' : 5, 'audio_gain' : 0.9} + } \ No newline at end of file