This example shows how to compute the time-domain response of a simple bandpass filter. The eight steps involved in computing the time-domain response of a simple bandpass filter are,
使用classic image parameter design to assign inductance and capacitance values to the bandpass filter.
使用circuit
,,,,capacitor
,,,,and电感器
objects with the添加
功能以编程方式构建Butterworth电路。
使用setports
功能以将电路定义为2端口网络。
使用Sparameters
function to extract the S-parameters of the 2-port network over a wide frequency range.
使用S2TF
功能以计算从输入到输出的电压传输函数。
使用合理的
object to generate rational fits that capture the ideal RC circuit to a very high degree of accuracy.
使用兰德
function to create noise in order to create a noisy input voltage waveform.
使用计时器
function
要计算对嘈杂输入电压波形的瞬态响应。
图像参数设计是用于分析计算被动过滤器中串联和并行组件的值的框架。有关图像参数的更多信息,请参见Cotter W. Sayre的“完整无线设计”,McGraw-Hill 2008 p。331。
图1:Butterworth带通滤波器由两个半部分构建。
生成较低3 dB截止频率为2.4 GHz的带通滤波器的组件值,并且上3 dB截止频率为2.5 GHz。
Ro = 50; f1C = 2400e6; f2C = 2500e6; Ls = (Ro / (pi*(f2C - f1C)))/2;%LS1和LS2CS = 2*(F2C -F1C)/(4*Pi*ro*f2c*f1c);% Cs1 and Cs2lp = 2*ro*(f2c -f1c)/(4*pi*f2c*f1c);%LP1and Lp2Cp =(1 /(π* Ro * (f2C - f1C))) / 2;%cp1and Cp2
在使用构建电路之前电感器
andcapacitor
objects, nodes in the circuit are numbered. This is shown in figure 1.
图2:节点编号添加到Butterworth带通滤波器中。
创建一个circuit
对象并用电感器
和capacitor
objects using the添加
功能。
ckt =电路('Butterworthbpf');添加(CKT,[3 2],电感器(LS));%ls1添加(ckt,[4 3],capacitor(Cs));% Cs1添加(ckt,[5 4],capacitor(Cs));% Cs2添加(ckt,[6 5],inductor(Ls));%ls2添加(CKT,[4 1],电容器(CP));%cp1添加(ckt,[4 1],inductor(Lp));%LP1添加(ckt,[4 1],inductor(Lp));%lp2添加(CKT,[4 1],电容器(CP));%CP2
To extract S-parameters from the circuit object, first use thesetports
功能以将电路定义为2端口网络。
freq = linspace(2e9,3e9,101);
使用Sparameters
功能以在感兴趣的频率下提取S-参数。
setports(ckt,[2 1],[6 1]) S = sparameters(ckt,freq);
使用S2TF
功能以从S-参数对象生成传输函数。
tfS = s2tf(S);
使用合理的
object to fit the transfer function data to a rational function.
fit = Rational(Freq,TFS);
使用freqresp
function to verify that the rational fit approximation has reasonable behavior outside both sides of the fitted frequency range.
widerfreqs = linspace(2e8,5e9,1001);RESS = freqresp(fit,widerfreqs);
图可视化理性拟合近似。理性拟合表现良好,超出了拟合频率范围。
图半学(FREQ,ABS(TFS),WIDERFREQS,ABS(RESS),'--',,,,“线宽”,2)Xlabel(“频率(Hz)”);ylabel('震级');legend('data',,,,'合身');标题('Rational Fit Approximation');
为了测试由图像参数技术设计的带通滤波器,从嘈杂的输入信号中回收了2.45 GHz的正弦信号。噪声输入信号是通过将零均值随机噪声和2.35 GHz的阻滞剂纳入输入信号而产生的。
Construct a input and a noisy input signal with 8192 samples.
fcenter = 2.45e9;fblocker = 2.35e9;周期= 1/fcenter;sampletime = ofient/16;Signallen = 8192;t =(0:signallen-1)'*sampletime;% 256 periods输入= sin(2*pi*fcenter*t);%干净输入信号rng('default') noise = randn(size(t)) + sin(2*pi*fBlocker*t); noisyInput = input + noise;% Noisy input signal
使用计时器
function to compute the analytic solutions of the state-space.
output = timeresp(fit,noisyInput,sampleTime);
Plot the input signal, noisy input signal, and the band pass filter output in a figure window.
xmax = t(end)/8;图子图(3,1,1)图(t,输入)轴([0 xmax -1.5 1.5])标题('Input')子图(3,1,2)图(t,noisyInput)轴([0 Xmax落地(min(noisyInput))CEIL(max(noisyInput))]);标题('Noisy Input');ylabel(“振幅(伏特)”);子图(3,1,3)图(t,输出)轴([0 xmax -1.5 1.5]);标题(“过滤输出”);Xlabel('Time (sec)');
Overlaying the noisy input and the filter response in the frequency domain explains why the filtering operation is successful. Both the blocker signal at 2.35 GHz and much of the noise are significantly attenuated.
nfft = 2^nextPow2(signallen);y长度的2个下一个功率2的下一个功率y = fft(noisyInput,nfft)/signallen;SamplingFreq = 1/SampleTime;f = samplingfreq/2*linspace(0,1,nfft/2+1)';o = fft(输出,nfft)/signallen;图子图(2,1,1)图(FREQ,ABS(TFS),'b',,,,“线宽”,,,,2) axis([freq(1) freq(end) 0 1.1]); legend(“滤波器传输功能”);标题(“带通滤波器的传输函数”);ylabel('震级');subplot(2,1,2) plot(f,2*abs(Y(1:NFFT/2+1)),‘g’,f,2*abs(o(1:nfft/2+1)),'r',,,,“线宽”,,,,2) axis([freq(1) freq(end) 0 1.1]); legend(“输入+噪声”,,,,'输出');标题('Filter characteristic and noisy input spectrum.');Xlabel(“频率(Hz)”);ylabel('Magnitude (Volts)');
要使用RFCKT对象计算和显示此带通滤波器响应,请参见使用RFCKT对象的带通滤波器响应。