EmbeddedRelated.com
Forums

fft / ifft using dspic

Started by siva...@gmail.com November 5, 2008
Dear,
I have decided to use dspic 30f4012 with 48k rom and 2k ram for implementing fft/ifft. My aim is to sample the incoming voice from a mic to the adc module for 5sec and then perform fft. I also wanted to inverse the process to play back the voice, just to check the process.
So please help me regarding the SAMPLING RATE, HOW TO USE THE LIBRARY FUNCTION IN DSPIC FOR MY DEVICE, WHAT SHOULD BE MY ARGUMENTS TO THE FFT MODULE.
Iam using a 16 bit 28 pin starter demo board from microchip and mplab with c30 c compiler for this purpose.

And also am I using the correct devices for my project?

Thanks in advance
Siva

Hi Siva.

You need to be sampling your incoming signal at twice it's maximum
frequency to avoid aliasing.
The highest frequency the human ear can detect is 20kHz, although you
may not need as high a frequency depending on your application. I.E.
if you want the full spectrum, then you need to sample at 40kHz.
You will also need to put a high pass filter in between the microphone
and the ADC to ensure you get rid of the frequencies above the cutoff
frequency.

5 seconds of data at a 16bit resolution and sampled at 40kHz will
generate 5*80kBytes and you need to be able to write the data to
memory between samples.

For the FFT, you should be able to implement it using 512 or 1024
samples and get a reasonable resolution, but again it depends on your
application.

Hope this was what you were looking for.

Regards,

2008/11/5 :
> Dear,
> I have decided to use dspic 30f4012 with 48k rom and 2k ram for implementing
> fft/ifft. My aim is to sample the incoming voice from a mic to the adc
> module for 5sec and then perform fft. I also wanted to inverse the process
> to play back the voice, just to check the process.
> So please help me regarding the SAMPLING RATE, HOW TO USE THE LIBRARY
> FUNCTION IN DSPIC FOR MY DEVICE, WHAT SHOULD BE MY ARGUMENTS TO THE FFT
> MODULE.
> Iam using a 16 bit 28 pin starter demo board from microchip and mplab with
> c30 c compiler for this purpose.
>
> And also am I using the correct devices for my project?
>
> Thanks in advance
> Siva

Hi Williams,

Thanks a lot. But actually my aim is to store four phrases such as 'left', 'right' and so on. Then compare with the runtime input and if it matches the stored phrase I take the required control. I want to store the samples as fft and I wanted to know whether can i compare the stored phrase fft and runtime fft. Will it be the same?

Can I do that?

Please also help me in using the dspic library for fft / ifft

Thanks in advance,
Siva

Hi Siva.

You may find the following free online book helpful.

http://www.dspguide.com/

For voice recognition, you most probably will be able to get away with a
much lower sampling rate. You will need to play around though and see.

Once potential pitfall is that your magnitude will vary between your
stored phrase and your runtime phrase. Maybe look at correlation as an
alternative to compare the input signals.

s...@gmail.com wrote:

> Hi Williams,
>
> Thanks a lot. But actually my aim is to store four phrases such as
> 'left', 'right' and so on. Then compare with the runtime input and if
> it matches the stored phrase I take the required control. I want to
> store the samples as fft and I wanted to know whether can i compare
> the stored phrase fft and runtime fft. Will it be the same?
>
> Can I do that?
>
> Please also help me in using the dspic library for fft / ifft
>
> Thanks in advance,
> Siva
>
>
Hi,
building on Williams advice, for speech recognition you may have to use time-frequency analysis, rather than just one lumped fft. Time-frequency analysis adds the dimension of time, this is done by effectively slicing up the recording period into slots and performing a an fft on each slot, this is known as an STFT (short-term Fourier transform). This is usually displayed as time along the horizontal axis, frequency along the vertical axis, and the magnitude of the signal at a particular point of time-frequency as colour. The result is effectively a colourful 2D picture, or in terms of the microprocessor system a 3 dimensional array (time by frequency by magnitude). Then your speech pattern is a picture, and so this can be identified by a neural net. All that being said, for a few words, you might just get away with an ordinary fft.

I would sample the speech at 7.5kHz, this is what is used by the telephone system, and if this is good enough for a human to recognise a large portion of the English vocabulary, than it should be enough for a microprocessor to recoginise a three of four words. 5s record time, 7.5kHz sampling would require about 37k per word storage. For an fft, your frequency step is usually the inverse of the recording period, for 5s this would be 1/5=0.2Hz, there is no point in having a finner fft. The maximum frequency over which the fft is taken is just the maximum frequency component, for 7.5kHz sampling this is 3.75kHz. So the maximum number of points in the fft will be 3.75kHz/0.2 = 18750 points, or about 18k of memory per word to store it as an fft. This would retain the maximum information in the data you collect. I know this is not exactly how to do it, but the figures should help in the design.

As a side note, yes the fft does take less memory than the original time data, the reason is that with the fft you are retaining only the magnitude information, the phase information is lost in this application (an fft usually results in a set of data points in the form of complex numbers, which contain both phase and magnitude information, but this is not required here).

cheers,

Gavin

--- On Thu, 11/6/08, s...@gmail.com wrote:
From: s...@gmail.com
Subject: [piclist] Re: fft / ifft using dspic
To: p...
Date: Thursday, November 6, 2008, 11:33 AM

Hi Williams,

Thanks a lot. But actually my aim is to store four phrases such as 'left', 'right' and so on. Then compare with the runtime input and if it matches the stored phrase I take the required control. I want to store the samples as fft and I wanted to know whether can i compare the stored phrase fft and runtime fft. Will it be the same?

Can I do that?

Please also help me in using the dspic library for fft / ifft

Thanks in advance,

Siva