From 7ad09f5b14eb4c7972029428393ac974ea822f46 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sat, 27 Oct 2012 11:28:06 -0700 Subject: [PATCH] Added option for pulse matched filtering Pulse matched filtering places a boxcar filter upstream of the averager and preamble detector. The filter length is equivalent to the number of samples in one Mode S chip (0.5us). This technique enhances operation when using sample rates > 4Msps. When using --pmf, the threshold may need to be reduced a dB or two from what would have been optimal without --pmf. * rx_path.py now takes 'use_pmf', defaults to False * modes_rx has new CLI option '-p' or '--pmf' to turn on PMF * modes_gui has new checkbox on Setup tab --- apps/modes_gui | 3 ++- apps/modes_rx | 4 +++- python/rx_path.py | 18 ++++++++++++++---- res/modes_rx.ui | 19 ++++++++++++++++--- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/apps/modes_gui b/apps/modes_gui index 48368ed..5287579 100755 --- a/apps/modes_gui +++ b/apps/modes_gui @@ -242,6 +242,7 @@ class mainwindow(QtGui.QMainWindow): options["gain"] = float(self.ui.line_gain.text()) options["threshold"] = float(self.ui.line_threshold.text()) options["filename"] = str(self.ui.line_inputfile.text()) + options["pmf"] = self.ui.check_pmf.checkState() self.fg = adsb_rx_block(options, self.queue) #create top RX block self.runner = top_block_runner(self.fg) #spawn new thread to do RX @@ -423,7 +424,7 @@ class adsb_rx_block (gr.top_block): else: raise NotImplementedError - self.rx_path = air_modes.rx_path(rate, options["threshold"], queue) + self.rx_path = air_modes.rx_path(rate, options["threshold"], queue, options["pmf"]) if use_resampler: self.lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3) diff --git a/apps/modes_rx b/apps/modes_rx index ff582f3..550ffcb 100755 --- a/apps/modes_rx +++ b/apps/modes_rx @@ -110,7 +110,7 @@ class adsb_rx_block (gr.top_block): if options.output_all : pass_all = 1 - self.rx_path = air_modes.rx_path(rate, options.threshold, queue) + self.rx_path = air_modes.rx_path(rate, options.threshold, queue, options.pmf) if use_resampler: self.lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3) @@ -163,6 +163,8 @@ if __name__ == '__main__': help="FlightGear server to send aircraft data, in format host:port") parser.add_option("-d","--rtlsdr", action="store_true", default=False, help="Use RTLSDR dongle instead of UHD source") + parser.add_option("-p","--pmf", action="store_true", default=False, + help="Use pulse matched filtering") (options, args) = parser.parse_args() diff --git a/python/rx_path.py b/python/rx_path.py index 09d9a2f..63911de 100644 --- a/python/rx_path.py +++ b/python/rx_path.py @@ -24,7 +24,7 @@ import air_modes_swig class rx_path(gr.hier_block2): - def __init__(self, rate, threshold, queue): + def __init__(self, rate, threshold, queue, use_pmf=False): gr.hier_block2.__init__(self, "modes_rx_path", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0,0,0)) @@ -32,12 +32,20 @@ class rx_path(gr.hier_block2): self._rate = int(rate) self._threshold = threshold self._queue = queue + self._spc = int(rate/2e6) # Convert incoming I/Q baseband to amplitude self._demod = gr.complex_to_mag() + self._bb = self._demod + + # Pulse matched filter for 0.5us pulses + if use_pmf: + self._pmf = gr.moving_average_ff(self._spc, 1.0/self._spc, self._rate) + self.connect(self._demod, self._pmf) + self._bb = self._pmf # Establish baseline amplitude (noise, interference) - self._avg = gr.moving_average_ff(100, 1.0/100, 400) # FIXME + self._avg = gr.moving_average_ff(48*self._spc, 1.0/(48*self._spc), self._rate) # 3 preambles # Synchronize to Mode-S preamble self._sync = air_modes_swig.modes_preamble(self._rate, self._threshold) @@ -45,6 +53,8 @@ class rx_path(gr.hier_block2): # Slice Mode-S bits and send to message queue self._slicer = air_modes_swig.modes_slicer(self._rate, self._queue) - self.connect(self, self._demod, (self._sync, 0)) - self.connect(self._demod, self._avg, (self._sync, 1)) + # Wire up the flowgraph + self.connect(self, self._demod) + self.connect(self._bb, (self._sync, 0)) + self.connect(self._bb, self._avg, (self._sync, 1)) self.connect(self._sync, self._slicer) diff --git a/res/modes_rx.ui b/res/modes_rx.ui index 3fce593..335b099 100644 --- a/res/modes_rx.ui +++ b/res/modes_rx.ui @@ -85,7 +85,7 @@ - 3 + 0 @@ -103,7 +103,7 @@ 10 20 236 - 193 + 251 @@ -214,7 +214,7 @@ - 1 + 0 @@ -303,6 +303,19 @@ + + + + 10 + 200 + 221 + 22 + + + + Use Pulse Matched Filtering + +