SHARE
TWEET

fsk_demod

a guest Jun 10th, 2012 159 Never
  1. #!/usr/bin/env python
  2. """ Block to demodulate FSK via coherent PLL frequency estimation
  3.    Not exactly hardcore but it works
  4. """
  5. from gnuradio import gr, gru, blks2
  6. from gnuradio import eng_notation
  7. from gnuradio.gr import firdes
  8. from math import pi
  9. from gnuradio import digital
  10.  
  11. def euclid(numA, numB):
  12.     while (numB != 0):
  13.         numRem = (numA % numB)
  14.         numA = numB
  15.         numB = numRem
  16.  
  17.     return numA
  18.  
  19.  
  20. class fsk_demod(gr.hier_block2):
  21.     __module__ = __name__
  22.  
  23.     def __init__(self, options):
  24.         gr.hier_block2.__init__(self, 'fsk_demod', gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_char))
  25.         self._syms_per_sec = options.syms_per_sec
  26.         self._samples_per_second = options.samples_per_second
  27.         self._gain_mu = options.gain_mu
  28.         self._mu = options.mu
  29.         self._omega_relative_limit = options.omega_relative_limit
  30.         self._freqoffset = options.offset
  31.         self._filtdecim = 1
  32.         self._clockrec_oversample = 10
  33.         self._downsampletaps = gr.firdes.low_pass(1, self._samples_per_second, 10000, 1000, firdes.WIN_HANN)
  34.         self._decim = int((self._samples_per_second / (self._syms_per_sec * self._clockrec_oversample)))
  35.         self._demod_sample_rate = int((self._samples_per_second / self._decim))
  36.         print ('Demodulator decimation: %i' % (self._decim))
  37.         print ('Demodulator output sample rate: %i' % self._demod_sample_rate)
  38.         self._downsample = gr.freq_xlating_fir_filter_ccc(self._decim, self._downsampletaps, self._freqoffset, self._samples_per_second)
  39.         self._quad_demod = gr.quadrature_demod_cf(5.7000000000000002)
  40.         self._lpfcoeffs = gr.firdes.low_pass(1000, self._demod_sample_rate, self._syms_per_sec, 100, firdes.WIN_HANN)
  41.         self._lpf = gr.fir_filter_fff(self._filtdecim, self._lpfcoeffs)
  42.         print ('Samples per symbol: %f' % ((self._demod_sample_rate / self._syms_per_sec)))
  43.         self._softbits = digital.clock_recovery_mm_ff(((float(self._samples_per_second) / self._decim) / self._syms_per_sec), ((0.25 * self._gain_mu) * self._gain_mu), self._mu, self._gain_mu, self._omega_relative_limit)
  44.         self._slicer = digital.binary_slicer_fb()
  45.         self.connect(self, self._downsample, self._quad_demod, self._softbits, self._slicer, self)
RAW Paste Data
Top