09-22-2009 05:22 AM
I implemented an external 16 vits ADC using the SPI connection, and it works fine (great!).
I save the different output values of this ADC in a board in my C program.
Now, I have for example 1024 points, which are on 16 bits. When I make the FFT on matlab of a 1 kHz, the results are quite good.
Now, I would like to measure the SNR, and the THD of my sinewave, and store the value in my program...
Do you know if it's possible to measure the SNR and THD using a C program ? If yes, could you give me some information, because I did not find anyone on the internet.
If it's not possible, do you know how can I measure it and store the results ?
10-01-2009 11:01 AM
As you may know, a common way to measure S/N and distortion is to use a good notch filter to remove your 1KHz, and look at what is left. The same data that you compute S/N with will also give you THD. See Wikipedia "signal-to-noise ratio" and "total harmonic distortion" for the math.
So what I would suggest is to find some C code on the web (or have Matlab generate it) for a good notch filter (either FIR or IIR), implement that, and run your A/D samples through that.
Alternatively, you could implement an FFT in C code to compute power spectrum, run your A/D samples through that, and compare the power at 1KHz to other stuff, like 2KHz, 3KHz, etc.
If you are using the C compiler in Xilinx Platform Studio, you can use floats, and can configure your MicroBlaze for floating point support to speed it up.