2. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
About the Author
He is both a programmer and a communication engineer.
He learned Python in 2000 and has used it extensively on
improving his workflow ever since. He has been working in
communication IC industry for more than eight years. His
interests include communication engineering and
engineering communication, which consists of fields from
physical 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
5. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communication
system implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIA
i500 LTE SDR modems, etc.
6. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communication
system implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIA
i500 LTE SDR modems, etc.
Background knowledge required for SDR programmer
Digital Signal Processing (the most fundamental
knowledge)
Programming
Probability and Statistics
Communication System
7. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Software-Defined Radio
Software-Defined Radio (SDR) is a radio communication
system implemented (mostly) in software.
Application areas
Military systems, space exploration, base stations, NVIDIA
i500 LTE SDR modems, etc.
Background knowledge required for SDR programmer
Digital Signal Processing (the most fundamental
knowledge)
Programming
Probability and Statistics
Communication System
This talk is going to illustrate how easy digital signal
processing is! Don’t be hesitated!
8. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Introduction to GNU Radio
GNU Radio is a free & open-source software development
toolkit that provides signal processing blocks to implement
software radios.
Primarily written in Python with performance-critical
signal processing components written in C++ [1].
C++ classes are wrapped by SWIG [2].
Python can be used to develop rapid prototype for SDR in
an 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 by
Python” on SlideShare.net
10. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Top Block
1 #!/ us r / bin /env python
2 from PyQt4 import Qt
3 # Other imports are hidden
4 c l a s s top bl ock ( gr . top block , 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 are hidden here
7 s e l f . samp rate = samp rate = 16000
8 # q t g u i s i n k s t u f f hidden
9 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 = analog . s i g s o u r
11 samp rate , analog . 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))
16
17 i f name == ’ m a i n ’ :
18 tb = top bl ock ()
19 tb . s t a r t ()
20 tb . show ()
21 tb . stop ()
11. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Adding a Simple Moving Average Filter
1 #!/ us r / bin /env python
2 from gnuradio import f i l t e r # Add t h i s l i n e i n t o top bl ock . p
3 # Other imports are hidden
4 c l a s s top bl ock ( gr . top block , 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 are hidden here
7 s e l f . samp rate = samp rate = 44100
8 # q t g u i s i n k s t u f f hidden
9 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
11 s e l f . a n a l o g s i g s o u r c e x 1 = analog . s i g s o u r
12 # ==============================
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))
21
22 # ==============================
12. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
What Is This Filter?!
self.flt = filter.fir filter fff(1, (0.25, 0.25, 0.25, 0.25) )
FIR filter block
Input: Float
Output: Float
Coefficients: 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 input
sample, and so on...
y[n]: current output sample
It’s just adding/multiplying numbers together, right?
Pretty easy, huh?
17. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
How to Analyze This Filter?
Back-of-the-Envelope Method
Do fast calculation in the back of the envelope
Handy to get a feel of this filter’s frequency response
Discrete Fourier Transform (DFT)
All transformations are giving us different perspectives
DFT gives us frequency response of a filter
z Transform
Gives us more than just frequency response
Also give us more thorough information, such as stability,
etc.
20. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 of
attendees here...
21. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 of
attendees here...
Let’s use back-of-the-envelope method
22. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 of
attendees here...
Let’s use back-of-the-envelope method
Remember the filter time domain equation is
y[n] = (x[n] + x[n − 1] + x[n − 2] + x[n − 3])/4
29. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 you
will get...
x[n − k]− > X[z] × z−k
y[n]− > Y [z]
30. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 you
will 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
31. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 you
will 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]
32. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 you
will 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 of
B[z] = 1 + z−1 + z−2 + z−3 = 0 (There are three zeros at
z=1j, z=-1, and z=-1j)
Poles are values to make |H[z]| = ∞ and are roots of
A[z] = 0 (There isn’t any pole for this filter)
37. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
z Transform and Frequency Response
−2
−1.5
−1
−0.5
0
0.5
1
1.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
38. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Sampling Rate and Real Frequency
[0, 1] −→ [0, 1
2 Fs]
[0, π] −→ [0, 1
2Fs]
Fs is sampling rate
The highest digital frequency we can represent is 1, and it
will be mapped to Fs
2 .
Fs
2 plays an important role in digital signal processing, and
is called Nyquist frequency.
To sample 8kHz analog signals, you need Fs
2 ≥ 8 kHz, i.e.
Fs ≥ 16 kHz to represent it. (Nyquist-Shannon sampling
theorem)
41. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
Concluding Remarks
GNU Radio provides us a signal processing framework in
Python.
Digital signal processing seems not easy at first glance.
By visualizing z plane and frequency response, DSP
becomes easier to understand!
Finally, don’t forget Fs ≥ 2 Finterest, where Finterest is the
highest frequency for signal you’re interested in.
With these visualization techniques, you can use
gr filter design tool in GNU Radio to design filter without
analyzing it.
43. Introduction
to Digital
Signal
Processing
Using GNU
Radio
Albert
Chun-Chieh
Huang
PyCon Taiwan
2013
Introduction
to SDR and
GNU Radio
Adding a
Filter in GNU
Radio
Analyzing
Filters
Concluding
Remarks
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 evaluation
and future directions,” in Telesystems Conference, 1992.
NTC-92., National, 1992, p. 13.