MATLAB Examples

FRS/GMRS Walkie-Talkie Transmitter with USRP® Hardware

This example shows how to use the Universal Software Radio Peripheral® (USRP®) 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). You can listen to the transmitted signal using a commercial walkie-talkie device.

In order to run this example, you need a USRP® board with an appropriate transmitter daughterboard that supports the UHF 462-467 MHz band (for example, WBX). Please refer to the Setup and Configuration section of Documentation for USRP® Radio for details on configuring your host computer to work with the SDRu Transmitter System object™.

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.

Contents

Overview

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 USRP® device in this example will transmit messages at either 462 or 467 MHz, in a manner that is compatible with FRS/GMRS devices.

Please refer to the Simulink® model in the FRS/GMRS Walkie-Talkie Transmitter with USRP® Hardware example for a block diagram view of the system.

Discover Radio

Discover radio(s) connected to your computer. This example uses the first USRP® radio found using the findsdru function. Check if the radio is available and record the radio type. If no available radios are found, the example uses a default configuration for the system but does not run the main loop.

connectedRadios = findsdru;
if strncmp(connectedRadios(1).Status, 'Success', 7)
  radioFound = true;
  platform = connectedRadios(1).Platform;
  switch connectedRadios(1).Platform
    case {'B200','B210'}
      address = connectedRadios(1).SerialNum;
    case {'N200/N210/USRP2','X300','X310'}
      address = connectedRadios(1).IPAddress;
  end
else
  radioFound = false;
  address = '192.168.10.2';
  platform = 'N200/N210/USRP2';
end
Checking radio connections...

Initialization

The getParamsSdruFRSGMRSTxDemo.m script initialize some simulation parameters and generates a structure, frsTx. The fields of this structure are the parameters of the FRS/GMRS transmitter system at hand.

% Configure the example to transmit on channel 12 with the CTCSS code 5.
channel = 12;
CTCSSCode = 5;

frsTxParams = getParamsSdruFRSGMRSTxDemo(platform, channel, CTCSSCode)
frsTxParams = 

        RadioMasterClockRate: 20000000
             RadioSampleRate: 200000
                   RadioGain: 15
    RadioInterpolationFactor: 100
            RadioFrameLength: 24000
          FrequencyDeviation: 2500
         InterpolationFactor: 25
      InterpolationNumerator: [1x600 double]
            SourceSampleRate: 8000
           SourceFrameLength: 960
               ToneFrequency: 880
              ChirpSweeptime: 1
            ChirpInitialFreq: 600
             ChirpTargetFreq: 1200
    AudioInterpolationFactor: 160
       AudioDecimationFactor: 441
            AudioFrameLength: 2646
                     Channel: 12
                   CTCSSCode: 5
              CTCSSAmplitude: 0.1500
        CTCSSToneFrequencies: [38x1 double]
                    StopTime: 10
             SourceFrameTime: 0.1200

FRS/GMRS Transmitter

The FRS/GMRS transmitter combines signals from a source and CTCSS tone generator. The script FM modulates the combined signal and sends to the USRP® board to transmit over the air.

Source Signals

This example uses an FRSGMRSDemoSource 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 hSource. The source object 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 FRSGMRSDemoAudioSource 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 = FRSGMRSDemoSource('Sound file', frsTxParams.SourceSampleRate, ...
  'SamplesPerFrame', frsTxParams.SourceFrameLength);

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™.

interpolator = dsp.FIRInterpolator(frsTxParams.InterpolationFactor, ...
    frsTxParams.InterpolationNumerator);

This example uses the FM Modulator Baseband System object 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);

Configuration of Receiver Object

The script communicates with the USRP® board using the SDRu transmitter System object. B200 and B210 series USRP® radios are addressed using a serial number while USRP2, N200, N210, X300 and X310 radios are addressed using an IP address.

% Setup radio object to use the found radio
switch platform
  case {'B200','B210'}
    radio = comm.SDRuTransmitter(...
      'Platform', platform, ...
      'SerialNum', address, ...
      'MasterClockRate', frsTxParams.RadioMasterClockRate);
  case {'X300','X310'}
    radio = comm.SDRuTransmitter(...
      'Platform', platform, ...
      'IPAddress', address, ...
      'MasterClockRate', frsTxParams.RadioMasterClockRate);
  case {'N200/N210/USRP2'}
    radio = comm.SDRuTransmitter(...
      'Platform', platform, ...
      'IPAddress', address);
end

Set the master clock rate and interpolation factor to obtain a sample rate of 200 kHz at the output of the SDRu receiver object. For example, for a B210 radio, set MasterClockRate to 20 MHz and DecimationRate to 100. For N200, N210, and USRP2 radios master clock rate is fixed at 100 MHz. The 200 kHz sample rate enables us to use a simple interpolation filter to convert the sampling rate from 8 kHz to 200 kHz. This example configures the radio object to accept the center frequency as an input argument. Set the gain to 30 dB.

radio.CenterFrequencySource = 'Input port';
radio.Gain = frsTxParams.RadioGain;
radio.InterpolationFactor = frsTxParams.RadioInterpolationFactor;

% Display SDRu receiver object
radio
radio = 

  System: comm.SDRuTransmitter 

  Properties:
                       Platform: 'B210'      
                      SerialNum: 'F5BA51'    
                 ChannelMapping: 1           
          LocalOscillatorOffset: 0           
                           Gain: 15          
                      PPSSource: 'Internal'
                    ClockSource: 'Internal'
                MasterClockRate: 20000000    
            InterpolationFactor: 100         
              TransportDataType: 'int16'
                EnableBurstMode: false       
                                             

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 SDRu properties. You can verify that the daughterboard covers the UHF frequency range, which is 462 MHZ to 467 MHz.

hwInfo = info(radio)
hwInfo = 

                    Mboard: 'B210'
                  RXSubdev: 'FE-RX2'
                  TXSubdev: 'FE-TX2'
    MinimumCenterFrequency: 40000000
    MaximumCenterFrequency: 6.0100e+09
               MinimumGain: 0
               MaximumGain: 89.7500
                  GainStep: 0.2500
           CenterFrequency: 0
     LocalOscillatorOffset: 0
                      Gain: 15
           MasterClockRate: 20000000
       InterpolationFactor: 100
        BasebandSampleRate: 200000

Running the Example

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 = convertChan2FreqFRSGMRSDemo(frsTxParams.Channel);

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 USRP® board. The loop runs for 10 seconds and you should be able to hear the voice from your commercial walkie-talkie device.

Check for the status of the USRP® radio

if radioFound
  % 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);

    step(radio, outMod, fc);

    timeCounter = timeCounter + frsTxParams.SourceFrameTime;
  end
else
  warning(message('sdru:sysobjdemos:MainLoop'))
end

Release the USRP® resources and FM Modulator

release(fmMod)
release(radio)

If you cannot hear the voice, slightly increase the CTCSS amplitude parameter using the Amplitude property of the hCTCSS object, and try again. You can also edit the value of the CTCSSAmplitude field of the frsTxParams structure in getParamsSdruFRSGMRSTxDemo.m.

Instead of using a commercial walkie-talkie device, you can also run this example alongside an additional USRP® device running the FRS/GMRS receiver example.

Conclusion

In this example, you used Communications System Toolbox™ System objects to build an FRS/GMRS transmitter utilizing a USRP® device. This example showed that the MATLAB script can generate signals for the USRP® device in real time.

Further Exploration

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 (FD) 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 sensitivity parameter (K) 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.

Appendix

The following function and System object are used in this example.

References

Copyright Notice

Universal Software Radio Peripheral® and USRP® are trademarks of National Instruments Corp.