Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me understand FFT analyzes

Status
Not open for further replies.

yen

Member level 5
Member level 5
Joined
Apr 21, 2005
Messages
85
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
2,230
I have a matlab question.
My input is a 1MHz sine wave and my clk is 80MHz.
When I do fft about SFDR,my peak value is not in 1MHz in fft picture.
Can you tell me detail if you know.
Thank you.


My input is out1.txt

0010101010
0010101010
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101000
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010101011
1010100000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110000
1010110011
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1010111111
1100000001
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000000
1100000001
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
0111111111
1000001101
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001100
1000001101
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1000111111
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010010011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1011011000
1011011000
1011011000
1011011000
1011011000
1011011001
1011011000
1011011000
1011011000
1011011000
1011011000
1011011000
1011011010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011011
1100011110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1100111110
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101010100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1101110100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110001100
1110000101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110100101
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1110110111
1111000000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111001000
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111010111
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111100010
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111101111
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110010
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111110000
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111101001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111100001
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111010110
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1111000111
1110100110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110110110
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110100010
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1110001001
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101110011
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1101010101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100110101
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1100010111
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111001
1011111000
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1011010100
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010101110
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1010001010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1001011010
1000010101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000110101
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
1000010001
0110101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111101100
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0111000011
0110001101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0110011101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101101101
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0101001100
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100100110
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0100000100
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011100101
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0011000000
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010100111
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001110100
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001011011
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0001000111
0000001001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000101001
0000001110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000011110
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010101
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000010001
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001110
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000001101
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010010
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000010110
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000011111
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000101010
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000111001
0000001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001001001
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001011101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0001110101
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001011
0010001001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0010101001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011001001
0011000111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0011100111
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100000110
0100001011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0100101011
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010001
0101010101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0101110101
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0110100100
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111001001
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
0111101110
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000010011
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1000111010
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1001100101
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010001111
1010000011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1010110011
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011001
1011011010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1011111010
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011001
1100011111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1100111111
1101011001
1101011001
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000
1101011000






















































and my matlab code is
clc;
clear;
fclk=80E+6;
numpt=1200;
numbit=10;
load out1.txt; % Load data from disk;
a=out1';
N=length(a);
[M,N]=size(a); % Number of data;
for i=1:1:N; %
c=int2str(a(i)); % Change integer type data to string type;
temp=0; %
Nlength=length(c); % Length of the string;
for j=1:1:Nlength; %
d=str2num(c(j))*2^(Nlength-j); % Binary to decimalization
temp=temp+d; %
end; %
code(i)=temp;%/3988*2.5; %
end;
N=length(code);
%Display a warning, when the input generates a code greater than full-scale
if (max(code)==2^numbit-1) | (min(code)==0)
disp('Warning: ADC may be clipping!!!');
end
%Plot results in the time domain

zoom xon;
%Recenter the digital sine wave
Dout=code-(2^numbit-1)/2;
subplot(3,1,1);
plot([1:N],Dout);
title('TIME DOMAIN');
xlabel('SAMPLES');
ylabel('DIGITAL OUTPUT CODE');
%If no window function is used, the input tone must be chosen to be unique and with
%regard to the sampling frequency. To achieve this prime numbers are introduced and the
%input tone is determined by fIN = fSAMPLE * (Prime Number / Data Record Size).
%To relax this requirement, window functions such as HANNING and HAMING (see below) can
%be introduced, however the fundamental in the resulting FFT spectrum appears 'sharper'
%without the use of window functions.
%Doutw=Dout;
window=hanning(numpt);
subplot(3,1,2);
plot(window);
Doutw=Dout.*window';
%Doutw=Dout.*hamming(numpt);
%Performing the Fast Fourier Transform
Dout_spect=fft(Doutw,numpt);
%Recalculate to dB
Dout_dB=20*log10(abs(Dout_spect));

subplot(3,1,3);

plot([1:N/2],Dout_dB(1:N/2));
%Display the results in the frequency domain with an FFT plot

maxdB=max(Dout_dB(2:numpt/2));
%For TTIMD, use the following short routine, normalized to —6.5dB full-scale.
plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB-6.5);
%plot([0:numpt/2-1].*fclk/numpt,Dout_dB(1:numpt/2)-maxdB);

title('FFT PLOT');
xlabel('ANALOG INPUT FREQUENCY (MHz)');
ylabel('AMPLITUDE (dB)');
%a1=axis; axis([a1(1) a1(2) -120 a1(4)]);
 

1011011001

First, you should do fft analysis on 1024 points not 1200 points as in you code.
Second, you shouldn't sample only one period of sin wave.
For example: Fclk=80M, sample points=1024, circles=499(should be a prime number), so fsin='80*499/1024'M
 

1010101110

flushrat said:
First, you should do fft analysis on 1024 points not 1200 points as in you code.
Second, you shouldn't sample only one period of sin wave.
For example: Fclk=80M, sample points=1024, circles=499(should be a prime number), so fsin='80*499/1024'M

Dear flushrat,
Why do I do fft must be 1024 or 512 points?
Is your fsin a input sine wave?
Why circles must be a prime number?
Thank you.
 

0110100100

Dear Yen,

The FFT is FAST algorithm to obtain the Discrete Fourier Transform (DFT) of a signal, where the number of points MUST be a power of two.

The DFT assumes that the input vector (i.e. the samples) repeats itself until infinity. Theferore, when making the FFT/DFT of a sinewase one must guarantee that the first and last samples are ADJACENT. If this does not happen there is SPECTRAL LEAKAGE. To find out more go to:

https://zone.ni.com/devzone/conceptd.nsf/webmain/4D2F2B3C170CC02E862568C1006857EB

or search google. This is ensured by carefully choosing either the input or the clock frequency:
M.Ti = N.Ts
Where
Ti-input signal period
Ts- clock period
N- number of points in the DFT/FFT
M- Prime number.

In principle, M could be any number, but there would be the risk of sampling repeatedly the the same values of the input sinewave. If M is prime this does not happen.

Rgds
 

1000111010

Hi yen,

Your question in the forum sparked my interest. How do you generate the file out1.txt? Is it from SPICE simulation output? Is it resulted from transient analysis?If so what is the syntax to generate the file? Appreciate if you can share.

thanks in advance
-snoop835-
 

0001001001

Dear Yen,
this page can help you
**broken link removed**
Rgds
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top