Re: need help with DSP

From: larryjanow (larrywj_at_attbi.com)
Date: 2002-06-17 18:01:03


Hi Michal,

You can't discard the 'imaginary' half of the FFT output, you need
it to calculate the actual output amplitude at each frequency.

The formula is:

Amplitude(m) = square root of( ( Real(m) * Real(m) ) + ( Imag(m) *
Imag(m) ) ) / ( N / 2 ), where N is the FFT sample size (256 in your
example below)

For example, to calculate the 10Hz amplitude using your example
below, Real(m) would be bin 11 (bin 0 is the real part of the DC
component), and Imag(m) would be bin 139 (bin 128 is the imaginary
part of DC).

You can also use the imaginary bins to calculate the phase of each
component:

phase = inverse tangent of( Imag(m) / Real(m) )

Good luck!

- Larry

--- In buildcheapeeg_at_yahoogroups.com, Michal Wallace <sabren_at_manifestation.com> wrote:
> On Sat, 15 Jun 2002, Jim Peters wrote:
>
> > Jim Peters wrote:
> > > Bear in mind that the lowest band in your FFT will be centred
on
> > > 0Hz, then 4Hz, then 8Hz, 16Hz, 24Hz, and so on up to 128Hz.
> >
> > Oops -- my mistake. It goes 0, 4, 8, 12, 16, 20, ... 128;
> > basically (0..32)*4Hz. The 4Hz comes from the
> > window-length: 256/64 == 4Hz.
>
>
> Hey Jim,
>
> Thanks for this, too. I think I'm starting to understand the
> properties of the FFT results a little better.
>
> Let me see if I have this straight:
>
> 1. We want to pick up waves in the 0-Beta range, where
> beta is around 30. Some people may even want "super beta",
> so we may want to go up as high as 40-50?
>
> 2. Since Nyquist's rule says we need to sample at least
> twice as fast as the highest frequency we want to detect,
> the hardware folks have chosen a sample rate of 128Hz
> or 256Hz. (I'm not sure about this, I thought I'd read
> it somewhere... Can anyone tell me the actual rates?)
>
> 3. The FFT returns an array of the same length as the
> input, but we discard half of it because it deals with
> imaginary numbers. Each slot in the array (or "bin", I've
> seen it called) represents a set of frequencies
> max-detectible-frequency/window-length wide.
> Is that true?
>
> So, if I want each bar to represent 0hz, 1hz, ... 32hz, and
> we have 256 samples per second, then then I need to have all
> 256 samples, which gives me 128 bins, each 1Hz wide. Then I
> can just show the first 32. Is that right?
>
> If so... Do I just update the screen once a second? Or
> should I show the last second's worth of data every 1/4th of
> a second, even though 75% of the data is the same each time?
>
>
> Thanks,
>
> - Michal http://www.sabren.net/ sabren_at_manifestation.com
> ------------------------------------------------------------
> Switch to Cornerhost! http://www.cornerhost.com/
> High Powered Hosting - With a Human Touch. :)
> ------------------------------------------------------------



This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:43 BST