This example shows how to use an RTL-SDR radio connected to a Raspberry Pi hardware with Simulink® and Communications Toolbox® to monitor TV white space signal levels. To run this example, you need to install Communications Toolbox Support Package for RTL-SDR Radio and Simulink Support Package for Raspberry Pi Hardware.
Simulink Support Package for Raspberry Pi Hardware enables you to create and run Simulink models on Raspberry Pi hardware. Communications Toolbox Support Package for RTL-SDR Radio enables you to receive radio signals from the RTL-SDR radio. You can use these two support packages together to receive RF signals in a given bandwidth in the TV white space on the Raspberry Pi hardware.
In this example you will learn how to run the TV White Space Monitor Simulink model on Raspberry Pi hardware, and how to tune and monitor the algorithm in real time as it is executing.
Simulink's External mode feature enables you to accelerate the process of parameter tuning by letting you change certain parameter values while the model is running on target hardware, without stopping the model. When you change parameter values from within Simulink, the modified parameter values are communicated to the target hardware immediately. The effects of the parameters tuning activity may be monitored by viewing algorithm signals on scopes or displays in Simulink.
This example introduces the Simulink External mode feature by showing you how to:
Configure communications between Simulink and Raspberry Pi hardware
Tune parameters of an algorithm from the same Simulink model that is running on the Raspberry Pi hardware
Use Display block to monitor results from an algorithm running on Raspberry Pi hardware
To run this example, you will need the following hardware:
Raspberry Pi hardware
The following shows the TV white space monitor model. The model uses the RTL-SDR receiver block to receive radio signals and sends them to the signal strength estimator subsystem.
The signal strength estimator block estimates the signal power in a given band. You can vary the center frequency and signal bandwidth.
In this task, you will configure your model to run on Raspberry Pi hardware. You will then run your model on Raspberry Pi hardware in External mode. When you are prototyping and developing an algorithm, it is useful to monitor and tune the algorithm while it runs on hardware. The External mode feature in Simulink enables this capability.
1. If your Raspberry Pi hardware is not connected to an Ethernet network, follow the instructions in
Configure IP Settings on the Raspberry Pi Hardware.
2. In the model, set simulation stop time to 'inf' to run the simulation until you explicitly pause or stop the model.
3. In the Simulink model, click Tools > Run on Target Hardware> Options....
4. When the Configuration Parameters page opens up, set the Target hardware parameter to Raspberry Pi. Review the other parameters on that page. If you performed a Firmware Update, Board information will be automatically populated with the IP address, user name and password of your Raspberry Pi hardware. Also, notice the TCP/IP port edit box under Signal monitoring and parameter tuning. The default value of TCP/IP port is 17725. Simulink uses this TCP/IP port to communicate with Raspberry Pi hardware. Leave the TCP/IP port parameter to its default value. Click OK when you are done.
5. In the Simulink model, make sure that the Simulation mode on the toolbar is set to External. Then, click the Run button on the toolbar.
6. The model will now run on the Raspberry Pi hardware. A system command window will open that shows the messages coming from the model running on Raspberry Pi hardware:
7. Observe the estimated signal power level in the Uncalibrated Signal Power (dBm) block. Note that this value is uncalibrated and assumes that the output of the RTL-SDR receiver block is in Volts and the measurements are reference to 1 Ohm load.
8. Double-click the Model Parameters block. Change the Center frequency value to another band and observe that the estimated signal power level changes. You can get a list of TV channel numbers in your area using a simple web search such as "TV channels near me". In North America, you can map channel numbers to actual frequencies using North American TV Frequencies. In Natick, MA, USA, Channel 2, which has an ATSC pilot at 54.31 MHz, is available for TV White Space applications.
9. When you are done changing model parameters, press the Stop button on the model. Observe that system command window opened in the previous step indicates that the model has been stopped. At this point, you may close the system command window.
This example introduced the workflow for receiving RF signals with an RTL-SDR radio and processing the received signals using a Simulink model running on Raspberry Pi hardware. Using External mode, you changed system parameters while the model was running and observed the effects of parameter value changes.