FFT_BUENA
Dependencies: FastAnalogIn HSI2RGBW_PWM NVIC_set_all_priorities mbed-dsp mbed
Fork of KL25Z_FFT_Demo by
Diff: main.cpp
- Revision:
- 6:17a42dc976bb
- Parent:
- 5:6caecff3094d
- Child:
- 7:18e9a56bef9a
--- a/main.cpp Mon Dec 01 06:45:49 2014 +0000 +++ b/main.cpp Mon Dec 01 07:43:56 2014 +0000 @@ -14,10 +14,10 @@ DigitalOut led6(PTC6); DigitalOut led7(PTC10); DigitalOut led8(PTC11); +AnalogIn pot(A0); -float pulso=100; - -int fmin=40; +float pulso=0; +int fmin=50; int fmax=120; float sum=(fmax-fmin)/8; @@ -30,11 +30,12 @@ float ts=1/fs; int tiempo=5; float pi=3.1416; -float l=30/pulso; +float l=0; +float b=0; float a=1.6; -float b=(2*l)/0.11; int n=100; -float qrs1=(a/(2*b))*(2-b); +float qrs1=0; + #ifndef RGBW_ext // HSI to RGB conversion with direct output to PWM channels - on-board RGB LED @@ -319,6 +320,12 @@ float harm[512]; int inmax=0,max=0; + pulso=fmin+(fmax-fmin)*pot.read(); + pc.printf("%f\n\n\n",pulso); + l=30/pulso; + b=(2*l)/0.11; + qrs1=(a/(2*b))*(2-b); + for(int i=1; i<=n; i=i+1) { @@ -395,7 +402,7 @@ pc.printf("%d\t%f\n",i,magnitudes[i]); }*/ for(int i=1; i<FFT_SIZE/2; i=i+1) { - if(magnitudes[i]>max) { + if(magnitudes[i]>max&&abs(fs/(FFT_SIZE-1)*i*60-pulso)<10) { max=magnitudes[i]; inmax=i; } @@ -404,17 +411,7 @@ pulsocalculado=fs/(FFT_SIZE-1)*inmax*60; pc.printf("%f\n",pulsocalculado); - if (pulsocalculado<fmin){ - led1=0; - led2=0; - led3=0; - led4=0; - led5=0; - led6=0; - led7=0; - led8=0; - } - if (pulsocalculado>=fmin&&pulsocalculado<(fmin+sum)){ + if (pulsocalculado<(fmin+sum)){ led1=1; led2=0; led3=0; @@ -484,7 +481,7 @@ led7=1; led8=0; } - if (pulsocalculado>=(fmin+8*sum)){ + if (pulsocalculado>=(fmin+7*sum)){ led1=1; led2=1; led3=1;