On February 20th (the ninth day of the Lunar New Year) at midnight, the fifth issue of Funpack has ended, and the review process is nearing completion. Congratulations to those who passed the review! Of course, the most concerning question is when will the refunds be issued? This week, we will gradually release projects from those who have produced good videos and documents for everyone to reference, while also completing the refunds.
Today, let’s take a look at how a junior student majoring in Electronic Information at the University of Science and Technology of China, 【Hydrochlorinated Dechlorination Hypochlorous Acid】, uses the Simulink support package for PLUTO and implements an FM player interface using MATLAB App Designer.
Enjoy!
Platform Introduction
The ADALM-PLUTO active learning module (PlutoSDR) is easy to use and helps introduce electrical engineering students to the fundamentals of Software Defined Radio (SDR), Radio Frequency (RF), and wireless communication. This module is designed for students of varying levels and backgrounds and can be used for both teacher-led and self-directed learning, aiming to help students build a foundation in RF and communication technologies for real-world applications while pursuing degrees in science, technology, or engineering.
When used with a host, PlutoSDR acts as a portable laboratory that enhances classroom learning. MATLAB® and Simulink® are the two main software packages supported by PlutoSDR, providing an intuitive graphical user interface (GUI) that allows students to learn faster, work more cleverly, and explore more knowledge.
PlutoSDR features independent receive and transmit channels and can operate in full-duplex mode. The active learning module can generate or capture RF analog signals at frequencies ranging from 325 MHz to 3800 MHz at a maximum of 61.44 MSPS. PlutoSDR is very small, fitting in a shirt pocket, completely self-sufficient and powered by USB with default firmware. Since PlutoSDR starts via the libiio driver, it supports OS X®, Windows®, and Linux®, allowing students to learn and explore on multiple devices.
Development Environment
The development environment for this project is MATLAB (2020b) and Simulink, using the PLUTO software package in MATLAB to provide the programming interface for PLUTO, and using MATLAB App Designer to design the user interface, packaged as a MATLAB App program for easy development and use.
Toolboxes used:
Task Description: Expand the frequency range of ADALM-PLUTO, replace the ADALM-PLUTO antenna, and complete the functions of a common FM radio.
Basic requirements for the task:
After the Pluto connection switch in the app is turned on, the app automatically starts simulating the internal Simulink model and passes information such as the center frequency and volume to the model. The Simulink model includes the Pluto receive module, FM broadcast demodulation module, and audio playback module. The demodulated audio signal is then passed to the audio playback module, achieving the functionality of an FM radio.
1. PLUTO Frequency Band Expansion:
The default frequency band of Pluto is 325 – 3800 MHz, which does not include FM broadcasts. Enter the command in the MATLAB command line:
configurePlutoRadio('AD9364')
This can expand Pluto’s frequency band to 70 – 6000 MHz, allowing it to receive FM broadcasts.
(1) Pluto Receive Module (ADALM-Pluto Radio Receiver):
In the model, use the Constant Value module on the far left of the image above to pass the center frequency, so in the Pluto receive module, the source of center frequency should be set to Input Port. The baseband sample rate depends on the final audio sample rate. Set the final audio sample rate to 48000Hz, and the baseband sample rate needs to be an integer multiple of the audio sample rate, so it is set to 5 times, making the baseband sample rate 240kHz.
The frame size below, which is the size of the receive buffer, will only pass the signal to the demodulation module after the receive buffer is filled. Setting a reasonable buffer size can improve reception efficiency; here it is set to 3840.
All other parameters remain default.
(2) FM Broadcast Demodulation Module (FM Broadcast Demodulator Baseband):
Configure the sampling rate of the FM broadcast demodulation module to 240kHz and the audio sampling rate to 48000Hz, with a maximum frequency deviation of 75kHz.
This module comes with a de-emphasis filter. In FM broadcast transmission, a pre-emphasis circuit is used to improve the signal-to-noise ratio of high-frequency modulation, so a de-emphasis circuit must be used in FM radios to restore the audio signal. The time constant for domestic broadcast de-emphasis filters is 50μs.
The demodulated audio signal goes through a Gain module for volume adjustment, directly adjusting the volume by changing the waveform amplitude, and then is played back through the audio playback module (Audio Device Writer).
The user interface of the app is designed using MATLAB App Designer. The app design tool is an interactive development environment for designing app layouts and programming their behavior. It provides a complete integrated version of the MATLAB editor and a large number of interactive UI components. It also provides a grid layout manager to organize your user interface and options for automatic layout adjustments to make your app responsive to changes in screen size. It allows you to distribute the app by packaging it as an installer file directly from the app design tool toolbar or by creating standalone desktop or web apps.
(1) Interaction with Simulink Model
Record the model name with a variable:
model = 'funpack5_model'; % Simulink Model
load_system() is used to load the Simulink model into memory:
load_system(app.model);
After loading the model, use the set_param() function to change model parameters. The center frequency can be changed by modifying the Value of the CenterFrequency module in the Simulink model, and the volume can be changed by modifying the Gain of the Volume module. Both module parameters only accept strings containing numerical values, so the num2str() function is used to convert floating-point numbers to strings and keep two decimal places. Additionally, the volume needs to map the 0-100 volume value to a 0-1 signal gain value, so it is divided by 100.
set_param([app.model '/CenterFrequency'], 'Value', num2str(freq, '%.2f'));
set_param([app.model '/Volume'], 'Gain', num2str(vol/100, '%.2f'));
Call the sim() function to start the simulation:
To stop the simulation, also use the set_param() function:
set_param(app.model, 'SimulationCommand', 'stop');
During the simulation, call the open_system() function, and select the Spectrum Analyzer module to open the spectrum window, and call the lose_system() function to close the spectrum window.
open_system([app.model '/Spectrum Analyzer']);
(2) App Component Callback Functions
The app interface includes several interactive modules: connection switch, center frequency adjustment knob, center frequency fine-tuner, volume adjustment knob, volume fine-tuner, spectrum display button, and status indicator. The status indicator has no callback function, while the knobs and fine-tuners share one callback function, and the switch and button have their own callback functions.
Here, only the callback function for the connection switch will be introduced; the others are similar.
When the connection switch is turned on, the callback function PlutoConnectionSwitchValueChanged() is called. In the callback function, execute the function pluto_connecting_disconnecting(), which writes ‘y’ into the property Color of the status lamp, causing the lamp to turn yellow, indicating that Pluto is connecting.
Once connected successfully, the broadcast plays automatically, and ‘g’ is written into the property Color of the status lamp, causing it to turn green.
After turning off the connection switch, the callback function is entered again, the simulation stops, and ‘r’ is written into the property Color of the status lamp, causing it to turn red, indicating that the connection is disconnected.
When there is an error connecting to Pluto, an error window pops up, called by the main page of the app. The error window receives the error information passed from the main page and displays it in the startup function.
error_window(['Error connecting to Pluto!' newline newline 'Please check your Pluto connection.']);
The error window can be called with the error_window function, where the parameter is the string containing the error information.
The error window automatically calls the startup function when it pops up:
function startupFcn(app, str)
app.ErrorMessageLabel.Text = str
end
It receives the string and writes it to the page, completing the display of the error information.
The price of the ADALM-PLUTO kit is much higher than in previous issues, but its playability and expandability are very strong. As an electronic information major student, radio is an indispensable part, so I immediately placed an order on the first day of the event. Although I had no prior SDR experience, the PLUTO software package and App Designer provided by MATLAB significantly reduced the development difficulty. I hope the funpack activities continue to thrive!
The Yinghe team is dedicated to providing standardized core skill courses for electronic engineers and related students, helping everyone effectively enhance their professional abilities at various stages of learning and working.
Yinghe Academy
Let’s explore together in the field of electronics
Follow the Yinghe service account to access the classroom anytime
Click to read the original text to check the latest Funpack event