werkend filter: 50 hz notch 20 hz hoogdoorlaat 80 hz laagdoorlaat geabsoluteerd vermenigvuldigd met 10

Dependencies:   HIDScope mbed-dsp mbed

Fork of Project5-filtering2 by Dominique Clevers

Files at this revision

API Documentation at this revision

Comitter:
DominiqueC
Date:
Fri Oct 17 18:18:23 2014 +0000
Parent:
28:c40dc343033f
Child:
30:2162f7a82fc7
Commit message:
mogelijke moving average toevoegingen

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 16 19:30:22 2014 +0000
+++ b/main.cpp	Fri Oct 17 18:18:23 2014 +0000
@@ -52,7 +52,31 @@
     arm_biquad_cascade_df1_f32(&notch, &emg_value_f32, &filtered_emg_notch, 1 );
     arm_biquad_cascade_df1_f32(&highpass, &filtered_emg_notch, &filtered_emg_notch_highpass, 1 );
     arm_biquad_cascade_df1_f32(&lowpass, &filtered_emg_notch_highpass, &filtered_emg_notch_highpass_lowpass, 1 );
-    filtered_emg_eindsignaal_abs = 10*fabs(filtered_emg_notch_highpass_lowpass);
+    filtered_emg_eindsignaal_abs = 10*fabs(filtered_emg_notch_highpass_lowpass);    //gelijkrichter
+    
+    //Movag berekenen
+    
+    float mean(float *60, int n) {
+    float sum = 0.0;
+    for (int i=0; i<n; i++) {
+        sum += samples[i];
+    }
+    return sum / (float)n;
+}
+    
+    //of
+    typdef struct
+{
+    int32_t prev;
+    uint16_t gain;
+}IIR_Filter_Data;
+
+int16_t IIR_Filter(int16_t input, IIR_Filter_Data* Fdata)
+{
+    Fdata->prev += input * Fdata->gain;
+
+    return (Fdata->prev >> 16);
+}
     
     scope.set(0,emg_value_f32);
     scope.set(1,filtered_emg_notch);