Aansturen van een LED script dmv twee EMG signalen

Dependencies:   HIDScope MODSERIAL mbed-dsp mbed

Files at this revision

API Documentation at this revision

Comitter:
jessekaiser
Date:
Fri Oct 17 13:41:56 2014 +0000
Parent:
6:8f4138a811e0
Child:
8:ee16c139e10b
Commit message:
Met 2 EMG signalen licht aansturen. Inclusief Notch filter

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 16 13:34:51 2014 +0000
+++ b/main.cpp	Fri Oct 17 13:41:56 2014 +0000
@@ -24,6 +24,11 @@
 float highpass_const[] = {0.956542835577484, -1.913085671154968, 0.956542835577484, 1.911196288237583, -0.914975054072353};
 //state values
 float highpass_states[4];
+arm_biquad_casd_df1_inst_f32 notch;
+//highpass filter settings: Fc = 20 Hz, Fs = 500 Hz, Gain = -3 dB
+float notch_const[] = {0.7063988100714527, -1.1429772843080923, 0.7063988100714527, 1.1429772843080923, -0.41279762014290533};
+//state values
+float notch_states[4];
 
 //De globale variabele voor het gefilterde EMG signaal
 float filtered_biceps;
@@ -63,11 +68,13 @@
     //process emg biceps
     arm_biquad_cascade_df1_f32(&highpass, &emg_value1_f32, &filtered_biceps, 1 );
     filtered_biceps = fabs(filtered_biceps);
+    arm_biquad_cascade_df1_f32(&notch, &filtered_biceps, &filtered_biceps, 1 );
     arm_biquad_cascade_df1_f32(&lowpass, &filtered_biceps, &filtered_biceps, 1 );
 
     //process emg deltoid
     arm_biquad_cascade_df1_f32(&highpass, &emg_value2_f32, &filtered_deltoid, 1 );
     filtered_deltoid = fabs(filtered_deltoid);
+    arm_biquad_cascade_df1_f32(&notch, &filtered_deltoid, &filtered_deltoid, 1 );
     arm_biquad_cascade_df1_f32(&lowpass, &filtered_deltoid, &filtered_deltoid, 1 );
 
     /*send value to PC. */
@@ -129,6 +136,7 @@
     //set up filters. Use external array for constants
     arm_biquad_cascade_df1_init_f32(&lowpass,1 , lowpass_const, lowpass_states);
     arm_biquad_cascade_df1_init_f32(&highpass,1 ,highpass_const,highpass_states);
+    arm_biquad_cascade_df1_init_f32(&notch,1 , notch_const, notch_states);
 
     /**Here you attach the 'void looper(void)' function to the Ticker object
     * The looper() function will be called every 0.01 seconds.