DSPRelated.com
Forums

FFT on dsPIC33F

Started by charlyb May 3, 2008
Hi,

Can anyone help with this ? :-

I am using the fft function on the dsPIC from the Microchip library.

When I do a fft I get a non linear result. The dsPIC function claims the
result will be 1/N where N=fft size.

When I do a 512 fft with a 20Hz sine signal sampled at 640Hz - I can
extract the frequency = 20Hz

I dont see how the result is scaled relative to the original signal
amplitude. 

ip is 100mV peak(200mV p2p) fft result is 0x0014 (20)	
ip is 200mV peak(400mV p2p) fft result is 0x0052 (82)
ip is 250mV peak(500mV p2p) fft result is 0x0080 (128)   
ip is 300mV peak(600mV p2p) fft result is 0x00b2 (178)
.
.
ip is 500mV peak (1V p2p) fft result is 0x0200 (512)
.
.
.
.
ip is 1V peak (2V p2p) fft result is 0x07ff (2047)


I have used the same signals on the ADevices simulator and the results are
linear and look meaningful. 


On May 3, 5:13&#4294967295;pm, "charlyb" <c...@eca.co.za> wrote:
> Hi, > > Can anyone help with this ? :- > > I am using the fft function on the dsPIC from the Microchip library. > > When I do a fft I get a non linear result. The dsPIC function claims the > result will be 1/N where N=fft size. > > When I do a 512 fft with a 20Hz sine signal sampled at 640Hz - I can > extract the frequency = 20Hz > > I dont see how the result is scaled relative to the original signal > amplitude. > > ip is 100mV peak(200mV p2p) fft result is 0x0014 (20) &#4294967295; > ip is 200mV peak(400mV p2p) fft result is 0x0052 (82) > ip is 250mV peak(500mV p2p) fft result is 0x0080 (128) &#4294967295; > ip is 300mV peak(600mV p2p) fft result is 0x00b2 (178) > . > . > ip is 500mV peak (1V p2p) fft result is 0x0200 (512) > . > . > . > . > ip is 1V peak (2V p2p) fft result is 0x07ff (2047) > > I have used the same signals on the ADevices simulator and the results are > linear and look meaningful.
Charlie, Just stabbing in the dark, but have you set your twiddle coefficients? I might be able to help out a little more if I could see some code. Cheers, Tim.
>ip is 100mV peak(200mV p2p) fft result is 0x0014 (20) >ip is 200mV peak(400mV p2p) fft result is 0x0052 (82) >ip is 250mV peak(500mV p2p) fft result is 0x0080 (128) >ip is 300mV peak(600mV p2p) fft result is 0x00b2 (178) >. >. >ip is 500mV peak (1V p2p) fft result is 0x0200 (512) >. >. >. >. >ip is 1V peak (2V p2p) fft result is 0x07ff (2047)
Just a guess, but as you're voltage is doubling, the fft result is increasing by 4X. Perhaps the fft output is relative to power (magnitude squared) and not voltage?
>>ip is 100mV peak(200mV p2p) fft result is 0x0014 (20) >>ip is 200mV peak(400mV p2p) fft result is 0x0052 (82) >>ip is 250mV peak(500mV p2p) fft result is 0x0080 (128) >>ip is 300mV peak(600mV p2p) fft result is 0x00b2 (178) >>. >>. >>ip is 500mV peak (1V p2p) fft result is 0x0200 (512) >>. >>. >>. >>. >>ip is 1V peak (2V p2p) fft result is 0x07ff (2047) > >Just a guess, but as you're voltage is doubling, the fft result is >increasing by 4X. Perhaps the fft output is relative to power
(magnitude
>squared) and not voltage? >
Thanks for responding you are quiet right. It is a power squared function. Thank you