Tummas Tomasson / Mbed 2 deprecated PingDetector_mbedadc

Dependencies:   mbed

Committer:
tummastt
Date:
Tue Aug 21 14:23:03 2012 +0000
Revision:
1:227db871d328
Parent:
0:efb27fbc92c0
Pinger detection program for mbed

Who changed what in which revision?

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