# get 1kHz signal from noises, FFT? or FIR?

Discussion in 'General Electronics Chat' started by richiechen, Mar 23, 2012.

1. ### richiechen Thread Starter Member

Jan 1, 2012
93
0
Hey everyone

I am trying to measure the amplitude of a 1kHz signal (3-5V), from 300mV noises(0-30kHz).

I am planning to use a dsPIC doing FFT to measure the amplitude of the 1kHz sine wave.

The sampling rate will be 32kHz and 256 points FFT will be used.

Do you think the sampling rate is too high? Because under this sampling rate, signal below 16kHz will be sampled, which means the noises will be sampled.
If I use 16kHz sampling rate, then signals below 8kHz is sampled which means the noises 8kHz-16kHz are moved away by sampling....

Any suggestions on the length of FFT? Is 256 point enough?
What if I use a FIR instead of a FFT?

Thank you very much

Best regards
Richie

2. ### MrChips Moderator

Oct 2, 2009
12,650
3,460
You need to understand the sampling theorem also known as the Nyquist Theorem, which states that:

The sampling frequency must be greater than twice the highest frequency component in the signal.

Just as important, the corollary states that:

There must be no frequency component greater than one-half the sampling frequency.

Hence, if you choose a sampling frequency of 32kHz, you must filter out everything above 16kHz.

Likewise, if you choose a sampling frequency of 16kHz, you must filter out everything above 8kHz.

It is erroneous to believe that by sampling at 16kHz you will remove noise above 8kHz.

The number of samples taken will determine the record length and hence the resolution in frequency space.

With a sampling rate of 32kHz, 256 samples will give a sample length of 8ms. Hence your resolution will be 125Hz.

At 16kHz, the resolution will be 62.5Hz.

richiechen likes this.
3. ### MrChips Moderator

Oct 2, 2009
12,650
3,460
There are better ways to measure a known frequency signal buried in noise such as phase-locked loop, deconvolution or correlation techniques.

4. ### crutschow Expert

Mar 14, 2008
13,509
3,385
As noted by MrChips, any noise above 1/2 the sample frequency will be seen in the sample. It is aliased into the passband and cannot be removed by digital filtering and will be seen as signal by the FFT.

Think about it. If you are sampling at 16kHz and a 32kHz signal is present, the sample will still contain some of that 32kHz signal, which will then appear as part of the sampled signal.

If you signal is only 1kHz then you want to use an analog (anti-alias) filter to roll off all noise above 1kHz with a high order filter as possible. That way you can use a lower sample rate without aliasing the noise into the signal bandwidth. The amount of filter rolloff you need depends upon the amplitude and frequency of the noise.

Last edited: Mar 24, 2012
richiechen likes this.
5. ### richiechen Thread Starter Member

Jan 1, 2012
93
0
Thank you Mr Chips

Could you explain more about why phase-locked loop is better?
If the frequency component could be calculated through FFT...

I will check more about deconvolution and correlation techniques because I have not heard of them before.

Thank you very much.

Best regards
Richie

6. ### richiechen Thread Starter Member

Jan 1, 2012
93
0
Thank you Crustschow

I has put a 4th-order active filter before the input of ADC.
The stop frequency is 20kHz, however.

Is it possible to implement a very sharp and narrow passing-band?

Best regards
Richie

7. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,222
Lock-in amplification is a technique used to separate a small, narrow-band signal from interfering noise. The lock-in amplifier acts as a detector and narrow-band filter combined. Very small signals can be detected in the presence of large amounts of
uncorrelated noise when the frequency and phase of the desired signal are known.
The lock-in amplifier is basically a synchronous demodulator followed by a low-pass filter. ​

richiechen likes this.
8. ### DickCappels Moderator

Aug 21, 2008
2,780
675
Last edited: Mar 24, 2012
richiechen likes this.
9. ### MrChips Moderator

Oct 2, 2009
12,650
3,460
Another solution using a DSP is to perform a least-squares fit.

richiechen likes this.
10. ### crutschow Expert

Mar 14, 2008
13,509
3,385
The filter stop frequency should be slightly above 1kHz.

If your signal is fixed at 1kHz then you can use a narrow-band bandpass filter with a 1kHz center frequency to filter out much of the noise.

An easy way to design active filters is the Filterpro free software from TI.

richiechen likes this.
11. ### richiechen Thread Starter Member

Jan 1, 2012
93
0
Thank you Mr Chips.

Is least square fitting same as linear regression?

Why is it related with demodulation with a known-frequency signal?

Thank you very much.

Best regards
Richie

Jan 1, 2012
93
0