Jump to content
  • 0

XADC and the FFT


mohamed shffat

Question

Hello 

I'm trying to take an FFT on the FPGA after getting sampled data comes from XADC , but i couldn't get any results ! 

Here i figured out that the problem might be from the XADC's data , i tried to fix it but so far still no results . 

In my design i'm inserting an analog input signal to VP/VN pins on XADC header , then i'm trying to get some data comes out from the 1MSPS XADC . 

When i plot the output data it looks as it sampled correctly , but when i try to take its FFT whether on FPGA FFT CORE or on MATLAB , i get no results . The sampled signal and its FFT are shown below in the pics . 

Also i tried many frequencies for the input signal starts from 10KHz up to 480KHz , but they are all giving the same result , empty window in the Freq-domain . 

If someones know what's the problem i would really appreciate the help . 

Regards 

sampled sin with 50khz.jpg

Spectrum of the sampled sin.jpg

Link to comment
Share on other sites

Recommended Posts

@D@n  sir when i try to run the @mohamed shffat  sin10khz.csv file in MATLAB iam getting errors in first line how did u remove it and how that FFT function command(plot(10*log(fftshift(abs(fft(X(4,:)))))/log(10)))   has worked could you explain it . please do let me know sir why iam getting  errors. I generated the frequency spectrum of sinewave(10khz) using zedboard through VGA module below is it attachmments and xadc sampled output in vivado simulator. Iam getting some distortions in frequency spectrum couldnt rectify it so wanted to try sin10khz.csv file of @mohamed shffat in MATLAB please do let me know where iam making mistake in MATLAB as i have a  very less time for project submission below has the attachments of matlab errors.

xadcsample reg output.PNG

sin10khz.PNG

20180831_151638.jpg

sin10khz.csv

Link to comment
Share on other sites

@farhanazneen,

