Mirjam Bos / Mbed 2 deprecated emg_calibration

Dependencies:   BiQuad4th_order Biquad HIDScope MODSERIAL biquadFilter mbed

Fork of emg_calibration by Silvie van den Bogaard

Revision:
0:802c9c6b30d3
Child:
1:f99650c5b9eb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 31 12:57:37 2018 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "MODSERIAL.h"
+#include "BiQuad.h"
+#include "BiQuad4.h"
+#include "FilterDesign.h"
+#include "FilterDesign2.h"
+MODSERIAL pc(USBTX, USBRX); //makes sure the computer is hooked up
+
+AnalogIn emg1_raw(A0);
+AnalogIn emg2_raw(A1);
+DigitalOut led(LED_RED);
+
+//global variables
+double emg1_cal = 0.00000; //measured value of the first emg
+double emg2_cal = 0.00000; //measured value of the second emg
+double EMG_calibrated_max_1 = 0.00000; //final calibration value of EMG1
+double EMG_calibrated_max_2 = 0.00000; //final calibration value of EMG2
+
+
+void EMG_calibration(){
+    for (int i = 0; i <= 10; i++) //10 measuring points
+        { 
+        emg1_cal = FilterDesign(emg1_raw.read());
+        emg2_cal = FilterDesign2(emg2_raw.read());
+        
+        if (emg1_cal > EMG_calibrated_max_1){
+            EMG_calibrated_max_1 = emg1_cal;}
+            
+        if (emg2_cal > EMG_calibrated_max_2){
+            EMG_calibrated_max_2 = emg2_cal;}
+        
+        wait(0.5f);
+        }
+}
+
+        
+
+int main(){
+    pc.baud(115200);
+    while (true) {
+        led = 0;
+        EMG_calibration();
+        led = 1;
+        pc.printf("EMG1 = %f, EMG2 = %f \r\n",EMG_calibrated_max_1,EMG_calibrated_max_2);
+    }
+}
\ No newline at end of file