Upload
albert-huang
View
18.120
Download
3
Embed Size (px)
Citation preview
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Introduction to Digital Signal ProcessingUsing GNU Radio
Albert Chun-Chieh HuangPyCon Taiwan 2013
May 25, 2013
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
About the Author
He is both a programmer and a communication engineer.He learned Python in 2000 and has used it extensively onimproving his workflow ever since. He has been working incommunication IC industry for more than eight years. Hisinterests include communication engineering andengineering communication, which consists of fields fromphysical layer to MAC layer as well as typesetting.
Blog: Random Notes,http://alberthuang314.blogspot.com/
LinkedIn:http://www.linkedin.com/in/alberthuang314
Email address: alberthuang314 AT gmail DOT com
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Outline
1 Introduction to SDR and GNU Radio
2 Adding a Filter in GNU Radio
3 Analyzing Filters
4 Concluding Remarks
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communicationsystem implemented (mostly) in software.
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communicationsystem implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIAi500 LTE SDR modems, etc.
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communicationsystem implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIAi500 LTE SDR modems, etc.
Background knowledge required for SDR programmer
Digital Signal Processing (the most fundamentalknowledge)ProgrammingProbability and StatisticsCommunication System
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communicationsystem implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIAi500 LTE SDR modems, etc.
Background knowledge required for SDR programmer
Digital Signal Processing (the most fundamentalknowledge)ProgrammingProbability and StatisticsCommunication System
This talk is going to illustrate how easy digital signalprocessing is! Don’t be hesitated!
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Introduction to GNU Radio
GNU Radio is a free & open-source software developmenttoolkit that provides signal processing blocks to implementsoftware radios.
Primarily written in Python with performance-criticalsignal processing components written in C++ [1].
C++ classes are wrapped by SWIG [2].
Python can be used to develop rapid prototype for SDR inan elegant and fast way.
“Install GNU Radio 3.6.2 on MacOSX 10.8.2”http://goo.gl/mJQmA
“A Glimpse into Developing Software-Defined Radio byPython” on SlideShare.net
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
GNU Radio Companion
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Top Block
1 #!/ us r / b in / env python2 from PyQt4 import Qt3 # Other impor t s a r e h i dden4 c l a s s t op b l o ck ( gr . top b l ock , Qt . QWidget ) :5 def i n i t ( s e l f ) :6 # GUI−r e l a t e d s t u f f a r e h i dden he re7 s e l f . s amp ra te = samp ra te = 160008 # q t g u i s i n k s t u f f h i dden9 s e l f . t o p l a y o u t . addWidget ( s e l f . q t g u i s i n k x
10 s e l f . a n a l o g s i g s o u r c e x 1 = ana log . s i g s o u r11 samp rate , ana l og .GR COS WAVE, 8000 ,12 s e l f . connect ( ( s e l f . a n a l o g s i g s o u r c e x 1 , 0)13 ( s e l f . a u d i o s i n k 0 , 0) )14 s e l f . connect ( ( s e l f . a n a l o g s i g s o u r c e x 1 , 0)15 ( s e l f . q t g u i s i n k x 0 , 0) )1617 i f name == ’ ma i n ’ :18 tb = top b l o ck ( )19 tb . s t a r t ( )20 tb . show ( )21 tb . s top ( )
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Adding a Simple Moving Average Filter
1 #!/ us r / b in / env python2 from gnurad i o import f i l t e r # Add t h i s l i n e i n t o t op b l o ck . p3 # Other impor t s a r e h i dden4 c l a s s t op b l o ck ( gr . top b l ock , Qt . QWidget ) :5 def i n i t ( s e l f ) :6 # GUI−r e l a t e d s t u f f a r e h i dden he re7 s e l f . s amp ra te = samp ra te = 441008 # q t g u i s i n k s t u f f h i dden9 s e l f . t o p l a y o u t . addWidget ( s e l f . q t g u i s i n k x
1011 s e l f . a n a l o g s i g s o u r c e x 1 = ana log . s i g s o u r12 # ==============================13 taps = (0 . 25 , 0 . 25 , 0 . 25 , 0 . 25 )14 s e l f . f l t = f i l t e r . f i r f i l t e r f f f (1 , taps )15 s e l f . connect ( ( s e l f . a n a l o g s i g s o u r c e x 1 , 0)16 ( s e l f . f l t , 0 ) )17 s e l f . connect ( ( s e l f . f l t , 0 ) ,18 ( s e l f . q t g u i s i n k x 0 , 0) )19 s e l f . connect ( ( s e l f . f l t , 0 ) ,20 ( s e l f . a u d i o s i n k 0 , 0) )2122 # ==============================23 #s e l f . connect ( ( s e l f . a ud i o s ou r c e 0 , 0) ,
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
What Is This Filter?!
self.flt = filter.fir filter fff(1, (0.25, 0.25, 0.25, 0.25) )
FIR filter blockInput: FloatOutput: FloatCoefficients: Float
Time domain equation:y [n] = 0.25x [n]+0.25x [n−1]+0.25x [n−2]+0.25x [n−3]
x[n]: current input sample, x[n-1] previous one inputsample, and so on...
y[n]: current output sample
It’s just adding/multiplying numbers together, right?Pretty easy, huh?
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Digital Frequency
Digital frequency is not related to real frequency (yet).
So forget about Hz right now.
Normally mapped to [0, π] or [0, 1].
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Digital Frequency: Highest
0 1 2 3 4 5 6 7 8 9 10-2
-1
0
1
2
b
b
b
b
b
b
b
b
b
b
b
Figure : π in [0, π], or 1 in [0, 1]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Digital Frequency: Lowest or DC
0 1 2 3 4 5 6 7 8 9 10-2
-1
0
1
2
b b b b b b b b b b b
Figure : 0
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Digital Frequency: Middle
0 1 2 3 4 5 6 7 8 9 10-2
-1
0
1
2
b
b
b
b
b
b
b
b
b
b
b
Figure : π/2 in [0, π], or 0.5 in [0, 1]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
How to Analyze This Filter?
Back-of-the-Envelope Method
Do fast calculation in the back of the envelopeHandy to get a feel of this filter’s frequency response
Discrete Fourier Transform (DFT)
All transformations are giving us different perspectivesDFT gives us frequency response of a filter
z Transform
Gives us more than just frequency responseAlso give us more thorough information, such as stability,etc.
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope Method
Is the filter low pass filter, high pass filter, or?
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope Method
Is the filter low pass filter, high pass filter, or?
Let’s input these coefficients into Octave to tell us...
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope Method
Is the filter low pass filter, high pass filter, or?
Let’s input these coefficients into Octave to tell us...
What if your Octave is not installed, like most ofattendees here...
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope Method
Is the filter low pass filter, high pass filter, or?
Let’s input these coefficients into Octave to tell us...
What if your Octave is not installed, like most ofattendees here...
Let’s use back-of-the-envelope method
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope Method
Is the filter low pass filter, high pass filter, or?
Let’s input these coefficients into Octave to tell us...
What if your Octave is not installed, like most ofattendees here...
Let’s use back-of-the-envelope method
Remember the filter time domain equation isy [n] = (x [n] + x [n − 1] + x [n − 2] + x [n − 3])/4
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope: Highest
0 1 2 3 4 5 6 7 8 9 10-1
0
1 b
b
b
b
b
b
b
b
b
b
b
0 1 2 3 4 5 6 7 8 9 10-1
0
1
b b b b b b b b b b b
Figure : π in [0, π], or 1 in [0, 1]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope: Middle
0 1 2 3 4 5 6 7 8 9 10-1
0
1 b
b
b
b
b
b
b
b
b
b
b
0 1 2 3 4 5 6 7 8 9 10-1
0
1
b b b b b b b b b b b
Figure : π/2 in [0, π], or 0.5 in [0, 1]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope: Lowest or DC
0 1 2 3 4 5 6 7 8 9 10-1
0
1 b b b b b b b b b b b
0 1 2 3 4 5 6 7 8 9 10-1
0
1 b b b b b b b b b b b
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Back-of-the-Envelope: Frequency Response
0 10
1 b
b b
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Complete Frequency Response
0 0.5 1 1.5 2 2.5 3 3.5−60
−50
−40
−30
−20
−10
0
dB
radian/sample
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Transforming Time Domain Equations into
z-Domain
y [n] = x [n]+x [n−1]+x [n−2]+x [n−3]4
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Transforming Time Domain Equations into
z-Domain
y [n] = x [n]+x [n−1]+x [n−2]+x [n−3]4
Looking up z transform pairs in DSP textbook, and youwill get...
x [n − k ]− > X [z]× z−k
y [n]− > Y [z]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Transforming Time Domain Equations into
z-Domain
y [n] = x [n]+x [n−1]+x [n−2]+x [n−3]4
Looking up z transform pairs in DSP textbook, and youwill get...
x [n − k ]− > X [z]× z−k
y [n]− > Y [z]
Y [z ] = X [z ]+X [z ]×z−1+X [z ]×z−2+X [z ]×z−3
4
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Transforming Time Domain Equations into
z-Domain
y [n] = x [n]+x [n−1]+x [n−2]+x [n−3]4
Looking up z transform pairs in DSP textbook, and youwill get...
x [n − k ]− > X [z]× z−k
y [n]− > Y [z]
Y [z ] = X [z ]+X [z ]×z−1+X [z ]×z−2+X [z ]×z−3
4
H[z ] = Y [z ]X [z ] =
1+z−1+z−2+z−3
4 = B[z ]A[z ]
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Transforming Time Domain Equations into
z-Domain
y [n] = x [n]+x [n−1]+x [n−2]+x [n−3]4
Looking up z transform pairs in DSP textbook, and youwill get...
x [n − k ]− > X [z]× z−k
y [n]− > Y [z]
Y [z ] = X [z ]+X [z ]×z−1+X [z ]×z−2+X [z ]×z−3
4
H[z ] = Y [z ]X [z ] =
1+z−1+z−2+z−3
4 = B[z ]A[z ]
Zeros are values to make |H[z ]| = 0 and are roots ofB [z ] = 1 + z−1 + z−2 + z−3 = 0 (There are three zeros atz=1j, z=-1, and z=-1j)
Poles are values to make |H[z ]| = ∞ and are roots ofA[z ] = 0 (There isn’t any pole for this filter)
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Visualization of equations: z Plane
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Visualization of z Plane 1/3
“Logic will get you from A to Z (Plane); imaginationwill get you everywhere.” – Albert Einstein
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Visualization of z Plane 2/3
Imagine...
Zeros drag surface to groundPoles bring surface up in the sky
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Visualization of z Plane 3/3
−2−1.5
−1−0.5
00.5
11.5
2
−2
−1.5
−1
−0.5
0
0.5
1
1.5
2
−30
−20
−10
0
10
20
30
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
z Transform and Frequency Response
−2−1.5
−1−0.5
00.5
11.5
2
−2
−1.5
−1
−0.5
0
0.5
1
1.5
2
−30
−20
−10
0
10
20
30
0 0.5 1 1.5 2 2.5 3 3.5−60
−50
−40
−30
−20
−10
0
dB
radian/sample
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Sampling Rate and Real Frequency
[0, 1] −→ [0, 12Fs ]
[0, π] −→ [0, 12Fs ]
Fs is sampling rate
The highest digital frequency we can represent is 1, and itwill be mapped to Fs
2 .Fs2 plays an important role in digital signal processing, andis called Nyquist frequency.
To sample 8kHz analog signals, you need Fs2 ≥ 8 kHz , i.e.
Fs ≥ 16 kHz to represent it. (Nyquist-Shannon samplingtheorem)
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Demo: Seeing Is Believing
No, in this case,
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Demo: Seeing Is Believing
No, in this case,Hearing is believing!
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Concluding Remarks
GNU Radio provides us a signal processing framework inPython.
Digital signal processing seems not easy at first glance.
By visualizing z plane and frequency response, DSPbecomes easier to understand!
Finally, don’t forget Fs ≥ 2 Finterest , where Finterest is thehighest frequency for signal you’re interested in.
With these visualization techniques, you can usegr filter design tool in GNU Radio to design filter withoutanalyzing it.
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
Q & A
Introductionto DigitalSignal
ProcessingUsing GNU
Radio
AlbertChun-Chieh
HuangPyCon Taiwan
2013
Introductionto SDR andGNU Radio
Adding aFilter in GNURadio
AnalyzingFilters
ConcludingRemarks
References
“GNU Radio Project Wiki.” [Online]. Available:http://gnuradio.org/redmine/projects/gnuradio/wiki
“SWIG - Simple Wrapper and Interface Generator.”[Online]. Available: http://swig.org
J. Mitola, III, “Software radios-survey, critical evaluationand future directions,” in Telesystems Conference, 1992.NTC-92., National, 1992, p. 13.