Software Radio Network Testbed - Home - Walter Scott, Jr...

26
1 Software Radio Network Testbed First Semester Report Fall Semester 2015 -Full Report- By: Ziheng Gu Prepared to partially fulfill the requirements for ECE401 Department of Electrical and Computer Engineering Colorado State University Fort Collins, Colorado 80523 Project Advisor: Dr. Liuqing Yang Ph.D. Student Advisor: Xilin Chen Approved by: Dr. Liuqing Yang

Transcript of Software Radio Network Testbed - Home - Walter Scott, Jr...

1

Software Radio Network Testbed

First Semester Report

Fall Semester 2015

-Full Report-

By:

Ziheng Gu

Prepared to partially fulfill the requirements for ECE401

Department of Electrical and Computer Engineering

Colorado State University

Fort Collins, Colorado 80523

Project Advisor: Dr. Liuqing Yang

Ph.D. Student Advisor: Xilin Chen

Approved by: Dr. Liuqing Yang

2

Abstract

The software defined radio is a radio communication system where people use the

software in computers to define components and to implement functions into Universal Software

Radio Peripheral (USRP) hardware to achieve radio communication. Comparing with the

software defined radio, the traditional radio is a system whose component have been typically

implemented in hardware, which means one kind of hardware is mapped into one typical

traditional radio system. The software defined radio turns radio hardware problems into

software problems which are easier to solve. The basic features of software defined radio are that

software defines the transmitted waveforms and software demodulates the received waveforms.

In contrast, the traditional radio is implemented by analog circuits or a combination of analog

circuits and digital chips.

In this project, we are going to set up and design a software defined radio system to do

wireless communication and simulation. The main system is based on Orthogonal Frequency

Division Multiplexing (OFDM) technology. We design the basic OFDM system and use it to

build different types of wireless communication prototypes including underwater wireless

communication prototypes. And we will test and compare different prototypes of underwater

communication. As a device, users should use our system to transmit and receive voice, video,

picture, and other types of data in the form of OFDM symbols. Our system could switch from

different prototypes to achieve specific needs. In order to test and compare our system, we will

do BER/SER computation to get the performance of the system in a different module.

So far, we have built an FM radio system and a basic OFDM system. We built the FM

radio system in order to be familiar with software defined radio system. And the basic OFDM

system is the fundamental system of all OFDM wireless communication prototypes.

3

Table of Contents

Abstract……………………………………………………………………………………………2

Table of Contents………………………………………………………………………………….3

List of Figures………………………………………………………………………………..……4

List of Tables………………………...……………………………………………………………4

Chapter 1 – Introduction…………………………………………………………………………..5

1.1 Background……………………………………………………………………………5

1.2 Project Goal…………………………………………………………………………...7

Chapter 2 – Summary of Previous Work………………………………………………………….8

2.1 Preparatory Work……………………………………………………………………...8

2.2 FM Communication System………………………………………………………....10

2.3 OFDM Communication System……………………………………………………..13

Chapter 3 – Conclusion and Future Work……………………………………………….............16

3.1 Conclusion………………………………………………………………...................16

3.2 Future Work……………………………………………………………………….....16

References………………………………………………………………………………………..17

Appendix…………………………………………………………………………………………18

Appendix A – Abbreviations…………………………………………………………….18

Appendix B – Budgets…………………………………………………………………...18

Appendix C – Timeline…………………………………………………………………..19

Appendix D – GRC Python Code………………………………………………………..20

Acknowledgement……………………………………………………………………………….26

4

List of Figures

Figure 1 - Typical software radio block diagram………………………………………………………….6

Figure 2 - Universal Software Radio Peripheral……………………………………………………………7

Figure 3 - Demonstration figure of SDR system communication………………………………….8

Figure 4 - Single station of the SDR system………………………………………………………9

Figure 5 - Flow Graph of FM communication system…………………………………………..10

Figure 6 - The spectrum of original music……………………………………………………….11

Figure 7 - The spectrum of received music……………………………………………………...11

