Am receiver

Hello friends,

I(shijesh) made debute to USRP & GNUradio a few days back.
I have a querry as mentioned after the environment observations given
below

My environment is :
O.S :: Ubuntu 7.04 Feisty fawn
CPU :: Core2 DUO Intel
gcc :: 4.2.0
SWIG :: 1.3.31
GNU CODE VERSION :: 3.0.4

when i tried to receive AM with the program “am_rcv.py” , it didn’t
work. Later on when i went through the code i realised that, it did not
feature the option for changing the SOUND CARD RATE , so i modified
the program as shown below, but even then it was all in vain

###### program for receiving AM ########***
#!/usr/bin/env python
from gnuradio import gr, eng_notation
from gnuradio import audio
from gnuradio import usrp
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
import math
from gnuradio.wxgui import stdgui, fftsink
import wx
class am_rx_graph (stdgui.gui_flow_graph):
def init(self,frame,panel,vbox,argv):
stdgui.gui_flow_graph.init (self,frame,panel,vbox,argv)

######modified for including option for changing the sound card rate
#######

    parser=OptionParser(option_class=eng_option)
    parser.add_option("-O", "--audio-output", type="string", 

default="",
help=“pcm device name. E.g., hw:0,0 or
surround51 or /dev/dsp”)

    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.print_help()
        sys.exit(1)

    self.frame = frame
    self.panel = panel

    self.vol = 0
    self.state = "FREQ"
    self.freq = 0

###################### modification ends ######################
station = parseargs(argv[1:])
offset_freq = 30e3
IF_freq = offset_freq - station
adc_rate = 64e6
usrp_decim = 250
if_rate = adc_rate / usrp_decim # 256 kHz
if_decim = 4
demod_rate = if_rate / if_decim # 64 kHz
audio_decimation = 2
audio_rate = demod_rate / audio_decimation # 16 kHz

    # usrp is data source
    src = usrp.source_c (0, usrp_decim)
    src.set_rx_freq (0, IF_freq)
    actual_IF_freq =src.rx_freq(0)
    actual_offset = actual_IF_freq + station

    #print actual_IF_freq
    #print actual_offset

    src.set_pga(0,20)
    # sound card as final sink
    audio_sink = audio.sink (int (audio_rate), options.audio_output, 

False)

    channel_coeffs = \
                   gr.firdes.low_pass (1.0,           # gain
                                       if_rate,   # sampling rate
                                       9e3,         # low pass 

cutoff freq
10e3, # width of
trans. band
gr.firdes.WIN_HANN)
ddc = gr.freq_xlating_fir_filter_ccf
(if_decim,channel_coeffs,-actual_offset,if_rate)
magblock = gr.complex_to_mag()
volumecontrol = gr.multiply_const_ff(.003)
# Deemphasis. Is this necessary on AM?
TAU = 75e-6 # 75us in US, 50us in EUR
fftaps = [ 1 - math.exp(-1/TAU/if_rate), 0]
fbtaps= [ 0 , math.exp(-1/TAU/if_rate) ]

    deemph = gr.iir_filter_ffd(fftaps,fbtaps)
      # compute FIR filter taps for audio filter
    width_of_transition_band = audio_rate / 8
    audio_coeffs = gr.firdes.low_pass (1.0,            # gain
                                       if_rate,      # sampling rate
                                       9e3,         #audio_rate/2 - 

width_of_transition_band,
4e3, #
width_of_transition_band,
gr.firdes.WIN_HANN)

    # input: float; output: float
    audio_filter = gr.fir_filter_fff (audio_decimation, 

audio_coeffs)

    print len(channel_coeffs)
    print len(audio_coeffs)

    # now wire it all together
    self.connect (src, ddc)
    self.connect (ddc, magblock)
    self.connect (magblock, volumecontrol)
    self.connect (volumecontrol,deemph)
    self.connect (deemph,audio_filter)
    self.connect (audio_filter, (audio_sink, 0))
      if 1:
        pre_demod = fftsink.fft_sink_c (self, panel, 

title=“Pre-Demodulation”, fft_size=128, sample_rate=if_rate)
self.connect (src, pre_demod)
vbox.Add (pre_demod.win, 1, wx.EXPAND)
if 0:
post_demod = fftsink.fft_sink_c (self, panel, title=“Post
Demodulation”, fft_size=256, sample_rate=demod_rate)
self.connect (ddc, post_demod)
vbox.Add (post_demod.win, 1, wx.EXPAND)
if 0:
post_filt = fftsink.fft_sink_f (self, panel, title=“Post
Filter”, fft_size=512, sample_rate=audio_rate)
self.connect (magblock,post_filt)
vbox.Add (post_filt.win, 1, wx.EXPAND)

def parseargs (args):
nargs = len (args)
if nargs == 1:
freq1 = float (args[0]) * 1e3
else:
sys.stderr.write (‘usage: am_rcv freq1\n’)
sys.exit (1)
return freq1
if name == ‘main’:
app = stdgui.stdapp (am_rx_graph, “AM RX”)
app.MainLoop ()
############################program endss########################

I have used the following command for the execution
###############################################################
[email protected]:/home/sabu#
GNUradio/gnuradio-3.0.4/gnuradio-examples/python/usrp/am_rcv.py 1164000
-o plughw:0,0
#############################################################
I know that it is a silly question for all of u friends, but for me it
really will be worth, Please extend your helping hand.

SHIJESH AK
INDIA

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