Tummas Tomasson / Mbed 2 deprecated PingDetector_mbedadc

Dependencies:   mbed

Committer:
tummastt
Date:
Mon Jul 30 09:57:42 2012 +0000
Revision:
0:efb27fbc92c0
Child:
1:227db871d328
Working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tummastt 0:efb27fbc92c0 1 /*
tummastt 0:efb27fbc92c0 2
tummastt 0:efb27fbc92c0 3
tummastt 0:efb27fbc92c0 4 */
tummastt 0:efb27fbc92c0 5
tummastt 0:efb27fbc92c0 6 #ifndef FFT_H
tummastt 0:efb27fbc92c0 7 #define FFT_H
tummastt 0:efb27fbc92c0 8
tummastt 0:efb27fbc92c0 9 #include "mbed.h"
tummastt 0:efb27fbc92c0 10 #include "../Parameters.h"
tummastt 0:efb27fbc92c0 11
tummastt 0:efb27fbc92c0 12 class FFT {
tummastt 0:efb27fbc92c0 13 public:
tummastt 0:efb27fbc92c0 14 FFT () {
tummastt 0:efb27fbc92c0 15 float temp = float(FREQ)*SAMPLES/SAMPLE_RATE;
tummastt 0:efb27fbc92c0 16 if (fmod(temp,1)<0.5)
tummastt 0:efb27fbc92c0 17 centerFreq = 2+floor(temp)*2;
tummastt 0:efb27fbc92c0 18 else
tummastt 0:efb27fbc92c0 19 centerFreq = 2+ceil(temp)*2;
tummastt 0:efb27fbc92c0 20 }
tummastt 0:efb27fbc92c0 21
tummastt 0:efb27fbc92c0 22 int DetectSignal(short data[]);
tummastt 0:efb27fbc92c0 23 /* Used to detect if the pinger signal is present
tummastt 0:efb27fbc92c0 24 returns found if signal is detected
tummastt 0:efb27fbc92c0 25 retruns notFound if no signal is detected
tummastt 0:efb27fbc92c0 26 Parameters defined in Parameters.h
tummastt 0:efb27fbc92c0 27 FREQ is the frequency in kHz of the pinger signal
tummastt 0:efb27fbc92c0 28 AMPLITUDE_LIMIT is what the signal amplitude has to be
tummastt 0:efb27fbc92c0 29 to be considered found. It used the amplitude sum of
tummastt 0:efb27fbc92c0 30 +-0.3kHz. E.g. if FREQ 10k AMP = AMP_9.7k+AMP_10k+AMP_10.3k
tummastt 0:efb27fbc92c0 31 */
tummastt 0:efb27fbc92c0 32
tummastt 0:efb27fbc92c0 33 void CalculateFFT(short data[]);
tummastt 0:efb27fbc92c0 34
tummastt 0:efb27fbc92c0 35
tummastt 0:efb27fbc92c0 36 short my[SAMPLES*2]; // output data 16 bit,4 byte aligned y0r,y0i,y1r,y1i,....
tummastt 0:efb27fbc92c0 37
tummastt 0:efb27fbc92c0 38 private:
tummastt 0:efb27fbc92c0 39 short mx[SAMPLES*2]; // input data 16 bit, 4 byte aligned x0r,x0i,x1r,x1i,....
tummastt 0:efb27fbc92c0 40 int amp;
tummastt 0:efb27fbc92c0 41 int centerFreq;
tummastt 0:efb27fbc92c0 42 int i;
tummastt 0:efb27fbc92c0 43 };
tummastt 0:efb27fbc92c0 44
tummastt 0:efb27fbc92c0 45 #endif