4 directional EMG control of the XY table. Made during my bachelor end assignment.

Dependencies:   C12832_lcd HIDScope mbed-dsp mbed

Files at this revision

API Documentation at this revision

Comitter:
jessekaiser
Date:
Wed May 27 12:29:19 2015 +0000
Parent:
33:3c9f8c1e9adf
Child:
35:b0737ee24b43
Commit message:
Nog wat regels weggehaald. Proportionele EMG. LCD doet het opeens niet

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri May 22 08:43:27 2015 +0000
+++ b/main.cpp	Wed May 27 12:29:19 2015 +0000
@@ -4,11 +4,11 @@
 #include "HIDScope.h"
 
 #define K_Gain      65      //Gain of the filtered EMG signal
-#define Damp        2         //Deceleration of the motr
-#define Mass        1         // Mass value
-#define dt          0.002       //Sample frequency
-#define MAX_emg 
-#define MIN_freq    900 
+#define Damp        2       //Deceleration of the motor
+#define Mass        1       // Mass value
+#define dt          0.002   //Sample frequency
+#define MAX_emg             //Can be used for normalisation of the EMG signal
+#define MIN_freq    900     //The motor turns off below this frequency
 
 //Motor control
 DigitalOut Dir(p21);
@@ -38,22 +38,12 @@
 float setpoint = 9000; //Frequentie
 float step_freq = 1;
 
-
-// Filters
-arm_biquad_casd_df1_inst_f32 lowpass_pot;
-arm_biquad_casd_df1_inst_f32 lowpass_step;
-
-//lowpass filter settings: Fc = 1 Hz, Fs = 100 Hz, Gain = -3 dB onepole-lp
-float lowpass_const[] = {0.0201, 0.0402 , 0.0201, 1.5610, -0.6414};
-//Lowpass filter potmeter: Fc = 0.5 Hz, Fs = 500 Hz,
-//float lowpass_const[] = {0.000009825916403675327, 0.000019651832807350654, 0.000009825916403675327, 1.991114207740345, -0.9911535114059596};
-
 //EMG filter
 arm_biquad_casd_df1_inst_f32 lowpass_biceps;
 //lowpass filter settings biceps: Fc = 2 Hz, Fs = 500 Hz, Gain = -3 dB
-float lowpass2_const[] = {0.00015514839749793376, 0.00031029679499586753, 0.00015514839749793376, 1.9644602512795832, -0.9650808448695751};
+float lowpass_const[] = {0.00015514839749793376, 0.00031029679499586753, 0.00015514839749793376, 1.9644602512795832, -0.9650808448695751};
 arm_biquad_casd_df1_inst_f32 highnotch_biceps;
-//highpass filter settings: Fc = 20 Hz, Fs = 500 Hz, Gain = -3 dB, notch Fc = 50, Fs =500Hz, Gain = -3 dB
+//highpass filter settings: Fc = 20 Hz, Fs = 500 Hz, notch Fc = 50, Fs =500Hz
 float highnotch_const[] = {0.8370879899975344, -1.6741759799950688, 0.8370879899975344, 1.6474576182593796, -0.7008943417307579, 0.7063988100714527, -1.1429772843080923, 0.7063988100714527, 1.1429772843080923, -0.41279762014290533};
 
 //state values
@@ -63,15 +53,10 @@
 
 //global variabels
 float filtered_biceps;
-float filtered_average_bi;
-float filt_avg_bi_old;
-float filtered_pot;
-float pot_value1_f32;
 float speed_old;
 float acc;
 float force;
 float speed;
-float speed_old;
 float D;
 
 void looper_emg()
@@ -89,7 +74,7 @@
     arm_biquad_cascade_df1_f32(&highnotch_biceps, &emg_value1_f32, &filtered_biceps, 1 );
     filtered_biceps = fabs(filtered_biceps);
     arm_biquad_cascade_df1_f32(&lowpass_biceps, &filtered_biceps, &filtered_biceps, 1 );
-    average_biceps(filtered_biceps,&filtered_average_bi);
+ 
 
     /*send value to PC. */
     scope.set(0,filtered_biceps); //Filtered EMG signal