Figure 8 - The Spectrum of modulated FM signal at transmitter RF end………………………..12

Figure 9 - The spectrum of modulated FM signal at received RF end…………………………..12

Figure 10 - Physical layer of the OFDM transceiver…………………………………………….13

Figure 11 - The flow graph of OFDM transceiver……………………………………………….14

Figure 12 - Spectrum of OFDM………………………………………………………………….14

Figure 13 - Real time value of OFDM signal……………………………………………………15

List of Table

Table 1 - Packet loss rate Vs number of transmitted byte……………………………………….15

Table 2 – Budgets………………………………………………………………………………..18

Table 3 – Timeline……………………………………………………………………………….19

5

Chapter 1 Introduction

1.1 Background

Traditional radio system uses fixed and non-programmable hardware to process,

transmit and receive signal. Traditional radio equipment only has a single function and

cannot be changed to implement other functions. For example, if we have an 802.11a

standard Wi-Fi adapter. We cannot use the same equipment to implement 802.11b standard.

We must redesign the whole analog and digital circuit to build a device that follows the

802.11b standard. But if we use software radio, we can easily to implement a new design

just by build a new GNU Radio program. Due to these facts, we can see that traditional radio

has a higher cost than software radio. Also, it is hard to design a new radio product. For,

software radio, the cost will be lower and it is good for new design.

As for the software, GNU Radio is the software part of the software-defined radio. It

is a free and open source software development toolkit which is used to design software

defined radio. GNU Radio provides many signals processing block that we can use those

blocks to implement signal processing in the physical layer. Conceptually, blocks process

infinite steams of data flowing from their input ports to their output ports. Blocks‟ attributes

contain the number of input and output ports, and the most frequently used types are short,

float and complex. Some blocks only have input ports or output ports. Those blocks are

called sink and source. Those sources read data from a file or ADC, and those sinks write

data to a file or DAC or graphical display. Also, GNU Radio can be used with Universal

Software Radio Peripheral (USRP) to create software radio system. The block in GNU

Radio is written by C+ language. And we can use Python to connect those blocks. We also

can write custom block according to our specific need by C++ and add it into GNU Radio.

And there is a powerful tool called GNU Radio Companion (GRC) which provide a

graphical user interface to connect blocks. This tool is pretty like Simulink in Matlab. The

users can build a software-defined radio by creating a flow graph in GNU Radio Companion.

Figure 1 shows what GNU Radio does for the software defined radio system.

6

Figure 1 Typical software radio block diagram

As for the hardware, USRP is the hardware of the software radio. USRP is an

extremely flexible USB device that connects radio frequency world to our computer. The

USRP contains a small motherboard which consist four Analog to Digital Convertors and

four Digital to Analog Convertors, a million gate-field programmable gate array (FPGA) and

a programmable USB 2.0 controller. The motherboard can supports four daughterboards

which are two transmit and two receive Radio Frequency (RF) front end daughterboards.

Different daughterboards are used to handle different frequency bands. The most important

component of USRP is FPGA. The job of FPGA is general high-speed operations such as

digital up and down conversion, sampling, and interpolation. Works related to waveform

processing likes modulation and demodulation are done by CPU of the computer. Figure 2

shows the internal structure of a USRP.

7

Figure 2. Universal Software Radio Peripheral

The USRP we use in our project is USRP N210. The USRP N210 has a dual ADC up

to 100MS/s and a dual DAC up to 400 MS/s. It can operate signal from DC to 6 GHz which

is a wide frequency band compared with most other radio equipment. It also supports

multiple input multiple output (MIMO) configuration which means it works with multiple

antennas.

1.2 Project Goal

For our project, we have two USRP N210, two computers to control USRP and two

GPS disciplined clocks to provide synchronization. We are going to set up the connection

between each computer and USRP. Then we use GNU radio to implement software defined

radio communication between two USRPs. The final design goal is to implement OFDM

communication which refers to orthogonal frequency division multiplexing communication

in our system. In our final design, we require each hardware can transmit and receive

