Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-examples / python / digital-bert / transmit_path.py
1 #
2 # Copyright 2008 Free Software Foundation, Inc.
3 #
4 # This file is part of GNU Radio
5 #
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10 #
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
20 #
21
22 from gnuradio import gr
23 from math import pi, log10
24 import cmath
25
26 class transmit_path(gr.hier_block2):
27     """
28     This transmits a BERT sequence of bits using filtered BPSK and
29     outputs the complex baseband waveform.
30     """
31     def __init__(self,
32                  sps,          # Samples per symbol
33                  excess_bw,    # RRC filter excess bandwidth (typically 0.35-0.5)
34                  amplitude     # DAC output level, 0-32767, typically 2000-8000
35                  ):
36
37         gr.hier_block2.__init__(self, "transmit_path",
38                                 gr.io_signature(0, 0, 0),                    # Input signature
39                                 gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
40
41         # Create BERT data bit stream   
42         self._bits = gr.vector_source_b([1,], True)      # Infinite stream of ones
43         self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler
44
45         # Map to constellation
46         self._constellation = [-1+0j, 1+0j]
47         self._mapper = gr.chunks_to_symbols_bc(self._constellation)     
48
49         # Create RRC with specified excess bandwidth
50         taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
51                                             sps,            # Sampling rate
52                                             1.0,            # Symbol rate
53                                             excess_bw,      # Roll-off factor
54                                             11*sps)         # Number of taps
55
56         self._rrc = gr.interp_fir_filter_ccf(sps,           # Interpolation rate
57                                              taps)          # FIR taps
58
59         # Wire block inputs and outputs
60         self.connect(self._bits, self._scrambler, self._mapper, self._rrc, self)
61