Merge pull request #84 from surligas/noaa_cpu

Reduce CPU utilization and distribute the workload to multiple filters
This commit is contained in:
Manolis Surligas 2017-06-23 16:42:01 +03:00 committed by GitHub
commit 1cbe18d9da
2 changed files with 194 additions and 31 deletions

View File

@ -109,6 +109,83 @@ the quadrature demodulation</value>
<value>2</value>
</param>
</block>
<block>
<key>variable</key>
<param>
<key>comment</key>
<value>The first stage decimation tries to decrease
the sampling rate of the device in order to keep
the CPU utilization of the next processing blocks
in acceptable levels especially for embedded devices.</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(1306, 460)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>first_stage_decimation</value>
</param>
<param>
<key>value</key>
<value>2</value>
</param>
</block>
<block>
<key>variable_low_pass_filter_taps</key>
<param>
<key>beta</key>
<value>6.76</value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>cutoff_freq</key>
<value>0.2</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(16, 689)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>gain</key>
<value>1.0</value>
</param>
<param>
<key>id</key>
<value>first_stage_filter_taps</value>
</param>
<param>
<key>samp_rate</key>
<value>1.0</value>
</param>
<param>
<key>width</key>
<value>0.1</value>
</param>
<param>
<key>win</key>
<value>firdes.WIN_HAMMING</value>
</param>
</block>
<block>
<key>variable</key>
<param>
@ -177,7 +254,7 @@ the quadrature demodulation</value>
</param>
<param>
<key>width</key>
<value>0.01</value>
<value>0.02</value>
</param>
<param>
<key>win</key>
@ -256,7 +333,7 @@ TX sampling rate</value>
</param>
<param>
<key>quad_rate</key>
<value>samp_rate_rx / int(samp_rate_rx / initial_bandwidth)</value>
<value>samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth))</value>
</param>
</block>
<block>
@ -327,7 +404,7 @@ TX sampling rate</value>
</param>
<param>
<key>samp_rate</key>
<value>(samp_rate_rx / int(samp_rate_rx / initial_bandwidth)) / audio_decimation</value>
<value>samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation</value>
</param>
<param>
<key>width</key>
@ -440,7 +517,7 @@ TX sampling rate</value>
</param>
<param>
<key>decim</key>
<value>int(samp_rate_rx / initial_bandwidth)</value>
<value>int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)</value>
</param>
<param>
<key>_enabled</key>
@ -448,7 +525,7 @@ TX sampling rate</value>
</param>
<param>
<key>_coordinate</key>
<value>(719, 123)</value>
<value>(721, 124)</value>
</param>
<param>
<key>_rotation</key>
@ -534,6 +611,65 @@ TX sampling rate</value>
<value>fff</value>
</param>
</block>
<block>
<key>freq_xlating_fir_filter_xxx</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>center_freq</key>
<value>lo_offset</value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>decim</key>
<value>first_stage_decimation</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(296, 312)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>freq_xlating_fir_filter_xxx_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>samp_rate</key>
<value>samp_rate_rx</value>
</param>
<param>
<key>taps</key>
<value>first_stage_filter_taps</value>
</param>
<param>
<key>type</key>
<value>ccc</value>
</param>
</block>
<block>
<key>hilbert_fc</key>
<param>
@ -2138,7 +2274,7 @@ we shift the LO a little further</value>
</param>
<param>
<key>decim</key>
<value>int(((samp_rate_rx / int(samp_rate_rx / initial_bandwidth)) / audio_decimation) / 2)</value>
<value>int((samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation)/2)</value>
</param>
<param>
<key>_enabled</key>
@ -2409,7 +2545,7 @@ we shift the LO a little further</value>
</param>
<param>
<key>sampling_rate</key>
<value>samp_rate_rx</value>
<value>samp_rate_rx /first_stage_decimation</value>
</param>
<param>
<key>target_freq</key>
@ -2560,6 +2696,12 @@ we shift the LO a little further</value>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>freq_xlating_fir_filter_xxx_0</source_block_id>
<sink_block_id>satnogs_coarse_doppler_correction_cc_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>hilbert_fc_0</source_block_id>
<sink_block_id>blocks_complex_to_mag_0</sink_block_id>
@ -2568,7 +2710,7 @@ we shift the LO a little further</value>
</connection>
<connection>
<source_block_id>osmosdr_source_0</source_block_id>
<sink_block_id>satnogs_coarse_doppler_correction_cc_0</sink_block_id>
<sink_block_id>freq_xlating_fir_filter_xxx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>

