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.

MATLAB program for SFDR

Status
Not open for further replies.

snoop835

Advanced Member level 4
Joined
Feb 7, 2005
Messages
102
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,298
Location
Penang, Malaysia
Activity points
1,371
adc sfdr measurement matlab scripts example

Hi all,

I am trying to simulate ADC for SFDR,SNR,THD and SNDR. The MATLAB code is attached as below. I am new in MATLAB and couldn't fully understand the program.

To simulate, I input low frequency sinewave signal and the ADC is running at 50Ms/s. Should I take the output from the ADC or do I need to connect the output of ADC to an ideal DAC and use the output from that ideal DAC and run the program below?


(1) Can somebody explain the program below.
%Span of the input freq on each side
%span=5;
span=max(round(numpt/200),5);


(2) When I run the program, it shows error and I don't know how to fix it! Can somebody correct the program below to be used in 10-bit ADC at 50MHz clock frequency.

I appreciate any helps.



**********************************************************************

%-------------------------------------------------%
%%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).
 

span=max(round(numpt/200),5)

You can use the output of the ADC as the input of this program. And you must modify some parameter of this program according to your need. For example fclk, numbt, etc.
 

matlab sfdr

it is maxism's program,

1. parameter 'span' is the number of signal bins. These bins will be considered as signal power.

2.u have to modify some parameters according to ur ckts setup.

Added after 4 minutes:

and u don't need a dac,
The file 'test.dat' should be ur adc simulation results.
 

sfdr calculation

hi, can u tell me where you download this matlab file?
 

adc snr sndr sinad hspice

thanks!
A question: why span=max(round(numpt/200),5)? why choose numpt/200? if numpt is very large and fundamental frequency is very low, the next power calculate will be wrong
 

fundamental frequency matlab code

showtime said:
thanks!
A question: why span=max(round(numpt/200),5)? why choose numpt/200? if numpt is very large and fundamental frequency is very low, the next power calculate will be wrong

I have the same questions. Why :?:200.

I am testing DAC using the discrete data obtained from HSPICE simulation. Data frequency is (15/32)*50M and sampling frequency is 50MHz.

However I found that even the data is got from ideal DAC , the FFT plot is not satisfying in matlab with only about 20dB SFDR.

Anyone can tell what is the problem ?
Even with more data points, the situation is the same.

I am using a perl script to generate the ideal DAC output , I am wondering whether the perl script does not have enough accuracy.

I am using 512 sampling points.



