DSP Module

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
martinsimpson
Date:
Fri Oct 13 09:29:43 2017 +0000
Commit message:
First Commit

Changed in this revision

LP_2KHz_Fc_40KHz_Fs_100N.h Show annotated file Show diff for this revision Revisions of this file
LP_2KHz_Fc_40KHz_Fs_37N.h Show annotated file Show diff for this revision Revisions of this file
LP_2KHz_Fc_6KHz_Fs_37N.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2470e37cc502 LP_2KHz_Fc_40KHz_Fs_100N.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LP_2KHz_Fc_40KHz_Fs_100N.h	Fri Oct 13 09:29:43 2017 +0000
@@ -0,0 +1,106 @@
+#define Fs  40000
+#define N       101
+
+float b[N]={
+-0.000000, 
+0.000055, 
+0.000138, 
+0.000242, 
+0.000357, 
+0.000462, 
+0.000533, 
+0.000543, 
+0.000468, 
+0.000290, 
+-0.000000, 
+-0.000392, 
+-0.000858, 
+-0.001353, 
+-0.001814, 
+-0.002164, 
+-0.002326, 
+-0.002228, 
+-0.001817, 
+-0.001069, 
+0.000000, 
+0.001326, 
+0.002801, 
+0.004271, 
+0.005551, 
+0.006444, 
+0.006756, 
+0.006328, 
+0.005058, 
+0.002923, 
+-0.000000, 
+-0.003531, 
+-0.007381, 
+-0.011174, 
+-0.014463, 
+-0.016769, 
+-0.017624, 
+-0.016614, 
+-0.013426, 
+-0.007888, 
+0.000000, 
+0.010052, 
+0.021894, 
+0.034978, 
+0.048621, 
+0.062048, 
+0.074450, 
+0.085050, 
+0.093166, 
+0.098262, 
+0.100000, 
+0.098262, 
+0.093166, 
+0.085050, 
+0.074450, 
+0.062048, 
+0.048621, 
+0.034978, 
+0.021894, 
+0.010052, 
+0.000000, 
+-0.007888, 
+-0.013426, 
+-0.016614, 
+-0.017624, 
+-0.016769, 
+-0.014463, 
+-0.011174, 
+-0.007381, 
+-0.003531, 
+-0.000000, 
+0.002923, 
+0.005058, 
+0.006328, 
+0.006756, 
+0.006444, 
+0.005551, 
+0.004271, 
+0.002801, 
+0.001326, 
+0.000000, 
+-0.001069, 
+-0.001817, 
+-0.002228, 
+-0.002326, 
+-0.002164, 
+-0.001814, 
+-0.001353, 
+-0.000858, 
+-0.000392, 
+-0.000000, 
+0.000290, 
+0.000468, 
+0.000543, 
+0.000533, 
+0.000462, 
+0.000357, 
+0.000242, 
+0.000138, 
+0.000055, 
+-0.000000
+};
diff -r 000000000000 -r 2470e37cc502 LP_2KHz_Fc_40KHz_Fs_37N.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LP_2KHz_Fc_40KHz_Fs_37N.h	Fri Oct 13 09:29:43 2017 +0000
@@ -0,0 +1,42 @@
+#define Fs  40000
+#define N       37
+
+float b[N]={
+-0.000212, 
+-0.000639, 
+-0.001360, 
+-0.002338, 
+-0.003402, 
+-0.004224, 
+-0.004324, 
+-0.003117, 
+0.000000, 
+0.005531, 
+0.013756, 
+0.024621, 
+0.037672, 
+0.052057, 
+0.066591, 
+0.079906, 
+0.090628, 
+0.097588, 
+0.100000, 
+0.097588, 
+0.090628, 
+0.079906, 
+0.066591, 
+0.052057, 
+0.037672, 
+0.024621, 
+0.013756, 
+0.005531, 
+0.000000, 
+-0.003117, 
+-0.004324, 
+-0.004224, 
+-0.003402, 
+-0.002338, 
+-0.001360, 
+-0.000639, 
+-0.000212
+};
diff -r 000000000000 -r 2470e37cc502 LP_2KHz_Fc_6KHz_Fs_37N.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LP_2KHz_Fc_6KHz_Fs_37N.h	Fri Oct 13 09:29:43 2017 +0000
@@ -0,0 +1,42 @@
+#define Fs      6000
+#define N       37
+
+float b[N]={
+-0.000000, 
+-0.000684, 
+0.001238, 
+-0.000000, 
+-0.003098, 
+0.004522, 
+-0.000000, 
+-0.008736, 
+0.011729, 
+-0.000000, 
+-0.020268, 
+0.026356, 
+-0.000000, 
+-0.045082, 
+0.060638, 
+-0.000000, 
+-0.133528, 
+0.273491, 
+0.666667, 
+0.273491, 
+-0.133528, 
+-0.000000, 
+0.060638, 
+-0.045082, 
+-0.000000, 
+0.026356, 
+-0.020268, 
+-0.000000, 
+0.011729, 
+-0.008736, 
+-0.000000, 
+0.004522, 
+-0.003098, 
+-0.000000, 
+0.001238, 
+-0.000684, 
+-0.000000
+};
diff -r 000000000000 -r 2470e37cc502 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 13 09:29:43 2017 +0000
@@ -0,0 +1,60 @@
+#include "mbed.h"
+
+//Just Comment out the Dataset you DO NOT wish to use and UN-Comment the one that you wish to use
+//and then 'Build' <F7> and once complete 'Load' to the STM-Discovery board <F8>
+
+#include "LP_2KHz_Fc_6KHz_Fs_37N.h"
+//#include "LP_2KHz_Fc_40KHz_Fs_37N.h"
+//#include "LP_2KHz_Fc_40KHz_Fs_100N.h"
+
+#define ON      1
+#define OFF     0
+
+float x[N]={0};
+float yn;
+
+void sampler(void);                     //Ticker routine PROTOTYPE
+
+//MBED Class Instances follows
+DigitalOut SampLED(LED1);               //Digital Output  (GREEN LED is PB_3, D13 You can use an Oscilloscope on This pin to confirm sample rate)
+
+AnalogIn  Ain(PA_1);                    //Analog Input (Signal Input 0 to +3 Volts)
+AnalogOut Aout(PA_4);                   //Analog Output (Signal Input 0 to +3 Volts) NB PA_4 because Arduin Nano Compatability
+                                        //on STM32F303k8 uses I2C PA_5 to PB7
+
+Ticker sample_timer;                    //Ticker class instance called sample_timer
+
+PwmOut test(PWM_OUT);
+
+
+int main() {
+    float duty=0.1f;
+    test.period_ms(1);
+    test=duty;
+  
+    float sample_rate=(1.0/Fs)*1000000.0; //Calculate the number of uS required for a Frequency Sampling Rate
+                                          //Fs held in *.h
+  
+    sample_timer.attach_us(&sampler,(int)sample_rate);
+                                          //Ticker Instance serviced by routine at a repeat rate in microseconds
+  
+    while(1) {
+        sleep();
+    }
+}
+
+void sampler(void){                     //Ticker routine
+    
+    SampLED = ON;                       //LED Indicates start of sampling
+    int i;                              //Initialise local variable i
+    x[0]=Ain;                           //Input ADC. N.B. ADC in MBED is 0.0 to 1.0 float!!!!!!
+    yn=0.0;                             //output accumulation, start as zero
+    
+    for(i=0; i<N; i++) yn+=x[i]*b[i];   //generate output from filter components FIR a=0
+    for(i=N-1; i!=0; i--) x[i]=x[i-1];  //shift data
+    
+    Aout=yn;                            //Output resultant to DAC. Again MBED uses 0.0 to 1.0 float!!!!!!
+    
+    SampLED = OFF;                      //LED Indicates end of sampling
+    }
+
diff -r 000000000000 -r 2470e37cc502 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 13 09:29:43 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file