Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

dynamic parameter of an adc

Status
Not open for further replies.

ati.fayaz

Newbie level 5
Joined
Nov 18, 2021
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
87
hi

in this command what is the output of the ADC as the input of this program? are they bits [b7 b6 b5 b4 b3 b2 b1 b0] in a matrix? or no?
what is it? what is test.dat exactly,please?


%-------------------------------------------------%
%%matlab code to calculate SNR,SNDR,THD SFDR
%%date : 11 July 2005
%%rev : 1
%-------------------------------------------------%
fclk = 80e+6;
numpt=32;
numbit=3;
load test.dat; %load data from disk
a = test';
N=length(a);
%[M,N]=size(a); %number of data
for i=1:1:N;
c=int2str(a(i)); %change integer type data to string type
temp=0;
Nlength=length(c); %length of the string;
for j=1:1:Nlength;
d=str2num(c(j))*2^(Nlength-j); %binary to dec
temp=temp+d;
end;
code(i)=temp;%/numpt*2.5;
end;
N=length(code);
%plot results in time domain
figure;
plot([1:N],code);
title('TIME DOMAIN')
xlabel('SAMPLES');
ylabel('DIGITAL OUTPUT CODE');
zoom xon;

%recenter the digital sinewave
Dout=(code-(2^numbit-1))/2;
%if no window functionis used,the input tone must be chosen
%to be unique and with regard to the sampling freq.To achieve
%this, prime numbers are introduced and the input tone is
%determined by fIN=fSAMPLE*(Prime Number/Data record size).
%To relax this requirement,window functions such as HANNING
%HAMING can be introduced,however the fundamental in the
%resulting FFT spectrum appears 'sharper' without
%the use of window functions.
Doutw=Dout;
%Doutw=Dout.*hanning(numpt);
%Doutw=Dout.*hamming(numpt);

%performing FFT
Dout_spect=fft(Doutw,numpt);
%recalculate to dB
Dout_dB=20*log10(abs(Dout_spect));
%plot([1:N/2],Dout_dB(1:N/2));
%display the results in the frequency domain with FFT plot
figure;
maxdB=max(Dout_dB(2:numpt/2));

%%for TTIMD,use the following short routine,normalized to -6.5dB
%full scale.
%plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB-6.5);
plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB);
grid on;
title('FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY(MHz)');
ylabel('AMPLITUDE(dB)');
%a1=axis;axis([a1(1) a1(2)-120 a1(4)]);

%-----------------------------------------------%
%calculate SNR,SINAD,ENOB,THD and SFDR values
%-----------------------------------------------%
%find the signal bin number, DC=bin 1
fin=find(Dout_dB(1:numpt/2)==maxdB);
%Span of the input freq on each side
%span=5;
span=max(round(numpt/200),5);
%approximate search span for harmonics on each side
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(span-fin:span+fin));
%vector/matric to store both freq and power of signals and harmonics
Fh=[];
%the 1st element in the vector/matrix represents the signal,
%the next element reps the 2nd harmonic,etc..
Ph=[];
%find harmonic freq and power components in the FFT spectrum
for har_num=1:10
%input tones greater than fSAMPLE are aliased back into the spectrum
tone=rem((har_num*(fin-1)+1)/numpt,1);
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))];
end

%determine the total distortion power
Pd=sum(Ph(2:5));
%determine the noise power
Pn=sum(spectP(1:numpt/2))-Pdc-Ps-Pd;
format;
A=(max(code)-min(code))
AdB=20*log10(A);

SINAD=10*log10(Ps/(Pn+Pd));
SNR=10*log10(Ps/Pn);
disp('THD is calculated from 2nd through 5th order harmonics');
THD=10*log10(Pd/Ph(1));
SFDR=10*log10(Ph(1)/max(Ph(2:10)));
disp('Signal & Harmonic power components:');
HD=10*log10(Ph(1:10)/Ph(1));
ENOB =(SNR-1.7)/6.0206;
%distinguish all harmonics locations within the FFT plot
hold on;
plot(Fh(2)*fclk,0,'mo',Fh(3)*fclk,0,'cx',Fh(4)*fclk,0,'r+',Fh(5)*fclk,0,'g*',Fh(6)*fclk,0,'bs',Fh(7)*fclk,0,'bd',Fh(8)*fclk,0,'kv',Fh(9)*fclk,0,'y^');
legend('1st','2nd','3rd','4th','5th','6th','7th','8th','9th');

