Receive data from RTL-SDR
RTL-SDR Receiver block with default ports
RTL-SDR Receiver block with all ports enabled
The RTL-SDR Receiver block is a signal source that receives data from an RTL-SDR radio and outputs a column vector signal of fixed length specified by the samples per frame parameter.
The following block diagram illustrates how Simulink®, the RTL-SDR Receiver block, and the USRP® hardware interface.
If your computer is not connected to any RTL-SDR hardware, you can still use this block to develop a model that propagates sample time and data type information. To propagate this information, select Edit > Update diagram; alternatively, you can press Ctrl + D.
To open the RTL-SDR Block library, enter the following at the MATLAB® prompt:
|Port||Supported Data Types|
The output port supports these complex data types only:
USB address of the RTL receiver. Must be a string containing a scalar, non-negative integer value. The default is '0'.
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.
Update block parameters in model. Clicking this button also causes the Hardware Information panel to be updated with current radio information.
Specifies the center frequency of the input signal for the RTL-SDR radio. You can specify this parameter using the block dialog mask or a block input port. If you specify a value out of range for your device, you will get an error.
Specify the desired tuner gain as coming from a block parameter setting (Property), a block input port (Input Port), or via automatic gain control (AGC). The default is AGC. The valid range of this property depends on the tuner chip of the RTL-SDR radio. However, if you specify a value out of range for the device, the actual tuner gain value is quantized to the minimum or maximum valid value.
Specify the desired sampling rate as a double-precision, nonnegative scalar. The default value is 250e3 MHz. The maximum sampling rate is 3.2 MHz.
Specify the frequency correction value in ppm as an integer. The valid range is [-1e4 1e4] ppm. The default value is 0. This parameter value is used to correct for frequency shifts that occur as a result of local oscillator offsets or clock rate inaccuracies.
Select this parameter to instruct the RTL-SDR Receiver block to output the number of lost samples during host-hardware data transfers.
Zero indicates no data loss.
A positive number indicates that overruns occurred.
The default value is not selected, which means that the port is not enabled and no information about dropped packets is displayed.
These port are useful diagnostic tools for determining real time operation of the block. If your model is not running in real time, try the techniques described in the section on Performance Maximization to approach or achieve real-time performance..
Select this parameter to instruct the RTL-SDR Receiver block to indicate latency during host-hardware data transfers in number of frames.
Specify the complex output data type as double, single, or int16. When you select double or single for the output data type, the complex values are scaled to the range of [-1,1]. When you select int16, the complex values are the raw 16–bit I and Q samples from the board. The default is int16.
This block supports the following complex output data types:
Double-precision floating point
Single-precision floating point
16-bit signed integers
Specify the number of samples in a frame for the block to output. This value must be a positive, scalar integer that is an integer multiple of 256. The default value is 1024.
You can verify that your RTL-SDR Receiver block is connected to the RTL device with the Initialize button on the block.
Open the block mask.
Click the Initialize button.
If the block is not connected, the panel will show the following message:
No attached SDR hardware or unable to retrieve hardware information.
When you set block values for center frequency, tuner gain, sampling rate, and frequency correction, the block initially performs some rudimentary checks that the values are scalar and real. If your values pass those checks, you can still provide values that are out of range for the RTL-SDR radio. In that case, the hardware will make a best effort to set the requested value, and will report the actual value in the Device value column of the block mask.
You can check if your model runs in real time using the two optional outputs, Lost samples output port and Latency output port. If your model runs in real-time, the lost samples output is always zero. Even when your model runs in real-time, received signals may experience latency. You can observe latency in real-time using the latency output port.
These port are useful diagnostic tools for determining real time operation of the block. If your model is not running in real time, try the techniques described in Performance Optimization to approach or achieve real-time performance.