Skip to content

Windows_info

Mark Wickert edited this page Jul 20, 2019 · 2 revisions

Windows Setup Information

This page will explain how to configure Windows x64 (version 10, but should be similar for 7 and 8) for the RTL-SDR dongle and Pyaudio for real-time DSP using internal and external audio devices.

RTL-SDR

The device you are configuring is the TV tuner USB dongle known as the RTL-SDR, which as this link shows can be purchased for under $20. During the tutorial a number of these dongles will be available for hands-on experimenting with signal capture and processing the signals into playback information, e.g., music, speech, and data bits. Not required, but encouraged for the hardware tinkerer, is to purchase your own dongle from the above link.

Background

On to the software driver set-up. A nice overview to consider is found at UC Berkeley. From this link you will find Windows set-up details including a link to a ZIP package. A newer source ZIP package can be found at (http://osmocom.org/attachments/download/2242/RelWithDebInfo.zip), but the USB driver configuration tool zadig is not included. To streamline the setup, I have placed a ZIP package in the tutorial repo that I describe below. The bottom line is on Windows everything is pre-build for you in x64 and x32 versions. In the next section I go through a 64-bit install and test.

Using the Pre-build Drivers ZIP Package

From this point forward I assume that you have cloned the tutorial repo (https://github.com/mwickert/SP-Comm-Tutorial-using-scikit-dsp-comm) to your machine. The cloned repo has a folder \hardware_configure\Windows_drivers\, which contains the drivers and utilities in subdirectory RelWithDebInfo and the USB driver configuration tool, zadig, inside the folder SDR#. The software can stay where it is, you just need to configure it for use. The steps are (1) configure the windows USB driver to talk with the RTL-SDR libraries using Zadig, (2) set a path to the libraries, and (3) pip install pyrtlsdr. The first step can only be done with a dongle, so unless you are buying your own you will have to wait and do this at the tutorial.

Using Zadig

When you have a dongle, plug it in an available USB port and launch the app Zadigfound the folder SDR#. The screenshots below take you though the process. Keep in mind what you are doing here is replacing the default TV Tuner driver with the WinUSB driver for bulk data transfer. This may have to be done more than once if you move the dongle to a different USB port on your computer. In trouble shooting it never hurts to run Zadig again to confirm that it has the proper USB driver set.

zadig_step1

With the devices listed, look for the name Bulk-In or perhaps a name that contains RTL or something similar. zadig_step2

Finally, the driver driver shown on the left in the below screen shot is replaced by the WinUSB driver shown on the right when you click the Reinstall Driver button. zadig_step3

Leave the dongle plugged-in and move on to setting a path to RTL-SDR libraries and utilities.

Setting a Path

Setting a path in windows is actually easier in Windows 10 than in earlier versions. I provide screen shots of how it is done under Windows 10 below. Setting the path makes it convenient for accessing the libraries from anywhere on your system, both at the command line and when using Python. In the tutorial repo the objective is to drill down to the x64 files: \Windows_drivers\RelWithDebInfo\rtl-sdr-release\x64. Begin by typing environment into the search window (lower left).

search for env. editor

System properties dialog

environment variables

path editor

path search order

As the final step pip install pyrtlsdr (I installed this earlier):

PS C:\Users\mwickert> pip install pyrtlsdr
Requirement already satisfied: pyrtlsdr in c:\users\mwickert\anaconda3\lib\site-packages

Testing the Install with/without the RTL-SDR Dongle

There are a number of command line utilities that are part of the RTL-SDR driver set, common to all platforms, i.e.:

PS C:\Users\mwickert\Documents\Scipy_tutorial\sp_comm_tutorial_repo\hardware_configure\Windows_drivers\RelWithDebInfo\rt
l-sdr-release\x64> ls *.exe

    Directory: C:\Users\mwickert\Documents\Scipy_tutorial\sp_comm_tutorial_repo\hardware_configure\Windows_drivers\RelWithDebInfo\rtl-sdr-release\x64

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        1/24/2014   4:32 PM          19968 rtl_adsb.exe
-a----        1/24/2014   4:32 PM          17408 rtl_eeprom.exe
-a----        1/24/2014   4:32 PM          28672 rtl_fm.exe
-a----        1/24/2014   4:32 PM          28672 rtl_power.exe
-a----        1/24/2014   4:32 PM          17920 rtl_sdr.exe
-a----        1/24/2014   4:32 PM          21504 rtl_tcp.exe
-a----        1/24/2014   4:32 PM          16896 rtl_test.exe

In particular rtl_eeprom reads registers in the dongle. To explore any of these utilities type util_name -h at the command line. Usage examples for some of them can be found at (http://osmocom.org/projects/sdr/wiki/rtl-sdr) . Open a terminal window in the repo at folder hardware_configure/ so you can type some commands. I use the below to see if all is well when the dongle is present. There is not too much to do without the dongle present, but some encouragement is the following:

PS C:\Users\mwickert\Documents\Scipy_tutorial\sp_comm_tutorial_repo\hardware_configure> rtl_eeprom -d 1
No supported devices found.

The above at least tells you the USB interface drivers are trying find a device. With the dongle plugged in I get different results depending upon the setting of the device_index, which by default is 0:

PS C:\Users\mwickert\Documents\Scipy_tutorial\sp_comm_tutorial_repo\hardware_configure\Windows_drivers\RelWithDebInfo\rtl-sdr-release\x64> rtl_eeprom -d 0
Found 2 device(s):
  0:  Generic RTL2832U OEM
  1:  Generic RTL2832U OEM

Using device 0: Generic RTL2832U OEM
usb_open error -12
Failed to open rtlsdr device #0.
PS C:\Users\mwickert\Documents\Scipy_tutorial\sp_comm_tutorial_repo\hardware_configure\Windows_drivers\RelWithDebInfo\rtl-sdr-release\x64> rtl_eeprom -d 1
Found 2 device(s):
  0:  Generic RTL2832U OEM
  1:  Generic RTL2832U OEM

Using device 1: Generic RTL2832U OEM
Found Rafael Micro R820T tuner

Current configuration:
__________________________________________
Vendor ID:              0x0bda
Product ID:             0x2838
Manufacturer:           Realtek
Product:                RTL2838UHIDIR
Serial number:          00000001
Serial number enabled:  yes
IR endpoint enabled:    yes
Remote wakeup enabled:  no
__________________________________________

So, yes the device is found, but on some WinOS machines I have found that you must manually set the device_index to 1 as 0 is found but not usable. Note: Setting the device_index will carry over to calling the device from Python as well. More on this later.

Capture Test

Once you have a RTL-SDR dongle available you can perform a sample capture using the code found in the Jupyter notebook RTL-SDR_Test.ipynb which is located in the tutorial repo folder hardware_configure.

Setting Up a GUI Receiver App (optional)

The repo folder SDR# contains the receiver application SDR#. To run this app just double-click the executable SDRSharp.exe. If you purchase your own dongle feel free to start playing with this app before the tutorial. In the tutorial you will be working with the signal samples output from the device.

SDR

Pyaudio

Audio I/O is another avenue for hardware interfacing between your PC and the signal processing capabilities of Python. Pure audio I/O is of interest unto itself, but you can also thing of streaming audio out of your PC as the back-end to streaming radio signals in via the RTL-SDR. The intent of the tutorial is to focus on processing signal captures made from the RTL-SDR. Setting up a real-time stream from the radio input the audio output is the ultimate challenge, and something that I have been contemplating, but do not have a polished solution for just yet. The speed limitations of Python means that the Python code that sits between the input and output be very lean and efficient, and requires the use of call-backs and buffer management.

To get started with analog I/O I like Pyaudio, which provides Python bindings to the well established cross-platform C/C++ library PortAudio. PortAudio is used in many of the RTL-SDR apps that you can read about on the Web. For Windows follow the instructions found on the Pyaudio project Web Site, which is summarized in one step: pip install pyaudio.

  • With the release of Python 3.7x, the compiler used for Python has changed and as of Spring 2019 pip does not have wheels (whl) files available. The best approach I have found (assuming you use conda) is to install pyaudio using conda install pyaudio
  • At this point you can go on to pip install scikit-dsp-comm as an editable install, i.e., pip install -e .[helpers]

Test the Installation

When installation is complete you can run code samples found in the Jupyter notebook Pyaudio_Test.ipynb which is located in the tutorial repo folder hardware_configure. You will be able hear sounds playing through your speakers or headphones.