This example shows how to use the Software Defined Radio hardware device with MATLAB® to implement a walkie-talkie transmitter. The specific radio standard that this example follows is FRS/GMRS (Family Radio Service / General Mobile Radio Service) with CTCSS (Continuous Tone-Coded Squelch System). The transmitted signal can be received by a compatible commercial walkie-talkie.
To run this example, you need a SDR board with an appropriate transmitter daughterboard that supports the UHF 462-467 MHz band (for example, Analog Devices FMComms1). Refer to Support Package Hardware Setup for details on configuring your host computer to work with the SDR Transmitter System object, comm.SDRADIFMCOMMSTransmitter.
This example is designed to work with USA standards for FRS/GMRS operation. The technical specifications for these standards can be found at [ 1 ] and [ 2 ]. Operation in other countries may or may not work.
Walkie-talkies provide a subscription-free method of communicating over short distances. Although their popularity has been diminished by the rise of cell phones, walkie-talkies are still useful when lack of reception or high per-minute charges hinders the cell phone use. Modern walkie-talkies operate on the FRS/GMRS standards. Both standards use frequency modulation (FM) at 462 or 467 MHz, which is in the UHF (Ultra High Frequency) band. The SDR device in this example will transmit messages at either 462 or 467 MHz, in a manner that is compatible with FRS/GMRS devices.
The getParamsSdrfFRSGMRSTxDemo.m function initializes a number of simulation parameters which are output to a structure, frsTxParams. The fields of this structure are the parameters of the FRS/GMRS transmitter system at hand. You can change the input arguments in a local copy of this file in order to match your hardware.
Type 'help sdrload' to see all possible board names.
% Configure the example to transmit on channel 12 with the CTCSS code 5. channel = 12; CTCSSCode = 5; frsTxParams = getParamsSdrfFRSGMRSTxDemo(channel, CTCSSCode)
The example communicates with the SDR board using the SDR Tramsmitter System object. An image must be loaded into the FPGA. The
sdrload function can be be used to download the configuration bit stream to the FPGA via a JTAG cable. Alternatively, the sdrfgensysace function can be used to create a SystemACE configuration image that can be copied to a compact flash card and used to configure the FPGA directly using SystemACE. See sdrload and sdrfgensysace. To configure the FPGA as part of the Example, the following lines should be uncommented:
sdrload('Device', frsTxParams.MotherboardName, ... 'RFBoard', frsTxParams.RFBoardName);
The FRS/GMRS transmitter combines signals from a source and CTCSS tone generator. The script FM modulates the combined signal and sends to the SDR board to transmit over the air.
This example uses a source object, source, which is an sdrfFRSGMRSDemoSource System object, to generate data signals for the transmitter. The source signal can be a pure tone sine wave, a chirp signal, or a multimedia file. To switch between these sources, you can change the Signal property of the source object which also allows you to set the pure tone frequency or the chirp signal target/sweep time (which controls the duration of the chirp signal). This example works properly with tones as low as 500 Hz and as high as 4 kHz. When using a multimedia file, the sampling rate needs to be converted to 8 kHz; therefore, the sdrfFRSGMRSDemoAudioSource System object class employs a rate conversion filter to convert the 22.5 kHz signal to an 8 kHz signal.
% Create a data source to transmit the contents of a sound file at a % sampling frequency of 8 kHz. source = sdrfFRSGMRSDemoSource('Sound file', frsTxParams.SourceSampleRate);
Continuous Tone-Coded Squelch System (CTCSS)
Walkie-Talkies operate on a shared public channel, allowing multiple users to access the same channel simultaneously. The CTCSS [ 3 ] method filters out undesired communication or interference from these other users by generating a tone between 67 Hz and 250 Hz and transmitting it along with the source signal. The receiver contains logic to detect this tone, and acknowledges a message if the detected tone matches the code setting on the receiver. The receiver filters out the tone so that the user does not hear it.
The CTCSS tone generator generates a continuous phase sine wave with a frequency corresponding to the selected private code. The amplitude of the tone is usually 10%-15% of the maximum amplitude of the modulating signal. Note that because the maximum amplitude of all the source signals is 1, the default amplitude of 0.15 for the CTCSS tone corresponds to 15% of the modulating signal's maximum amplitude.
ctcss = dsp.SineWave(frsTxParams.CTCSSAmplitude, ... frsTxParams.CTCSSToneFrequencies(frsTxParams.CTCSSCode), ... 'SampleRate', frsTxParams.SourceSampleRate, ... 'SamplesPerFrame', frsTxParams.SourceFrameLength, ... 'OutputDataType', 'single');
Interpolator and FM Modulator
The interpolator converts the sampling rate of the sum of the modulating signal and the CTCSS tone to match the SDR hardware sampling rate of 200 kHz. The resampling filter is designed using the FIRInterpolator object from the DSP System Toolbox (TM).
interpolator = dsp.FIRInterpolator(frsTxParams.InterpolationFactor, ... frsTxParams.InterpolationNumerator);
This example uses the FM Modulator Baseband System object (TM) whose sample rate and maximum frequency deviations are set to 200 kHz and 2.5 kHz, respectively.
fmMod = comm.FMModulator('SampleRate', frsTxParams.RadioSampleRate, ... 'FrequencyDeviation', frsTxParams.FrequencyDeviation);
The script communicates with the SDR board using the SDR Transmitter System object. You can supply the IP address of the SDR board as an argument when you construct the object. The IP address can be any address within the same sub-network as the host computer. You set the rest of the properties using name-value pair arguments. This example configures the hSDR object to accept the center frequency as an input argument.
The interpolation factor is set to 234 to convert the 200 kHz signal to a signal of the Radio DAC rate which is 46.8 MHz.
radio = comm.SDRADIFMCOMMSTransmitter('IPAddress', '192.168.2.2', ... 'CenterFrequencySource', 'Input port', ... 'DACRate', frsTxParams.RadioDACRate, ... 'InterpolationFactor', frsTxParams.RadioInterpolationFactor)
Turn on your walkie-talkie, set the channel to 12 and the private code to 5. The center frequency is a function of the selected channel number.
% Get the carrier frequency for the selected channel fc = mConvertChan2FreqFRSGMRSDemo(frsTxParams.Channel);
You can obtain the information about the daughterboard using the info method of the object. This method returns a structure with fields that specify the valid range of SDR properties. You can verify that the daughterboard covers the UHF frequency range, which is 462 MHZ to 467 MHz.
Stream Processing Loop
Generate a data signal for the FRS/GMRS transmitter using the hSource object. Combine the data signal with the CTCSS tone, and pass them through a rate converter to generate a 200 kHz signal. FM modulate the resampled signal and send it to the SDR board. The loop runs for 20 seconds and you should be able to hear the voice from your commercial walkie-talkie device.
try % Loop until the example reaches the target stop time. timeCounter = 0; while timeCounter < frsTxParams.StopTime data = step(source); dataWTone = data + step(ctcss); outResamp = step(interpolator, dataWTone); % FM modulator outMod = step(fmMod, outResamp); lostSamples = step(radio,outMod,fc); if lostSamples warning('Transmitter lost samples'); end timeCounter = timeCounter + frsTxParams.SourceFrameTime; end catch ME rethrow(ME); end
Release the SDR resources
If you cannot hear the voice, slightly increase the CTCSS amplitude parameter using the Amplitude property of the ctcss object, and try again. You can also edit the value of the CTCSSAmplitude field of the frsTxParams structure in getParamsSdrfFRSGMRSTxDemo.m.
In this example, you used Communications System Toolbox™ System objects to build an FRS/GMRS transmitter utilizing a SDR hardware device. This example showed that the MATLAB script can generate signals for the SDR hardware device in real time.
You can set your walkie-talkie channel to one of the 14 channels (numbered 1 to 14) and the private code to either one of the 38 private codes (numbered 1 to 38) or 0, in which case the squelch system is not used and all received messages are accepted. Note that the private codes above 38 are digital codes and are not implemented in this example. Set the channel and private code in the example so that they match the walkie-talkie.
Part 95.637 (Modulation standards) of the FCC wireless standards [ 4 ] state that the maximum frequency deviation is 2.5 kHz for FRS and 5 kHz for GMRS. In practice, it is usually set to 2.5 kHz for both systems. If the maximum signal amplitude increases, the frequency deviation parameter should decrease. Otherwise, the receiving walkie-talkie will not decode the CTCSS code correctly. You can try to use a different signal with different values for frequency deviation to see if your walkie-talkie works properly. If the frequency deviation value is too large, you may not hear anything from your receiver when using a non-zero CTCSS private code. Set the CTCSS code to 0, which disables the squelch system. If you hear the transmitted signal, the CTCSS decoding of the non-zero code is incorrect.
You can reduce the amplitude of the CTCSS tone to determine the minimum amplitude required for your receiver to work correctly.
The following scripts and System objects are used in this example.