Software Defined Radio using MATLAB & Simulink' and the RTL-SDR
Software Defined Radio using MATLAB® & Simulink' and the RTL-SDR
Robert W. Stewart Kenneth W. Barlee Dale S. W. Atkinson Louise H. Crockett
Departme...
Software Defined Radio using MATLAB® & Simulink' and the RTL-SDR
Robert W. Stewart Kenneth W. Barlee Dale S. W. Atkinson Louise H. Crockett
Department of Electronic and Electrical Engineering University of Strathclyde Glasgow, Scotland, UK 1st Edition
Table of Contents Book and Support File Information
i
Foreword
xi
A Few SDR Thoughts
xiii
Preface
xv
Acknowledgements
xix
1
Introduction 1.1 Real Time Desktop Software Defined Radio 1.2 What is the RTL-SDR? 1.3 What Do I Need to Get Started? 1.4 The Aim and Objectives of this Book 1.5 The Evolution of the Software Defined Radio Architecture 1.6 RTL-SDR Hardware 1.7 Interfacing with the RTL-SDR from MATLAB and Simulink 1.8 Practicalities and Some Challenges of (Low Cost) Desktop SDR 1.9 Working with Discrete and Continuous Time Signals and Equations . . . . 1.10 The Structure of the Book and Format of the Exercises
1 2 3 5 7 8 10 17 20 22 22
2
Open the Box! First SDR with MATLAB and Simulink 2.1 Getting Started: Hardware and Software Checklist 2.2 Getting Started: Installing the RTL-SDR Hardware Support Package 2.3 Getting Started: Book Support Files and the MATLAB Environment 2.4 Running the First Desktop RTL-SDR Receiver Designs 2.5 Summary
Different Signals, Different Frequencies Spectrum Usage and Allocations Around the Globe Working with a Suitable Antenna Go Forth and Explore the Spectrum! Spectral Viewing — Spectrum Analyser and Waterfall Plots Spectral Viewing — RTL-SDR Tuner GUI Controls Engineering Requirements — Eyeball Radio Tuning & More FM Radio Stations Mobile (Cell) Phone Signals—2G, 3G and 4G 433MHz: Key Fobs and Wireless Sensors Digital Video & Audio Signals Using Multiple RTL-SDRs Sweeping the Spectrum: Receiving from 25MHz to 1.75GHz Summary
Getting Started with MATLAB and Simulink
99
4.1
100
Introducing MATLAB
Software Defined Radio Using MATLAB & Simulink and the RTL-SDR 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14
MATLAB Functions Plotting in MATLAB MATLAB Arrays, Matrices, and Structures MATLAB System Objects Introducing Simulink Creating Simulink Models Variables and Parameters Generating Frequency Domain Plots Sampling Rates, Samples and Frames Data Types Working with Input and Output Files Saving and Re-importing RTL-SDR Data Summary
Complex Signals, Spectra and Quadrature Modulation 5.1 Real and Complex Signals — it's all Sines and Cosines 5.2 Viewing Real Signals in the Frequency Domain via Complex Spectra 5.3 Standard Amplitude Modulation 5.4 Quadrature Modulation and Demodulation (QAM) 5.5 Quadrature Amplitude Modulation using Complex Notation 5.6 Quadrature Amplitude Demodulation using Complex Notation 5.7 Spectral Representation for Complex Demodulation 5.8 Frequency Offset Error and Correction at the Receiver 5.9 Frequency Correction using a Complex Exponential 5.10 RTL-SDR Quadrature / Complex Architecture 5.11 Summary
171 172 173 182 187 191 192 195 199 199 201 201
Amplitude Modulation (AM) Theory and Simulation
203
6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9
203 203 210 217 225 227 227 231 234
Amplitude Modulation — An Introduction AM-DSB-SC: Double Sideband Suppressed Carrier AM AM-DSB-TC: Double Sideband Transmitted Carrier AM AM-SSB: Single Sideband AM AM-VSB: Vestigial Sideband AM Theoretical AM Demodulation Receiving and Downconv AM-DSB-TC Signals to Complex Baseband... Non-Coherent AM Demodulation: The Envelope Detector Summary
Frequency Tuning and Simple Synchronisation 7.1 Selecting a Frequency Band: Tuning 7.2 The Synchronisation Problem 7.3 Demodulation of AM Signals 7.4 Coherent Demodulation and Carrier Synchrony 7.5 Introduction to Phase Locked Loops 7.6 Discrete Time PLL Model 7.7 PLL Behaviours, Parameters and Characteristics 7.8 PLL Design
235 235 238 241 242 245 252 256 264
Table of Contents
8
9
v
7.9 PLL Performance in Noise 7.10 Carrier Synchronisation 7.11 Summary
272 273 277
Desktop AM Transmission and Reception
279
8.1 8.2 8.3 8.4 8.5 8.6
280 290 310 316 326 328
Transmitting AM Signals with a USRP* Radio Implementing Non-Coherent AM Receivers with the RTL-SDR Implementing Coherent AM Receivers with the RTL-SDR Audio Multiplexing with the USRP* and RTL-SDR Hardware Alternative Hardware for Generating Desktop AM Signals Summary
Frequency Modulation (FM) Theory and Simulation
329
9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10
329 331 335 347 348 350 355 358 361 366
The History of the FM Standard The Mathematics of FM & the Modulation Index FM Signal Bandwidth FM Demodulation Using Differentiation Receiving and Downconverting FM Signals to Complex Baseband Non-Coherent FM Demod: Complex Differentiation Discriminator Non-Coherent FM Demod: The Complex Delay Line Discriminator Coherent FM Demodulation: The Phase Locked Loop Demodulating Signals from Commercial FM Radio Stations Summary
10 Desktop FM Transmission and Reception 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8
Transmitting Mono WFM Signals with the USRP* Hardware Implementing Mono FM Receivers with RTL-SDR and Simulink Transmitting Stereo WFM Signals with the USRP* Hardware Implementing Stereo FM Receivers with RTL-SDR and Simulink Manipulating the MPX: Transmitting AM Signals with FM Transmitters. Manipulating the MPX: Audio Multiplexing with FM Transmitters Alternative Hardware for Generating Desktop FM Signals Summary
11 Digital Communications Theory and Simulation 11.1 Digital Modulation Schemes 11.2 Pulse Shaping 11.3 Digital Up and Downconversion 11.4 Carrier Synchronisation 11.5 Timing Errors and Symbol Recovery 11.6 Symbol Timing Synchronisation 11.7 Digital Receiver Design: Joint Carrier and Timing Synchronisation 11.8 Coarse Frequency Synchronisation 11.9 Phase Ambiguity 11.10 Differential Encoding and Decoding 11.11 Synchronisation with a Unique Word 11.12 Summary
Sofiware Defined Radio UsingMATLAB & Simulink and the RTL-SDR 12 Desktop Digital Communications: QPSK Transmission and Reception 12.1 Pulse Shaping with Real Time QPSK Transmitter and Receiver Designs.. 12.2 Coarse Frequency Synchronisation in a Real-time System 12.3 Carrier and Timing Synchronisation with the RTL-SDR 12.4 Developing a Simple Communications Protocol 12.5 ASCII Encoding and Decoding 12.6 Data and Frame Synchronisation 12.7 ASCII Message Transmission and Reception 12.8 Transmitting Images Across the Desktop 12.9 Transmitting Data Using FM Transmitters 12.10 Summary
503 504 512 516 523 525 528 544 551 556 566
Appendix A: Hardware Setup
569
A.l A.2 A.3
The RTL-SDR Hardware Support Package The USRP* Hardware Support Package RTL-SDR Frequency Error Correction
569 571 577
Appendix B: Common Equations
581
Appendix C: Digital Filtering and Multirate C.l Filter Classes and Characteristics C.2 Filter Specification and Design C.3 FIR Filter Processing Architecture C.4 Computation and Trade-offs C.5 Multirate Filtering: The Motivation C.6 Decimation C.7 Interpolation
583 583 584 586 586 587 588 590
Appendix D: PLL Design D.l Digital Type 2 PLL Linear Model and Z-Domain Transfer Function D.2 Analogue Type 2 PLL Linear Model and S-Domain Transfer Function... D.3 Extraction of Digital PLL Params Based on Analogue PLL Equivalence .. D.4 Phase Detector Gain D.5 Oscillator Gain
593 593 596 597 602 605
Appendix E: AM and FM Transmitters E.l Upconverting AM Radio Signals with the Ham It Up E.2 Building an 'RT4' 433.9MHz AM Transmitter E.3 Using the Raspberry Pi as an FM Transmitter