+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Newbie level 5
    Points: 492, Level: 4

    Join Date
    Dec 2016
    Posts
    10
    Helped
    0 / 0
    Points
    492
    Level
    4

    Calculating SNR from for an ADC

    i am trying to calculate the SNR for the Ideal ADC model in cadence ahdllib , i know that it should be equal to or around 6.02N+1.76

    i have implemeted a code to calculate the FFT of the output of ADC using matlab and i will attach the code

    my problem is that i dont know how to calculate the SNR from the FFT of the output signal

    Code:
    Afs = 5;
    fs = 1e6;
    N = 2048;
    cycles = 5;
    fx = fs*cycles/N;
    t = linspace(0, (N-1)/fs, N);
    %signal frequency
    y = table2array(bitsinfullscale);
    y = y';
    s = (abs(fft(y)/N/Afs*2));
    % drop redundant half
    s = s(1:N/2);
    f = (0:length(s)-1) / N*fs;
    figure
    plot(t,y)
    hold on;
    figure
    plot(f,s)

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 74,672, Level: 66
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,143
    Helped
    3448 / 3448
    Points
    74,672
    Level
    66

    Re: Calculating SNR from for an ADC

    Hi,

    i know that it should be equal to or around 6.02N+1.76
    N = 2048;
    Mind that both "N" represent different things.

    ****
    SNR = Signal to Noise Ratio = Signal / Noise.
    SNR usually is given in "dB" and signal and noise are given in voltage_RMS.

    Thus in most cases: SNR(dB) = 20 x log(Signal_RMS / Noise_RMS)

    Signal_RMS
    .. is usually a single sinusoidal signal. Thus signal(RMS) in LSB = 2^ADC_bit_resolution / (2 x sqrt(2))
    Example: for a 16 bit ADC: 23170 LSB_RMS

    Noise_RMS
    ...is the sum of all frequencies voltage_RMS. (except DC)
    noise_RMS = sqrt( n1_RMS^2 + n2_RMS^2 +n3_RMS^2 ....)

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 5
    Points: 492, Level: 4

    Join Date
    Dec 2016
    Posts
    10
    Helped
    0 / 0
    Points
    492
    Level
    4

    Re: Calculating SNR from for an ADC

    thanks KlausST but i want to calculate it from the data collected from the FFT i will attach the signal
    it is a sine wave output for 4 bit Ideal ADC
    Click image for larger version. 

Name:	time.jpg 
Views:	3 
Size:	39.5 KB 
ID:	153195
    Click image for larger version. 

Name:	freq.jpg 
Views:	3 
Size:	47.1 KB 
ID:	153197
    Code:
    Afs = 5;
    fs = 1e6;
    N = 2048;
    cycles = 5;
    fx = fs*cycles/N;
    t = linspace(0, (N-1)/fs, N);
    %signal frequency
    y = table2array(bitsinfullscale);
    y = y';
    s = 20*log10 (abs(fft(y)/N/Afs*2));
    % drop redundant half
    s = s(1:N/2);
    f = (0:length(s)-1) / N*fs;
    figure
    plot(t,y)
    hold on;
    figure
    plot(f,s)
    bx = N*fx/fs + 1;
    As = 20*log10 (s(bx));
    %set signal bin to 0
    s(bx) = 0;
    An = 10*log10 (sum(s.^2));
    SNR = As - An



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 74,672, Level: 66
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,143
    Helped
    3448 / 3448
    Points
    74,672
    Level
    66

    Re: Calculating SNR from for an ADC

    Hi,

    then just take bin5 as your "signal", and all the rest (without DC) as noise.

    But your "sine" is distorted... and it seems it just has 4 bits of resolution, thus you get a lot of overtones.

    These overtones play a big role in caclulation.. and thus you donīt get "noise only" --> the result is more "THD+N" instead of "SNR".

    --> either use a THD free input signal, or donīt use an input signal at all.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



--[[ ]]--