2018 Build your own SDR By Julie VK3FOWL and Joe VK3YSP
Introduction Why build your own Software Defined Radio? Learn about Digital Signal Processing, GNU Radio Flow Graphs, IQ, Linux and Python Create your own embedded radio projects and test instruments Use those old, forgotten, SDR Dongles in your junk box Explore ALL Modes: AM,FM,SSB,PSK,AIS,ADS-B,DRM,TETRA,DMR,NXDN,D-STAR Why buy a $25 RTL-SDR USB DVB-TV Dongle? Frequency: 24MHz-1.766GHz with 1ppm TO Bandwidth: 2.4MHz Max Also runs on Windows with free SDR#, HDSDR, PowerSDR & more Why buy a $65 Raspberry Pi 3? 1.2GHz, 64bit, Quad-Core, 5V, credit card size computer with WiFi, HDMI & Linux. Also runs: WSJT-X, DIGI, HAMLIB, GPREDICT & more
Hardware Required
Hardware Required Computer/Laptop with fast Internet access, USB &/or Micro SDHC Card adapter. HDMI monitor (TV)/HDMI cable/usb Keyboard/USB Mouse/PC Speakers. Raspberry Pi 3 $ 65.15 Pi Australia inc P&P Micro USB Power Supply 5V, >= 2A $ 18.45 ebay (AU Stock) Micro SDHC card (>=8GB) + adapter $ 11.00 Officeworks (16GB) USB Extension Cables (x2) $ 1.14 - ebay RTL-SDR Dongle (US$19.95) $ 25.20 - https://www.rtl-sdr.com Total Cost (Approx) $122.08
Buying a Raspberry Pi 3
Buying a RTL-SDR Dongle
Downloading Raspberry Pi Software Requires a PC with a fast Internet connection. This will take 2-3 hours. Download Raspbian Jessie (the latest Stretch version will not work): https://downloads.raspberrypi.org/raspbian/images/raspbian-2017-07-05/2017-07-05-raspbian-jessie.zip Unzip 2017-07-05-raspbian-jessie.img to the desktop Download and Install Etcher for your PC from https://etcher.io/
Creating a Micro SDHC Boot Disk 1. Insert Micro SDHC card into adapter and adapter into computer. 2. Run Etcher. Select the.img file above. Select your Micro SDHC card. 3. Press Flash! Etcher will create a boot disk. Warning: All Data Erased! 4. Important: Ignore Format Disk if Windows asks! 5. Remove the Micro SDHC card from the computer.
Starting up the Raspberry Pi 3 1. Insert Micro SDHC card into Raspberry Pi 3. 2. Connect an HDMI Monitor and turn it on 3. Connect amplified PC speakers and turn them on 4. Connect a USB RTL-SDR DVB-TV Dongle 5. Connect a USB Keyboard 6. Connect a USB Mouse 7. Connect a 5V Micro USB power supply and turn it on 8. The Raspberry Pi 3 should boot up to the desktop
Setting up the Raspberry Pi 3 Click Preferences Raspberry Pi Configuration Set Password Default is raspberry Set Locale, Time Zone, WiFi Country Select Wired/Wireless Network icon Connect to your WiFi router Check clock is updated automatically
Install Applications on the Raspberry Pi 3 Open a Terminal window. Type the commands in blue. sudo apt-get update sudo apt-get y upgrade sudo apt-get y install rtl-sdr gr-osmosdr amixer set PCM 100% Shutdown and cycle power to reset RTL-SDR Dongle. Start GNU Radio Companion: Click Programming GRC
Create a GNU Radio Companion flow graph Drag a Signal Source and an Audio Sink to the flow graph. Connect the two blocks. Select the samp_rate variable and change it to 48000. Change the Signal Source Output type from Complex to Float. Change the Audio Sink Device Name to hw:0,1 Press F6 and listen to the 1kHz tone on the speaker.
Create a GNU Radio Companion flow graph Drag an RTL-SDR Source to the flow graph Drag a QT GUI Frequency Sink to the flow graph Connect the two blocks Select the samp_rate Variable and change it to 240000 Select the Options and change to QT GUI Press F6 to run
Changing flow block properties
Hints and Tips Create a GNUradio Projects folder in the Documents folder Use either QT or WX GUI widgets and select the same in Options Connected blocks must have compatible input/output types Use to cycle between flow block input/output types Use and to rotate flow blocks RTL2832 sample rates: 240,288,300,960,1200,1440,1600,1800,1920,2400kHz Audio Sink sample rates: 16, 24, 32, 48kHz. Audio Device Names are: hw:0,1 (Internal RPi BCM2835 Sound Device) hw:1,0 (External USB Sound Dongle) To calibrate SDR: Type rtl_test p and use the cumulative ppm Select View Find Blocks Press F5 to generate an executable Python 2 script
Project #1: Receiver Frequency Range: 24MHz 1.766GHz. Mode Selection: AM, FM, LSB, USB. Bandwidth Selection: 600, 2400, 2800, 3200, 6400Hz. Squelch Control. Automatic Gain Control. Clarifier Control. Waterfall Display.
RTL-SDR DONGLE RASPBERRY PI + GNURADIO RF IF BB AM DEMODULATOR RMS THRESHOLD (SQUELCH) 434.6MHz RF AMP 24MHz-1.766GHz IF AMP 10kHz LOW PASS FILTER 0.6 6.4kHz NBFM DEMODULATOR AGC GATE VOLUME AF AMP 1 ST LO f t = 434.590MHz 2 ND LO f o = 10kHz SSB DEMODULATOR DECISION: f o WILL BE JUST OUTSIDE OF THE AUDIO BANDPASS, SAY 10kHz DECISION: f s WILL BE THE MINIMUM SDR SAMPLE FREQUENCY f s = 240kHz DECISION: f s WILL BE 5 TIMES f a FOR EASY DOWNSAMPLING f a = 48kHz DECISION: f a WILL BE THE MAXIMUM AUDIO SAMPLE FREQUENCY OF THE SOUND DEVICE
The RTL-SDR dongle provides a Complex (IQ) Signal It has two components: Real (In-Phase) and Imaginary (Quadrature-Phase) RF RE IM L U RF RTL-SDR SOURCE IF 240kHz (0 ) (0 ) L U (+90 ) L + U = Complex RE = Real IM = Imaginary RF OSC f t ADC 90 OSC f s Down Converter/Sampler/Quadrature Demodulator RE (I) IM (Q) Complex (IQ) Signal (-90 )
RF 0 // X X X f t L f c U X X f c = Carrier frequency f t = SDR tuner frequency f s = SDR sample frequency = 434.600MHz = 434.590MHz = 240kHz DC SPIKE (OUCH!) U = Upper Sideband L = Lower Sideband X = Unwanted Signals IF -f s /2 X X X L U X X 0 f c - f t +f s /2 RF IF Negative Frequency? RTL-SDR SOURCE 240kHz Complex Output?
DC SPIKE (OUCH!) IF -f s /2 X X X L U X X 0 f o = f c - f t +f s /2 f s = SDR sample frequency = 240kHz f o = Intermediate Frequency = 10kHz TRANSLATE BY -f o LOW PASS FILTER DECIMATE BY 5 BB f a = Audio sample frequency f b = Filter bandwidth RTL-SDR SOURCE 240kHz // -f b L 0 = 48kHz = 3kHz U +f b +f a =+f s /10 Rule: Multiplying real frequencies in the time domain = Adding and subtracting frequencies in the frequency domain. But: Multiplying complex frequencies in the time domain = Adding frequencies in the frequency domain No ambiguity. RF IF BB SIGNAL SOURCE -f o -f a =-f s /10 240kHz MULTIPLY // 240kHz LOW PASS FILTER DECIMATE = 5 48kHz
BB -24kHz // -3kHz L 0 U +3kHz // = Complex = Floating Point COMPLEX TO MAG AM RMS THRESHOLD (SQUELCH) 48kHz NBFM RECEIVE FM SELECTOR (AM/FM/LSB/USB) DC BLOCKER AGC SSB DEMODULATOR LSB USB AUDIO SINK MULTIPLY CONSTANT (VOLUME) MULTIPLY
RE 1 2 3 (0 ) (0 ) (0 ) (0 ) (0 ) (0 ) L U L U + L U = L (180 ) BB 48kHz COMPLEX TO OAT RE IM HILBERT COMPLEX TO OAT RE IM 1 2 ADD 3 LSB 48kHz = Complex = Floating Point RE = Real IM = Imaginary (+90 ) L IM U HILBERT COMPLEX RE 4 ADD 6 TO OAT IM 5 USB 4 (+90 ) L U + = L 5 6 U 48kHz U (-90 ) (-90 ) (-90 ) (-90 ) (-90 )
QT GUI ENTRY (FREQ) QT GUI CHOOSER (BANDWIDTH) QT GUI CHOOSER (MODE) QT GUI RANGE (SQUELCH) QT GUI RANGE (VOLUME) QT GUI RANGE (CLARIFIER) RTL-SDR SOURCE SIGNAL SOURCE -f o MULTIPLY QT GUI WATERFALL SINK LOW PASS FILTER COMPLEX TO MAG NBFM RECEIVE AM FM COMPLEX TO OAT RE IM HILBERT COMPLEX TO OAT RE IM 1 2 ADD 3 LSB HILBERT COMPLEX RE 4 ADD 6 TO OAT IM 5 USB AUDIO SINK MULTIPLY CONSTANT (VOLUME) MULTIPLY AGC DC BLOCKER SELECTOR (AM/FM/LSB/USB) THRESHOLD (SQUELCH) RMS
Create An Executable Press F5 to generate an executable Python 2 script Note: GNUradio applications do not currently execute under Python 3 Can include GNUradio applications in other Python scripts Can run a GNUradio Class as a thread Can control GNUradio threads in real-time using Class methods like: set_freq(434.6) #!/usr/bin/env python ################################################## # Gnuradio Python Flow Graph # Title: RTL-SDR AM FM SSB Receiver # Author: Julie VK3FOWL and Joe VK3YSP # Description: www.sarcnet.org # Generated: Wed Jan 31 22:10:15 2018 ################################################## from PyQt4 import Qt from PyQt4.QtCore import QObject, pyqtslot from gnuradio import analog from gnuradio import audio from gnuradio import blocks from gnuradio import eng_notation from gnuradio import filter from gnuradio import gr from gnuradio import qtgui from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from grc_gnuradio import blks2 as grc_blks2 from optparse import OptionParser import PyQt4.Qwt5 as Qwt import osmosdr import sip import sys from distutils.version import StrictVersion class rtl_sdr(gr.top_block, Qt.QWidget): def init (self): gr.top_block. init (self, "RTL-SDR AM FM SSB Receiver") Qt.QWidget. init (self) self.setwindowtitle("rtl-sdr AM FM SSB Receiver") try: self.setwindowicon(qt.qicon.fromtheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setlayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setframestyle(qt.qframe.noframe) self.top_scroll_layout.addwidget(self.top_scroll) self.top_scroll.setwidgetresizable(true) self.top_widget = Qt.QWidget() self.top_scroll.setwidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addlayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rtl_sdr") self.restoregeometry(self.settings.value("geometry").tobytearray())
Project #2: Transmitter Modulation Monitor
References IQ Principles http://whiteboard.ping.se/sdr/iq https://www.dsprelated.com/showarticle/192.php SSB Receivers https://www.dsprelated.com/showarticle/176.php GNU Radio https://wiki.gnuradio.org/index.php/main_page GRC Source Files http://www.sarcnet.org/projects.html
The End Thank You