fprintf('SINAD=%gdB \n',SINAD);
fprintf('SNR=%gdB \n',SNR);
fprintf('THD=%gdB \n',THD);
fprintf('SFDR=%gdB \n',SFDR);
fprintf('ENOB=%g \n',ENOB);

%dynamic range specs,TTIMD
%two tone IMD can be a tricky measurement,because the additional equipment
%required(a power combiner to combine two input frequencies) can contribute
%unwanted intermodulation products that falsify the ADC's intermodualtion
%distortion.You must observe the following conditions to optimize IMD
%performance,although they make the selection of proper input freq a
%tedious task.
%First,the input tones must fall into the passband of the input filter.If
%these tones are close together(several tens or hundreds of kilohertz for a
%megahertz bandwidth),an appropriate window function must be chosen as
%well.Placing them too close together,however ,may allow the power combiner
%to falsify the overall IMD readings by contributing unwanted 2nd and 3rd
%order IMD products(depending on the input tones' location within the
%passband).Spacing the input tones too far apart may call for a different
%window type that has less freq resolution.The setup also requires a min of
%three phase-locked signal generators.This requirement seldom poses a
%problem for test labs,but generators have different capabilities for
%matching freq and amplitude.Compensating such mismatches to achieve (for
%example) a -0.5dB FS two-tone envelope and signal amplitudes of -6.5dB FS
%will increase your effort and test time(see the following program-code
%extraction).
 
Last edited by a moderator:

hi

in this command what is the output of the ADC as the input of this program? are they bits [b7 b6 b5 b4 b3 b2 b1 b0] in a matrix? or no?
what is it? what is test.dat exactly,please?
There is no "output of the ADC". The input to the program is from the file test.dat. When test.dat is loaded, the data is placed in the variable (matrix) "test". It is then transposed and placed in variable "a".
 

Where can I get test.dat? is it [bit0 bit1 bit2 bit3 bit4 bit5 bit6] from an adc hspice simulation results for example? can you help me and say what is exactly please? what is its matrix exactly to i load it in this matlab program?
thanks
 

HOW DO WE KNOW WHAT test.dat is? This is YOUR project, not ours. There’s no universal test.dat file that someone can send you.
 

HOW DO WE KNOW WHAT test.dat is? This is YOUR project, not ours. There’s no universal test.dat file that someone can send you.
No. I mean, assuming my converter is 7-bit and I simulated it in hspice, which nodes should I use as the ADC output and how should those nodes be arranged in the test.dat matrix to be ready for loading in progpam?
Because this program is for calculating the dynamic parameters of an ADC.
 
Last edited by a moderator:

If you actually read the matlab code you'll see that it is expecting the input data as INTs.
I do not understand what you said. Could you please explain more. I'm not strong in MATLAB programming. what does it mean?"it is expecting the input data as INTs."؟؟؟
 
Last edited:

INTegers.
Does this mean that "a" is a matrix containing arrays 0 and 1?



In this example(Down), is "a" a 3 x 32 matrix?

numpt=32;
numbit=3;
load test.dat; %load data from disk
a = test';
N=length(a);
%[M,N]=size(a); %number of data
 

I think you need to learn matlab; I’m not here to teach you everything.

There is nothing in your code snippet to imply that a is a 3x32 matrix. a is the transpose if whatever is loaded from test.dat. numpt is 32; numbit is 3. That’s all you can infer from your code.
 

I think you need to learn matlab; I’m not here to teach you everything.

There is nothing in your code snippet to imply that a is a 3x32 matrix. a is the transpose if whatever is loaded from test.dat. numpt is 32; numbit is 3. That’s all you can infer from your code.
I do not have much trouble with MATLAB, Master.

It is difficult for me to identify inputs and arrange them in this program. I have downloaded these codes from the internet.
Thanks
 

If you “do not have much trouble with matlab” then you should understand that the inputs are what’s in the test.dat file. I’ve already told you that from the code it appears that the data in test.dat are integers (because of the assignment “c=int2str...).
 

If you “do not have much trouble with matlab” then you should understand that the inputs are what’s in the test.dat file. I’ve already told you that from the code it appears that the data in test.dat are integers (because of the assignment “c=int2str...).
Does test.dat contain ADC output bits?
 

Or https://www.edaboard.com/threads/need-help-to-implement-this-matlab-code-to-calculate-sfdr.158379/

