blob: 2f2a4abc353868627acd91b5b139bff4eb2b6bf2 [file] [log] [blame]
piotr6b78abc2014-07-08 23:29:13 +02001#!/usr/bin/env python
2##################################################
3# Gnuradio Python Flow Graph
4# Title: FCCH Bursts Detector
5# Author: Piotr Krysik
6#
7# Description: Detects positions of FCCH bursts. At the end of each
8# detected FCCH burst adds to the stream a tag with key "fcch" and value
9# which is a frequency offset estimate. The input sampling frequency
10# should be integer multiply of GSM GMKS symbol rate - 1625000/6 Hz.
11##################################################
12
13from gnuradio import blocks
14from gnuradio import gr
15from gnuradio.filter import firdes
ptrkrysik3be74a72014-12-13 10:11:00 +010016import grgsm
piotr6b78abc2014-07-08 23:29:13 +020017
Piotr Krysik8715da02016-01-06 22:21:09 +010018class fcch_detector(grgsm.hier_block):
piotr6b78abc2014-07-08 23:29:13 +020019
20 def __init__(self, OSR=4):
Piotr Krysik8715da02016-01-06 22:21:09 +010021 grgsm.hier_block.__init__(
piotr6b78abc2014-07-08 23:29:13 +020022 self, "FCCH bursts detector",
23 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
24 gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
25 )
26
27 ##################################################
28 # Parameters
29 ##################################################
30 self.OSR = OSR
31
32 ##################################################
33 # Variables
34 ##################################################
35 self.f_symb = f_symb = 1625000.0/6.0
36 self.samp_rate = samp_rate = f_symb*OSR
37
38 ##################################################
39 # Blocks
40 ##################################################
ptrkrysik3be74a72014-12-13 10:11:00 +010041 self.gsm_fcch_burst_tagger_0 = grgsm.fcch_burst_tagger(OSR)
piotr6b78abc2014-07-08 23:29:13 +020042 self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0, 0, 0)
43 self.blocks_threshold_ff_0 = blocks.threshold_ff(int((138)*samp_rate/f_symb), int((138)*samp_rate/f_symb), 0)
44 self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
45 self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int((142)*samp_rate/f_symb), 1, int(1e6))
46 self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(OSR))
47 self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
48
49 ##################################################
50 # Connections
51 ##################################################
52 self.connect((self, 0), (self.blocks_multiply_conjugate_cc_0, 0))
53 self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
54 self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_threshold_ff_0_0, 0))
55 self.connect((self, 0), (self.blocks_delay_0, 0))
56 self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_arg_0, 0))
57 self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_threshold_ff_0, 0))
58 self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_moving_average_xx_0, 0))
59 self.connect((self.gsm_fcch_burst_tagger_0, 0), (self, 0))
60 self.connect((self, 0), (self.gsm_fcch_burst_tagger_0, 0))
61 self.connect((self.blocks_threshold_ff_0, 0), (self.gsm_fcch_burst_tagger_0, 1))
62
63 def get_OSR(self):
64 return self.OSR
65
66 def set_OSR(self, OSR):
67 self.OSR = OSR
68 self.set_samp_rate(self.f_symb*self.OSR)
69 self.blocks_delay_0.set_dly(int(self.OSR))
70
71