View File

@ -5,7 +5,7 @@
# Title: NOAA APT Decoder
# Author: Manolis Surligas, George Vardakis
# Description: A NOAA APT Decoder with automatic image synchronization
# Generated: Tue Apr 11 00:15:28 2017
# Generated: Fri Jun 23 15:41:33 2017
##################################################
from gnuradio import analog
@ -23,28 +23,32 @@ import time
class satnogs_noaa_apt_decoder(gr.top_block):
def __init__(self, doppler_correction_per_sec=1000, lo_offset=100e3, ppm=0, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200', image_file_path='/tmp/noaa.png'):
def __init__(self, doppler_correction_per_sec=1000, image_file_path='/tmp/noaa.png', lo_offset=100e3, ppm=0, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200'):
gr.top_block.__init__(self, "NOAA APT Decoder")
##################################################
# Parameters
##################################################
self.doppler_correction_per_sec = doppler_correction_per_sec
self.image_file_path = image_file_path
self.lo_offset = lo_offset
self.ppm = ppm
self.rigctl_port = rigctl_port
self.rx_freq = rx_freq
self.rx_sdr_device = rx_sdr_device
self.image_file_path = image_file_path
##################################################
# Variables
##################################################
self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate']
self.noaa_filter_taps = noaa_filter_taps = firdes.low_pass(1.0, 1.0, 0.17, 0.01, firdes.WIN_HAMMING, 6.76)
self.noaa_filter_taps = noaa_filter_taps = firdes.low_pass(1.0, 1.0, 0.17, 0.02, firdes.WIN_HAMMING, 6.76)
self.initial_bandwidth = initial_bandwidth = 100e3
self.first_stage_filter_taps = first_stage_filter_taps = firdes.low_pass(1.0, 1.0, 0.2, 0.1, firdes.WIN_HAMMING, 6.76)
self.first_stage_decimation = first_stage_decimation = 2
self.audio_decimation = audio_decimation = 2
##################################################
@ -52,7 +56,7 @@ class satnogs_noaa_apt_decoder(gr.top_block):
##################################################
self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000, 1500)
self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink(image_file_path, 2080, 1500, True, False, False)
self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx)
self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx /first_stage_decimation)
self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
interpolation=4160,
decimation=9600,
@ -61,7 +65,7 @@ class satnogs_noaa_apt_decoder(gr.top_block):
)
self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
interpolation=9600,
decimation=int(((samp_rate_rx / int(samp_rate_rx / initial_bandwidth)) / audio_decimation) / 2),
decimation=int((samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation)/2),
taps=None,
fractional_bw=None,
)
@ -79,15 +83,16 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.osmosdr_source_0.set_bandwidth(samp_rate_rx, 0)
self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(first_stage_decimation, (first_stage_filter_taps), lo_offset, samp_rate_rx)
self.fir_filter_xxx_1 = filter.fir_filter_fff(2, ([0.5, 0.5]))
self.fir_filter_xxx_1.declare_sample_delay(0)
self.fir_filter_xxx_0 = filter.fir_filter_ccc(int(samp_rate_rx / initial_bandwidth), (noaa_filter_taps))
self.fir_filter_xxx_0 = filter.fir_filter_ccc(int(samp_rate_rx/ first_stage_decimation / initial_bandwidth), (noaa_filter_taps))
self.fir_filter_xxx_0.declare_sample_delay(0)
self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
self.band_pass_filter_0 = filter.fir_filter_fff(1, firdes.band_pass(
6, (samp_rate_rx / int(samp_rate_rx / initial_bandwidth)) / audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
6, samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
self.analog_wfm_rcv_0 = analog.wfm_rcv(
quad_rate=samp_rate_rx / int(samp_rate_rx / initial_bandwidth),
quad_rate=samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)),
audio_decimation=audio_decimation,
)
@ -100,8 +105,9 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_0_0, 0))
self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0))
self.connect((self.fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0))
self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_mag_0, 0))
self.connect((self.osmosdr_source_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0))
self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
self.connect((self.rational_resampler_xxx_0, 0), (self.hilbert_fc_0, 0))
self.connect((self.rational_resampler_xxx_0_0, 0), (self.satnogs_noaa_apt_sink_0, 0))
self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.fir_filter_xxx_0, 0))
@ -112,12 +118,19 @@ class satnogs_noaa_apt_decoder(gr.top_block):
def set_doppler_correction_per_sec(self, doppler_correction_per_sec):
self.doppler_correction_per_sec = doppler_correction_per_sec
def get_image_file_path(self):
return self.image_file_path
def set_image_file_path(self, image_file_path):
self.image_file_path = image_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_ppm(self):
return self.ppm
@ -151,12 +164,6 @@ class satnogs_noaa_apt_decoder(gr.top_block):
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_image_file_path(self):
return self.image_file_path
def set_image_file_path(self, image_file_path):
self.image_file_path = image_file_path
def get_samp_rate_rx(self):
return self.samp_rate_rx
@ -164,7 +171,7 @@ class satnogs_noaa_apt_decoder(gr.top_block):
self.samp_rate_rx = samp_rate_rx
self.osmosdr_source_0.set_sample_rate(self.samp_rate_rx)
self.osmosdr_source_0.set_bandwidth(self.samp_rate_rx, 0)
self.band_pass_filter_0.set_taps(firdes.band_pass(6, (self.samp_rate_rx / int(self.samp_rate_rx / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
self.band_pass_filter_0.set_taps(firdes.band_pass(6, self.samp_rate_rx/ ( self.first_stage_decimation * int(self.samp_rate_rx/ self.first_stage_decimation / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
def get_noaa_filter_taps(self):
return self.noaa_filter_taps
@ -178,14 +185,28 @@ class satnogs_noaa_apt_decoder(gr.top_block):
def set_initial_bandwidth(self, initial_bandwidth):
self.initial_bandwidth = initial_bandwidth
self.band_pass_filter_0.set_taps(firdes.band_pass(6, (self.samp_rate_rx / int(self.samp_rate_rx / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
self.band_pass_filter_0.set_taps(firdes.band_pass(6, self.samp_rate_rx/ ( self.first_stage_decimation * int(self.samp_rate_rx/ self.first_stage_decimation / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
def get_first_stage_filter_taps(self):
return self.first_stage_filter_taps
def set_first_stage_filter_taps(self, first_stage_filter_taps):
self.first_stage_filter_taps = first_stage_filter_taps
self.freq_xlating_fir_filter_xxx_0.set_taps((self.first_stage_filter_taps))
def get_first_stage_decimation(self):
return self.first_stage_decimation
def set_first_stage_decimation(self, first_stage_decimation):
self.first_stage_decimation = first_stage_decimation
self.band_pass_filter_0.set_taps(firdes.band_pass(6, self.samp_rate_rx/ ( self.first_stage_decimation * int(self.samp_rate_rx/ self.first_stage_decimation / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
def get_audio_decimation(self):
return self.audio_decimation
def set_audio_decimation(self, audio_decimation):
self.audio_decimation = audio_decimation
self.band_pass_filter_0.set_taps(firdes.band_pass(6, (self.samp_rate_rx / int(self.samp_rate_rx / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
self.band_pass_filter_0.set_taps(firdes.band_pass(6, self.samp_rate_rx/ ( self.first_stage_decimation * int(self.samp_rate_rx/ self.first_stage_decimation / self.initial_bandwidth)) / self.audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76))
def argument_parser():
@ -194,6 +215,9 @@ def argument_parser():
parser.add_option(
"", "--doppler-correction-per-sec", dest="doppler_correction_per_sec", type="intx", default=1000,
help="Set doppler_correction_per_sec [default=%default]")
parser.add_option(
"", "--image-file-path", dest="image_file_path", type="string", default='/tmp/noaa.png',
help="Set image_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]")
@ -209,9 +233,6 @@ def argument_parser():
parser.add_option(
"", "--rx-sdr-device", dest="rx_sdr_device", type="string", default='usrpb200',
help="Set rx_sdr_device [default=%default]")
parser.add_option(
"", "--image-file-path", dest="image_file_path", type="string", default='/tmp/noaa.png',
help="Set image_file_path [default=%default]")
return parser
@ -219,7 +240,7 @@ def main(top_block_cls=satnogs_noaa_apt_decoder, options=None):
if options is None:
options, _ = argument_parser().parse_args()
tb = top_block_cls(doppler_correction_per_sec=options.doppler_correction_per_sec, lo_offset=options.lo_offset, ppm=options.ppm, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device, image_file_path=options.image_file_path)
tb = top_block_cls(doppler_correction_per_sec=options.doppler_correction_per_sec, image_file_path=options.image_file_path, lo_offset=options.lo_offset, ppm=options.ppm, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device)
tb.start()
tb.wait()