diff --git a/apps/flowgraphs/fm_demod.grc b/apps/flowgraphs/fm_demod.grc index fd5f6f3..35abf0b 100644 --- a/apps/flowgraphs/fm_demod.grc +++ b/apps/flowgraphs/fm_demod.grc @@ -10,7 +10,7 @@ window_size - 3000,3000 + 3000, 3000 category @@ -81,33 +81,6 @@ FM Generic Demodulation - - variable - - comment - - - - _enabled - True - - - _coordinate - (1864, 12) - - - _rotation - 0 - - - id - audio_decimation - - - value - 2 - - variable @@ -122,7 +95,7 @@ SDR received samples _coordinate - (1296, 12) + (1704, 796) _rotation @@ -149,7 +122,7 @@ SDR received samples _coordinate - (2072, 12) + (1704, 52) _rotation @@ -161,7 +134,7 @@ SDR received samples value - 44100 + 48000 @@ -174,11 +147,11 @@ SDR received samples _enabled - True + 0 _coordinate - (1088, 12) + (1704, 348) _rotation @@ -205,7 +178,61 @@ SDR received samples _coordinate - (1680, 12) + (1480, 988) + + + _rotation + 0 + + + id + deviation + + + value + 5000 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (1704, 260) + + + _rotation + 0 + + + id + filter_rate + + + value + 250000 + + + + variable + + comment + + + + _enabled + 0 + + + _coordinate + (1704, 508) _rotation @@ -233,7 +260,7 @@ TX sampling rate _coordinate - (1512, 12) + (1704, 956) _rotation @@ -268,7 +295,7 @@ TX sampling rate _coordinate - (32, 788) + (48, 716) _rotation @@ -296,34 +323,18 @@ TX sampling rate - analog_sig_source_x - - amp - 1 - - - alias - - + variable comment - - affinity - - _enabled - 0 - - - freq - -lo_offset + True _coordinate - (320, 12) + (1704, 164) _rotation @@ -331,39 +342,15 @@ TX sampling rate id - analog_sig_source_x_0 + xlate_filter_taps - maxoutbuf - 0 - - - minoutbuf - 0 - - - offset - 0 - - - type - complex - - - samp_rate - samp_rate_rx - - - waveform - analog.GR_COS_WAVE + value + firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) - analog_wfm_rcv - - audio_decimation - audio_decimation - + analog_quadrature_demod_cf alias @@ -378,19 +365,23 @@ TX sampling rate _enabled - 1 + True _coordinate - (1176, 476) + (1088, 564) _rotation - 0 + 180 + + + gain + (2*math.pi*deviation)/audio_samp_rate id - analog_wfm_rcv_0 + analog_quadrature_demod_cf_0 maxoutbuf @@ -400,64 +391,9 @@ TX sampling rate minoutbuf 0 - - quad_rate - quadrature_rate - - blocks_multiply_const_vxx - - alias - - - - comment - - - - const - audio_gain - - - affinity - - - - _enabled - 1 - - - _coordinate - (1808, 484) - - - _rotation - 0 - - - id - blocks_multiply_const_vxx_0 - - - type - float - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_multiply_xx + rational_resampler_xxx alias @@ -470,13 +406,21 @@ TX sampling rate affinity + + decim + 125 + _enabled + True + + + fbw 0 _coordinate - (568, 140) + (1272, 268) _rotation @@ -484,11 +428,11 @@ TX sampling rate id - blocks_multiply_xx_0 + blks2_rational_resampler_xxx_1 - type - complex + interp + 24 maxoutbuf @@ -499,12 +443,12 @@ TX sampling rate 0 - num_inputs - 2 + taps + [] - vlen - 1 + type + ccc @@ -535,7 +479,7 @@ TX sampling rate _coordinate - (2056, 464) + (1088, 664) _rotation @@ -570,7 +514,7 @@ TX sampling rate _coordinate - (1904, 192) + (64, 984) _rotation @@ -613,7 +557,7 @@ TX sampling rate _coordinate - (1272, 192) + (736, 984) _rotation @@ -660,7 +604,7 @@ TX sampling rate decim - decimation_rx + int(samp_rate_rx/filter_rate) _enabled @@ -668,7 +612,7 @@ TX sampling rate _coordinate - (808, 452) + (680, 268) _rotation @@ -692,7 +636,7 @@ TX sampling rate taps - taps + xlate_filter_taps type @@ -716,7 +660,7 @@ we shift the LO a little further _coordinate - (1736, 192) + (1704, 608) _rotation @@ -2047,7 +1991,7 @@ we shift the LO a little further _coordinate - (16, 368) + (16, 376) _rotation @@ -2150,368 +2094,6 @@ we shift the LO a little further - - pfb_arb_resampler_xxx - - alias - - - - comment - - - - affinity - - - - _enabled - 1 - - - _coordinate - (1456, 452) - - - _rotation - 0 - - - id - pfb_arb_resampler_xxx_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - nfilts - 32 - - - rrate - audio_samp_rate / (quadrature_rate * 1.0 / audio_decimation) - - - samp_delay - 0 - - - atten - 100 - - - taps - firdes.low_pass_2(32, 32, 0.8, 0.1, 100) - - - type - fff - - - - qtgui_freq_sink_x - - autoscale - False - - - average - 1.0 - - - axislabels - True - - - bw - samp_rate_rx - - - alias - - - - fc - 0 - - - comment - - - - ctrlpanel - True - - - affinity - - - - _enabled - 0 - - - fftsize - 1024 - - - _coordinate - (728, 120) - - - gui_hint - - - - _rotation - 0 - - - grid - True - - - id - qtgui_freq_sink_x_0 - - - legend - True - - - alpha1 - 1.0 - - - color1 - "blue" - - - label1 - - - - width1 - 1 - - - alpha10 - 1.0 - - - color10 - "dark blue" - - - label10 - - - - width10 - 1 - - - alpha2 - 1.0 - - - color2 - "red" - - - label2 - - - - width2 - 1 - - - alpha3 - 1.0 - - - color3 - "green" - - - label3 - - - - width3 - 1 - - - alpha4 - 1.0 - - - color4 - "black" - - - label4 - - - - width4 - 1 - - - alpha5 - 1.0 - - - color5 - "cyan" - - - label5 - - - - width5 - 1 - - - alpha6 - 1.0 - - - color6 - "magenta" - - - label6 - - - - width6 - 1 - - - alpha7 - 1.0 - - - color7 - "yellow" - - - label7 - - - - width7 - 1 - - - alpha8 - 1.0 - - - color8 - "dark red" - - - label8 - - - - width8 - 1 - - - alpha9 - 1.0 - - - color9 - "dark green" - - - label9 - - - - width9 - 1 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - name - "" - - - nconnections - 1 - - - showports - True - - - freqhalf - True - - - tr_chan - 0 - - - tr_level - 0.0 - - - tr_mode - qtgui.TRIG_MODE_FREE - - - tr_tag - "" - - - type - complex - - - update_time - 0.01 - - - wintype - firdes.WIN_BLACKMAN_hARRIS - - - label - Relative Gain - - - ymax - 10 - - - ymin - -140 - - - units - dB - - parameter @@ -2528,7 +2110,7 @@ we shift the LO a little further _coordinate - (1576, 192) + (472, 984) _rotation @@ -2571,7 +2153,7 @@ we shift the LO a little further _coordinate - (1432, 192) + (616, 984) _rotation @@ -2614,7 +2196,7 @@ we shift the LO a little further _coordinate - (1080, 192) + (312, 984) _rotation @@ -2661,7 +2243,7 @@ we shift the LO a little further _coordinate - (464, 460) + (352, 276) _rotation @@ -2708,7 +2290,7 @@ we shift the LO a little further _coordinate - (24, 196) + (16, 204) _rotation @@ -2748,53 +2330,29 @@ we shift the LO a little further - analog_sig_source_x_0 - blocks_multiply_xx_0 - 0 - 0 - - - analog_wfm_rcv_0 - pfb_arb_resampler_xxx_0 - 0 - 0 - - - blocks_multiply_const_vxx_0 + analog_quadrature_demod_cf_0 blocks_wavfile_sink_0 0 0 - blocks_multiply_xx_0 - qtgui_freq_sink_x_0 + blks2_rational_resampler_xxx_1 + analog_quadrature_demod_cf_0 0 0 freq_xlating_fir_filter_xxx_0 - analog_wfm_rcv_0 + blks2_rational_resampler_xxx_1 0 0 - - osmosdr_source_0 - blocks_multiply_xx_0 - 0 - 1 - osmosdr_source_0 satnogs_coarse_doppler_correction_cc_0 0 0 - - pfb_arb_resampler_xxx_0 - blocks_multiply_const_vxx_0 - 0 - 0 - satnogs_coarse_doppler_correction_cc_0 freq_xlating_fir_filter_xxx_0 diff --git a/apps/flowgraphs/satnogs_fm_demod.py b/apps/flowgraphs/satnogs_fm_demod.py index c78df64..b8d85ed 100755 --- a/apps/flowgraphs/satnogs_fm_demod.py +++ b/apps/flowgraphs/satnogs_fm_demod.py @@ -5,7 +5,7 @@ # Title: FM Generic Demodulation # Author: Manolis Surligas (surligas@gmail.com) # Description: A generic FM demodulation block -# Generated: Mon Nov 7 19:50:22 2016 +# Generated: Fri Jan 20 15:58:24 2017 ################################################## from gnuradio import analog @@ -15,8 +15,8 @@ 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 math import osmosdr import satnogs import time @@ -41,26 +41,20 @@ class satnogs_fm_demod(gr.top_block): # 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.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) 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.filter_rate = filter_rate = 250000 + self.deviation = deviation = 5000 + self.audio_samp_rate = audio_samp_rate = 48000 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", rigctl_port, False, 1000, 1500) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx) - 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) @@ -74,23 +68,24 @@ class satnogs_fm_demod(gr.top_block): 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_rx/filter_rate), (xlate_filter_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, + self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc( + interpolation=24, + decimation=125, + taps=None, + fractional_bw=None, ) + self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((2*math.pi*deviation)/audio_samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_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.analog_quadrature_demod_cf_0, 0), (self.blocks_wavfile_sink_0, 0)) + self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0)) + self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_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_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) def get_doppler_correction_per_sec(self): @@ -134,63 +129,59 @@ class satnogs_fm_demod(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_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) + self.set_audio_gain(satnogs.fm_demod_settings[self.rx_sdr_device]['audio_gain']) 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.set_xlate_filter_taps(firdes.low_pass(1, self.samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76)) 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 get_xlate_filter_taps(self): + return self.xlate_filter_taps - def set_decimation_rx(self, decimation_rx): - self.decimation_rx = decimation_rx - self.set_quadrature_rate(self.samp_rate_rx / self.decimation_rx) + def set_xlate_filter_taps(self, xlate_filter_taps): + self.xlate_filter_taps = xlate_filter_taps + self.freq_xlating_fir_filter_xxx_0.set_taps((self.xlate_filter_taps)) 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 get_filter_rate(self): + return self.filter_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 set_filter_rate(self, filter_rate): + self.filter_rate = filter_rate + + def get_deviation(self): + return self.deviation + + def set_deviation(self, deviation): + self.deviation = deviation + self.analog_quadrature_demod_cf_0.set_gain((2*math.pi*self.deviation)/self.audio_samp_rate) 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)) + self.analog_quadrature_demod_cf_0.set_gain((2*math.pi*self.deviation)/self.audio_samp_rate) 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(): diff --git a/python/hw_settings.py b/python/hw_settings.py index 570b875..8ed7f94 100644 --- a/python/hw_settings.py +++ b/python/hw_settings.py @@ -46,5 +46,5 @@ hw_rx_settings = {'usrpb200' : {'rf_gain' : 20.0, 'if_gain' : 0.0, 'bb_gain' : 20.0, 'samp_rate' : 2e6, 'antenna' : '', 'dev_arg': 'hackrf'}, 'rtlsdr' : {'rf_gain' : 32.0, 'if_gain' : 0.0, - 'bb_gain' : 0.0, 'samp_rate' : 1.024e6, + 'bb_gain' : 0.0, 'samp_rate' : 2e6, 'antenna' : '', 'dev_arg' : 'rtl'} }