Software Defined Radio with HackRF by Michael Ossmann, Lesson 1

Software Defined Radio with HackRF by Michael Ossmann, Lesson 1

Introduction to Software Defined Radio with HackRF

Overview of Software Defined Radio (SDR)

  • Michael Ossmann introduces the course on Software Defined Radio, emphasizing its use of digital signal processing to implement radio functions.
  • The HackRF One is presented as a versatile SDR peripheral that connects via USB, allowing for transmission and reception across a wide frequency range.

Course Background and Structure

  • The course is derived from an intensive two-day training class focused on teaching the basics of SDR and probing security in radio systems.
  • While the course has a security angle, it is accessible to anyone interested in learning about SDR, regardless of their professional background.

Target Audience and Prerequisites

  • Participants are expected to have some programming knowledge; however, non-programmers can still benefit if they are adept at using computers.
  • The course aims to provide more content than the traditional two-day class by being available online under an open content license.

Teaching Methodology

  • The format will be informal, with videos produced quickly but accurately. Errors will be corrected on the accompanying website.
  • Each lesson will have its own webpage containing video content, additional text for clarification, and information about exercises or homework.

Course Tools and Resources

Use of GNU Radio Companion

  • The primary tool for exercises will be GNU Radio Companion, which provides a graphical interface for working with GNU Radio.
  • Although HackRF is central to many exercises, understanding digital signal processing fundamentals is crucial for building flexible SDR systems in the future.

Hardware Requirements

  • Students may use other hardware besides HackRF; however, having an SDR platform is encouraged for completing practical exercises.
  • Different platforms may suit different exercises; thus flexibility in hardware choice is acknowledged while emphasizing HackRF's broad applicability.

Getting Started with GNU Radio Companion

Introduction to Software Defined Radio

  • The exercise begins with building an FM radio receiver, often referred to as the "Hello World of Software Defined Radio."
  • GNU Radio Companion (GRC) is introduced as a graphical interface for creating software radios, allowing users to develop programs in C++ or Python.

Creating a Flow Graph

  • GRC enables users to create visual flow graphs that represent how the program will function; clicking a button generates and runs corresponding Python code.
  • The osmocom source block is selected, which serves as an abstraction layer for communication with various hardware devices in software radio.

Understanding Signal Flow

  • The osmocom source produces digital signals consumed by subsequent blocks in the flow graph, streaming samples from HackRF over USB.
  • Familiarity with GRC and comfort in manipulating blocks are emphasized; detailed explanations of each block will follow in future lessons.

Configuring Blocks

  • A WX GUI FFT sync block is added to visualize frequency components of the signal; connections between blocks are established visually.
  • Adjustments are made to sample rates and other properties using exponential notation for clarity and efficiency.

Finalizing the Flow Graph

  • Changes include tuning into 97.9 MHz within the FM broadcast band and adjusting RF gain settings for optimal performance.
  • Averaging is enabled on the FFT sync block for better visualization of individual FM stations; keyboard shortcuts are encouraged for efficiency.

Executing the Flow Graph

  • After completing the flow graph setup, it can be executed to visualize live radio information through an FFT plot.
  • Upon saving, GRC creates both a .grc file representing the flow graph and a generated Python program that executes immediately.

Adjusting Flow Graph and Center Frequency

Setting Up the Flow Graph

  • The speaker discusses adjusting the flow graph to display frequencies accurately, specifically setting a baseband frequency of 97.9 million Hz.
  • A variable named center_freq is created for easier adjustments across multiple blocks in the flow graph, ensuring consistency and reducing errors.

Synchronizing Frequencies

  • After creating center_freq, it is linked to both the FFT sync and osmocom source, allowing for simultaneous updates when changes are made.
  • Observations on local radio stations reveal that stronger signals may not be familiar to listeners due to proximity to transmitting antennas.

Listening to Radio Stations

Shifting Frequencies

  • The speaker explains the process of shifting a specific station's frequency (96.5 MHz) to center in the plot without changing hardware settings.
  • A math operator is introduced for point-by-point multiplication of digital signals, emphasizing that each line represents a digital signal stream.

Creating Channel Frequency Variables

  • A new variable called channel_freq is established by copying an existing block, set at 96.5 MHz for tuning purposes.
  • The expression for calculating frequency shifts utilizes Python syntax within GRC, showcasing flexibility in programming.

Demodulating Signals

Verifying Signal Processing

  • An additional FFT sink is created to verify that the multiplication operation aligns with expectations; this helps visualize channel frequencies effectively.
  • Upon execution, two FFT plots show successful centering of 96.5 MHz in the display after adjusting baseband frequency settings.

