File Exchange

image thumbnail

SDRplay RSP2 Matlab Toolbox

version 1.1 (35.7 KB) by Athanasios Vasileiadis
Simple interface to communicate with your RSP2 device through Matlab

3 Downloads

Updated 23 Jun 2018

View Version History

View License

!!! READ ME – START !!!
Matlab does not allow .dll or MEX files, so you need to do the following steps or if you trust me, get a ready x64 compiled version from git -> https://github.com/VasAthanasios/SDRplay_RSP2_Matlab_Toolbox/
1) Download the API from https://www.sdrplay.com/downloads/
a. Copy paste the .dll and .lib depending on your windows version (x86 or x64) in the same folder.
b. Rename it as “mir_sdr_api.dll”. The .dll needs to be in the same folder with the correct name.
2) Compile the C/MEX file with the following command,
a. "mex sdrplay_mex.c mir_sdr_api.lib"

!!! READ ME – END !!!
The SDRplay MEX/class is a simple wrapper for the SDRplay library to receive directly from Matlab. It allows uninterrupted transfers without storing signals on disk intermediately.

You can access parameters like Frequency, Sample rate, Bandwidth, and Gain reduction settings. For the appropriate settings please look at the specifications. To enable the stream, run the command Stream. To receive a packet of data when you want to use callback function: GetPacket. The timer is set to dump complex data every 0.25s. The internal buffer of the MEX file is set to 2000000, so depending on your sample rate you can access data periodically. The output data can be an integer vector in the range [-127, 127], or a single or double vector in the range [-1, 1]. By default, the data type is double and values are in the range [-1, 1]. Alternatively, you can set rxNumericType to 'int16'.

The class "SDRplay.m" is used with the compiled MEX "SDRplay_mex" to communicate with a single RSP.

The file "SDRplay_mex.c" contains C/MEX code that enables the communication between Matlab and the RSPii. This version of C/MEX contains an overlapping buffer. When the buffer is full, it starts writing samples at the start, overwriting the previous samples. A circular buffer will be implemented in the future!
I have also included two spectral analysis examples, using the Communication System Toolbox.

"SDRplay_ex_SpectGUI" is a simple GUIDE which can be used interactively to look at the spectrum.

"SDRplay_ex_SpectrumAnalyzer.m" is a simple .m file which shows how the Class/MEX can be used from Matlab's editor.

Features to be implemented in the future if requested!
-- Control of Gain Mode
-- Control of Lo Mode
-- Control of Ppm
-- Control of DC offset IQ imbalance
-- AGC Selection
-- BiasT Selection
-- AM port Selection
-- RF notch Selection

HUGE thanks to the SDRplay team for their assistance on the API usage!

Big thanks to Tillmann Stübler for his work on the HackRF toolbox.

For any questions or assistance, you can find me at,

avasileiadis1@sheffield.ac.uk

Cite As

Athanasios Vasileiadis (2020). SDRplay RSP2 Matlab Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/67816-sdrplay-rsp2-matlab-toolbox), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Technically RSP1 and RSP2 share the same drivers so it should, but I have not tried it.

The Communication toolbox is required for the example code.

When the sdrplay.m object initializes it opens the devices and with the appropriate commands it starts to stream. As long as Matlab is open the RSP is accessible unless it is closed with the appropriate command, or "close all" is used in the Command Window. In that case, the link between Matlab and the RSP is broken and needs to be re-initialized.

Dean Carhoun

I presume this will also work with RSP1a using the default port A. Is that correct? Why is the Communications toolbox required? Can the SDRplay devices be accessed directly from core Matlab?

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: hackRF toolbox with spectrum analyzer

Communities

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!