main content

digital up and down conversion for family radio service in matlab -凯发k8网页登录

family radio service (frs) is an improved walkie talkie fm radio system authorized in the united states since 1996. this personal radio service uses channelized frequencies in the ultra high frequency (uhf) band. devices operating in the frs band must be authorized under part 95 subpart b "family radio service" (sections 95.191 through 95.194) of the fcc rules. the authorized bandwidth of frs channels is 12.5 khz and the center frequency separation between channels is 25 khz.

digital up converter (duc) and digital down converter (ddc) system objects can be used to design a family radio service transmitter and receiver. these objects provide tools to design interpolation and decimation filters and simplify the steps required to implement the up and down conversion process. this example illustrates the matlab® implementation using the and the system objects. a simulink® implementation is featured in and uses the and blocks. speech signal is used as an input and the signal after transmission is played back.

introduction

this example discusses the digital up conversion of a signal to be transmitted through an frs channel, and the down conversion of the signal coming from the frs radio transmitter.

the 8 khz speech is first resampled to 50khz. the duc at the transmitter up converts the signal from 50 khz to 2 mhz and shifts the signal to an if frequency of 455 khz. the receiver has an analog front end that brings the received signal to an if frequency of 455 khz. the signal is then sampled at a rate of 2 mhz. the ddc at the receiver brings the signal back to baseband with a sample rate of 50 khz. this is brought back to 8 khz speech range.

digital up converter design

design a digital up converter by creating a duc system object. the duc object consists of a cascade of three interpolation filters and an oscillator that up converts the interpolated signal to a specified passband frequency. a block diagram of the duc object is shown next.

the duc object provides options to define the interpolation filters. for instance, you can design the oscillator using either a sine wave generator or a numerically controlled oscillator. this section showcases the different options available to design the interpolation filters for the frs transmitter.

designing interpolation filters

the duc object implements the interpolation filter using three filter stages. when the duc object designs the filters internally, the first stage consists of a halfband or a lowpass filter, the second stage consists of a cic compensator, and the third stage consists of a cic interpolation filter. the duc object allows you to specify several characteristics that define the response of the cascade for the three filters, including passband and stopband frequencies, passband ripple, and stopband attenuation.

minimum order filter designs

by default (when the minimumorderdesign property is set to true) the duc object obtains minimum order interpolation filter designs using the passband and stopband specifications you provide.

for this example, you must upsample the transmitted signal from 50 khz to 2 mhz. this yields an interpolation factor of 40. the duc object automatically factors the interpolation value so that the first filter stage interpolates by 2, the second filter stage interpolates by 2, and the cic filter interpolates by 10.

the frs channel double sided bandwidth is 12.5 khz. set the bandwidth property of the duc object to 12.5 khz so that the passband frequency of the cascade response of the interpolation filters is 12.5e3/2 = 6.25 khz.

set the passband ripple to a small value of 0.05 db to avoid distortion of the frs signal. set the stopband attenuation to 60 db.

by default (when the stopbandfrequencysource property is set to 'auto') the duc object sets the cutoff frequency of the cascade response approximately at the input nyquist rate of 25 khz. the object also sets the stopband frequency at 2fc-fpass = 2*25e3 - 12.5e3/2 = 43.75 khz, where fc is the cutoff frequency and fpass is the passband frequency. in this scenario, the duc object relaxes the stopband frequency as much as possible, obtaining the lowest filter orders at the cost of allowing some energy of interpolation replicas in the transition band of the cascade response. this design tradeoff is convenient when your priority is to minimize filter orders.

duc = dsp.digitalupconverter(...
  samplerate=50e3,...
  interpolationfactor=40,...
  bandwidth=12.5e3,...
  passbandripple=0.05,...
  stopbandattenuation=60);

visualize the cascade response of the decimation filters using the or methods of the duc object. specify the arithmetic as 'double' so that the filter coefficients and operations are double-precision.

fvt = fvtool(duc, arithmetic='double');

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 2 objects of type line.

close(fvt)
fvt = visualizefilterstages(duc, arithmetic='double');

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 5 objects of type line. these objects represent halfband interpolator, interpolation factor = 2, cic compensator, interpolation factor = 2, cic interpolator, interpolation factor = 10, cascade response.

get the orders of the designed filters using the function.

s = getfilterorders(duc);
s.firstfilterorder
ans = 10
s.secondfilterorder
ans = 12

