Digital to analog converter 20 bits program using matlab

Status
Not open for further replies.

newbie_1

Member level 3
Joined
Sep 27, 2005
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,739
help on fft!

hi,
i created an ideal 20bit adc and 20bit dac using veriloga and tested them with a 15khz sinwave as input, the clk freq is 12.5Mhz. The output of the dac was dumped from cadence as out222.dat using ocnPrint with a time step of 80ns.
i wote a simple matlab program(snr_out2a.m) and plot the spectrum of the output signal but the spectrum is totally wrong coz the snr is really poor and actually it should be at least 120db.
please tell me what's wrong with the program, and i have some questions:
1. what should be the sampling freq in matlab program? should it be the same as that used in ad and da?
2.the data dumped from cadence didn't cover some integer num of periods, then should i use some window function? how about hann? and if i use hanning, is my using as line19 correct? and so long as the data has not enough samples, then how can i do much larger num points of fft?

thanks very much
newbie
 

help on fft!

You should set the sample rate value in MATLAB to be the same as your hardware.

Yes you should apply a window before doing an FFT of data with a non-integer number of samples. Your hann() code looks fine, but you assign the resut to data2 which you don't use anywhere.

Different window functions give different sidelobe attenuation. You must choose a window that suits your requirements. For 120 dB, I suppose you could use a Kaiser window with a large beta.

"... so long as the data has not enough samples, then how can i do much larger num points of fft?"
I don't understand the question. Please rephrase.

Here's another approach:
Code:
load out222.dat;
out222 = out222(1:5000,:);      % trim the data
y  = out222(:,2);               % data
N  = length(y);                 % number of points
fs = 12.5e6;                    % sample rate
h  = fft(y .* kaiser(N,10));    % window unnecessary if data has integer cycles
freq = fs * (0 : N/2) / N;
subplot(2,1,1); plot(freq, 20 * log10(2 / N * abs(h(1 : N / 2 + 1)))); xlabel('Hertz');
subplot(2,1,2); plot(y);
Your data isn't a clean sinewave. I see some low-amplitude buzzing at a couple hundred kilohertz.
 

    newbie_1

    Points: 2
    Helpful Answer Positive Rating
help on fft!

hi echo47
really thank you very much for your reply.
and it's a mistake that i didn't use data2.
and the question is, if i use hann window and because the input data only has limited numer of points, for example 6000 points, then how can i do 16384 points of fft still using hann window?

and can you tell me why u use kaiser and use such high beta?

really thanks a lot.

newbie
 

help on fft!

I still don't understand your question about number of points. You can apply any type window to any number of points, and you can do an FFT of any number of points (although powers of two are usually faster).

Kaiser is a convenient adjustable window. A high beta gives lower sidelobes but wider main lobe. You can choose whatever window meets your needs.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…