I refer to the maxim matlab code and also encounter errors at bin calculation.
The bin got from program is 1 , and it will make bin-spann negative, thus error occurs. :(
 

sfdr matlab

snoop835 said:
%extract overall signal power
Ps=sum(spectP(span-fin:span+fin));

I think it should be
Ps=sum(spectP(fin-span:fin+span));
Change it and try again. Good luck.
your sampling freuqncy should be set corretly

sixth

Added after 16 minutes:

lovseed said:
showtime said:
thanks!
A question: why span=max(round(numpt/200),5)? why choose numpt/200? if numpt is very large and fundamental frequency is very low, the next power calculate will be wrong

I have the same questions. Why :?:200.

I am testing DAC using the discrete data obtained from HSPICE simulation. Data frequency is (15/32)*50M and sampling frequency is 50MHz.

However I found that even the data is got from ideal DAC , the FFT plot is not satisfying in matlab with only about 20dB SFDR.

Anyone can tell what is the problem ?
Even with more data points, the situation is the same.

I am using a perl script to generate the ideal DAC output , I am wondering whether the perl script does not have enough accuracy.

I am using 512 sampling points.



I refer to the maxim matlab code and also encounter errors at bin calculation.
The bin got from program is 1 , and it will make bin-spann negative, thus error occurs. :(
Hi,
512 sampling points is not enough to calculate the SNDR. To get a correct result, I think 8192 is a good choice.
If you doest want to use the window function, you should use coherent sampling techinique, selecting your input frequency carefully, for your 50Mhz sampling freuqency, considering 8192 points, you can set your input frequency at 24.993896484375MHz
By the way, in your post, you said the SFDR is very low, not SNR, maybe the reason lies in the non linearity of your internal circuits
sixth
 

how to calculate sfdr

sixth said:
snoop835 said:
%extract overall signal power
Ps=sum(spectP(span-fin:span+fin));

I think it should be
Ps=sum(spectP(fin-span:fin+span));
Change it and try again. Good luck.
your sampling freuqncy should be set corretly

sixth

Added after 16 minutes:

lovseed said:
showtime said:
thanks!
A question: why span=max(round(numpt/200),5)? why choose numpt/200? if numpt is very large and fundamental frequency is very low, the next power calculate will be wrong

I have the same questions. Why :?:200.

I am testing DAC using the discrete data obtained from HSPICE simulation. Data frequency is (15/32)*50M and sampling frequency is 50MHz.

However I found that even the data is got from ideal DAC , the FFT plot is not satisfying in matlab with only about 20dB SFDR.

Anyone can tell what is the problem ?
Even with more data points, the situation is the same.

I am using a perl script to generate the ideal DAC output , I am wondering whether the perl script does not have enough accuracy.

I am using 512 sampling points.



I refer to the maxim matlab code and also encounter errors at bin calculation.
The bin got from program is 1 , and it will make bin-spann negative, thus error occurs. :(
Hi,
512 sampling points is not enough to calculate the SNDR. To get a correct result, I think 8192 is a good choice.
If you doest want to use the window function, you should use coherent sampling techinique, selecting your input frequency carefully, for your 50Mhz sampling freuqency, considering 8192 points, you can set your input frequency at 24.993896484375MHz
By the way, in your post, you said the SFDR is very low, not SNR, maybe the reason lies in the non linearity of your internal circuits
sixth

hi guys,

I found the data I generated has some problem.
After correct this error, I think it is ok. because the 512 sampling data is taken from post-layout simulation, it will be un-endurable long to simulate 8192 points.

For ideal DAC the SFDR is about 68dB, SNDR is about 62-63dB for nyquist frequency.

Anyway thanks for all you input!
 

Re: adc sfdr measurement matlab scripts example

Hi all,

I am trying to simulate ADC for SFDR,SNR,THD and SNDR. The MATLAB code is attached as below. I am new in MATLAB and couldn't fully understand the program.

To simulate, I input low frequency sinewave signal and the ADC is running at 50Ms/s. Should I take the output from the ADC or do I need to connect the output of ADC to an ideal DAC and use the output from that ideal DAC and run the program below?


(1) Can somebody explain the program below.
%Span of the input freq on each side
%span=5;
span=max(round(numpt/200),5);


(2) When I run the program, it shows error and I don't know how to fix it! Can somebody correct the program below to be used in 10-bit ADC at 50MHz clock frequency.

I appreciate any helps.



**********************************************************************

%-------------------------------------------------%
%%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).

please explain what does numpt refer to How do we calculate the number of points for the analysis ,and does numbits refer to number of bits . I am making a 2 bit adc Flash ADC and I dont understand how I should proceed with the SFDR calculation ? I am new to Matlab and hence dont understand this code. I have applied an AC signal with input frequency 10^7 Hz, and I am getting my output on PSPICE (ORCAD), but I dont know how to calculate SFDR . Can you please help me??

Any replies would be helpful
 
Last edited:

Re: adc sfdr measurement matlab scripts example

Hi all,

I am trying to simulate ADC for SFDR,SNR,THD and SNDR. The MATLAB code is attached as below. I am new in MATLAB and couldn't fully understand the program.

To simulate, I input low frequency sinewave signal and the ADC is running at 50Ms/s. Should I take the output from the ADC or do I need to connect the output of ADC to an ideal DAC and use the output from that ideal DAC and run the program below?


(1) Can somebody explain the program below.
%Span of the input freq on each side
%span=5;
span=max(round(numpt/200),5);


(2) When I run the program, it shows error and I don't know how to fix it! Can somebody correct the program below to be used in 10-bit ADC at 50MHz clock frequency.

I appreciate any helps.



**********************************************************************

%-------------------------------------------------%
%%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).



I have implemented 10bit ADC in cadence tool, now i want to calculate all ADC parameters in MATLAB , How to calculate that in Matlab
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top