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

matlab仿真SAR ADC时的INL,DNL

时间:10-02 整理:3721RD 点击:
为什么matlab仿真时,得出的理想ADC也会有INL、DNL,下图是仿真100次的结果,感觉好奇怪啊,是我的算法错了导致这奇怪的结果吗?请大神们指导


我的理解是,仿真时如果是理想的SAR ADC,是不是INL和DNL都应该是0呢?还是跟算法有关?




这是一次仿真的4096个点的结果,看上去也很奇怪,没经验,仿出来的结果都不能明白问题出在哪儿

你用的算法都没给出来,我们怎么给意见?

SAR的代码怎么实现的?光结果,没办法帮你啊。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%successive approximation converter%
%with finite DAC's slew-rate and bandwidth.%
%Case of binary weighted resistive array DAC%
%code by Fabrizio Conso, university of pavia, student%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function counter=kelvin(input,nbit,f_bw,sr,f_s,v)
% input = input sample
% nbit= bits of the converter
% f_bw= DAC bandwidth [f_s]
% sr= DAC slew-rate [V_fs/T_s]
% f_s= normalized sampling frequency
% v= thresholds array

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%global variables%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%threshold_id=v(12);%initializing ideal threshold to 0.5
threshold_id=v(nbit);
counter=0;
in=input;
threshold(1)=0.5;
tau=1/(2*pi*f_bw); %DAC的时间
Tmax=1/(f_s*nbit); %完成一次比较所需的最少时间
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for k=1:nbit

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%skip of last subtraction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%

if k < 3
%if k<6
Tmax=2*Tmax;
end

if k==nbit
if (in-threshold_id) > 0
bit=1;
else
bit=0;
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%finitebandwidth & slew-rate%
%error calculation%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
else
deltaV=abs(threshold_id-threshold(k));
slope=deltaV/tau;
if slope > sr
tslew=(deltaV/sr) - tau;
if tslew >= Tmax% only slewing
error = deltaV - sr*Tmax;
else
texp = Tmax - tslew;
error = (deltaV-sr*tslew)*exp(-texp/tau);
end

else
% only exponential settling
texp = Tmax;
error = deltaV*exp(-texp/tau);
end
%threshold(k+1)=threshold_id-sign(threshold_id-threshold(k))*error;
threshold(k+1)=threshold_id-sign(threshold(k)-threshold_id)*error;
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%successive approximation%
%conversion algorythm%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%if (in-threshold(k+1)) > 0
if (in-threshold(k+1)) > 0
threshold_id=threshold_id+v(nbit-k);
%threshold_id=threshold_id+v(nbit-k);
bit=1;
else
threshold_id=threshold_id-v(nbit-k);
%threshold_id=threshold_id-v(nbit-k);
bit=0;
end
end

Tmax=1/(f_s*nbit);
counter=(counter+bit*2^(nbit-k));
%counter=(counter+bit*0.5^(nbit-k+1));
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Output%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
counter=counter;
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


sorry 我忘记把代码贴上来了=。=大神们再看看~

理想的SARADC的INL和DNL是不是应该为0呢?

自己顶一个

matlab仿真SAR ADC时的INL,DNL

matlab仿真SAR ADC时的INL,DNL

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

网站地图

Top