packets consisting of OFDM symbols. From the user port, the system can send and receive

text, voice and other types of files. And we will test and compare the performance of

different prototypes of underwater communication.

8

Figure 3. Demonstration figure of SDR system communication

Chapter 2 Summary of Previous Work

2.1 Preparatory Work

Because GNU Radio is a branch new thing for me, and I hadn‟t had any experience on

implementing real radio system and reading Python code, I initially wanted to learn some of

the basic principles required for this design project. I start this project in the research step.

The first step is to do research on how to set up the whole system. With regard to set up

the system, we firstly want to install GNU Radio. And the GNU Radio requires the

operating system to be Linux. We choose the most convenient and simplest Linux system-

Ubuntu. At the beginning, I didn‟t have any experience on that. I found the installing file in

Ubuntu.com and installed it. I failed several times due to different unknown problems. Then

I give up installing Ubuntu as an operating system and wanted to install it in VMware virtual

machine. I successfully installed VM virtual machine and Ubuntu in my computer. Then I

tried to install GNU Radio. Firstly, I went to the official website of the GNU Radio and

found how to install. There are two methods to install, one is “build from source”, and the

other one is “build from binary”. I firstly built from binary. This method just required to

type some command. But when I finished the installation, I found that the version built by

this method is very old. So I uninstalled it and built it from sources. Building from source is

more complicated than from binary. It required me to install much dependence for the GNU

9

Radio. Also, I needed to install USRP Hardware Drive (UHD) manually. Those processes

really took lots of time. After those steps, I completed the installation of GNU Radio.

Next, I wanted to connect my computer with USRP. I followed the instruction of USRP

and connected them. I found that the USRP can only be connected with computer by Gigabit

cable. Unfortunately, the computer I used to install GNU Radio doesn‟t have cable port. So I

ordered one internet cable to USB 2.0 converter. After I got the converter, I started to ping

the USRP device from my computer. In order to ping to the device, we need to set up the

network first. So there was one problem occurred. Setting up network required the operating

system has to have the host IP address. But I was using VMware virtual machine couldn‟t

do that. The Ubuntu in VMware cannot be a host system. So now I needed to install Ubuntu

as an operating system and reinstall GNU Radio and UHD.

I asked help from one of Dr. Yang‟s graduate students, and he helped me install

Ubuntu on my computer. Then I repeated the process of installing GNU Radio and UHD

and finished the installation.

Next, I set up the network and connected the USRP with my computer successfully.

Then I downloaded and loaded the newest firmware ware into USRP. After that, the USRP

can work properly. So far, I only set up one USRP. The other USRP hardware has some

problem due to the bad firmware. We will fix the problem as soon as possible. Now, all of

our prototypes are based on one USRP device. Figure 4 is a picture of our single-Station

software-defined radio system.

Figure 4. Single station of the SDR system

10

2.2 FM Communication System

After setting up the USRP and the computer, we used GNU Radio to design an FM

communication system. With this system, we can transmit and receive FM signal. Figure 5

shows the Flow-chart of the GNU Radio software.

Figure 5. Flow-chart of FM communication system

This FM transmitter can transmits a WAV music file to the FM receiver. The FM receiver

can display the spectrum of the music and save it as a WAV file. This FM system can only

transmit WAV music file. The brief process is explained in the following. Firstly, play the

WAV file in GNU Radio. Then, sample the music signal and modulate the signal to a high-

frequency FM signal and be transmitted at transmitter RF front end. At the receiver RF end,

the USRP source receives and samples the FM signals. Then the computer will do the

demodulation and convert the FM signal to music signal and display it. Finally, the WAV sink

will save the music signal into a WAV file.

11

In this design, we placed four FFT Sinks to detect the original music spectrum, received

music spectrum, modulated FM signal spectrum at transmitter RF end and, modulated FM

signal spectrum at received RF end.

Figure 6. The spectrum of original music

Figure 7. The spectrum of received music

12

Comparing Figures 6 and 7, we can see that there is some noise in the received signal in

addition to original music spectrum.

