微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > RFIC设计学习交流 > SAR—ADC SNR仿真问题

SAR—ADC SNR仿真问题

时间:10-02 整理:3721RD 点击:
我做的5位的SAR—ADC,比较器用的是理想模块,其他都是电路,采样率是1k/s,输入100Hz的正弦信号,采样100个点进行fft,最后得出SNR=32.3dB,理论值为31.8dB,比理论还要高是怎么回事?
matlab代码如下:
clear
load file8.txt%WaveScan保存的波形文件,文件必须以英文开头
A=file8;%将测量数据赋给A,此时A为N×2的数组
x=A(:,1);%将A中的第一列赋值给x,形成时间序列
x=x';%将列向量变成行向量
y=A(:,2);%将A中的第二列赋值给y,形成被测量序列
y=y';%将列向量变成行向量

format long;
%傅立叶变换
y=y-mean(y);%消去直流分量,使频谱更能体现有效信息
fclk=1000;%仪器的采样频率
numpt=length(y);%data.txt中的被测量个数,即采样个数

Doutw=y'.*hanning(numpt);
%Doutw=y';

%Performing the Fast Fourier Transform
Dout_spect=fft(Doutw);

%Recalculate to dB
Dout_dB=20*log10(abs(Dout_spect));

%Display the results in the frequency domain with an FFT plot
figure; %建立图形
maxdB=max(Dout_dB(1:numpt*1/2));
%plot([0:numpt/10-1].*fclk/numpt,Dout_dB(1:numpt/10)-maxdB);
plot([0:numpt/1-1].*fclk/numpt,Dout_dB(1:numpt/1)-maxdB);
grid on;

title('FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (Hz)');
ylabel('AMPLITUDE (dB)');
a1=axis; axis([a1(1) a1(2) -140 a1(4)]);

%Calculate SNR, SINAD, THD and SFDR values
%Find the signal bin number, DC = bin 1
fin=find(Dout_dB(1:numpt/2)==maxdB);

spanh=1;%spanh=2;
%Determine power spectrum
spectP=(abs(Dout_spect)).*(abs(Dout_spect));
%Find DC offset power
%Pdc=sum(spectP(1:span));
%Extract overall signal power
Ps=sum(spectP(fin-spanh:fin+spanh));


%Pn=sum(spectP(1:numpt/(2*32)))-Ps;%Pn噪声功率Ps信号功率
Pn=sum(spectP(1:numpt/2))-Ps;%Pn噪声功率Ps信号功率
%Vector/matrix to store both frequency and power of signal and harmonics
Fh=[];
%The 1st element in the vector/matrix represents the signal, the next element represents
%the 2nd harmonic, etc.
Ph=[];
%Find harmonic frequencies and power components in the FFT spectrum
for har_num=1:10 %har_num谐波总数
%Input tones greater than fSAMPLE are aliased back into the spectrum
tone=rem((har_num*(fin-1)+1)/numpt,1); %rem(x,y)x除以y的余数numpt(Number of Points)
if tone>0.5
%Input tones greater than 0.5*fSAMPLE (after aliasing) are reflected
tone=1-tone;
end
Fh=[Fh tone];
%For this procedure to work, ensure the folded back high order harmonics do not overlap
%with DC or signal or lower order harmonics
%har_peak=max(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh));
%har_bin=find(spectP(round(tone*numpt)-spanh:round(tone*numpt)+spanh)==har_peak);
%har_bin=har_bin+round(tone*numpt)-spanh-1;
%Ph=[Ph sum(spectP(har_bin-1:har_bin+1))];
%Ph=[Ph sum(spectP(har_num*(fin-1):har_num*(fin-1)+2))];
end
%Determine the total distortion power
%Pd=sum(Ph(2:10)); %Pd总失真功率Ph(1) is fundamental harmonic谐波 power
%Determine the noise po*wer


format;%设置输出格式
SNDR =10*log10(Ps/Pn)%信噪比


% SINAD=10*log10(Ps/(Pn+Pd)) % SINAD = 10*log10(Ps/(Pn+Pd))信号与噪声失真比
% disp('THD is calculated from 2nd through 10th order harmonics');
% SFDR=10*log10(Ph(1)/max(Ph(2:10)))%SFDR无杂散动态范围
% ENOB = (SINAD-1.76)/6.02
% disp('Signal & Harmonic Power Components:');
% HD=10*log10(Ph(1:10)/Ph(1))

你才采样100个点,0.4-0.5dB的误差这不很正常吗?再说那个理想值是在假设量化噪声为白噪声的情况下等效得到的,又不是完全真正的理想!
建议看一下FFT和量化噪声模型相关资料!

谢谢师兄的回答,量化噪声模型我不太理解,师兄能否发给我一些好的资料呢?

我最近也在做SAR ADC的matlab仿真,频谱分析那边不太懂哎,请问那些fin,spanh,tone,Ph,是怎么计算的呢,这代码是小编自己写的不?求指导啊

还有,小编你是不是漏掉了span这个变量啊,因为Pdc=sum(spectP(1:span));
我看到一个例子里面是这么写的span=max(round(N/200),5);但是不知道这是怎么算出来的

小编求指导啊,如果您有空的话,真的谢谢啦~

“load file8.txt%WaveScan保存的波形文件,文件必须以英文开头“怎么保存为.txt格式啊?

thnak you

过电平采样的SNR怎么写程序?

多谢分享,正需要

您好,这个程序怎么运行不了呢?

我也求指导

请问小编最后找到原因了吗?我做的10bit SAR ADC最后得到的SNR和ENOB也比理想值要大。求指教

不是不太过采样啦

有问题啊

学习学习

5位的SAR—ADC

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top