This seams to be the third thread quoting a Matlab code picked up somewhere without fully understanding it. While the others threads are focussing on the calculations done in the code, you are already stumbling upon the input data format, which is unfortunately not described. I must confess that I don't recognize it at first sight, but playing with test data should clarify things. I presume the original poster of the 2005 thread did the same, otherwise he won't have set numpts=32 and numbits=3 which is most likely useless for a real measurement.
 

Or https://www.edaboard.com/threads/need-help-to-implement-this-matlab-code-to-calculate-sfdr.158379/

This seams to be the third thread quoting a Matlab code picked up somewhere without fully understanding it. While the others threads are focussing on the calculations done in the code, you are already stumbling upon the input data format, which is unfortunately not described. I must confess that I don't recognize it at first sight, but playing with test data should clarify things. I presume the original poster of the 2005 thread did the same, otherwise he won't have set numpts=32 and numbits=3 which is most likely useless for a real measurement.

thanks

Can you help me about these codes?
which nodes should I use as the ADC output and how should those nodes be arranged in the filename matrix to be ready for loading in progpam?

this program is in maxim site.

Code:
%Start MAX1448 Dynamic Performance Test Routine

<disp('HP16500C State Card');
filename=input('Type a:\filename or Press RETURN for HPIB Data Transfer: ');
if isempty(filename)
filename = 'listing';
end
fid=fopen(filename,'r');
numpt=input('Data Record Size (Number of Points)? ');
fclk=input('Sampling Frequency (MHz)? ');

%MAX1448 - 10-bit data converter
numbit=10;

%Discard first 13 lines from the data file, which do not contain data
for i=1:13,
fgetl(fid);
end
[v1,count]=fscanf(fid,'%f',[2,numpt]);
fclose(fid);

v1=v1';
code=v1:),2);

%Display a warning, when the input generates a code greater than full-scale
if (max(code)==2^numbit-1) | (min(code)==0)
disp('Warning: ADC may be clipping!!!');
end

%Plot results in the time domain
figure;
plot([1:numpt],code);
title('TIME DOMAIN')
xlabel('SAMPLES');
ylabel('DIGITAL OUTPUT CODE');

%Recenter the digital sine wave
Dout=code-(2^numbit-1)/2;

%If no window function is used, the input tone must be chosen to be unique and with
%regard to the sampling frequency. To achieve this prime numbers are introduced and the
%input tone is determined by fIN = fSAMPLE * (Prime Number / Data Record Size).
%To relax this requirement, window functions such as HANNING and HAMING (see below) can
%be introduced, however the fundamental in the resulting FFT spectrum appears 'sharper'
%without the use of window functions.
Doutw=Dout;
%Doutw=Dout.*hanning(numpt);
%Doutw=Dout.*hamming(numpt);

%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/2));

%For TTIMD, use the following short routine, normalized to —6.5dB full-scale.
%plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB-6.5);

plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB);
grid on;
title('FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (MHz)');
ylabel('AMPLITUDE (dB)');
a1=axis; axis([a1(1) a1(2) -120 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);
%Span of the input frequency on each side
span=max(round(numpt/200),5);
%Approximate search span for harmonics on each side
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-span:fin+span));
%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
%Input tones greater than fSAMPLE are aliased back into the spectrum
tone=rem((har_num*(fin-1)+1)/numpt,1);
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))];
end

%Determine the total distortion power
Pd=sum(Ph(2:5));
%Determine the noise power
Pn=sum(spectP(1:numpt/2))-Pdc-Ps-Pd;

format;
A=(max(code)-min(code))/2^numbit
AdB=20*log10(A)
SINAD=10*log10(Ps/(Pn+Pd))
SNR=10*log10(Ps/Pn)
disp('THD is calculated from 2nd through 5th order harmonics');
THD=10*log10(Pd/Ph(1))
SFDR=10*log10(Ph(1)/max(Ph(2:10)))
disp('Signal & Harmonic Power Components:');
HD=10*log10(Ph(1:10)/Ph(1))

%Distinguish all harmonics locations within the FFT plot
hold on;
plot(Fh(2)*fclk,0,'mo',Fh(3)*fclk,0,'cx',Fh(4)*fclk,0,'r+',Fh(5)*fclk,0,'g*',... Fh(6)*fclk,0,'bs',Fh(7)*fclk,0,'bd',Fh(8)*fclk,0,'kv',Fh(9)*fclk,0,'y^');
legend('1st','2nd','3rd','4th','5th','6th','7th','8th','9th');
hold off;
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top