Figure 8. The Spectrum of modulated FM signal at transmitter RF end

Figure 9. The spectrum of modulated FM signal at received RF end

These two figures show that the spectrums of modulated FM signal at transmitter and

receiver RF ends are very similar. Overall, the FM communication system can only transmit

and receive music signal and does not have a very good performance in terms of accuracy. So

we need to find a better communication system.

13

2.3 OFDM Communication System

In order to get a better system, we choose to use OFDM technology to build our system.

OFDM is orthogonal frequency division multiplexing which is a digital communication

technology. It can transmit many narrow-band signals in parallel over orthogonal subbands.

This technology is very powerful in the wireless communication field. It is widely used LTE,

Wi-Fi, and other high-speed communication models. Figure 10 shows the physical layer of our

OFDM transceiver. From the figure, we can know that the transceiver should first modulate

many signals into a digital stream. Then insert pilots into the stream. Then do inverse fast

Fourier transform for those digital signal. Next, convert the signal from baseband to passband

and become to OFDM symbols. After that, we transmit the signal into the wireless

environment. Next, we receive the OFDM symbols and do FFT, channel estimation. Then we

demodulate and decode the digital stream to recover the transimitted signal.

Figure 10. Physical layer of the OFDM transceiver

Figure 11 shows the flow chart of our current OFDM transceiver. In the system, we

haven‟t completed the part of converting the signal from analog to digital. Our system starts at

inserting pilots to a binary stream in the transmitter part and ends at storing date into a binaary

file at the receiver part. Namely, our system can modulate and transmit digital data into OFDM,

then receive OFDM signal and demodulate the signal and recover it into digital data.

14

Figure 11. The flow graph of OFDM transceiver

We use the OFDM transceiver to transmit a repeated random digital stream. We get the

following OFDM signal in the frequency domain and time domain at RF end, respectively.

The shape of the spectrum is exactly OFDM signal. Figures 12 and 13 show the spectrum of

modulated OFDM signal and real-time values of the modulated OFDM signal.

Figure 12. Spectrum of OFDM

15

Figure 13. Real time value of OFDM signal

From the Figure 12, we can see that the spectrum is exactly a spectrum of modulated

OFDM signal which means we successfully received the OFDM signal.

Then we use a virtual sink and a virtual source to connect the transmitting and the

receiving parts. Then we transmit unrepeated random digital stream. At the same time, we

record the binary stream from random source and receiver sink. Next, we read and compare

those data by Matlab. Change the transmitted number of data and repeat those steps. We get

some results in the table. Because we used a virtual connection and there is no real channel, no

bit error occurred. But data at the tail of stream lost. This may be caused by the delay of signal

transmitting. We will correct this issue in future. From the results, we know that increasing the

number of transmitted bytes leads to decreasing in packet loss rate.

Table 1. Packet loss rate vs number of transmitted byte

Number of

Transmitted

Byte (Byte)

300 400 500 600 700 800 900 100 1M

Packet Loss

Rate(%)

36 28 23.2 20 18 16 14.7 13.6 0.016

16

Chapter 3 Conclusions and Future Work

3.1 Conclusions

Based on the previous work, I believe that I will achieve the final goal of this project. So

far, we have set up the connection between the USRP and the computer and have completed

the FM transmitter and receiver. Also, we built the basic OFDM transceiver prototype which

can transmit and receive OFDM byte data in a virtual wireless environment. And from this

project, I learned a lot about analog communication theory and digital communication theory,

especially the OFDM communication technique. Also, I am much more familiar with the

Linux operating system now compared with the beginning of the project. Moreover, I learned

lots of stuff about Python and C++ programming and how to use GNU Radio.

3.2 Future Work

So far, we have only set up one USRP and we need to set up another USRP and

implement the communication between two USRPs. Our OFDM communication system only

starts at pilots insertion at the transmitter part and end at storing binary data at the receiver part.

In the next semester, we will implement decoding part and encoding part of files. Video, voice,

picture, and other types of files can be encoded into digital data and be passed through the

