The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design >> Mixed-Signal Design >> question about ADC spectral analysis
https://designers-guide.org/forum/YaBB.pl?num=1421471855

Message started by sun on Jan 16th, 2015, 9:17pm

Title: question about ADC spectral analysis
Post by sun on Jan 16th, 2015, 9:17pm

Hi
A matlab code for ADC spectral analysis is following:

clear;

afs = 1;   % 1V full scale
fs = 1e6;    %  1MHz sample rate
N = 2^11;   % number of samples
cyc = 67;
fx = fs*cyc/N;

t = linspace(0,(N-1)/fs,N);


B = 10;                        % internal ADC resolution
delta = afs/2^B;
y = cos(2*pi*fx/fs*[0:N-1]);
%quantize samples to delta=1LSB
y=round(y/delta)*delta;

s = abs(fft(y)/N/afs*2);
sdb = 20*log10(s);
sdb = sdb(1:N/2);  % drop redundant half
s = s(1:N/2);  % drop redundant half

f = (0:length(sdb)-1) / N;  % frequency vector (normalized to fs)



bx = N*fx/fs+1;
As = 10*log10(s(bx)^2);
%set signal bin to 0
s(bx) = 0;
An = 20*log10(sum(s));
SNR = As - An;


figure(1);
plot(f,sdb);
grid on;
text_handle = text(0.3,-30, sprintf('SNR = %4.1fdB\n',SNR));

fft output data contain a lot of 0s, resulting -infs in the dB scaled spectrum. The SNR calculated from the quantized signal is 43.1dB, which is far from the expected 62dB.
I don't understand above situations. is there any problem of quantization or fft?

Title: Re: question about ADC spectral analysis
Post by sun on Jan 18th, 2015, 1:15am

Hi all,
there is a bug in the code.
noise power should be calculated by:
An = 10*log10(sum(s.^2));
resulting SNR fit expected well. But I still dont understand why there are 0s in the fft results.

          Sun

Title: Re: question about ADC spectral analysis
Post by eternity on Jan 20th, 2015, 6:16am

Is there any definite trend that you see in the appearance of zeros in the output array which is used to plot the spectrum
Also its more readable if you plot a spectrum of 'continuous type' instead of dots.

Eternity

Title: Re: question about ADC spectral analysis
Post by RobG on Jan 20th, 2015, 3:37pm

I forgot why the zeros are there, but they are so it is not a bug in your program. I just add a small amount (like 1e-6) to the spectrum before converting it to dB. I don't think the zeroes are there in a real system that includes thermal noise.

Title: Re: question about ADC spectral analysis
Post by ywguo on Jan 23rd, 2015, 12:56am

Hello Sun,

Would you please plot with all dots connected one by one? Now those two plots are not discernible. I cannot find where is the signal in the first plot. What is the magnitude and frequency of the signal?

Best Regards,
Yawei

Title: Re: question about ADC spectral analysis
Post by sun on Jan 24th, 2015, 9:14pm

Hi Ethernity
I can not see any obvious trend. Actually, there are -infs between consecutive two zeros.

Sun


eternity wrote on Jan 20th, 2015, 6:16am:
Is there any definite trend that you see in the appearance of zeros in the output array which is used to plot the spectrum
Also its more readable if you plot a spectrum of 'continuous type' instead of dots.

Eternity


Title: Re: question about ADC spectral analysis
Post by sun on Jan 24th, 2015, 9:22pm

Hi
I got a perty spectrum after I add some noise before quantizing. In a real adc. device noise will dither signal. As you said, someone told me that there are zeros in the fft output. I'm also want to know how to explain this.

Sun


RobG wrote on Jan 20th, 2015, 3:37pm:
I forgot why the zeros are there, but they are so it is not a bug in your program. I just add a small amount (like 1e-6) to the spectrum before converting it to dB. I don't think the zeroes are there in a real system that includes thermal noise.


Title: Re: question about ADC spectral analysis
Post by sun on Jan 24th, 2015, 9:28pm

Hi Yawei
There are -infs between zeros. I have no ideal how to plot data for all dots. The signal is 0dB at about 16.3kHz.

Sun

ywguo wrote on Jan 23rd, 2015, 12:56am:
Hello Sun,

Would you please plot with all dots connected one by one? Now those two plots are not discernible. I cannot find where is the signal in the first plot. What is the magnitude and frequency of the signal?

Best Regards,
Yawei


The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.