# Best Approach on How To Sample and Process

I'm looking for some advice, I am hoping one of the many forum experts could help me with some advice on the sampling and processing of signals. I am using an STM32F4 processor with 12 bit ADC and DSP core. Presently, I can use either CMSIS DSP or Siglib libraries. Here's a point description of the problem space:

I can sample at whatever rate is required: in front of the ADC is a 10th order analog amplifier and LPF, Fc = 55Hz. Amplifier can be set to provide ideal ADC range of 3Vpp

Sinusoidal incoming signals are in the range of 10Hz to 40Hz that can be set for any duration in time. Ideally, in the range of 200ms to 300ms (can be changed)

In between these tones, there is dead space of (ideally) 50ms to 100ms (can be changed)

There would be a series of these tones with a total time of about 4, or possibly 5 seconds (can be processed after last signal arrives, ideally real-time)

I need the best amplitude and frequency accuracy possible, ideally about 2dB and 0.5Hz. The environment is noisy, but incoming signals can be kept 20dB over noise.

I am not looking for a code handout. Just a best approach algorithm and ideally some specifics such as sampling rate (is decimation required), buffer size, to use overlap-add/sliding window, signal processing chain - FIR required (how many taps), FFT method/size?

It may not be complex to many of you, but I haven't finished all the theory I need to try an implementation without spending a long time,(I have all the books but there's a lot of reading yet!) and the problem requires me to try for a solution now.

Thank you for your help! Roger

• Do you know the exact frequencies or can it be anything in the given range? Commented Jan 22, 2015 at 17:16
• Yes....the frequencies are known and exact. i.e, 31.5Hz Commented Jan 22, 2015 at 21:54
• If the set of possible frequencies is known in advance you could just use the FSK demodulator from the library. No need for an FFT. I thought the information is in the frequency of the tone only, but now you also mention the amplitude. So there's also information in the amplitude? What kind of modulation is it? Commented Jan 23, 2015 at 8:13

As I understand, you want to sample a noisy tone signal at 20dB SNR and in 10Hz-40Hz range with best possible amplitude and frequency accuracy using 12 bit ADC of STM32F4 ARM+DSP chip.

To get the most frequency accuracy you need more samples to be buffered and large FFt sizes for a given samplig rate Fs. This is for frequencies on a given range.

Using high sampling rate (oversampling) may be advantageous for increased SNRQ. See Sigma-Delta converters and Noise shapers for details.

Size of FIR filters: As again it is a direct compromise between computing power and processing quality. STM32F4 is quite powerful chip at 168 Mhz operating frequency and 32 bit FPU.

For FFT, you can write your own code if you have time. I can provide you a butterfly implementation. Or you better use it from some free library.

You should select long fft sizes for better frequency resolution.

please have a look at this document: http://support.ircam.fr/docs/AudioSculpt/3.0/co/Window%20Size.html

• Bulent - thank you for taking the time to reply. As mentioned, I can use libraries from Siglib or CMSIS DSP. I can sample as fast as required - by DMA driven or timer. However, a large sample buffer uses a lot of memory at high rates. The STM32F4 operates at 168MHz, so processing power isn't an issue. I thought frequency resolution was related to FFT size vs sampling rate? I'm not sure what you mean by "what kind of processing" - it's pretty much as I described, I'm trying to end up with a buffer of validated flags as to whether or not I did detect specific tones. Commented Jan 22, 2015 at 21:54
• @user10326 Frequency resolution of DFT X[k] of sampled signal x[n] depends on the size N of the FFT for a given sampling rate Fs. Large Fs will give you less resolution for a given window size N. (sorry if I mixed it on the post) Also an N-point FFT requires that, N , many samples to be buffered. And that also reqires the signal to have a long duration (long enough observation window). Please refer to Time-Frequency analysis for a discussion of frequency resolution vs signal duration. Commented Jan 22, 2015 at 22:33

I don't know all the details of your problem, such as signal stability, timing accuracy and so on, so I'll presume a few things and suggest using an FFT based Gaussian ratio technique.

The technique has been known, although not widely so, since 1991. Basically, it depends on using a Gaussian window on the input data, followed by an FFT, then it computes frequency and amplitude based on the natural log values of the FFT. A related technique is used at CERN, and they've done extensive analysis on it.

Based on your signals going up to 40 Hz, your minimum sample rate would be 80 Hz. But since your Fc is 55 Hz, if you have anything from 40 to 55 Hz, it will alias, so your minimum sample rate has to be at least 110 Hz. And your other requirements may force you to accept a higher rate.

But there are other issues independent of sample rate. First, you have sinusoidal signals from 10 to 40 Hz that exist for 200-300 msec (.2-.3 sec.). For a 10 Hz input, that works out to be only 2 to 3 cycles (and 8-12 cycles for a 40 Hz input). And keep in mind that a higher sample rate will not increase either the length of the signal or the number of cycles.

Second, since you have a 50-100 msec dead time between signals, you'll have to synchronize your processing with the input. You may want to have some kind of 'signal present' or 'not present' detector Given that your 10 Hz input would have a different rise/fall time than a 40 Hz input, such a detector may be overly complicated for you. So in the interest of keeping things simple, let's just presume your signal and dead time are stable with regards to their timing, and you can somehow determine when things start and stop.