OFDM system. And we did not use the real wireless channel, instead, we used a virtual source

and a virtual sink to connect the transmitting and the receiving parts. So we will connect the

system with the real wireless channel and implement channel estimation. Also, we will

implement the simulation of virtual channels in different wireless environment and implement

different wireless communication prototypes including underwater wireless communication.

After those works, we will test and compare different prototypes of wireless communication

by BER/SER computation.

17

References

[1] B. P. Lathi and Zhi Ding, Modern Digital and Analog Communication Systems,

4th Edition, Oxford University Press, 2009

[2] E. Blossom, “Exploring GNU Radio”

http://gnu.gds.tuwien.ac.at/software/gnuradio/doc/exploring-gnuradio.html

[3] GNU Radio Manual and C++ API Reference

https://gnuradio.org/doc/doxygen/page_ofdm.html

[4] M. Braun, “OFDM Packet Receivers in GNU Radio”

https://archive.fosdem.org/2014/schedule/event/tutorial_ofdm_packet_transcei

vers/attachments/slides/383/export/events/attachments/tutorial_ofdm_packet_tr

ansceivers/slides/383/MartinBraun_GNURadio_OFDM.pdf

[5] X. Cheng, M. Wen, X. Cheng, D. Duan, and L. Yang, ``Effective Mirror-

Mapping-Based Intercarrier Interference Cancellation for OFDM Underwater

Acoustic Communications,„‟ Elsevier Ad Hoc Networks, 2014.

18

Appendix A - Abbreviations

FPGA - Gate-Field Programmable Gate Array

GTC - GNU Radio Companion

MIMO - Multiple Input and Multiple Output

OFDM - Orthogonal Frequency Division Multiplexing

RF - Radio Frequency

UHD - USRP Hardware Drive

USRP - Universal Software Radio Peripheral

Appendix B- Budget

Item Price

USB2.0 Gigabit Ethernet Adapter $24

GPS Disciplined Clock $162.99

GPS Disciplined Clock $162.99

Total $349.98

19

Appendix C – Timeline

Deliverables Date

Do research on GNU Radio and USPR

hardware

9/13/15

Install Linux system and GNU Radio 9/13/15

Set up USRP hardware 10/10/15

Confirm functions and

features of the Radio system

10/10/15

Do research on FM communication system, 10/20/16

Finish the prototype of FM communication

system,

10/30/15

Do research on OFDM communication

system

11/10/15

Implement OFDM communication system

and test the performance of this system,

11/30/15

20

Appendix D – GRC Python code

OFDM Transceiver:

#!/usr/bin/env python2

##################################################

# GNU Radio Python Flow Graph

# Title: Fm Receiver

# Generated: Tue Dec 8 09:46:56 2015

##################################################

if __name__ == '__main__':

import ctypes

import sys

if sys.platform.startswith('linux'):

try:

x11 = ctypes.cdll.LoadLibrary('libX11.so')

x11.XInitThreads()

except:

print "Warning: failed to XInitThreads()"

from gnuradio import analog

from gnuradio import audio

from gnuradio import eng_notation

from gnuradio import filter

from gnuradio import gr

from gnuradio import uhd

from gnuradio import wxgui

from gnuradio.eng_option import eng_option

from gnuradio.fft import window

from gnuradio.filter import firdes

from gnuradio.wxgui import fftsink2

from gnuradio.wxgui import forms

from grc_gnuradio import wxgui as grc_wxgui

from optparse import OptionParser

import time

import wx

class FM_Receiver(grc_wxgui.top_block_gui):

def __init__(self):

grc_wxgui.top_block_gui.__init__(self, title="Fm Receiver")

_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"

self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

##################################################

# Variables

##################################################

self.samp_rate = samp_rate = 5e6

self.freq = freq = 105.7e6

##################################################

# Blocks

##################################################

self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)

21

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Spectrum")

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "1")

self.Add(self.notebook_0)

self._freq_text_box = forms.text_box(

parent=self.GetWin(),

value=self.freq,

callback=self.set_freq,

label='freq',

converter=forms.float_converter(),

)

