0% found this document useful (0 votes)
87 views12 pages

Narrowband FM Transmitter Script

This document describes a Python script that implements a narrowband FM transmitter and receiver using a USRP radio. It contains the code to define the transmitter and receiver signal paths, including sample rate conversions, filtering, and gain/volume control. The transmitter path modulates an audio input to an FM signal, filters it, amplifies it, and sends it to the USRP DAC. The receiver path receives the signal from the USRP ADC, filters it, downconverts and decimates it, and outputs the demodulated audio.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views12 pages

Narrowband FM Transmitter Script

This document describes a Python script that implements a narrowband FM transmitter and receiver using a USRP radio. It contains the code to define the transmitter and receiver signal paths, including sample rate conversions, filtering, and gain/volume control. The transmitter path modulates an audio input to an FM signal, filters it, amplifies it, and sends it to the USRP DAC. The receiver path receives the signal from the USRP ADC, filters it, downconverts and decimates it, and outputs the demodulated audio.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Usrp_nbfm_ppt.

py
Narrowband FM Transmitter
Basic GRC layout of NBFM Transmitter with sine wave
signal source.
class transmit_path(gr.hier_block2):
def __init__(self, subdev_spec, audio_input):
gr.hier_block2.__init__(self, "transmit_path",
gr.io_signature(0, 0, 0), # Input signature
gr.io_signature(0, 0, 0)) # Output signature

self.u = usrp.sink_c ()

dac_rate = self.u.dac_rate();
self.if_rate = 320e3 # 320 kS/s
self.usrp_interp = int(dac_rate // self.if_rate)
self.u.set_interp_rate(self.usrp_interp)
self.sw_interp = 10
self.audio_rate = self.if_rate // self.sw_interp # 32 kS/s

self.audio_gain = 10
self.normal_gain = 32000
lpf = gr.firdes.low_pass (1, # gain
self.audio_rate, # sampling rate
3800, # low pass cutoff freq
300, # width of trans. band
gr.firdes.WIN_HANN) # filter type

hpf = gr.firdes.high_pass (1, # gain


self.audio_rate, # sampling rate
325, # low pass cutoff freq
50, # width of trans. band
gr.firdes.WIN_HANN) # filter type
self.connect(self.audio, self.audio_amp, self.audio_filt,
(self.add_pl,0), self.fmtx, self.amp, self.u)

self.set_gain(self.subdev.gain_range()[1]) # set max Tx gain


def set_freq(self, target_freq):
r = self.u.tune(self.subdev._which, self.subdev, target_freq)
if r:
# Use residual_freq in s/w freq translator
return True

return False

def set_gain(self, gain):


self.gain = gain
self.subdev.set_gain(gain)
def __init__(self, subdev_spec, gain, audio_output):
gr.hier_block2.__init__(self, "receive_path",

gr.io_signature(0, 0, 0), # Input signature

gr.io_signature(0, 0, 0)) # Output signature

self.u = usrp.source_c ()
adc_rate = self.u.adc_rate()

self.if_rate = 256e3 # 256 kS/s


usrp_decim = int(adc_rate // self.if_rate)
if_decim = 4
self.u.set_decim_rate(usrp_decim)
self.quad_rate = self.if_rate // if_decim # 64 kS/s
audio_decim = 2
audio_rate = self.quad_rate // audio_decim # 32 kS/s
chan_coeffs = gr.firdes.low_pass (1.0, # gain

self.if_rate, # sampling rate

13e3, # low pass cutoff freq

4e3, # width of trans. band

gr.firdes.WIN_HANN) # filter type


def volume_range(self):
return (-20.0, 0.0, 0.5)

def set_volume (self, vol):


g = self.volume_range()
self.volume = max(g[0], min(g[1], vol))
self._update_audio_gain()

def set_enable(self, enable):


self.enabled = enable
self._update_audio_gain()

def _update_audio_gain(self):
if self.enabled:
self._audio_gain.set_k(10**(self.volume/10))
else:
self._audio_gain.set_k(0)
def set_squelch(self, threshold):
print "SQL =", threshold
self.squelch.set_threshold(threshold)

def threshold(self):
return self.squelch.threshold()

def set_freq(self, target_freq):


"""
Set the center frequency we're interested in.

if __name__ == '__main__':
main()

You might also like