BPSK modulation

Hello im i student of engineering telecommunication and im try to build
a
bpsk modulation, doing the modulation and saving in a audio.dat
(computer
to computer without usrp), thus the demodulation that obtain have a lot
of
noise, very very bad S/N,
the code …

//////////////Modulator
Bpsk///////////////////////////////////////////////////////////////////
class bpsk_mod(gr.hier_block):
def init(self, fg, spb, excess_bw, gray_code=True, verbose=True,
debug=False):
“”"
self.fg = fg
#self.spb = spb
self.spb= 48e3
self.excess_bw = excess_bw #factor roll-off

    if not isinstance(spb, int) or spb < 2:
        raise TypeError, ("sbp must be an integer >= 2, is %d" % 

spb)

    arity = pow(2,self.bits_per_baud())

    # turn bytes into k-bit vectors
    self.bytes2chunks = \
      gr.packed_to_unpacked_bb(self.bits_per_baud(), 

gr.GR_MSB_FIRST)

    self.chunks2symbols =

gr.chunks_to_symbols_bc(psk.constellation[arity])

    ntaps = 4 #
    # pulse shaping filter

self.rrc_taps = gr.firdes.root_raised_cosine(
2, # gain (spb since we’re interpolating by spb)
self.spb, # sampling rate
8, # symbol rate
self.excess_bw, # (roll-off factor)
ntaps)

self.rrc_filter = gr.interp_fir_filter_ccf(2, self.rrc_taps)

Connect and Initialize base class

    self.fg.connect(self.bytes2chunks,self.chunks2symbols,

self.rrc_filter)
gr.hier_block.init(self, self.fg, self.bytes2chunks,
self.rrc_filter)

//////////////////Demodulator_bpsk//////////////////////////////////////////////////////////////////////////////////////////////

class bpsk_demod__coherent_detection_of_psk(gr.hier_block):
def init(self, fg, spb=2, excess_bw=0.2, costas_alpha=0.005,
gain_mu=0.05, mu=0.5,
gray_code=True, verbose=True, debug=False):

    self.fg = fg
    self.spb = spb
    self.excess_bw = excess_bw
    self.costas_alpha = costas_alpha
    self.gain_mu = gain_mu

    if spb < 2:
        raise TypeError, "sbp must be >= 2"

    arity = pow(2,self.bits_per_baud())

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ºº
# Automatic gain control

    self.preamp = gr.multiply_const_cc(1e-4)
    #self.fg.connect(self.preamp, gr.file_sink(gr.sizeof_gr_complex,

“preamp.dat”))
self.agc = gr.agc_cc(1e-3, 1,1.0)

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ºº
# Costas loop (carrier tracking)
costas_order = 2
self.costas_alpha *= 15 # 2nd order loop needs more gain
beta = .25 * costas_alpha * costas_alpha

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ºº
self.costas_loop = gr.costas_loop_cc(self.costas_alpha, beta,
0.05,
-0.05, costas_order)

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ºº
self.fg.connect(self.costas_loop,
gr.file_sink(gr.sizeof_gr_complex,
“costas.dat”))

    # RRC data filter
    ntaps = 11*(2)
    self.rrc_taps = gr.firdes.root_raised_cosine(
        1,                # gain
        48000,                # sampling rate
        1,                # symbol rate
        self.excess_bw,     # excess bandwidth (roll-off factor)
        ntaps)

    self.rrc_filter=gr.fir_filter_ccf(5, self.rrc_taps)
    self.fg.connect(self.rrc_filter,gr.file_sink(gr.sizeof_gr_complex,

“rrc.dat”))

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# symbol clock recovery
omega = spb #=2
gain_omega = 0.25 * gain_mu * gain_mu #gain_mu =0.05
omega_rel_limit = 1
mu = 0.05
self.gain_mu = 1
self.clock_recovery=gr.clock_recovery_mm_cc(omega, gain_omega,
mu,
self.gain_mu, omega_rel_limit)

    # find closest constellation point
    #rot = .707 + .707j
    rot = 1
    rotated_const = map(lambda pt: pt * rot, 

psk.constellation[arity])

    self.slicer = gr.constellation_decoder_cb(rotated_const,

range(arity))
self.gray_decoder = gr.map_bb(psk.gray_to_binary[arity])

self.unpack=gr.unpacked_to_packed_bb(self.bits_per_baud(),gr.GR_LSB_FIRST)

    # Connect and Initialize base class
    self.fg.connect(self.costas_loop, self.rrc_filter, \
                    self.clock_recovery, self.slicer, 

self.gray_decoder,
self.unpack)
gr.hier_block.init(self, self.fg, self.costas_loop,
self.unpack)

If my audio.dat sample is 48k in modulation:
The RRC sample rate = 48k ? and simbol rate is the bits of sound card
output
(16 bits)??
and wha is the size on ntaps ??
and the RRC in the demodulator is the same params than in the
modulator?

the code it is rigth?? tanks


Grandes éxitos, superhéroes, imitaciones, cine y TV…
http://es.msn.kiwee.com/ Lo mejor para tu móvil.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs