Astrid Schut / Mbed 2 deprecated EMG_myo

Dependencies:   MovingAverage mbed HIDScope biquadFilter

Revision:
27:c0d748b7d5d1
Parent:
26:874d50f440d0
Child:
28:21746a69e96a
--- a/main.cpp	Tue Apr 09 07:51:20 2019 +0000
+++ b/main.cpp	Mon Apr 15 19:17:04 2019 +0000
@@ -4,14 +4,21 @@
 
 #include <iostream>
 #include "MovingAverage.h"
-#define NSAMPLE 200
+#define NSAMPLE1 100
+#define NSAMPLE2 200
+#define NSAMPLE3 300
+#define NSAMPLE 100
 DigitalOut led1(LED_GREEN);
 DigitalOut led2(LED_RED);
 DigitalOut led3(LED_BLUE);
-
+//Ticker scopeTimer;
 
 //MovingAverage
-MovingAverage <float>Movag_1(NSAMPLE,0.0); //Make Moving Average, Define NSAMPLE above
+MovingAverage <float>Movag_11(NSAMPLE1,0.0); //Make Moving Average, Define NSAMPLE above
+MovingAverage <float>Movag_12(NSAMPLE2,0.0); //Make Moving Average, Define NSAMPLE above
+MovingAverage <float>Movag_13(NSAMPLE3,0.0); //Make Moving Average, Define NSAMPLE above
+
+MovingAverage <float>Movag_1(NSAMPLE1,0.0); //Make Moving Average, Define NSAMPLE above
 MovingAverage <float>Movag_2(NSAMPLE,0.0); //Make Moving Average, Define NSAMPLE above
 MovingAverage <float>Movag_3(NSAMPLE,0.0); //Make Moving Average, Define NSAMPLE above
 MovingAverage <float>Movag_4(NSAMPLE,0.0); //Make Moving Average, Define NSAMPLE above
@@ -34,7 +41,7 @@
 int i = 0;
 
 //Define doubles for calibration and ticker
-double ts = 0.001; //tijdsstap
+double ts = 0.0005; //tijdsstap
 double calibration_time = 55; //time EMG calibration should take
 
 volatile double temp_highest_emg1 = 0; //highest detected value right biceps
@@ -272,19 +279,31 @@
 }
 
 
+   
+
+
+
+
 Ticker      sample_timer;
+HIDScope    scope( 4 );
+DigitalOut  led(LED1);
 
 
 void sample()
 {
-    pc.printf("Duim Right = %i", Duim);
-    pc.printf("Bicep Right = %i",Bicep);
-    pc.printf("tricep Left = %i", Tricep);
-    pc.printf("onderarm Left = %i", Onderarm);
+             
+       
+    scope.set(0, emg1.read() );
+    scope.set(1, emg2.read() );
+    scope.set(2, emg3.read() );
+    scope.set(3, emg4.read());
+    
+    scope.send();
     
     led = !led;
 }
 
+
 int main()
 {   
     sample_ticker.attach(&emgsample, ts);
@@ -305,8 +324,8 @@
     highp4.add( &highp4_1 ).add( &highp4_2 );
     notch4.add( &notch4_1 ).add( &notch4_2 );
     lowp4.add( &lowp4_1 ).add(&lowp4_2);
-    
-    
+    sample_timer.attach(&sample, 0.001);
+    //scopeTimer.attach_us(&scope, &HIDScope::send, 2e4);
                 temp_highest_emg1 = 0; //highest detected value right biceps
                 temp_highest_emg2 = 0;
                 temp_highest_emg3 = 0;
@@ -316,9 +335,9 @@
                 timer_calibration.start();
 
                 
-                CalibrationEMG();
-                sample_timer.attach(&sample, 0.5);
-                threshold_check_ticker.attach(&threshold_check, 0.001)
+                //CalibrationEMG();
+                
+                //threshold_check_ticker.attach(&threshold_check, 0.001);
                 //sample_ticker.detach();
                 //timer_calibration.stop();