首页 > 微波/射频 > RFIC设计学习交流 > 关于maxim测ADC dnl,inl的程序的一问

关于maxim测ADC dnl,inl的程序的一问

录入:edatop.com    阅读:
最近做了个7bitFLASH,想测一下它的DNL和INL,于是找到美信的一段程序,二楼会贴出代码,想问问各位大大,有了解这个程序的么,mid_code是怎么取得?

%Code density/histofgram test to calculate INL and DNL require a large number of samples.
%Step 1: Apply a close to full-scale sine wave (but not clipping) and find the mid-code for the applied signal.
%Step 2: Apply the same sine wave input, but slightly larger amplitude to clip the ADC slightly.
%Run the following program, enter the number of samples, resolution and mid-code from Step 1and continue.
%Copyright Au/Hofner, Maxim Integrated Products, 120 San Gabriel Drive, Sunnyvale, CA94086
%This program is believed to be accurate and reliable. This program may get altered without prior notification.
filename=input('Enter File Name: ');
if isempty(filename)
   filename = 'listing';
end
fid=fopen(filename,'r');
numpt=input('Enter Number of Data Points:  ');
numbit=input ('Enter ADC Resolution:  ');
mid_code=input('Enter Mid-Code (Mean Code):  ');
for i=1:13,       
   fgetl(fid);
end
[v1,count]=fscanf(fid,'%f',[2,numpt]);
fclose(fid);
v1=v1';
code=v1(:,2);
code_count=zeros(1,2^numbit);
for i=1:size(code),
   code_count(code(i)+1)=code_count(code(i)+1) + 1;
end
if code_count(1) == 0 | code_count(2^numbit) == 0 | ...
  (code_count(1) < code_count(2)) | (code_count(2^numbit-1) > code_count(2^numbit))
   disp('ADC not clipping ... Increase sinewave amplitude!');
   break;
end
A=max(mid_code,2^numbit-1-mid_code)+0.1;
vin=(0:2^numbit-1)-mid_code;       
sin2ramp=1./(pi*sqrt(A^2*ones(size(vin))-vin.*vin));
while sum(code_count(2:2^numbit-1)) < numpt*sum(sin2ramp(2:2^numbit-1))
  A=A+0.1;
  sin2ramp=1./(pi*sqrt(A^2*ones(size(vin))-vin.*vin));