the frs channel separation is 25 khz. most commercial frs radios offer 50 db or higher adjacent channel rejection (acr). clearly, the cascade response of the decimation filters designed above does not achieve a 50 db attenuation at 25 khz. one possible solution to this problem is to filter the baseband frs signal with a lowpass filter with the required transition width and stopband attenuation before passing the signal through the duc object. another solution is to set the duc object so that it designs a cascade response with a narrower transition bandwidth that meets the required spectral mask. to design an overall filter response with a narrower transition bandwidth, set the stopbandfrequencysource property to 'property' and the stopbandfrequency property to a desired value.

design the filters so that the cascade response has a stopband frequency at the edge of the passband of the adjacent frs channel, i.e. at 25e3-12.5e3/2 = 18.75 khz. set the stopbandattenuation property to 60 db to achieve a 60 db acr.

duc.stopbandfrequencysource = 'property';
duc.stopbandfrequency = 18.75e3;
duc.stopbandattenuation = 60;
close(fvt)
fvt = fvtool(duc,'arithmetic','double');

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 2 objects of type line.

get the filter orders

s = getfilterorders(duc);
s.firstfilterorder
ans = 23
s.secondfilterorder
ans = 7

the new cascade response achieves 60 db attenuation at 25 khz, i.e., at the center of the adjacent frs channel. the order of the first stage filter (lowpass interpolator) increases from 10 to 23. note however that the order of the second stage filter (cic compensator) decreases from 12 to 7. because the first stage response has a narrower bandwidth, the second stage stopband can be relaxed even more to the edge of the left stopband of the first replica of the first stage filter. since the second filter stage operates at a higher rate, this is a very convenient order reduction.

controlling the filter orders

there are cases when filter orders are the main design constraint. set the minimumorderdesign property to false to design interpolation filters with a specific order. in this configuration, you can still specify the required passband and stopband frequencies. the orders of the filters control the stopband attenuation and ripple of the cascade response.

to meet a constraint of a maximum of 20 coefficients in the first filter stage, set the firstfilterorder property to 20. set the secondfilterorder property to 7, and the number of cic sections to 4.

% keep a copy of the minimum order design so that we can use it later on
% this example.
ducminorder = clone(duc);
% specify the filter orders and visualize the cascade response.
duc.minimumorderdesign = false;
duc.firstfilterorder = 20;
duc.secondfilterorder = 7;
duc.numcicsections = 4;
close(fvt)
fvt = fvtool(duc, arithmetic='double');

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 2 objects of type line.

the new design has lower stopband attenuation and larger passband ripple due to the reduced first filter order.

oscillator design

use the oscillator property to select the type of oscillator the object uses to perform the frequency up conversion. set the property to 'sine wave' to obtain an oscillator signal from a sinusoidal computed using samples of the trigonometric function. alternatively, set the property to 'nco' so the object designs a numerically controlled oscillator. set the center frequency of the oscillator to the if frequency of 455 khz.

duc.oscillator = 'sine wave';
duc.centerfrequency = 455e3;

digital down converter design

you design a digital down converter (ddc) by creating a ddc system object. the ddc system object consists of an oscillator that down converts an input signal from a specific passband frequency to 0 hz. the object down samples the down converted signal using a cascade of three decimation filters. the following block diagram shows the ddc object.

as in the duc case, the ddc object offers different options for defining decimation filters. for instance, you can design the oscillator using either a sine wave generator or a numerically controlled oscillator. alternatively, you can provide an oscillator signal as an input.

designing decimation filters

the ddc object implements decimation using three filter stages. when the object designs the filters internally, the first stage consists of a cic decimator, the second stage consists of a cic compensator, and the third stage consists of a halfband or a lowpass decimation filter. as in the duc case, the ddc object allows you to specify characteristics that define the response of the cascade of the three filters, including passband and stopband frequencies, passband ripple, and stopband attenuation.

design minimum order decimation filters to receive an frs signal centered at an if frequency of 455 khz. decimate the signal by 40 to downsample it from 2 mhz to 50 khz. set the stopbandfrequencysource property to 'property' and the stopband attenuation to 60 db to design a cascade response that achieves an acr of 60 db.

ddcminorder = dsp.digitaldownconverter(...
  samplerate = 2e6,...
  decimationfactor = 40,...
  bandwidth = 12.5e3,...
  passbandripple = 0.05,...
  stopbandattenuation = 60,...
  stopbandfrequencysource = 'property',...
  stopbandfrequency = 18.75e3,...
  centerfrequency = 455e3);

