The Simulink-HackRF project is an Open Source Software Package allows interfacing MATLAB Simulink models with a HackRF device in real-time. Simulink-HackRF uses libhackrf to transmit or receive IQ samples. It is thus possible to build a wide variety of signal processing and wireless communication applications directly in Simulink while being able to test them on real hardware at the same time.
The Simulink-HackRF project was initiated at the Communication Engineering Lab (CEL) at the Karlsruhe Institute of Technology (KIT), Germany, http://www.cel.kit.edu.
MATLAB/Simulink (tested with R2015b) and compatible compiler
hackrf library (tested with 2014.08.1) from the Project GitHub page
Windows only: POSIX Threads for Win32 from the Project page
Make sure MATLAB's mex
compile script is configured. Open a MATLAB console:
>> mex -setup C
MEX configured to use 'gcc' for C language compilation.
...
You can also enter $ mex -setup C
a terminal (MATLAB executables must be in your PATH).
Get, (build) and install the hackrf library and tools: You can use the link above or install hackrf*
from your OS package repositories, if available. Make sure to include the development packages. Additional information can be found in the HackRF Wiki.
To test your hackrf installation plug-in your device and run the included application
$ hackrf_info
Found HackRF board.
...
If your device is not found, you can consult the HackRF FAQ for more information.
Get the Simulink-HackRF source from GitHub.
$ git clone git://github.com/kit-cel/simulink-hackrf.git
If you aren't using git you can get the latest release. Extract the archive to any folder you want.
There are two options for compiling the Simulink-HackRF blocks:
Run MATLAB, switch to your Simulink-HackRF directory and start the build process via
>> make
You might need to adapt the include and lib path for the hackrf library at the top of make.m to reflect your setup. Finally, add the build directory to the MATLAB Path.
As an alternative you can use CMake:
$ cd simulink-hackrf
$ mkdir build && cd build
$ cmake ..
...
$ make
$ make install
$ make install
puts all required files in ~/Documents/MATLAB which is in the MATLAB Path by default. You can also skip this step and add the build directory to the MATLAB Path instead.
After a refresh, you will find a new Toolbox named "HackRF" in the Simulink Library Browser. A simple spectrum scope model and a single-tone transmitter model is located in the directory demos. Also, there is MATLAB command >> hackrf_find_devices
which you can use to test your setup.
Install a compiler and setup MATLAB's mex
compile script: Here, we will use MinGW64 which is support since MATLAB 2015b. To set it up follow the instructions on the Mathworks page. Next, add the MinGW64 bin directory to your PATH (default is C:\TDM-GCC-64\bin)
To double-check, open a MATLAB console:
>> mex -setup C
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
...
Get the Simulink-HackRF source from GitHub. If you aren't using git you can get the latest release. Extract the archive and create a subdirectory deps in there.
Build the hackrf library (based on libhackrf README):
First, get the hackrf source code by cloning the repo or download it as an archive and extract. Next, you need to install CMake as well as windows binaries for libusb.
Start the CMake-GUI and set the source directory to your libhackrf sources, that is subdirectory 'host/libhackrf' in the repo. Create a directory 'build' in there and set it as the binaries directory in the CMake-GUI. Next, hit Configure and select 'MinGW Makefiles' as generator. Set the CMAKE_INSTALL_PREFIX to the 'deps' directory you created above. You will probably have to set the the include and lib settings for libusb manually: LIBUSB_INCLUDE_DIR must be set to the libusb directory, subfolder 'include/libusb-1.0'. LIBUSB_LIBRARIES can point to the static library shipped with the libusb binaries, 'MinGW64/static/libusb-1.0.a'. Finally, press Generate.
Open the MinGW Command Prompt, navigate to the 'libhackrf/build' directory and run mingw32-make
to build the hackrf library. Next, run mingw32-make install
.
Get Zadig, plug-in your device and run Zadig and install the driver.
Run MATLAB, switch to your Simulink-HackRF directory and start the build process via
>> make
If you get errors, create an empty file libhackrf.lib in 'deps/bin/' and rerun. Copy libhackrf.dll from 'deps/bin' into the 'build' folder. Finally, add the build directory to the MATLAB Path.
After a refresh, you will find a new Toolbox named "HackRF" in the Simulink Library Browser. A simple spectrum scope model and a single-tone transmitter model is located in the directory demos. Also, there is MATLAB command >> hackrf_find_devices
which you can use to test your setup.
video install HackRFOne in matlab on Win8 Install simulink-hackrf in win8
The Simulink-HackRF interface consists of software from several authors. The following table lists all included software packages:
If you have further questions concerning the Simulink-HackRF interface (e.g. the build process) or you've found a bug, please feel free to contact us: