数字上变频仿真设计

💡 我的毕设题目为多频点数字上变频器，因此先做了 DUC 的仿真，目标是将 48k 采样率的音频信号进 28 插值到 6.144M 的采样率，并将其做 AM 调制后发射出去。

Matlab 仿真

基本参数生成

Copy
%% base data gen
fs_base=48e3; % Sampling rate at input DUC
upsample_L=128;
fs_duc=fs_base*upsample_L; % Sampling rate at output DUC
Fc=5e6; % Carrier Frequency
Fpass=20e3; % AM baseband width
Fstop=30e3; % Stopband
Ap=0.1; % Passband ripple
Ast=60; % Stopband attenuation
T = 1; % 持续时间
t = 0:1/fs_base:T-1/fs_base;% 时间向量
outputframe=1;
N1_cycle = 128;
N2_cycle = 64;
N3_cycle = 32;
N4_cycle = 16;

系统的整体速率为 48k×128=6.144M，通过使能信号进行采样率的变换。信号输出为流式输出，帧大小为 1 。

第一级 低通 FIR 插值滤波器

Copy
%% First Lowpass Fir Interpolator

lowpassParams.FsIn=fs_base;
lowpassParams.InterpolationFactor = 2;
lowpassParams.FsOut=lowpassParams.FsIn*lowpassParams.InterpolationFactor;

lowpassSpec = fdesign.interpolator(lowpassParams.InterpolationFactor, ...
'lowpass','Fp,Fst,Ap,Ast',Fpass,Fstop,Ap,Ast,lowpassParams.FsOut);
lowpassFilt = design(lowpassSpec,'SystemObject',true)

输入信号采样率为基带速率，输出信号采样率为基带速率 × 插值因子，通过 fdesign.interpolator 设计滤波器系数，滤波器的幅频响应如下：

第二级 低通半带插值滤波器

Copy
%%
% *Second Halfband Interpolator*
%
% The halfband filter provides efficient interpolation by two. Halfband
% filters are efficient for hardware because approximately half of their
% coefficients are equal to zero, and those multipliers are excluded from
% the hardware implementation.

hbParams.FsIn = lowpassParams.FsOut;
hbParams.InterpolationFactor = 2;
hbParams.FsOut = lowpassParams.FsOut*hbParams.InterpolationFactor;
hbParams.TransitionWidth = hbParams.FsIn - 2*Fstop; % 通带，由于插值后频谱会根据输入信号的采样率做周期延拓
% 减去 2 倍的 Fstop 是为了确保插值后保留的信号带宽不会引入混叠，同时保证足够的衰减
hbParams.StopbandAttenuation = Ast;

hbSpec = fdesign.interpolator(hbParams.InterpolationFactor,'halfband', ...
'TW,Ast', ...
hbParams.TransitionWidth, ...
hbParams.StopbandAttenuation, ...
hbParams.FsOut);

hbFilt = design(hbSpec,'SystemObject',true)

半带滤波器的通带为输入信号采样率减去两倍的截止频率，确保插值后产生的频谱延拓的频带都能被滤除，不会引入混叠，同时保证了足够的衰减。

半带滤波器的幅频响应及两级滤波器级联的响应如下：

第三级 CIC 补偿滤波器

由于 CIC 插值滤波器通带内不平坦，因此要加入补偿滤波器。

Copy
% *CIC Compensation Interpolator*
%
% Because the magnitude response of the last CIC filter has a significant
% _droop_ within the passband region, the example uses an FIR-based droop
% compensation filter to flatten the passband response. The droop
% compensator has the same properties as the CIC interpolator. This filter
% implements interpolation by a factor of two,
% so you must also specify bandlimiting characteristics for the filter.
% Also, specify the CIC interpolator properties that are used for this
% compensation filter as well as the later CIC interpolator.
%
% Use the |design| function to return a filter System object with the
% specified characteristics.

compParams.FsIn = hbParams.FsOut;
compParams.InterpolationFactor = 2; % CIC compensation interpolation factor
compParams.FsOut = compParams.FsIn*compParams.InterpolationFactor; % New sampling rate
compParams.Fpass = 1/2*compParams.FsIn + Fpass; % CIC compensation passband frequency
compParams.Fstop = 1/2*compParams.FsIn + 1/4*compParams.FsIn; % CIC compensation stopband frequency
compParams.Ap = Ap; % Same passband ripple as overall filter
compParams.Ast = Ast; % Same stopband attenuation as overall filter
N = 31; % 32 tap filter to take advantage of 16 cycles between input

cicParams.InterpolationFactor = 16; % CIC interpolation factor
cicParams.DifferentialDelay = 1; % CIC interpolator differential delayb
cicParams.NumSections = 4; % CIC interpolator number of integrator and comb sections

compSpec = fdesign.interpolator(compParams.InterpolationFactor,'ciccomp', ...
cicParams.DifferentialDelay, ...
cicParams.NumSections, ...
cicParams.InterpolationFactor, ...
'N,Fp,Ap,Ast', ...
N,compParams.Fpass,compParams.Ap,compParams.Ast, ...
compParams.FsOut);
compFilt = design(compSpec,'SystemObject',true)

补偿滤波器的通带和阻带频率的设置原因如下：

compParams.Fpass = 1/2 * compParams.FsIn + Fpass:
这里的通带频率 Fpass 的设置是基于输入采样率 compParams.FsIn。CIC 滤波器通常对频率响应的衰减从 FsIn/2 开始变得明显，所以补偿滤波器的通带设置为 FsIn/2 + Fpass，这样可以确保补偿滤波器修正 CIC 滤波器在通带内的增益，特别是在高频部分。

compParams.Fstop = 1/2 * compParams.FsIn + 1/4 * compParams.FsIn:
阻带频率的设置为 FsIn/2 + 1/4 * FsIn，其目的是进一步保证在插值之后，信号频谱的带外部分能够被足够衰减，防止混叠现象的发生。由于插值过程会把输入信号的频谱周期性延拓，滤波器的阻带需要覆盖到这些延拓部分，以保证无用信号被滤除。

补偿滤波器的幅频响应图如下：

第四级 CIC 插值滤波器

Copy
%%
% *CIC Interpolator*
%
% The last filter stage is implemented as a CIC interpolator because of this
% type of filter's ability to efficiently implement a large decimation factor.
% The response of a CIC filter is similar to a cascade of moving average
% filters, but a CIC filter uses no multiplication or division. As a result,
% the CIC filter has a large DC gain.
cicParams.InterpolationFactor = 16; % CIC interpolation factor
cicParams.DifferentialDelay = 1; % CIC interpolator differential delayb
cicParams.NumSections = 4; % CIC interpolator number of integrator and comb sections

cicParams.FsIn = compParams.FsOut;
cicParams.FsOut = cicParams.FsIn*cicParams.InterpolationFactor;

cicFilt = dsp.CICInterpolator(cicParams.InterpolationFactor, ...
cicParams.DifferentialDelay,cicParams.NumSections)

前面经过三级的二插值滤波器以后，再经过 CIC 滤波器 16 倍插值即可完成 128 倍的插值。幅频响应如下：

Simulink 仿真

利用计数器产生不同的使能信号来控制滤波器进行采样率的变化