sun
Junior Member
Offline
Posts: 11
|
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?
|