3 # Copyright 2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr
25 class channel_model(gr.hier_block):
26 def __init__(self, fg, noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=[1.0,0.0]):
27 ''' Creates a channel model that includes:
28 - AWGN noise power in terms of noise voltage
29 - A frequency offest in the channel in ratio
30 - A timing offset ratio to model clock difference (epsilon)
35 self.timing_offset = gr.fractional_interpolator_cc(0, epsilon)
37 self.multipath = gr.fir_filter_ccc(1, taps)
39 self.noise_adder = gr.add_cc()
40 self.noise = gr.noise_source_c(gr.GR_GAUSSIAN,noise_voltage)
41 self.freq_offset = gr.sig_source_c(1, gr.GR_SIN_WAVE, frequency_offset, 1.0, 0.0)
42 self.mixer_offset = gr.multiply_cc()
44 fg.connect(self.timing_offset, self.multipath)
45 fg.connect(self.multipath, (self.mixer_offset,0))
46 fg.connect(self.freq_offset,(self.mixer_offset,1))
47 fg.connect(self.mixer_offset, (self.noise_adder,1))
48 fg.connect(self.noise, (self.noise_adder,0))
50 gr.hier_block.__init__(self, fg, self.timing_offset, self.noise_adder)
52 def set_noise_voltage(noise_voltage):
53 self.noise.set_amplitude(noise_voltage)
55 def set_frequency_offset(frequency_offset):
56 self.freq_offset.set_frequency(frequency_offset)
59 self.multipath.set_taps(taps)