Documentation Center

  • Trial Software
  • Product Updates

comm.SDRRTLReceiver class

Package: comm

Receive data from RTL-SDR radio

Description

The SDRRTLReceiver System object™ supports communication between MATLAB® and an RTL-SDR radio, by way of an RTL-SDR device attached to a USB port on the host computer, allowing simulation and development of various software-defined radio (SDR) applications. Although comm.SDRRTLReceiver receives data from an RTL-SDR radio, the object acts as a signal source that outputs a column vector signal of fixed length.

Supported Data Types

PortSupported Data Types

Output

The output port supports these complex data types only:

  • Double-precision floating point

  • Single-precision floating point

  • 16-bit unsigned integers

Construction

H = comm.SDRTRLReceiver creates an RTL-SDR radio receiver System object, H, that receives data from the RTL-SDR radio.

H = comm.SDRRTLReceiver(Name,Value) creates an RTL-SDR radio receiver object, H, with the specified property Name set to the specified Value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

H = comm.SDRRTLReceiver(RadioAddress,Name,Value) creates an RTL-SDR radio receiver System object, H, where RadioAddress is a string containing a non-negative, scalar integer that refers to the USB ID of the RTL-SDR radio, and the other specified properties set to the specified values.

Properties

RadioAddress

USB address of the RTL-SDR device

Specify the USB address of the radio you want to communicate with as a string. The default value is '0'. Use the sdrinfo function to discover which radios are connected to your computer.

    About USB port addresses   USB address are not assigned in a manner that it is intuitive. If a device is plugged into the first USB port, it is always at address 0. But if there is a device plugged into a second or third port, the address varies depending on whether there is a device in any of the previous ports. See the following illustrations for a visual explanation.

    This diagram illustrates how the USB port addresses are assigned when devices are added and then removed in FIFO order.

    This diagram illustrates how the USB port addresses are assigned when devices are added and then removed from port 0. Note that the radio address for the second RTL device changes based on whether or not the first port has a device in it. You must keep track of the plugged-in devices in order to access a radio with the correct radio address.

CenterFrequency

Desired center frequency in Hz

Specify the desired center frequency as a double precision, nonnegative scalar. The default value is 102.5 MHz. The valid range of this property depends on the tuner chip of the RTL-SDR radio. You can get a list of tuner chips and their frequency ranges at http://sdr.osmocom.org/trac/wiki/rtl-sdr#SupportedHardware and http://sdr.osmocom.org/trac/wiki/rtl-sdr#Specifications.

EnableTunerAGC

Turn the tuner automatic gain control (AGC) on (true) or off (false).

When set to true, this property will enable the tuner AGC to provide almost constant amplitude signals. The default value is true.

TunerGain

Desired tuner gain in dB

Specify the desired tuner gain as a double precision scalar. The default is 0 dB. The valid range of this property depends on the tuner chip of the RTL-SDR radio. Use the info method to get valid values. This property applies and appears only when EnableTunerAGC is set to false. This property is tunable.

SampleRate

Desired ADC sample rate in Hz

Specify the desired sample rate of the output samples of the step method, in Hertz, as a double-precision, positive, scalar value. The default is 250 KHz. The maximum ADC sample rate is 3.2 MHz.

OutputDataType

Data type of output

Specify the output data type as one of double, single, or int16. When you select double or single data type, the complex values are scaled to the range of [-1,1]. When selecting int16, the complex values are the raw 16-bit I and Q samples from the board. The default value is int16.

SamplesPerFrame

Number of samples in a frame

Specify the number of samples in a frame for the step method to output. This value must be a positive, scalar integer that is an integer multiple of 256. The default value is 1024.

FrequencyCorrection

Frequency correction value in ppm

Specify the frequency correction value in ppm as an integer. The valid range is [-1e4 1e4] ppm. The default value is 0. This property value is used to correct for frequency shifts that occur as a result of local oscillator offsets or clock rate inaccuracies.

Methods

info Obtain RTL-SDR radio informaion
isLockedLocked status (logical)
releaseAllow property value and input characteristics changes
resetReset the internal states of the RTL-SDR radio System object
stepReceive data from RTL-SDR radio

Usage

Object Connectivity

Verify that your SDRRTLReceiver System object is connected to an RTL-SDR radio by using the info method.

  1. Construct an SDRRTLReceiver System object.

    h = comm.SDRRTLReceiver
    h = 
    
      System: comm.SDRRTLReceiver
    
      Properties:
               RadioAddress: '0'      
            CenterFrequency: 102500000
             EnableTunerAGC: true     
                 SampleRate: 250000   
             OutputDataType: 'int16'  
            SamplesPerFrame: 1024     
        FrequencyCorrection: 0  
  2. Use the info method:

    S = info(h)

    The function returns the hardware information for object h in structure S. Note that the values returned show the actual current radio settings, not the property values of the RTL-SDR receiver System object.

    S = 
    
                    RadioName: 'ezcap USB 2.0 DVB-T/DAB/FM dongle'
                 RadioAddress: '0'
                    TunerName: 'R820T'
                 Manufacturer: 'Realtek'
                      Product: 'RTL2838UHIDIR'
                   GainValues: [1x29 double]
          RTLCrystalFrequency: 28800000
        TunerCrystalFrequency: 28800000
                 SamplingMode: 'Quadrature'
                 OffsetTuning: 'Disabled'
              CenterFrequency: 102500000
                   SampleRate: 250000
          FrequencyCorrection: 0

    Note that TunerGain does not appear if EnableAGC is true (which, in this example, it is).

    The info() method first initializes the radio with the System object properties, and then shows the actual values of center frequency, sample rate, and tuner gain. Note that the System object properties show user requested values and may be different than the values reported by the info() method due to quantization.

Desired vs. Actual Device System Object Parameter Values

You can set the desired values in the receiver System object for center frequency, gain, sample rate, and frequency correction. However, due to quantization or range issues, the actual values can differ from your desired values.

The System object properties always shows the requested values. For example, h.CenterFrequency displays the requested center frequency set by you. To see the actual center frequency set at the radio, call the info method, r = info(h): r.CenterFrequency shows the actual center frequency. The System object sends the requested values to the radio and reads the actual values back when either the info method is called or when step() is called.

Parameter to SetActual Value
h.CenterFrequencyr.CenterFrequency
h.TunerGainr.TunerGain
h.SampleRater.SampleRate
h.FrequencyCorrectionr.FrequencyCorrection

Examples

See either of the following featured examples for some basic radio functionality with the RTL-SDR Radio support package:

  • FM Monophonic Receiver with RTL-SDR Hardware

  • FM Stereo Receiver with RTL-SDR Hardware

For more examples featuring the RTL-SDR radio receiver System object, enter sdrexamples at the MATLAB command prompt.

Was this topic helpful?