discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] bpsk Simulation


From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] bpsk Simulation
Date: Thu, 11 Mar 2010 10:43:04 -0500

On Thu, Mar 11, 2010 at 4:09 AM, Axel Belliard <address@hidden> wrote:
> Hi,
>
> I'm new to gnu radio. To get familiar with this project, I'm trying to
> simulate a dbpsk link.
>
> My flow graph look like this :
> stream of bits => Modulation => frequency up translation => Noisy channel
> => frequency down translation => Demodulation
>
> But, there is something going wrong!! If the input stream looks like this
> : 0 0 1 1 0 0 1 1 0 0 1 1..... the output will be ( after Costa's loop and
> MM are stabilized )  : 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1......
>  I looked for an undesired decimation, but didn't find any. Do you Have
> any idea of what is going wrong?
>
> Axel

This is a bit confusing, but it makes sense in the way we meant for
the digital modulators to work. The problem is that you are trying to
put in "bits" into the modulator, which actually takes a "packet"
stream of bits. In other words, when you think you are putting in the
bits "0 0 1 1," you are actually telling it that you are putting in
the bytes "0 0 1 1" that gets unpacked into the bit stream "0 0 0 0 0
0 0 0, 0 0 0 0 0 0 0 0, 0 0 0 0 0 0 0 1, 0 0 0 0 0 0 0 1" or "0x00
0x00 0x01 0x01".

What you want to put in as the source is a vector of "0x33" instead.
You can also use the gr.unpacked_to_packed_bb on the demod side to
repack the bits. I've edited your code below to show how to do this.
Now, when you do this, you're still going to see some random stuff
going on in the output stream for the first few symbols. These garbage
bits are due to the filters' group delays.

One final thought. You're doing a frequency shift operation on the
complex baseband signal and then almost immediately downconverting it.
This doesn't really do anything of any consequence to your simulation
except require you to use a larger sampling rate than really required.
If you want to test frequency offset errors, you can use the features
in the channel model that we have (blks2.channel_model), which takes
in a noise voltage, frequency offset, timing offset, and a vector of
taps to simulate multipath.


> My code :
> class my_top_block(gr.top_block):
>        def __init__(self):
>                gr.top_block.__init__(self)
>                fg = gr.flow_graph()
>
>                sps = 8
>                symbol_rate = 1625000.0 / 6.0
>                sample_rate = sps * symbol_rate
>                p_size = 1024
>                lo_freq = 7.5e5
>                lp_cutoff = 2.5e5
>                lp_tw = 5e5
>                noise_mag = 0.0
>                #Source

                  N = <something>
                  self.src_data = N*[0x33, ] # make an N-long vector
with 0x33 in every element

>                self.src0 = gr.vector_source_b (self.src_data)
>                ######
>
>                ###Modulation####
>                self.objMod = dbpsk.dbpsk_mod(sps,0.35,False,False,False)
>                #################
>
>                ### Canal########
>                # Mix to IF
>                self.lo = gr.sig_source_c(sample_rate, gr.GR_SIN_WAVE, 
> lo_freq,1.0, 0)
>                self.mixer = gr.multiply_cc()
>                self.connect(self.lo, (self.mixer, 1))
>                # Simulate noise in the channel
>                self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_mag)
>                self.air_noise = gr.add_cc()
>                self.connect(self.noise, (self.air_noise, 1))
>                # Mix to baseband
>                self.chan_taps = gr.firdes.low_pass(1.0, sample_rate, 
> lp_cutoff, lp_tw,
> gr.firdes.WIN_HAMMING)
>                self.chan_filter = gr.freq_xlating_fir_filter_ccc(1,
> self.chan_taps,-lo_freq, sample_rate)
>                ###################
>
>                ### Demodulation######
>                self.objDeMod=dbpsk.dbpsk_demod(sps,0.35)

                 self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

>                ######################
>
>                ######Connection des blocs#####

                self.connect(self.src0,self.objMod, self.mixer, self.air_noise,
 self.chan_filter, self.objDeMod, self.pack)

>                #####################
>
>        ################# Observation entree/sortie########
>                self.sink1 = gr.vector_sink_b()

                  self.connect(self.pack, ,self.sink1)

>                self.sink2 = gr.vector_sink_b()
>                self.connect(self.src0,self.sink2)
>
>        def print_data(self):
>                print "demod: ",self.sink1.data()
>                print len(self.sink1.data())
>                print "check: ",self.sink2.data()
>                print len(self.sink2.data())
>         ################################################
> if __name__ == '__main__':
>        try:
>                tb=my_top_block()
>                tb.run()
>                tb.print_data()
>        except KeyboardInterrupt:
>                pass
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]