Walkie-Talkie Receiver Using Analog Devices AD9361/AD9364
This example shows how to use the Xilinx® Zynq-Based Radio Support Package with Simulink® to implement a walkie-talkie receiver. The received signal can be transmitted by a compatible commercial walkie-talkie. Alternatively, the transmission can be generated by the companion Walkie-Talkie Transmitter Using Analog Devices™ AD9361/AD9364 example if you have a second SDR platform.
Refer to the Getting Started documentation for details on configuring your host computer to work with the Support Package for Xilinx® Zynq-Based Radio.
Walkie-talkies provide a subscription-free method of communicating over short distances. There are a number of different standards used around the world. This example uses Simulink to implement two of these standards: Family Radio Service and Personal Mobile Radio 446.
- Family Radio Service (FRS): Operates on 14 channels at frequencies around 462 MHz and 467 MHz. The channel spacing is 25 kHz. FRS radios are commonly found in the North and South America. More details on FRS can be found in [ 1 ].
- Personal Mobile Radio 446 (PMR446): Operates on 8 channels around 446 MHz. The channel spacing is 12.5 kHz. PMR446 radios are commonly found in Europe. More details on PMR446 can be found in [ 2 ].
Both FRS and PMR446 use analog frequency modulation (FM) with a maximum frequency deviation of +-2.5 kHz. They also use a Continuous Tone-Code Squelch System (CTCSS) to filter unwanted signals at the receiver. CTCSS is implemented in this example.
Before running the example, ensure you have performed the following steps:
1. Configure your host computer to work with the Support Package for Xilinx® Zynq-Based Radio. See Getting Started for help.
- Some additional steps may be required if you want to run two radios from a single host computer. See Setup for Two Radios - One Host for help.
2. Ensure that you have a suitable transmitter. This example is designed to work in conjunction with any of the following possible transmitters:
- The Walkie-Talkie Transmitter Using Analog Devices AD9361/AD9364 MATLAB® example
- The Walkie-Talkie Transmitter Using Analog Devices AD9361/AD9364 Simulink example
- A commercial FRS/PMR446 radio
3. Ensure that your transmitter is set to the same protocol, channel and CTCSS code.
Running the Example
Once both the transmitter and receiver are active, you should hear the transmitted audio on your computers default audio output device.
You can configure various settings that control the model using the Model Parameters block. Except for the walkie-talkie protocol and the CTCSS decode block length, all of the parameters can be changed while the model is running.
Receiver Design: System Architecture
The top level of the model is shown below.
The general structure of the walkie-talkie receiver can be described as follows:
- Receive baseband data from the SDR hardware.
- Filter the signal to reduce noise from adjacent channels.
- Apply AGC to the signal.
- Filter out weak signals based on received signal power. Downstream processing is disabled if the signal is too weak.
- FM Demodulate the signal.
- Downsample the signal to a standard 8 kHz audio sample rate.
- Perform CTCSS decoding. If the received code matches the desired code, pass through the audio.
- High pass filter the audio to remove the CTCSS tone.
- Play the audio on the computers default audio output device.
Sections of the model that implement the above processes are explored in more detail below.
The SDR Receiver subsystem is where radio baseband data is received from the SDR hardware via an ZC706 and Analog Devices FMCOMMS2/3/4 Receiver block. The SDR hardware is configured to use input ports for the RF center frequency. Using an input port for these parameters allows them to be updated while the model is running. The desired center frequency is dependent on the channel selected in the Model Parameters block.
The Signal Conditioning subsystem is where the received signal is filtered to remove adjacent channel noise, AGC is applied and weak signals are blocked from proceeding to downstream processing.
The channel filter is implemented using a simple lowpass filter from the DSP System Toolbox™. FRS uses a channel separation of 25 kHz, while PMR446 uses a channel separation of 12.5 kHz. Making the channel filter a low pass filter with a cutoff frequency of 6 kHz and a stopband of 8 kHz gives a good tradeoff between adjacent channel attenuation and filter length.
The AGC block is from the Communications System Toolbox™. The automatic gain controller applies a variable gain to the received signal to assure that the received signal amplitude is at a known level. You can increase the update period to increase the speed of the AGC algorithm.
The squelch filter is implemented using simple MATLAB code. The threshold value can be changed in the Model Parameters block. The squelch filter has two major benefits. Firstly, when the received signal is too weak, the receiver will not play any audio, as opposed to playing random noise. Secondly, the downstream processing is disabled when the received signal is too weak. This can significantly help the real time performance of the model.
The FM Demodulation subsystem is where the received signal is FM demodulated. In this example, the demodulation is performed a simple differentiation operation.
A decimation filter converts the 640 kHz radio baseband rate to 8 kHz. This rate is one of the native sampling rates of your host computers output audio device.
Continuous Tone-Coded Squelch System (CTCSS)
The CTCSS Decoder subsystem is where the received CTCSS code is calculated and the signal blocked if the received code does not match the expected code.
The CTCSS_Decode function computes the power at each CTCSS tone frequency using the Goertzel algorithm [ 4 ] and outputs the code with the largest power. The Goertzel algorithm provides an efficient method to compute the frequency components at predetermined frequencies, i.e. the tone code frequencies used by CTCSS.
The CTCSSCodecompare function compares the received CTCSS code with the desired code. If they match, the audio data is passed through for playback. If they do not, the audio is muted.
More information on CTCSS can be found in [ 3 ].
The Audio Player subsystem is where the audio signal has the CTCSS tone removed before it is output to the computers default audio output device. A simple highpass filter is used to remove the CTCSS tones, which have a maximum frequency of 250.3 Hz.
Receiver Design: System Sample Rates
The system has two different sample rates:
- The SDR hardware baseband rate, 640 kHz
- The audio sample rate, 8 kHz
The downsample by 80 from 640 kHz to 8 kHz is done in software using a dsp.FIRDecimator object, softwareDecimator. The radio baseband rate of 640 kHz is necessary for two reasons:
- By Carson's rule, the approximate passband bandwidth of the desired FM signal is 2*(frequencyDeviation + peakAudioFrequency). In this example, that equates to a signal bandwidth of 2*(2.5e3 + 4e3) = 13 kHz. This means we need to use a sample rate greater than 13 kHz.
- The sample rates in software have no relation to the real world transmission rates. The actual reception rate is determined entirely by the SDR hardware baseband sample rate. To make the software sample rates meaningful, the sample rates at the software/hardware interface must match. For the AD9361/AD9364, one of the possible baseband sample rates that is a multiple of 8 kHz and greater than 13 kHz is 640 kHz. Using an integer downsampling factor means a smaller decimation filter (less taps) can be used.
Things to Try
To modify the example, double click on the Model Parameters block. Most of the parameters can be altered while the model is running. Some possible modifications include:
- Try changing the channel.
- Try changing the CTCSS code. Note that the receiver will not play the transmission out loud unless it has the same CTCSS code as the transmitter, or it has CTCSS disabled by setting the code to 0.
- Try changing the CTCSS decode block length, which is used to control the number of samples used in the Goertzel algorithm for detecting the CTCSS tones. Larger values result in a finer frequency resoultion and therefore better tone detection, at the expense of increased latency. For example, the default value of 4000 results in a delay of 0.5s.
This example implements a walkie-talkie receiver in Simulink. You can also view the equivalent system implemented using MATLAB in the Walkie-Talkie Receiver Using Analog Devices AD9361/AD9364 using MATLAB example.
Troubleshooting the Example
If you cannot hear the transmitted signal on your receiver, try the following:
- Make sure that the transmitter and the receiver are set to the same protocol, channel and CTCSS code.
- Disable CTCSS on the receiver by setting the code to 0. Note that codes higher than 38 use Digital Coded Squelch, which is not implemented in this example.
- Set the signal threshold for the squelch filter to 0 to disable filtering out weak signals. This can be done in the Model Parameters block. Try adjusting the value to achieve a good tradeoff between playing valid received signals and blocking noise when the received signal is too weak.
- Try varying the gain of the SDR receiver block depending on your received signal strength.
General tips for troubleshooting SDR hardware can be found in Xilinx Zynq-Based Radio Processing Errors and Fixes.
List of Example Helper Files
This example uses the following helper files:
- zynqRadioWalkieTalkieRxHelperAD9361AD9364SL_SimParams.m: returns a structure of variables used to control constant parameters in the model.
- sdrzWalkieTalkieRxHelper_ModelParamsMask.m: controls the Model Parameters mask and updates the model depending on the parameters supplied in the mask.
- sdrzWalkieTalkieHelper_Channel2Frequency.m: converts a channel number to an RF frequency.