self.Add(self._freq_text_box)

self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(

self.notebook_0.GetPage(1).GetWin(),

baseband_freq=0,

y_per_div=10,

y_divs=10,

ref_level=0,

ref_scale=2.0,

sample_rate=250e3,

fft_size=1024,

fft_rate=15,

average=False,

avg_alpha=None,

title="FFT Plot",

peak_hold=False,

)

self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win)

self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(

self.notebook_0.GetPage(0).GetWin(),

baseband_freq=freq,

y_per_div=10,

y_divs=10,

ref_level=0,

ref_scale=2.0,

sample_rate=samp_rate,

fft_size=1024,

fft_rate=15,

average=False,

avg_alpha=None,

title="FFT Plot",

peak_hold=False,

)

self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_0.win)

self.uhd_usrp_source_0 = uhd.usrp_source(

",".join(("", "")),

uhd.stream_args(

cpu_format="fc32",

channels=range(1),

),

)

self.uhd_usrp_source_0.set_samp_rate(samp_rate)

self.uhd_usrp_source_0.set_center_freq(freq, 0)

self.uhd_usrp_source_0.set_gain(15, 0)

self.uhd_usrp_source_0.set_antenna("RX2", 0)

self.uhd_usrp_source_0.set_bandwidth(freq, 0)

self.rational_resampler_xxx_0 = filter.rational_resampler_fff(

interpolation=250,

decimation=96,

taps=None,

fractional_bw=None,

)

22

self.low_pass_filter_0 = filter.fir_filter_ccf(20, firdes.low_pass(

1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76))

self.audio_sink_0 = audio.sink(48000, "", True)

self.analog_wfm_rcv_0 = analog.wfm_rcv(

quad_rate=250e3,

audio_decimation=1,

)

##################################################

# Connections

##################################################

self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))

self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))

self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))

self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))

self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))

self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0_0, 0))

def get_samp_rate(self):

return self.samp_rate

def set_samp_rate(self, samp_rate):

self.samp_rate = samp_rate

self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76))

self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)

self.wxgui_fftsink2_0_0.set_sample_rate(self.samp_rate)

def get_freq(self):

return self.freq

def set_freq(self, freq):

self.freq = freq

self._freq_text_box.set_value(self.freq)

self.uhd_usrp_source_0.set_center_freq(self.freq, 0)

self.uhd_usrp_source_0.set_bandwidth(self.freq, 0)

self.wxgui_fftsink2_0_0.set_baseband_freq(self.freq)

if __name__ == '__main__':

parser = OptionParser(option_class=eng_option, usage="%prog: [options]")

(options, args) = parser.parse_args()

tb = FM_Receiver()

tb.Start(True)

tb.Wait()

FM Transceiver

#!/usr/bin/env python2

##################################################

# GNU Radio Python Flow Graph

# Title: Fm Receiver

# Generated: Tue Dec 8 09:46:56 2015

##################################################

if __name__ == '__main__':

import ctypes

import sys

if sys.platform.startswith('linux'):

23

try:

x11 = ctypes.cdll.LoadLibrary('libX11.so')

x11.XInitThreads()

except:

print "Warning: failed to XInitThreads()"

from gnuradio import analog

from gnuradio import audio

from gnuradio import eng_notation

from gnuradio import filter

from gnuradio import gr

from gnuradio import uhd

from gnuradio import wxgui

from gnuradio.eng_option import eng_option

from gnuradio.fft import window

from gnuradio.filter import firdes

from gnuradio.wxgui import fftsink2

from gnuradio.wxgui import forms

from grc_gnuradio import wxgui as grc_wxgui

from optparse import OptionParser

import time

import wx

class FM_Receiver(grc_wxgui.top_block_gui):

def __init__(self):

grc_wxgui.top_block_gui.__init__(self, title="Fm Receiver")

_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"

self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

##################################################

# Variables

##################################################

self.samp_rate = samp_rate = 5e6