Filtering and Decimation

  • To prepare for demodulation into audio, a low pass filter is added with a cutoff frequency of 75 kHz and transition width of 25 kHz.
  • The speaker emphasizes decimation based on bandwidth needs, aiming to optimize CPU usage while focusing on relevant signal characteristics.

Understanding Sample Rate and Decimation in Signal Processing

Setting Up Channel Width and Decimation

  • The channel width is set to 200 kilohertz, with decimation calculated as the sample rate divided by the channel width (10 million / 200 thousand).
  • An error occurs because the block requires integer values for decimation; a conversion to an integer using the int function resolves this issue.
  • After correction, the expected output is confirmed: 10 million samples per second inputted into the low pass filter results in 200 thousand samples per second output.

Resampling Process

  • A rational resampler is introduced to change the sample rate again, utilizing a ratio of 12/5 for interpolation and decimation.
  • This adjustment allows for non-integer relations in sample rates, which was not possible with previous blocks that only handled integers.

Demodulation Configuration

  • The demodulator converts complex baseband signals into audio signals. It connects to a wideband FM (WBFM) receive block requiring specific parameters.
  • The input sample rate is set at 480,000, with further decimation leading to an audio sample rate of 48,000—standard for most sound cards.

Managing Multiple Sample Rates

  • The flow graph features multiple sample rates (four different ones), complicating configuration and increasing potential for errors if not managed correctly.
  • Using variables can help maintain consistency across these various rates within the flow graph setup.

Audio Output Adjustments

  • One FFT sync is disabled to simplify visualization; adjustments are made to ensure proper audio output from the radio station.
  • To control audio levels dynamically, a multiply constant block is added between signal paths. Type mismatches are resolved by changing properties accordingly.

Real-Time Volume Control Implementation

  • A wx GUI slider named "audio gain" is created to allow real-time volume adjustments during operation. Default settings include no gain and adjustable limits.
  • The multiply constant block's value links directly to this slider, enabling live volume control while listening to radio frequencies.

Performance Considerations

  • Users may experience performance issues if their hardware cannot keep up with data streams; reducing initial sample rates can alleviate choppiness or overruns indicated by capital 'O's in monitoring displays.

Understanding Decimation and Sample Rates in SDR

The Impact of Decimation on Signal Processing

  • Decimation alters the sample rate, allowing everything to the right of the low-pass filter to maintain its original sample rates while automatically adjusting the filter based on this new decimation property.
  • A narrower view of FM stations is observed when setting hardware limitations (e.g., 2 million samples per second), emphasizing the importance of selecting a channel frequency within the displayed band.

Performance Considerations with HackRF

  • Operating at maximum capacity (20 million samples per second) may strain CPU resources and requires a fast USB interface; performance can vary based on USB host controller capabilities.
  • Initial overruns may occur when starting up the flow graph, but ongoing overruns during operation indicate potential issues. Successful operation allows for monitoring all FM stations from 88 MHz to 108 MHz.

Homework Assignments and Practical Applications

  • Students are encouraged to use Pentoo Linux for practical exercises, which simplifies access to necessary software without installation hassles.
  • Creating a similar flow graph as demonstrated is recommended, along with enhancing it by adding GUI sliders for real-time adjustments of audio gain and channel frequency.

Exploring Advanced Features

  • An interesting challenge includes listening to two radio stations simultaneously, promoting hands-on learning through experimentation with SDR techniques.
  • Additional resources and homework details will be available on greatscottgadgets.com/sdr, providing guidance for completing assignments effectively.

Conclusion of Lesson One

  • The lesson wraps up with an overview of building an FM radio receiver using GNU Radio, highlighting that while FM broadcasts are analog signals, future lessons will delve into digital radio systems.
  • Emphasis is placed on completing homework assignments and checking online resources for corrections or additional information related to the course content.
Video description

This is the first lesson in the SDR with HackRF training series by Michael Ossmann of Great Scott Gadgets. In this lesson you can expect: * an introduction to SDR * an introduction to HackRF * course background * an introduction to GNU Radio Companion * “hello world”, receiving FM radio Homework for this video can be viewed on the Great Scott Gadgets website: https://greatscottgadgets.com/sdr/1/ Please note this training was first recorded in 2014 and many things have changed with GNU Radio Companion and HackRF since. You will (likely) need to: * download gr-osmosdr separately from https://osmocom.org/projects/gr-osmosdr/wiki/GrOsmoSDR * use QT blocks instead of WX blocks If you need assistance, please join our Discord server (https://discord.gg/rsfMw3rsU8). Lesson 2: https://youtu.be/xhV0bQ1DgOw