Receive data from RTL-SDR radio
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.
|Port||Supported Data Types|
The output port supports these complex data types only:
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.
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.
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.
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.
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.
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.
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.
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.
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.
|info||Obtain RTL-SDR radio informaion|
|isLocked||Locked status (logical)|
|release||Allow property value and input characteristics changes|
|reset||Reset the internal states of the RTL-SDR radio System object|
|step||Receive data from RTL-SDR radio|
Verify that your SDRRTLReceiver System object is connected to an RTL-SDR radio by using the info method.
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
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.
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 Set||Actual Value|
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.