self.freq = freq = 105.7e6

##################################################

# Blocks

##################################################

self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Spectrum")

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Spectrum")

self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "1")

self.Add(self.notebook_0)

self._freq_text_box = forms.text_box(

parent=self.GetWin(),

value=self.freq,

callback=self.set_freq,

label='freq',

converter=forms.float_converter(),

)

self.Add(self._freq_text_box)

self.wxgui_fftsink2_1 = fftsink2.fft_sink_f(

self.notebook_0.GetPage(1).GetWin(),

baseband_freq=0,

y_per_div=10,

y_divs=10,

ref_level=0,

ref_scale=2.0,

sample_rate=250e3,

fft_size=1024,

24

fft_rate=15,

average=False,

avg_alpha=None,

title="FFT Plot",

peak_hold=False,

)

self.notebook_0.GetPage(1).Add(self.wxgui_fftsink2_1.win)

self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(

self.notebook_0.GetPage(0).GetWin(),

baseband_freq=freq,

y_per_div=10,

y_divs=10,

ref_level=0,

ref_scale=2.0,

sample_rate=samp_rate,

fft_size=1024,

fft_rate=15,

average=False,

avg_alpha=None,

title="FFT Plot",

peak_hold=False,

)

self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0_0.win)

self.uhd_usrp_source_0 = uhd.usrp_source(

",".join(("", "")),

uhd.stream_args(

cpu_format="fc32",

channels=range(1),

),

)

self.uhd_usrp_source_0.set_samp_rate(samp_rate)

self.uhd_usrp_source_0.set_center_freq(freq, 0)

self.uhd_usrp_source_0.set_gain(15, 0)

self.uhd_usrp_source_0.set_antenna("RX2", 0)

self.uhd_usrp_source_0.set_bandwidth(freq, 0)

self.rational_resampler_xxx_0 = filter.rational_resampler_fff(

interpolation=250,

decimation=96,

taps=None,

fractional_bw=None,

)

self.low_pass_filter_0 = filter.fir_filter_ccf(20, firdes.low_pass(

1, samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76))

self.audio_sink_0 = audio.sink(48000, "", True)

self.analog_wfm_rcv_0 = analog.wfm_rcv(

quad_rate=250e3,

audio_decimation=1,

)

##################################################

# Connections

##################################################

self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0, 0))

self.connect((self.analog_wfm_rcv_0, 0), (self.wxgui_fftsink2_1, 0))

self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))

self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))

self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))

self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0_0, 0))

def get_samp_rate(self):

return self.samp_rate

25

def set_samp_rate(self, samp_rate):

self.samp_rate = samp_rate

self.low_pass_filter_0.set_taps(firdes.low_pass(1, self.samp_rate, 100e3, 10e3, firdes.WIN_HAMMING, 6.76))

self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)

self.wxgui_fftsink2_0_0.set_sample_rate(self.samp_rate)

def get_freq(self):

return self.freq

def set_freq(self, freq):

self.freq = freq

self._freq_text_box.set_value(self.freq)

self.uhd_usrp_source_0.set_center_freq(self.freq, 0)

self.uhd_usrp_source_0.set_bandwidth(self.freq, 0)

self.wxgui_fftsink2_0_0.set_baseband_freq(self.freq)

if __name__ == '__main__':

parser = OptionParser(option_class=eng_option, usage="%prog: [options]")

(options, args) = parser.parse_args()

tb = FM_Receiver()

tb.Start(True)

tb.Wait()

26

Acknowledgements

I would like to thank my supervisor, Dr. Liuqing Yang for her great support for the project.

She has provided me many useful resources about OFDM communication system and insightful

guidance when I encounter problems.

I would like to thank my Ph.D. student advisor Xilin Cheng for guiding me to learn the

basic theory about OFDM communication and providing advice for my project.

I would like to thank Dr. Yang‟s Ph.D. student Dexin Wang and Luoyang Fang for giving

me frequent supports on this project.

I would like to thank Yu Shen for providing me many suggestions on solving system set up

problems.