lab system overview : usrp – universal software radio ... · flowgraph models in python...

14
TSKS01 Digital Communication Lecture 5 Software Defined Radio Mikael Olofsson Department of EE (ISY) Div. of Communication Systems Outline of the Lecture Introduction to software defined radio Lab system overview My first impressions Abstraction layers The hardware – USRP The software – GNU radio Connecting stuff Running stuff Introduction to Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 2 Introduction to SDR Idea: As much as possible in software – Provides flexibility Wide-band sampling – Can be a problem. Vision: Flexible radio equipment, easy updates. The industry is interested in SDR. 2011-09-20 TSKS01 Digital Communication - Lecture 5 3 Lab System Overview : USRP – Universal Software Radio Peripheral Made by Ettus Research Mostly open-source design Suitable for prototyping Used for Software Defined Radio research Normal PC used for signal processing USB interface to PC Programmable FPGA for base-band manipulations Fixed replaceable RF frontends 2011-09-20 TSKS01 Digital Communication - Lecture 5 4

Upload: others

Post on 12-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

TS

KS

01

Dig

ita

l C

om

mu

nic

atio

n

Le

ctu

re5

Soft

ware

Defined

Radio

Mik

ael O

lofs

son

Depart

me

nt

of

EE

(IS

Y)

Div

. of

Com

mun

icatio

n S

yste

ms

Outlin

eof

the L

ectu

re

In

troduction

tosoft

ware

defined

radio

L

ab

syste

m o

ve

rvie

w

M

yfirs

tim

pre

ssio

ns

A

bstr

actio

nla

ye

rs

T

he h

ard

ware

–U

SR

P

T

he s

oft

ware

–G

NU

radio

C

on

ne

ctin

gstu

ff

R

un

nin

gstu

ff

In

troduction

toP

yth

on

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

2

Intr

oduction

toS

DR

Id

ea

: A

s m

uch

as p

ossib

lein

soft

ware

–P

rovid

es

flexib

ility

W

ide-b

and

sam

plin

g –

Can

be a

pro

ble

m.

V

isio

n:

Fle

xib

le r

adio

equip

ment,

easy

update

s.

T

he industr

yis

inte

reste

din

SD

R.

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

3

Lab S

yste

m O

verv

iew

: U

SR

P

–U

niv

ers

al S

oft

ware

Radio

Periphera

l

M

ade b

y E

ttus

Researc

h

M

ostly o

pen-s

ourc

e d

esig

n

S

uitable

for

pro

toty

pin

g

U

sed f

or

Soft

ware

Defined R

adio

researc

h

N

orm

al P

C u

sed f

or

sig

nal pro

cessin

g

U

SB

inte

rface to P

C

P

rogra

mm

able

FP

GA

for

base

-band m

anip

ula

tions

F

ixed r

epla

ceable

RF

fro

nte

nds

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

4

Page 2: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

Lab S

yste

m O

verv

iew

: G

NU

Radio

O

pen-s

ourc

e s

oft

ware

fra

mew

ork

for

SD

R

R

uns o

n s

tandard

Lin

ux/W

indow

s c

om

pute

rs

F

low

gra

phs

define s

ignal pro

cessin

g c

hain

s

P

rim

itiv

e b

locks w

ritt

en in C

++

F

low

gra

ph

models

in P

yth

on

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

5

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

6

Overv

iew

: In

tera

ction

GN

U-R

adio

code

Softw

are

on h

ost

com

pute

r

US

RP

moth

erb

oard

Pro

gra

mm

able

dig

ital hard

ware

Fle

xib

ility

: D

o a

s m

uch

of

the

sig

na

l p

roce

ssin

ga

s p

ossib

lein

so

ftw

are

.

Signal

generation

Settings

Signal

processin

g

D/A

Interpolating

filters

A/D

Decim

ating

filters

MUX

A/D

MUX

D/A

128 M

S/s

64 MS/s

USB

Daughte

r board

s

Manually

sele

cta

ble

analo

g h

ard

ware

Initial sig

nal

manipulation

Furth

er signal

manipulation

Furth

er signal

manipulation

Initial sig

nal

manipulation

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

7

First Im

pre

ssio

ns

Yik

es!!

Docum

enta

tio

n?

Tuto

rials

?

VH

DL

C+

+

SW

IGP

yth

on

Hard

ware

US

B

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

8

Abstr

action L

ayers

US

RP

Ho

st co

mp

ute

r

Python co

deConnecting blocks

SWIG

Glue between P

ython and C

++

C++ m

odules

Definition of blocks

VHDL co

de on FPGA

Programm

able filters

Hardware

Electrical signals

Page 3: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

9

The U

SR

P –

Fro

nt P

anel

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

10

The U

SR

P –

Moth

er

Board

FP

GA

Connecto

r to

Tx

daughte

rboard

A

A/D

and D

/A

convert

ers

Connecto

r to

Rx

daughte

rboard

AC

onnecto

r to

Tx

daughte

rboard

B

A/D

and D

/A

convert