end
disp('You Have Applied a Sine Wave of (dBFS): ');
Amplitude=A/(2^numbit/2)
figure;
plot([0:2^numbit-1],code_count,[0:2^numbit-1],sin2ramp*numpt);
title('CODE HISTOGRAM - SINE WAVE');
xlabel('DIGITAL OUTPUT CODE');
ylabel('COUNTS');
axis([0 2^numbit-1 0 max(code_count(2),code_count(2^numbit-1))]);
code_countn=code_count(2:2^numbit-1)./(numpt*sin2ramp(2:2^numbit-1));
figure;
plot([1:2^numbit-2],code_countn);
title('CODE HISTOGRAM - NORMALIZED')
xlabel('DIGITAL OUTPUT CODE');
ylabel('NORMALIZED COUNTS');
dnl=code_countn-1;
inl=zeros(size(dnl));
for j=1:size(inl')
   inl(j)=sum(dnl(1:j));
end
%End-Point fit INL
%[p,S]=polyfit([1,2^numbit-2],[inl(1),inl(2^numbit-2)],1);
%Best-straight-line fit INL
[p,S]=polyfit([1:2^numbit-2],inl,1);
inl=inl-p(1)*[1:2^numbit-2]-p(2);
disp('End Points Eliminated for DNL and INL Calculations');
figure;
plot([1:2^numbit-2],dnl);
grid on;
title('DIFFERENTIAL NONLINEARITY vs. DIGITAL OUTPUT CODE');
xlabel('DIGITAL OUTPUT CODE');
ylabel('DNL (LSB)');
figure;
plot([1:2^numbit-2],inl);
grid on;
title('INTEGRAL NONLINEARITY vs. DIGITAL OUTPUT CODE');
xlabel('DIGITAL OUTPUT CODE');
ylabel('INL(LSB)');

  1. %Code density/histofgram test to calculate INL and DNL require a large number of samples.
  2. %Step 1: Apply a close to full-scale sine wave (but not clipping) and find the mid-code for the applied signal.
  3. %Step 2: Apply the same sine wave input, but slightly larger amplitude to clip the ADC slightly.
  4. %Run the following program, enter the number of samples, resolution and mid-code from Step 1and continue.
  5. %Copyright Au/Hofner, Maxim Integrated Products, 120 San Gabriel Drive, Sunnyvale, CA94086
  6. %This program is believed to be accurate and reliable. This program may get altered without prior notification.

  7. filename=input('Enter File Name: ');
  8. if isempty(filename)
  9.    filename = 'listing';
  10. end
  11. fid=fopen(filename,'r');
  12. numpt=input('Enter Number of Data Points:  ');
  13. numbit=input ('Enter ADC Resolution:  ');
  14. mid_code=input('Enter Mid-Code (Mean Code):  ');

  15. for i=1:13,       
  16.    fgetl(fid);
  17. end
  18. [v1,count]=fscanf(fid,'%f',[2,numpt]);
  19. fclose(fid);

  20. v1=v1';
  21. code=v1(:,2);
  22. code_count=zeros(1,2^numbit);

  23. for i=1:size(code),
  24.    code_count(code(i)+1)=code_count(code(i)+1) + 1;
  25. end

  26. if code_count(1) == 0 | code_count(2^numbit) == 0 | ...
  27.   (code_count(1) < code_count(2)) | (code_count(2^numbit-1) > code_count(2^numbit))
  28.    disp('ADC not clipping ... Increase sinewave amplitude!');
  29.    break;
  30. end

  31. A=max(mid_code,2^numbit-1-mid_code)+0.1;
  32. vin=(0:2^numbit-1)-mid_code;       
  33. sin2ramp=1./(pi*sqrt(A^2*ones(size(vin))-vin.*vin));

  34. while sum(code_count(2:2^numbit-1)) < numpt*sum(sin2ramp(2:2^numbit-1))
  35.   A=A+0.1;
  36.   sin2ramp=1./(pi*sqrt(A^2*ones(size(vin))-vin.*vin));
  37. end

  38. disp('You Have Applied a Sine Wave of (dBFS): ');
  39. Amplitude=A/(2^numbit/2)
  40. figure;
  41. plot([0:2^numbit-1],code_count,[0:2^numbit-1],sin2ramp*numpt);
  42. title('CODE HISTOGRAM - SINE WAVE');
  43. xlabel('DIGITAL OUTPUT CODE');
  44. ylabel('COUNTS');
  45. axis([0 2^numbit-1 0 max(code_count(2),code_count(2^numbit-1))]);
  46. code_countn=code_count(2:2^numbit-1)./(numpt*sin2ramp(2:2^numbit-1));
  47. figure;
  48. plot([1:2^numbit-2],code_countn);
  49. title('CODE HISTOGRAM - NORMALIZED')
  50. xlabel('DIGITAL OUTPUT CODE');
  51. ylabel('NORMALIZED COUNTS');

  52. dnl=code_countn-1;
  53. inl=zeros(size(dnl));
  54. for j=1:size(inl')
  55.    inl(j)=sum(dnl(1:j));
  56. end

  57. %End-Point fit INL
  58. %[p,S]=polyfit([1,2^numbit-2],[inl(1),inl(2^numbit-2)],1);

  59. %Best-straight-line fit INL
  60. [p,S]=polyfit([1:2^numbit-2],inl,1);
  61. inl=inl-p(1)*[1:2^numbit-2]-p(2);

  62. disp('End Points Eliminated for DNL and INL Calculations');
  63. figure;
  64. plot([1:2^numbit-2],dnl);
  65. grid on;
  66. title('DIFFERENTIAL NONLINEARITY vs. DIGITAL OUTPUT CODE');
  67. xlabel('DIGITAL OUTPUT CODE');
  68. ylabel('DNL (LSB)');
  69. figure;
  70. plot([1:2^numbit-2],inl);
  71. grid on;
  72. title('INTEGRAL NONLINEARITY vs. DIGITAL OUTPUT CODE');
  73. xlabel('DIGITAL OUTPUT CODE');
  74. ylabel('INL(LSB)');

复制代码

学习一下。

申明:网友回复良莠不齐,仅供参考。如需专业解答,请学习本站推出的微波射频专业培训课程

上一篇:做电压跟随器的运放
下一篇:以P衬底和N阱搭成的二极管的反向耐压大概为多少

射频和天线工程师培训课程详情>>

  网站地图