The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 28th, 2024, 4:48am
Pages: 1
Send Topic Print
question about ADC spectral analysis (Read 6433 times)
sun
Junior Member
**
Offline



Posts: 11

question about ADC spectral analysis
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?
Back to top
« Last Edit: Jan 16th, 2015, 10:23pm by sun »  

untitled_002.png
View Profile   IP Logged
sun
Junior Member
**
Offline



Posts: 11

Re: question about ADC spectral analysis
Reply #1 - 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
Back to top
 

untitled_003.png
View Profile   IP Logged
eternity
Junior Member
**
Offline



Posts: 28

Re: question about ADC spectral analysis
Reply #2 - 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
Back to top
 
 
View Profile   IP Logged
RobG
Community Fellow
*****
Offline



Posts: 569
Bozeman, MT
Re: question about ADC spectral analysis
Reply #3 - 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.
Back to top
 
 
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: question about ADC spectral analysis
Reply #4 - 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
Back to top
 
 
View Profile   IP Logged
sun
Junior Member
**
Offline



Posts: 11

Re: question about ADC spectral analysis
Reply #5 - 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

Back to top
 
 
View Profile   IP Logged
sun
Junior Member
**
Offline



Posts: 11

Re: question about ADC spectral analysis
Reply #6 - 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.

Back to top
 
 
View Profile   IP Logged
sun
Junior Member
**
Offline



Posts: 11

Re: question about ADC spectral analysis
Reply #7 - 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

Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.