ers

Connecto

r to

Rx

daughte

rboard

B

US

B

inte

rface

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

11

US

RP

–M

oth

er

Board

Functionalit

y

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

12

US

RP

–M

oth

er

Board

Blo

ck D

iagra

m

Page 4: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

The U

SR

P –

US

B I

nte

rface

U

SB

capabili

ties

U

SB

2.0

: 4

80

Mb

it/s

F

PG

A f

irm

wa

re: 3

2 M

B/s

(=

25

6 M

bit/s

) u

se

ful d

ata

ra

te

3

2 b

it c

om

ple

x s

am

ple

s (

16

bits e

ach

fo

r re

al/im

ag

)

L

imit: 8

MS

/s (

co

mb

ine

d fo

r a

ll tx

/rx

str

ea

ms o

n o

ne

co

mp

ute

r)

U

SB

tra

nsm

issio

n o

rder:

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

13

I0Q

0I1

Q1

I0Q

0I1

Q1

16 b

its

16 b

its

16 b

its

16 b

its

16 b

its

16 b

its

16 b

its

16 b

its

The U

SR

P –

Daughte

r B

oard

s 1

(2)

B

ase-b

and b

oard

s: B

asic

TX

/Basic

RX

, LF

TX

/LF

RX

B

an

dw

idth

: 2

50

MH

z (

Ba

sic

), 3

0 M

Hz (

LF

)

C

an

no

t co

nn

ect d

ire

ctly to

an

ten

na

W

BX

-W

ide

-band t

ransceiv

er

5

0 M

Hz –

2.2

GH

z

R

ela

tive

ly p

oo

r p

erf

orm

an

ce

T

VR

X -

50 –

860 M

Hz r

eceiv

er

B

an

dw

idth

: 6

MH

z

S

uita

ble

fo

r re

ce

ivin

g T

V s

ign

als

R

FX

-series -

Genera

l fu

ll-duple

x t

ransceiv

ers

B

an

dw

idth

: 3

0 M

Hz

B

an

ds: 4

00

–5

00

MH

z, 7

50

–1

05

0 M

Hz, 1

15

0–1

45

0M

Hz,

1.5

–2

.1 G

Hz,

2.3

–2

.9 G

Hz

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

14

Use

din

la

b.

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

15

The U

SR

P –

Daughte

r B

oard

s 2

(2)

LF

TX

LF

RX

RF

X-2

40

0

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

16

GN

U R

adio

–S

oft

ware

Layers

Pyth

on

Co

nfig

& U

I

SW

IGS

WIG

SW

IGG

lue

Da

ta flo

w

Sig

na

l

Pro

ce

ssin

g

Prim

itiv

es

Ha

rdw

are

US

RP

US

RP

C+

+C

++

C+

+

Bu

ffe

rso

n a

ll b

lock o

utp

uts

Page 5: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

17

GN

U R

adio

–F

low

gra

phs

Co

mp

lex

sym

bo

ls

Data

sourc

eF

ram

er

Err

or

contr

ol

Modula

tor

Bit

mapper

US

RP

Da

ta typ

es

mu

st m

atc

h in

ea

ch

co

nn

ectio

n.

Bits

Filt

er

Co

mp

lex

sa

mp

les

Da

ta typ

es

ma

yva

rya

lon

ga

flo

wg

rap

h.

from

gnuradioimportgr

from

gnuradioimportaudio

classmy_top_block(gr.top_block):

def__init__(self):

gr.top_block.__init__(self)

sample_rate= 48000

ampl= 0.1

src0 = gr.sig_source_f(sample_rate,

gr.GR_SIN_WAVE, 350, ampl)

src1 = gr.sig_source_f(sample_rate,

gr.GR_SIN_WAVE, 440, ampl)

dst=audio.sink(sample_rate)

self.connect(src0, (dst, 0))

self.connect(src1, (dst, 1))

tb=

my_top_block()

tb.run()

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

18

GN

U R

adio

–H

ello

World!

gr.sig

_sourc

e_f

gr.sig

_sourc

e_f

audio

.sin

k

GN

U R

adio

–B

lock N

am

ing C

onvention

B

lock n

am

es: lib

.blo

ck_suffix

lib

is th

e lib

rary

:

gr

for

most

prim

itiv

e s

ignal pro

cessin

g b

locks

blks2

for

hig

h-level sig

nal pro

cessin

g b

locks

usrp

for

US

RP

inte

rfacin

g b

locks

audio

for

audio

sourc

es a

nd s

inks

qtgui

for

GU

I lib

rary

(re

latively

bare

)wxgui

for

old

GU

I lib

rary

Pro

jects

usually

use their o

wn lib

rary

su

ffix

de

term

ine

s p

ort

typ

es

bfo

r byte

, s

for

16-b

it int,i

for

32-b

it int,f

for

32-b

it f

loat, c

for

64-b

it c

om

ple

x

xfo

r sourc

es a

nd s

inks

xx

for

two-p

ort

blo

cks

xxx

for

para