I don't have @mohamed shffat's code, nor have I seen it.  Therefore, I would struggle to answer your question regarding how he accomplished (or didn't accomplish) this task.  As I recall, I've posted all of the details of my own solution on zipcpu.com, although several of the components were spread across multiple different blog posts.  I think I've already linked to these above, though, so if you are missing some part of my own solution, please speak up.

By the way, my solution is done in completely in Verilog.  I haven't used the XADC (yet).  It's also highly dependent upon what I call a debugging bus: a concept explored (and built) on my blog as well.

Dan

Link to comment
Share on other sites

please do let me know that how your giving input to the vp/vn pins in xadc header is it done through a test bench? or signal generator if it is  through signal generator  how can i give directly input to the xadc  header  and how  to do coding please do let me know sir

Link to comment
Share on other sites

hello, @D@n

 sir iam trying to  capture the xadc output in vivado through  ILA logic analyzer core  and then wanted to send that output to the input of fft please do let me know how to capture the xadc signals in the ILA core 

The below is my design in vivado please do let me know im very new to vivado and iam working on a zedboard

fft.rar

Link to comment
Share on other sites

@Arvind,

Not sure I understand your question ... you connect the output data from the ADC to the input of the FFT, and the data valid wire on the input of the FFT to the data valid indicator from your ADC.

Can you be clearer about what part of the design you are struggling with?

Dan

Link to comment
Share on other sites

@Arvind,

Is there a "process" ... you mean like an engineering process to do this task?  Absolutely!

Here's a blog post I wrote about this sort of topic that should give you an idea of what's required.

In very short sum, you'll want to:

  1. Place a known input signal into your FPGA,
  2. Match it to a known output.

Don't make it any harder than that, your task will be hard enough without making it any harder.

You'll want to skip the whole xADC portion, though, until you've gotten this one step working.  If you don't, you'll never know what your problem is.

For your test bench, there are two basic FFT inputs that should tell you everything you need: The first is the vector with one value set, but the rest are all zeros.  This should return a sine/cosine wave at  the appropriate frequency--depending on where the one nonzero value is within your FFT window.  The second input is a sine or cosine wave at a frequency that is an exact multiple of your FFT length.  You should be able to suddenly switch between these two, and still get the right answer (there will be some delay between input and output, and should also be a synchronization pulse to help you get the right delay path.)

That's part one.

Part two is for the xADC: You'll want to read from the xADC a known value, dump it into a buffer (WITHOUT GOING THROUGH THE FFT), and make sure you can read a signal properly there.  At the right rate, too--if the xADC is only sampling at 102kHz, make sure you are only getting inputs at a rate of 102kHz.  Before you go into your FFT, you'll want to make sure that you can send inputs to it at 102kHz (or whatever your sample rate is) ONLY--no duplicated or dropped samples.  But ... for now, just make sure you have the sampling right coming out of the XADC.

Part 3 is putting the two together.  Don't skip part 1 or part 2 to get here.  To do part 3, you'll want an internal scope looking at the inputs to the FFT and the outputs in a synchronized fashion.  (You may have chosen to use such a scope before you go to this point as well, to do parts 1 and 2)  Otherwise, you'll never know what's going wrong when (if) anything goes wrong.

 

That's the "process" you are looking for.

You should find example code on my blog for several of the required pieces of this process.  (Sadly, I don't have all of the pieces described on the blog yet.  The biggest missing pieces are 1) the UART to wishbone interface, 2) the software side of that interface, and 3) how to write a VCD file)

Once you get that far, you'll still have the challenge of FFT windows to deal with.  You can see a challenge I gave regarding achieving good frequency resolution here, and the beginnings of a response (with references) here--that will start to show you how to do better than the traditional frequency resolution.

Dan

 

Link to comment
Share on other sites

Dear sir,

 I am new to this feild. I wanted to a small help from your side. I have implemented XADC  16 bit. I want to verify my output is in sync with the input signal. Is there any process so that I can check my implementation correct or not.

thanx

Link to comment
Share on other sites

@mohamed shffat,

Ah, yes, v9 ... that's right, they moved to an AXI protocol and got rid of the CE line, didn't they?

The answer to your "or" question is to some extent "it depends", but I think I'm going to give you the answer "yes".  Here's why:

  1. Testing the FFT with a new sample every clock period will give you some confidence that the FFT works.  Do this first--it's easier.
  2. However, once you have that confidence, you'll want to apply it to the XADC, where a new sample will not be ready every clock period.

So ... try both.  Get comfortable with your tools (i.e. the FFT, your test harness, etc).  Then, when/if they don't work, you'll have a better understanding as to why or why not.

Dan

Link to comment
Share on other sites

On 12/5/2016 at 6:57 PM, D@n said:

But ... you've got another problem here as well.  You have too many samples.  Your sampler sampled at a rate of about 1000x faster than your ADC.  If you want this FFT to work, you are going to need to gate the recorder, so that it only records valid samples--one each from one comes out of the recorder.

Dan

Ok sir thanks too much , i'm gonna try to handle it . 

My last question now is that i'm using the 9.0th version of the FFT on the Vivado tool , and i'm not taking the data directly from the XADC . I'm storing a 1024 samples inside a FIFO memory first , then i'm reading and inserting these samples to the FFT core , and the clock speed of the memory is 100MHZ . So should i here control the S_axis_data_valid line with the writing speed from the FIFO memory or i should just control according to the sampling rate out of the XADC . 

Regards sir . 

Link to comment
Share on other sites

But ... you've got another problem here as well.  You have too many samples.  Your sampler sampled at a rate of about 1000x faster than your ADC.  If you want this FFT to work, you are going to need to gate the recorder, so that it only records valid samples--one each from one comes out of the recorder.

Dan

Link to comment
Share on other sites

Yeah, so ... I'm not having a problem with your data at all.  Here's what I did:

% First, I removed the top-line from your CSV file, then ...
a = load('sin10khz.csv');
X = transpose(a);
plot(10*log(fftshift(abs(fft(X(4,:)))))/log(10)); grid on;

and you can see the result I got (attached--if all goes well).

Dan

Screenshot from 2016-12-05 11:53:06.png

Link to comment
Share on other sites

@D@n 

Yep sir , even the MATLAB couldn't do the FFT of the sampled data that i got from the XADC . On MATLAB all what i'm doing is just giving the samples or values that i extracted from the XADC , and trying to take it's simple FFT without any limits in X or Y axis . 

Here my MATLAB script , and the .csv file which contains the 32768 extracted samples from the XADC by the ILA debugging core . 

x = input('ADC data = ') ;

X = transpose(x) ;

y = abs(fft(x)) ;

subplot(2,1,1)

 plot(X) ; 

subplot(2,1,2)

plot(y); 

My .csv file is submitted below , it's contains the samples of a 10 KHz sampled sin from XADC .

Regards sir 

sin10khz.csv

Link to comment
Share on other sites

@mohamed shffat,

MATLAB won't do an FFT of it?  If that's the case, it's because either 1) You aren't giving MATLAB the right values, or 2) You aren't giving it the right plotting command.  An easy way to test is to "plot" the values before doing the FFT.  If you get a good looking plot output, the result isn't the values you are giving MATLAB, but rather the plot command you are giving the FFT--and perhaps the X or Y axis limits.

Want to share your MATLAB script, together with a text file with your values that MATLAB is failing on?  That alone should be fairly easy to get working.  The Xilinx FFT ... that'll take more work.

Dan

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...