diff --git a/CMakeLists.txt b/CMakeLists.txt index 566d626..cbdf2d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ set(Boost_ADDITIONAL_VERSIONS "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" ) -find_package(Boost "1.35" COMPONENTS filesystem system) +find_package(Boost "1.35" COMPONENTS filesystem system chrono thread) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost required to compile satnogs") diff --git a/apps/flowgraphs/cw_decoder.grc b/apps/flowgraphs/cw_decoder.grc index 2d7abc1..bbbaf24 100644 --- a/apps/flowgraphs/cw_decoder.grc +++ b/apps/flowgraphs/cw_decoder.grc @@ -1,5 +1,5 @@ - + Thu May 5 00:22:45 2016 @@ -72,6 +72,10 @@ run True + + sizing_mode + fixed + thread_safe_setters @@ -80,6 +84,10 @@ title CW Decoder + + placement + (0,0) + variable @@ -108,33 +116,6 @@ 48000 - - variable - - comment - - - - _enabled - True - - - _coordinate - (574, 546) - - - _rotation - 0 - - - id - lpf_decimation - - - value - 5 - - variable @@ -280,6 +261,65 @@ TX sampling rate complex + + analog_agc_xx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1372, 339) + + + _rotation + 0 + + + gain + 1.0 + + + id + analog_agc_xx_0 + + + max_gain + 65536 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + rate + 1e-4 + + + reference + 1.0 + + + type + float + + analog_pll_carriertracking_cc @@ -316,7 +356,7 @@ TX sampling rate max_freq - 2*math.pi*2e3/(samp_rate_rx/xlating_decimation/lpf_decimation) + 2*math.pi*2e3/audio_samp_rate maxoutbuf @@ -324,7 +364,7 @@ TX sampling rate min_freq - -2*math.pi*2e3/(samp_rate_rx/xlating_decimation/lpf_decimation) + -2*math.pi*2e3/audio_samp_rate minoutbuf @@ -428,6 +468,10 @@ TX sampling rate short_id + + hide + none + type string @@ -471,6 +515,10 @@ TX sampling rate short_id + + hide + none + type eng_float @@ -516,6 +564,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type eng_float @@ -611,61 +663,6 @@ tone. This tone is typically 1 kHz. 1 - - blocks_moving_average_xx - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (1400, 348) - - - _rotation - 0 - - - id - blocks_moving_average_xx_0 - - - length - 300 - - - max_iter - 4000 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - scale - 1 - - - type - float - - blocks_multiply_xx @@ -751,6 +748,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type string @@ -794,6 +795,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type string @@ -837,6 +842,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type intx @@ -880,6 +889,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type intx @@ -923,6 +936,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type string @@ -960,7 +977,7 @@ tone. This tone is typically 1 kHz. _coordinate - (520, 188) + (287, 379) _rotation @@ -1025,6 +1042,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type eng_float @@ -1130,6 +1151,10 @@ tone. This tone is typically 1 kHz. short_id + + hide + none + type string @@ -1174,6 +1199,10 @@ we shift the LO a little further short_id + + hide + none + type eng_float @@ -1195,7 +1224,7 @@ we shift the LO a little further comment - Output samplerate: 100k / 5 = 20k + affinity @@ -1207,7 +1236,7 @@ we shift the LO a little further decim - lpf_decimation + 1 _enabled @@ -1219,7 +1248,7 @@ we shift the LO a little further _coordinate - (768, 284) + (1268, 179) _rotation @@ -1227,7 +1256,7 @@ we shift the LO a little further gain - lpf_decimation + 1 id @@ -1247,7 +1276,7 @@ we shift the LO a little further samp_rate - samp_rate_rx/xlating_decimation + audio_samp_rate width @@ -1322,7 +1351,7 @@ we shift the LO a little further samp_rate - samp_rate_rx/xlating_decimation/lpf_decimation + audio_samp_rate width @@ -2740,6 +2769,69 @@ we shift the LO a little further + + pfb_arb_resampler_xxx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (662, 227) + + + _rotation + 0 + + + id + pfb_arb_resampler_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nfilts + 32 + + + rrate + (audio_samp_rate) / (samp_rate_rx / xlating_decimation) + + + samp_delay + 0 + + + atten + 80 + + + taps + + + + type + ccf + + parameter @@ -2774,6 +2866,10 @@ we shift the LO a little further short_id + + hide + none + type intx @@ -2783,124 +2879,6 @@ we shift the LO a little further 0 - - rational_resampler_xxx - - alias - - - - comment - Output samplerate: 48k - - - affinity - - - - decim - int((samp_rate_rx/xlating_decimation)) - - - _enabled - 1 - - - fbw - 0 - - - _coordinate - (864, 76) - - - _rotation - 0 - - - id - rational_resampler_xxx_0 - - - interp - audio_samp_rate - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - taps - - - - type - ccc - - - - rational_resampler_xxx - - alias - - - - comment - Output samplerate: 48k - - - affinity - - - - decim - int((samp_rate_rx/xlating_decimation)/lpf_decimation) - - - _enabled - 1 - - - fbw - 0 - - - _coordinate - (1088, 580) - - - _rotation - 180 - - - id - rational_resampler_xxx_0_0 - - - interp - audio_samp_rate - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - taps - - - - type - ccc - - parameter @@ -2935,6 +2913,10 @@ we shift the LO a little further short_id + + hide + none + type eng_float @@ -2978,6 +2960,10 @@ we shift the LO a little further short_id + + hide + none + type intx @@ -3021,6 +3007,10 @@ we shift the LO a little further short_id + + hide + none + type eng_float @@ -3064,6 +3054,10 @@ we shift the LO a little further short_id + + hide + none + type string @@ -3093,7 +3087,7 @@ we shift the LO a little further _coordinate - (280, 304) + (446, 239) _rotation @@ -3113,7 +3107,7 @@ we shift the LO a little further sampling_rate - samp_rate_rx + samp_rate_rx / xlating_decimation target_freq @@ -3124,7 +3118,7 @@ we shift the LO a little further satnogs_cw_to_symbol threshold - 0.75 + 0.8 alias @@ -3168,64 +3162,13 @@ we shift the LO a little further sampling_rate - samp_rate_rx/xlating_decimation/lpf_decimation/4 + audio_samp_rate/4 wpm wpm - - satnogs_doppler_correction_cc - - alias - - - - comment - - - - affinity - - - - corrections_per_sec - 1000 - - - _enabled - 0 - - - _coordinate - (288, 192) - - - _rotation - 0 - - - id - satnogs_doppler_correction_cc_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - sampling_rate - samp_rate_rx - - - target_freq - rx_freq - - satnogs_frame_file_sink @@ -3593,6 +3536,10 @@ we shift the LO a little further short_id + + hide + none + type string @@ -3636,6 +3583,10 @@ we shift the LO a little further short_id + + hide + none + type intx @@ -3679,6 +3630,10 @@ we shift the LO a little further short_id + + hide + none + type string @@ -3722,6 +3677,10 @@ we shift the LO a little further short_id + + hide + none + type intx @@ -3737,6 +3696,12 @@ we shift the LO a little further 0 1 + + analog_agc_xx_0 + low_pass_filter_0_0 + 0 + 0 + analog_pll_carriertracking_cc_0 blocks_complex_to_mag_squared_0 @@ -3751,7 +3716,7 @@ we shift the LO a little further blocks_complex_to_mag_squared_0 - blocks_moving_average_xx_0 + analog_agc_xx_0 0 0 @@ -3761,27 +3726,15 @@ we shift the LO a little further 0 0 - - blocks_moving_average_xx_0 - low_pass_filter_0_0 - 0 - 0 - blocks_multiply_xx_0 - rational_resampler_xxx_0_0 + blocks_complex_to_real_0 0 0 freq_xlating_fir_filter_xxx_0 - low_pass_filter_0 - 0 - 0 - - - freq_xlating_fir_filter_xxx_0 - rational_resampler_xxx_0 + satnogs_coarse_doppler_correction_cc_0 0 0 @@ -3805,31 +3758,31 @@ we shift the LO a little further osmosdr_source_0 - satnogs_coarse_doppler_correction_cc_0 + freq_xlating_fir_filter_xxx_0 0 0 - rational_resampler_xxx_0 + pfb_arb_resampler_xxx_0 + low_pass_filter_0 + 0 + 0 + + + pfb_arb_resampler_xxx_0 satnogs_iq_sink_0 0 0 - rational_resampler_xxx_0 + pfb_arb_resampler_xxx_0 satnogs_waterfall_sink_0 0 0 - - rational_resampler_xxx_0_0 - blocks_complex_to_real_0 - 0 - 0 - satnogs_coarse_doppler_correction_cc_0 - freq_xlating_fir_filter_xxx_0 + pfb_arb_resampler_xxx_0 0 0 @@ -3839,12 +3792,6 @@ we shift the LO a little further out in - - satnogs_doppler_correction_cc_0 - freq_xlating_fir_filter_xxx_0 - 0 - 0 - satnogs_morse_decoder_0 satnogs_frame_file_sink_0_0 @@ -3863,10 +3810,4 @@ we shift the LO a little further freq freq - - satnogs_tcp_rigctl_msg_source_0 - satnogs_doppler_correction_cc_0 - freq - freq - diff --git a/apps/flowgraphs/satnogs_cw_decoder.py b/apps/flowgraphs/satnogs_cw_decoder.py index fc411d4..9961814 100755 --- a/apps/flowgraphs/satnogs_cw_decoder.py +++ b/apps/flowgraphs/satnogs_cw_decoder.py @@ -5,10 +5,9 @@ # Title: CW Decoder # Author: Manolis Surligas (surligas@gmail.com) # Description: A CW (Morse) Decoder -# Generated: Tue May 15 22:58:51 2018 +# Generated: Mon May 21 18:50:09 2018 ################################################## - from gnuradio import analog from gnuradio import blocks from gnuradio import eng_notation @@ -16,6 +15,7 @@ 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 @@ -58,7 +58,6 @@ class satnogs_cw_decoder(gr.top_block): self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.xlating_decimation = xlating_decimation = int(samp_rate_rx/100e3) self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) - self.lpf_decimation = lpf_decimation = 5 self.audio_samp_rate = audio_samp_rate = 48000 ################################################## @@ -71,20 +70,14 @@ class satnogs_cw_decoder(gr.top_block): self.satnogs_morse_decoder_0 = satnogs.morse_decoder(ord('#'), 3) self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump) self.satnogs_frame_file_sink_0_0 = satnogs.frame_file_sink(decoded_data_file_path, 0) - self.satnogs_cw_to_symbol_0 = satnogs.cw_to_symbol(samp_rate_rx/xlating_decimation/lpf_decimation/4, 0.75, 0.75, wpm) - self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx) - self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( - interpolation=audio_samp_rate, - decimation=int((samp_rate_rx/xlating_decimation)/lpf_decimation), - taps=None, - fractional_bw=None, - ) - self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( - interpolation=audio_samp_rate, - decimation=int((samp_rate_rx/xlating_decimation)), - taps=None, - fractional_bw=None, - ) + self.satnogs_cw_to_symbol_0 = satnogs.cw_to_symbol(audio_samp_rate/4, 0.8, 0.75, wpm) + self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx / xlating_decimation) + self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( + (audio_samp_rate) / (samp_rate_rx / xlating_decimation), + taps=None, + flt_size=32) + self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) + self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + satnogs.handle_rx_dev_args(rx_sdr_device, dev_args) ) self.osmosdr_source_0.set_sample_rate(samp_rate_rx) self.osmosdr_source_0.set_center_freq(rx_freq - lo_offset, 0) @@ -99,19 +92,22 @@ class satnogs_cw_decoder(gr.top_block): self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0) self.low_pass_filter_0_0 = filter.fir_filter_fff(4, firdes.low_pass( - 4, samp_rate_rx/xlating_decimation/lpf_decimation, 100, 100, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0 = filter.fir_filter_ccf(lpf_decimation, firdes.low_pass( - lpf_decimation, samp_rate_rx/xlating_decimation, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) + 4, audio_samp_rate, 100, 100, firdes.WIN_HAMMING, 6.76)) + self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( + 1, audio_samp_rate, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlating_decimation, (xlate_filter_taps), lo_offset, samp_rate_rx) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) - self.blocks_moving_average_xx_0 = blocks.moving_average_ff(300, 1, 4000) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.analog_sig_source_x_0 = analog.sig_source_c(audio_samp_rate, analog.GR_COS_WAVE, bfo_freq, 1, 0) - self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(2*math.pi/100, 2*math.pi*2e3/(samp_rate_rx/xlating_decimation/lpf_decimation), -2*math.pi*2e3/(samp_rate_rx/xlating_decimation/lpf_decimation)) + self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(2*math.pi/100, 2*math.pi*2e3/audio_samp_rate, -2*math.pi*2e3/audio_samp_rate) + self.analog_agc_xx_0 = analog.agc_ff(1e-4, 1.0, 1.0) + self.analog_agc_xx_0.set_max_gain(65536) self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 0.0) self.analog_agc2_xx_0_0.set_max_gain(65536) + + ################################################## # Connections ################################################## @@ -120,22 +116,21 @@ class satnogs_cw_decoder(gr.top_block): self.msg_connect((self.satnogs_morse_decoder_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in')) self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_coarse_doppler_correction_cc_0, 'freq')) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_xx_0, 1)) + self.connect((self.analog_agc_xx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) - self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) + self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0)) - self.connect((self.blocks_moving_average_xx_0, 0), (self.low_pass_filter_0_0, 0)) - self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0_0, 0)) - self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) - self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) + self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.satnogs_cw_to_symbol_0, 0)) - self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) - self.connect((self.rational_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) - self.connect((self.rational_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) - self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_complex_to_real_0, 0)) - self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) + self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_iq_sink_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.satnogs_waterfall_sink_0, 0)) + self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) def get_antenna(self): return self.antenna @@ -279,22 +274,16 @@ class satnogs_cw_decoder(gr.top_block): self.samp_rate_rx = samp_rate_rx self.set_xlating_decimation(int(self.samp_rate_rx/100e3)) self.set_xlate_filter_taps(firdes.low_pass(1, self.samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76)) + self.pfb_arb_resampler_xxx_0.set_rate((self.audio_samp_rate) / (self.samp_rate_rx / self.xlating_decimation)) self.osmosdr_source_0.set_sample_rate(self.samp_rate_rx) self.osmosdr_source_0.set_bandwidth(self.samp_rate_rx, 0) - self.low_pass_filter_0_0.set_taps(firdes.low_pass(4, self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation, 100, 100, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0.set_taps(firdes.low_pass(self.lpf_decimation, self.samp_rate_rx/self.xlating_decimation, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) - self.analog_pll_carriertracking_cc_0.set_max_freq(2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation)) - self.analog_pll_carriertracking_cc_0.set_min_freq(-2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation)) def get_xlating_decimation(self): return self.xlating_decimation def set_xlating_decimation(self, xlating_decimation): self.xlating_decimation = xlating_decimation - self.low_pass_filter_0_0.set_taps(firdes.low_pass(4, self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation, 100, 100, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0.set_taps(firdes.low_pass(self.lpf_decimation, self.samp_rate_rx/self.xlating_decimation, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) - self.analog_pll_carriertracking_cc_0.set_max_freq(2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation)) - self.analog_pll_carriertracking_cc_0.set_min_freq(-2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation)) + self.pfb_arb_resampler_xxx_0.set_rate((self.audio_samp_rate) / (self.samp_rate_rx / self.xlating_decimation)) def get_xlate_filter_taps(self): return self.xlate_filter_taps @@ -303,22 +292,17 @@ class satnogs_cw_decoder(gr.top_block): self.xlate_filter_taps = xlate_filter_taps self.freq_xlating_fir_filter_xxx_0.set_taps((self.xlate_filter_taps)) - def get_lpf_decimation(self): - return self.lpf_decimation - - def set_lpf_decimation(self, lpf_decimation): - self.lpf_decimation = lpf_decimation - self.low_pass_filter_0_0.set_taps(firdes.low_pass(4, self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation, 100, 100, firdes.WIN_HAMMING, 6.76)) - self.low_pass_filter_0.set_taps(firdes.low_pass(self.lpf_decimation, self.samp_rate_rx/self.xlating_decimation, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) - self.analog_pll_carriertracking_cc_0.set_max_freq(2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_decimation)) - self.analog_pll_carriertracking_cc_0.set_min_freq(-2*math.pi*2e3/(self.samp_rate_rx/self.xlating_decimation/self.lpf_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.samp_rate_rx / self.xlating_decimation)) + self.low_pass_filter_0_0.set_taps(firdes.low_pass(4, self.audio_samp_rate, 100, 100, firdes.WIN_HAMMING, 6.76)) + self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.audio_samp_rate, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0.set_sampling_freq(self.audio_samp_rate) + self.analog_pll_carriertracking_cc_0.set_max_freq(2*math.pi*2e3/self.audio_samp_rate) + self.analog_pll_carriertracking_cc_0.set_min_freq(-2*math.pi*2e3/self.audio_samp_rate) def argument_parser():