analyze the responses of the decimator filters and verify that the cascade response achieves an attenuation of 60 db at 25 khz. note how the ddc relaxes the response of the second stage (cic compensator) to the edge of the left stopband of the first alias of the third stage (lowpass decimator) to minimize order.

close(fvt)
fvt = visualizefilterstages(ddcminorder, arithmetic='double');

figure figure 1: magnitude response (db) contains an axes object. the axes object with title magnitude response (db), xlabel frequency (khz), ylabel magnitude (db) contains 5 objects of type line. these objects represent cic decimator, decimation factor = 10, cic compensator, decimation factor = 2, lowpass decimator, decimation factor = 2, cascade response.

similar to the duc case, you can define the filter orders by setting the minimumorderdesign property to false.

matlab processing loop

the fcc part 95 specifies an fm modulation with a maximum frequency deviation of 2.5 khz and a maximum audio frequency of 3.125 khz. frequency-modulate the audio signal to obtain the frs baseband signal (the signal does not include a squelch tone). up convert and down convert the baseband frs signal using the duc and ddc objects that were designed in the previous sections using minimum order filters. demodulate the signal and play it using audio player.

% initialize simulation parameters
close(fvt)
fs = 50e3;
framelength = 1000;
maxaudiofrequency = 3.125e3; % maximum allowed audio frequency for frs radios
deltaf = 2.5e3;              % maximum allowed frequency deviation for frs radios
freqsensitivitygain = deltaf*2*pi/fs;  % k=fd/a*(2*pi*ts)
modulationfilter = dsp.iirfilter(numerator=1, denominator=[1, -1]);
demodulationdelay = dsp.delay(1);
audioreader = dsp.audiofilereader('speech_dft_8khz.wav', ...
                playcount = 3, samplesperframe = framelength);
srctx = dsp.samplerateconverter(inputsamplerate=audioreader.samplerate, ...
                outputsamplerate = fs, bandwidth = 6.25e3);
srcrx = dsp.samplerateconverter(inputsamplerate = fs, ...
    outputsamplerate = audioreader.samplerate, bandwidth = 6.25e3);
audiowriter = audiodevicewriter(samplerate = 8e3);
ducminorder.centerfrequency = 455e3;
basebandsignalspectrum = spectrumanalyzer(...
        method = 'welch', ...
        averagingmethod = 'exponential', ...
        forgettingfactor = 0.1, ...
        samplerate = fs, ...
        showlegend = true, ...
        channelnames = {'baseband input', 'down-converted output'}, ...
        title = 'power spectrum of baseband signal');
    
upconvertedsignalspectrum = spectrumanalyzer(...
        method = 'welch', ...
        averagingmethod = 'exponential', ...
        forgettingfactor = 0.1, ...
        samplerate = fs*ducminorder.interpolationfactor, ...
        title = 'power spectrum of signal after duc');

stream data

while ~isdone(audioreader)
  % input speech signal
  audioin = audioreader();
  
  % resample
  audioin_200khz = srctx(audioin);
  
  % fm modulation
  xfmbaseband = exp(1j * freqsensitivitygain * modulationfilter(audioin_200khz));
  
  % up conversion  
  xup = ducminorder(xfmbaseband);
  upconvertedsignalspectrum(xup);
  % down conversion
  xdown = ddcminorder(xup);
  basebandsignalspectrum([xfmbaseband, xdown]);
  
  % fm demodulation
  audioout_200khz = angle(demodulationdelay(xdown) .* conj(xdown));
  
  % resample
  audioout = srcrx(audioout_200khz);
  
  % play audio
  audiowriter(audioout);  
end
  
% cleanup
release(audioreader);
release(srctx);
release(modulationfilter);
release(ducminorder);
release(ddcminorder);
release(demodulationdelay);
release(srcrx);
release(basebandsignalspectrum);

release(upconvertedsignalspectrum);

release(audiowriter);

conclusions

in this example, you designed a digital up and down converter for an frs transmitter and receiver using the dsp.digitalupconverter and dsp.digitaldownconverter system objects. the example has explored the different options offered by these objects to design interpolation and decimation filters. the example has also explored the filter analysis tools available in the dsp.digitalupconverter and dsp.digitaldownconverter objects such as the visualizefilterstages, fvtool, and getfilterorders functions.

the digital up converter and digital down converter objects designed in this example operate with double-precision filter coefficients and double-precision arithmetic. see the example if you are interested in designing a digital up converter and digital down converter that operates with fixed-point inputs.

see also

functions

objects

  • | | | | | | |

related topics

    网站地图