# FFT: Could you help me to clarify some doubts?

Started by October 27, 2011
```Hello
I should calculate a FFT of signal that have max 500Hz of frequency.

I know that for avoid aliasing problem I must have a sample rate of Fmax*2,
so I have fix it to:

Sample_Rate_Frequency= 1024Hz

Question 1)

[Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
1024                 1 sec                     1Hz
512                 1/2 sec                   2Hz
256                 1/4 sec                   4Hz
128                 1/8 sec                   8Hz

Question 2)
Suppose first previous case of 1024 Acquisited Point saved in IMX() and
REX()vectors.
Suppose I would calculate and plot the Power() = IMX()*IMX() + REX()*REX()

Is correct that Power vector must have the HALF SIZE of IMX()or REX()

For Index=1 to 512
Power(Index) = IMX(Index)*IMX(Index) + REX(Index)*REX(Index)
Next

Because the second half (513 - 1024) contain only an alias of signal?

Question 3)
If point 1 and 2 are correct, if I acquire only 128 point, calculate power
on 64, I have resolution of 8Hz??

```
```On 27.10.11 4:59 , gpezzella wrote:
> Hello
> I should calculate a FFT of signal that have max 500Hz of frequency.
>
> I know that for avoid aliasing problem I must have a sample rate of Fmax*2,
> so I have fix it to:
>
>                      Sample_Rate_Frequency= 1024Hz
>

The aliasing problem is not so simple: you need an analog filter
before sampling. The filter must attenuate the alias frequencies
so that the remaining energy is negligible in your application.

If you have a signal bandwidth of 500 Hz, you're specifying a
nearly impossible anti-alias analog filter with 1024 Hz sampling
rate. The alias frequency of 500 Hz will then be at 524 Hz, so
you're specifying a filter with null attenuation at 500 Hz and
very high attenuation at 524 Hz.

--

Tauno Voipio
```
```>The aliasing problem is not so simple: you need an analog filter
>before sampling. The filter must attenuate the alias frequencies
>so that the remaining energy is negligible in your application.
>
>If you have a signal bandwidth of 500 Hz, you're specifying a
>nearly impossible anti-alias analog filter with 1024 Hz sampling
>rate. The alias frequency of 500 Hz will then be at 524 Hz, so
>you're specifying a filter with null attenuation at 500 Hz and
>very high attenuation at 524 Hz.

Why analog?

Supponing that I will use it, could you reply my 3 questions?

Thanks
```
```On 10/27/2011 12:00 PM, gpezzella wrote:
>> The aliasing problem is not so simple: you need an analog filter
>> before sampling. The filter must attenuate the alias frequencies
>> so that the remaining energy is negligible in your application.
>>
>> If you have a signal bandwidth of 500 Hz, you're specifying a
>> nearly impossible anti-alias analog filter with 1024 Hz sampling
>> rate. The alias frequency of 500 Hz will then be at 524 Hz, so
>> you're specifying a filter with null attenuation at 500 Hz and
>> very high attenuation at 524 Hz.
>
> Why analog?
>
> Supponing that I will use it, could you reply my 3 questions?

OK.

> Question 1)
> Is correct the follow table:
>
> [Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
>        1024                 1 sec                     1Hz
>         512                 1/2 sec                   2Hz
>         256                 1/4 sec                   4Hz
>         128                 1/8 sec                   8Hz

Probably not. I'm not sure that I understand it.

> Question 2)
> Suppose first previous case of 1024 Acquisited Point saved in IMX()
> and REX()vectors.
> Suppose I would calculate and plot the Power() = IMX()*IMX() +
> REX()*REX()
>
> Is correct that Power vector must have the HALF SIZE of IMX()or REX()
>
>    For Index=1 to 512
>        Power(Index) = IMX(Index)*IMX(Index) + REX(Index)*REX(Index)
>    Next
>
> Because the second half (513 - 1024) contain only an alias of signal?

What second half? The FFT yields as many bins as the number of samples
allows. If you sample for 10 seconds, you will have 10240 samples, with
a resolution of 0.1 Hz *at all frequencies up to fs/2*.

> Question 3)
> If point 1 and 2 are correct, if I acquire only 128 point, calculate
> power on 64, I have resolution of 8Hz??

It's not correct.

Jerry

P.S. Tauno is right. You won't be able to make an effective anti-alias
filter.
--
Engineering is the art of making what you want from things you can get.
```
```"gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com> wrote in message
news:nNKdnSVjGf1b_jTTnZ2dnUVZ_t2dnZ2d@giganews.com...
> Hello
> I should calculate a FFT of signal that have max 500Hz of frequency.
>
> I know that for avoid aliasing problem I must have a sample rate of
> Fmax*2,
> so I have fix it to:
>
>                    Sample_Rate_Frequency= 1024Hz
>
> Question 1)
> Is correct the follow table:
>
> [Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
>      1024                 1 sec                     1Hz
>       512                 1/2 sec                   2Hz
>       256                 1/4 sec                   4Hz
>       128                 1/8 sec                   8Hz

Yes.

FFT Length = Number_of_samples / Sampling_rate
Frequency_resolution = 1 / Length

You certainly can't see a pattern repeating at 1 cycle per second if you
have less 1 second of data!

>
>
> Question 2)
> Suppose first previous case of 1024 Acquisited Point saved in IMX() and
> REX()vectors.
> Suppose I would calculate and plot the Power() = IMX()*IMX() + REX()*REX()
>
> Is correct that Power vector must have the HALF SIZE of IMX()or REX()
>
>  For Index=1 to 512
>      Power(Index) = IMX(Index)*IMX(Index) + REX(Index)*REX(Index)
>  Next
>
> Because the second half (513 - 1024) contain only an alias of signal?

This happens when the input data are purely real i.e. input imaginary parts
are all zero.  Actually, if you look at the imaginary output data, you will
see that IMX(1024-i) = - IMX(i) but this is masked by squaring.  It is
different when the input data is complex.

>
>
> Question 3)
> If point 1 and 2 are correct, if I acquire only 128 point, calculate power
> on 64, I have resolution of 8Hz??
>
>
>
>

FFT Length = 128 / 1024
1 / Length = 1024 / 128 = 8 Hz

Bin 0 = DC
Bin 1 = 8 Hz
Bin 2 = 16 Hz
Bin 3 = 24 Hz
.
.
.
Bin 61 = 488 Hz
Bin 62 = 496 Hz
Bin 63 = 504 Hz which is just under fs / 2

```
```Hello,
I will try to explain what I would do.....

***************************************************************************
My Case
***************************************************************************
I have a Microwave Sensor that detect human being presence (google innosent
ipm 65 and click on first result that will appeare).

When human being is detect, IPM 65 return in output frequency from 6Hz -
600 Hz). When other things are detect, bird, car etc other frequency are
generate in output.

I would check frequency between 6Hz - 600Hz, avoiding if possible analog
filter, for see where are peaks in this range.

In this manner I could try to discriminate different case: human, dogs
etc.
***************************************************************************

***************************************************************************
Theory
***************************************************************************

I try to repost the question in different way.

Suppose to sample the output of Innosent IPM 65 after the amplify filter
showed in fig3 of datasheet (6-600 Hz with 60dB gain)

Suppose to have FIXED SAMPLING RATE = 1024 Hz
Suppose to perform 4 different acquisition

1) Aquisition = 1024 Points
2) Aquisition =  512 Points
3) Aquisition =  256 Points
4) Aquisition =  128 Points

[Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
1)      1024                 1 sec                     ?
2)       512                 1/2 sec                   ?
3)       256                 1/4 sec                   ?
4)       128                 1/8 sec                   ?

1) Which is the resolution of every acquistion?
(Plase fill the resolution field)

After every acquisiton I calculate FFT that return me 2 vectors: REX() and
IMX()

2) Is the lenght of this 2 vectors equal at number of points acquisited?

3) If I calculate the power OUT()= IMX()*IMX()+ REX()*REX() is the lenght
of vector OUT() equal at number of acquisited points?

4) Which range of points of the vector OUT()I should plot for be sure to
show theoretically correct information?

[Acquisited Point]  [Acquisition Duration]          [Range]
1)      1024                 1 sec                     ?
2)       512                 1/2 sec                   ?
3)       256                 1/4 sec                   ?
4)       128                 1/8 sec                   ?

(Plase fill the range field)

```
```On 10/27/2011 4:56 PM, gpezzella wrote:
> Hello,
> I will try to explain what I would do.....
>
>
> ***************************************************************************
> My Case
> ***************************************************************************
> I have a Microwave Sensor that detect human being presence (google innosent
> ipm 65 and click on first result that will appeare).
>
> When human being is detect, IPM 65 return in output frequency from 6Hz -
> 600 Hz). When other things are detect, bird, car etc other frequency are
> generate in output.
>
> I would check frequency between 6Hz - 600Hz, avoiding if possible analog
> filter, for see where are peaks in this range.
>
> In this manner I could try to discriminate different case: human, dogs
> etc.
> ***************************************************************************
>
>
>
>
>
> ***************************************************************************
> Theory
> ***************************************************************************
>
> I try to repost the question in different way.
>
> Suppose to sample the output of Innosent IPM 65 after the amplify filter
> showed in fig3 of datasheet (6-600 Hz with 60dB gain)
>
> Suppose to have FIXED SAMPLING RATE = 1024 Hz
> Suppose to perform 4 different acquisition
>
> 1) Aquisition = 1024 Points
> 2) Aquisition =  512 Points
> 3) Aquisition =  256 Points
> 4) Aquisition =  128 Points
>
> [Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
> 1)      1024                 1 sec                     ?
> 2)       512                 1/2 sec                   ?
> 3)       256                 1/4 sec                   ?
> 4)       128                 1/8 sec                   ?
>
> 1) Which is the resolution of every acquistion?
> (Plase fill the resolution field)

You had it right the first time. I wasn't sure I understood.

> After every acquisiton I calculate FFT that return me 2 vectors: REX() and
> IMX()
>
> 2) Is the lenght of this 2 vectors equal at number of points acquisited?

The length of each of them. For N points into the FFT, there are N
complex numbers out.

> 3) If I calculate the power OUT()= IMX()*IMX()+ REX()*REX() is the lenght
> of vector OUT() equal at number of acquisited points?
>
> 4) Which range of points of the vector OUT()I should plot for be sure to
> show theoretically correct information?
>
> [Acquisited Point]  [Acquisition Duration]          [Range]
> 1)      1024                 1 sec                     ?
> 2)       512                 1/2 sec                   ?
> 3)       256                 1/4 sec                   ?
> 4)       128                 1/8 sec                   ?
>
>                     (Plase fill the range field)

[Acquired Point]   [Acquisition Duration]          [Range]
1)      1024                 1 sec                   1024
2)       512                 1/2 sec                  512
3)       256                 1/4 sec                  256
4)       128                 1/8 sec                  128

The validity of result depends on the absence of all frequencies greater
than half the sampling frequency *before* the sampling takes place.

Let me know if I missed anything.

Jerry
--
Engineering is the art of making what you want from things you can get.
```
```On Thu, 27 Oct 2011 08:59:34 -0500, gpezzella wrote:

> Hello
> I should calculate a FFT of signal that have max 500Hz of frequency.
>
> I know that for avoid aliasing problem I must have a sample rate of
> Fmax*2, so I have fix it to:
>
>                     Sample_Rate_Frequency= 1024Hz

http://www.wescottdesign.com/articles/Sampling/sampling.pdf for a
discussion.

>
> Question 1)
> Is correct the follow table:
>
> [Acquisited Point]  [Acquisition Duration]  [Frequency Resolution]
>       1024                 1 sec                     1Hz
>        512                 1/2 sec                   2Hz
>        256                 1/4 sec                   4Hz
>        128                 1/8 sec                   8Hz

Well, the bins will be spaced apart by the frequencies that you're
calling "frequency resolution".  There's more to resolving signal
frequencies than that, though.

> Question 2)
> Suppose first previous case of 1024 Acquisited Point saved in IMX() and
> REX()vectors.
> Suppose I would calculate and plot the Power() = IMX()*IMX() +
> REX()*REX()
>
> Is correct that Power vector must have the HALF SIZE of IMX()or REX()

No.

>   For Index=1 to 512
>       Power(Index) = IMX(Index)*IMX(Index) + REX(Index)*REX(Index)
>   Next
>
> Because the second half (513 - 1024) contain only an alias of signal?

DC (your index 1, I think) is unique, as is Fs/2.  Sum _all_ the bins.

> Question 3)
> If point 1 and 2 are correct, if I acquire only 128 point, calculate
> power on 64, I have resolution of 8Hz??

No; see my comments on resolution.  It ain't that easy.  Specifically,
you're going to have to window your data, which is going to smear out

--
www.wescottdesign.com
```
```@Wescott
on

If I have understand good, I must remove frequency over Fsampling/2
*before*

acquire the signal and I must do it with analog filter.

Since is pratically impossible have super high order low pass filter, is
better first

improve the sampling rate frequency and if not was sufficient reduce a
cutoff

frequency of the analog filter.

In this mannery I avoid to introduce unexpected aliased energy into my
interested

range of frequency.

Now I need suggest that come from real experience into real world. This is
my case:

*******************************************************************
I have a Microwave Sensor that detect human being presence (google innosent
ipm 65

and click on first result that will appeare).
When human being is detect, IPM 65 return in output frequency
from 6Hz - 600Hz.
*******************************************************************

1)Which kind od analog filter and which sample rate you suggest me?
2)How many point (hence resolution or Bins like you say) I need?
3)What I should check for see if human being was detect? Power, Amplitude,
Phase ??

@Andrew
Thanks for your formula on Frequency_Resolution.
Moreover I have check my signal.It is a perfect sin(x) wave and effectively
IMX() vector have all zero value.

Thanks
```
```Hi
no one have still reply my previous post?
Thanks
```