mete

rized b

locks

(e.g

. ccf

for

FIR

filt

er

with c

om

ple

x d

ata

and f

loat

coeffic

ients

)vx,vxx

for

blo

cks w

ith v

ecto

r port

s

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

19

GN

U R

adio

–S

om

e U

sefu

l B

locks

gr.noise_source_f

:

Ge

ne

rate

s r

an

do

m flo

at sa

mp

les w

ith

sp

ecifie

d d

istr

ibu

tio

n.

gr.add_cc

:

Ad

ds tw

o s

tre

am

s o

f co

mp

lex s

am

ple

s.

gr.nlog10_ff

:

Co

mp

ute

s d

B o

f a

str

ea

m o

f flo

ats

.

gr.fir_filter_ccc

:

FIR

filt

er

with

co

mp

lex in

pu

t, o

utp

ut a

nd

co

effic

ien

ts.

audio.source

:

Str

ea

m o

f flo

ats

fro

m lin

e-in

/mic

.

usrp.sink_c

:

US

RP

sin

k fo

r co

mp

lex s

tre

am

.

qtgui.sink_c

:

GU

I e

lem

en

t w

ith

oscill

osco

pe

, F

FT

an

d c

on

ste

llatio

n d

iag

ram

.

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

20

Page 6: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

21

GN

U R

adio

–N

este

d B

locks

Gr.

hie

r_blo

ck2

Blo

ck1

Blo

ck2

Blo

ck3

Blo

ck4

classmy_hier_block(gr.hier_block2):

def__init__(self):

gr.hier_block2.__init__(self,”my_hier_block”,

gr.io_signature(1, 1, gr.sizeof_char),

gr.io_signature(1, 1, gr.sizeof_gr_complex)

)

# Block definitions

self.connect(self, ...)

self.connect(..., self)

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

22

GN

U R

adio

–C

onnecting B

locks

Blo

ck1

Blo

ck2

Blo

ck3

self.connect(Block1, Block2)

self.connect(Block1, Block3)

Blo

ck1

Blo

ck2

Blo

ck3

self.connect(Block1, Block2, Block3)

Re

str

ictio

n:B

oth

Blo

ck2

an

d B

lock3

mu

st co

nsu

me

the

da

ta.

If B

lock2

do

es

no

t, th

en

Blo

ck3

will

sta

ll.

GN

U R

adio

–R

un-T

ime B

ehavio

ur

H

eavily

thre

aded

E

ach

blo

ck r

un

s in

se

pa

rate

thre

ad

M

ost b

locks h

ave

th

rea

d-

sa

fe c

on

fig

ura

tio

n fu

nctio

ns

S

tart

ing a

flo

w g

raph:

gr.top_block.run()

:

Sp

aw

ns th

rea

ds, w

aits fo

r

co

mp

letio

n

gr.top_block.start()

:

Sp

aw

ns th

rea

ds a

nd

re

turn

s

S

toppin

g it:

gr.top_block.stop()

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

23

from

gnuradioimportgr

from

gnuradioimportaudio

classmy_top_block(gr.top_block):

def__init__(self):

gr.top_block.__init__(self)

self.src=

gr.sig_source_f(48000,

gr.GR_SIN_WAVE, 350, 0.1)

self.dst=

audio.sink(48000)

self.connect(self.src0,self.dst)

tb=

my_top_block()

tb.start()

f = 440

whilef>0:

c = raw_input(”Enterfrequency: ”)

f = float(c)

tb.src.set_frequency(f)

tb.stop()

Pyth

on

P

yth

on

is

Afu

ll-blo

wn

hig

h-levelpro

gra

mm

ing

language

Half-c

om

pile

d,

half-inte

rpre

ted

P

yth

on

support

s

Obje

ct-

oriente

dpro

gra

mm

ing

Pro

cedura

lpro

gra

mm

ing

Functionalpro

gra

mm

ing

(to

som

eexte

nt)

Inte

ractive

testing

ofcode

P

yth

on

is u

sed

for

Scripting

Web-d

evelo

pm

ent

Full-

blo

wn

com

pute

r applic

ations

with

GU

Isand w

hat-

not.

P

yth

on

is u

sed

by

Google

, Y

ouT

ube,

NA

SA

, D

isney,

Hubble

, C

om

mS

ys,

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

24

Page 7: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

25

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

26

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

27

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

28

Page 8: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

29

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

30

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

31

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

32

Page 9: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

33

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

34

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

35

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

36

Page 10: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

37

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

38

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

39

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

40

Page 11: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

41

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

42

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

43

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

44

Page 12: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

45

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

46

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

47

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

48

Page 13: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

49

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

50

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

51

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

52

Page 14: Lab System Overview : USRP – Universal Software Radio ... · Flowgraph models in Python 2011-09-20 TSKS01 Digital Communication - Lecture 5 5 Overview: Interaction Software on host

2011-0

9-2

0T

SK

S01 D

igital C

om

munic

ation -

Lectu

re 5

53

ww

w.liu

.se