| Author |
Message |
|
JAda
|
Post subject: FFT Question ( based on Spectrum Analyser Frequency) Posted: Sun Apr 08, 2012 2:07 pm |
|
Joined: Sun Apr 08, 2012 1:59 pm Posts: 5
|
|
Hi,
I really appreciate your great work on FFT spectrum analyzer, and want to ask you about the code you put. We currently get an analogue siganl from an accelerometer, and want to do FFT to it using PIC18 in order to be able to get the natural frequency. I looked at your code and it looks great and have the following question:
1) Since the frequency input won't be more than 100Hz, is it possible to enhance accuracy of FFT by getting more samples by reducing the Hz from 10k to 10Hz?
2) After getting the 32 complex numbers you talked about and getting their magnitutdes, I believe this is the dB, but what should we do next to find the frequency with highest dB i.e. fundemental frequqncy?
Thanks, appreciate your help and looking forward for your reply.
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Sun Apr 08, 2012 6:51 pm |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 888
|
|
Hi
For (1) the answer is yes, however this increases the sample time required and therefore makes the FFT output less 'dynamic'. If the sound you are monitoring is fairly constant this shouldn't be an issue.
For (2) the output is the intensity of the frequency range represented by the bucket. In an ideal world this would be easily translated into something meaningful, however unless you have a well calibrated input and know where 0dBs is in the ADC range it is better to consider them as 'relative' intensities. To find the frequency range with the highest intensity you have to find the bucket with the greatest value.
On the whole you may have issues detecting a specific frequency with any accuracy due to the fact that the code uses rectangular windowing for simplicity (I only intended to use it as a simple audio display). Overall a von Hann window would probably be better unless the input signal is very simple.
/Simon
|
|
 |
|
 |
|
JAda
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Sun Apr 08, 2012 7:07 pm |
|
Joined: Sun Apr 08, 2012 1:59 pm Posts: 5
|
Hi Simon, Thanks a lot for the fast reply. If we keep the same accuracy by leaving the sampling time untouched, how can we use the 32 buckets intensities we get and identify the frequency range they represent? for example, having maximum of 100 Hz, does it mean we represent each bucket by 100/32 = 3.125 Hz and thus the first bucket is representing 0-3.125 Hz? If I would be able to identify the frequency range, that would be beneficial too to me and would be a possible solution rather than getting an exact frequency figure. NB: I am not using sound as an input, I am using the analogue output from an accelerometer to find the "g" in terms of an analogue voltage signal. Thanks for your cooperation and looking forward hearing from you. 
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Mon Apr 09, 2012 5:04 am |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 888
|
|
There is a table included in the FFT article which shows how the frequency range is divided between the buckets. Effectively the frequency range is divided equally between the buckets starting from 0 and going up to the Nyquist.
The exceptions are the first and last buckets. The first bucket contains the DC offset of the FFT not the frequency intensity and the last only shows the intensity to the Nyquist so has less 'range' than the others.
I'm not sure about your application though. The device needs to produce a signal which has a frequency component; if the device is just outputing a voltage which varies with accelleration you don't need FFT to read it; just a straight-forward ADC would do the trick.
|
|
 |
|
 |
|
JAda
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Mon Apr 09, 2012 12:37 pm |
|
Joined: Sun Apr 08, 2012 1:59 pm Posts: 5
|
|
Hi,
Thanks for your reply, actually the problem is not getting the "g" acceleration, as this is done in the PIC18 easily and using the equation to convert voltage to g in the sensor DS. I want to convert that analogue voltage signal to frequency domain to get the natural frequency of the signal.
Would appreciate your help.
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Mon Apr 09, 2012 4:24 pm |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 888
|
|
I'm still not 100% clear on your application. Is the accelerometer attached to something that is vibrating and you want to get the vibration frequency? If so you wouldn't need FFT, you would just time the peaks... I'm guessing that I'm missing something here?
|
|
 |
|
 |
|
JAda
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Mon Apr 09, 2012 5:11 pm |
|
Joined: Sun Apr 08, 2012 1:59 pm Posts: 5
|
|
Hi Sir,
Greeat, yes, we have an accelerometer attached to something that is vibrating and we want to get the vibration frequency. How can we do that? Could you guide me please on the method you said i.e. time the peaks. what peaks you mean?
Thanks
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Tue Apr 10, 2012 5:25 am |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 888
|
|
Since the device is vibrating you would sample the ADC just like in the FFT project; if you were to plot the results you would see a basic sine-wave as the voltage swings up and down. Since this is a fairly simple signal (there will be some harmonics, but they will be very small) you simply sample for enough time to capture both the max and min peak (the required sample time can be calculated based on the minimum expected vibration frequency). You then look at the collected sample data and work out where the peaks are (biggest and smallest levels) and, since you know the sample timing, you work out the number of samples between them and that gives you the frequency. Once you have a few frequency measurements you use the average.
If the frequency is very high, this might not work. I imagine that it's relatively slow though since it's mechanical.
|
|
 |
|
 |
|
JAda
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Tue Apr 10, 2012 6:10 am |
|
Joined: Sun Apr 08, 2012 1:59 pm Posts: 5
|
|
Hi,
Thanks for the info. What I really want is the natural frequency Wn of the input vibration, and I believe using your method, it will measure the average frequency of the input and not the natural, am I right?
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: FFT Question ( based on Spectrum Analyser Frequency) Posted: Mon Apr 16, 2012 7:14 pm |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 888
|
|
Correct; since I'm still unsure of your application I was just thinking out loud about the possibilities.
|
|
 |
|
 |
|