Highpass en Notch filter voor EMG verwerking

Dependencies:   HIDScope mbed-dsp mbed

Fork of EMG_HIDScope by First Last

Revision:
16:24e992616cf6
Parent:
15:d3a849ab3697
Parent:
14:94a4a5863689
Child:
17:1388f1a2d7b2
--- a/main.cpp	Wed Sep 24 08:26:36 2014 +0000
+++ b/main.cpp	Wed Sep 24 08:31:30 2014 +0000
@@ -1,11 +1,13 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
+#include "HIDScope.h"
 
 //Define objects
 AnalogIn    emg0(PTB1); //Analog input
 PwmOut      red(LED_RED); //PWM output
 Ticker log_timer;
 MODSERIAL pc(USBTX,USBRX);
+HIDScope scope(2);
 
 typedef struct second_order_constants
 {
@@ -50,8 +52,11 @@
     emg_value = emg0.read_u16(); // read direct ADC result, converted to 16 bit integer (0..2^16 = 0..65536 = 0..3.3V)
     filtered_emg = second_order((float)emg_value,highpass, highpass_values);
     /*send value to PC. Line below is used to prevent buffer overrun */
-    if(pc.rxBufferGetSize(0)-pc.rxBufferGetCount() > 30)
-        pc.printf("%u\t%f\n",emg_value, filtered_emg);
+
+    scope.set(0,emg_value);
+    scope.set(1,filtered_emg);
+    scope.send();
+
     /**When not using the LED, the above could also have been done this way:
     * pc.printf("%u\n", emg0.read_u16());
     */
@@ -60,14 +65,14 @@
 int main()
 {
     /*setup baudrate. Choose the same in your program on PC side*/
-    pc.baud(115200);
+    //pc.baud(115200);
     /*set the period for the PWM to the red LED*/
     red.period_ms(2);
     /**Here you attach the 'void looper(void)' function to the Ticker object
     * The looper() function will be called every 0.01 seconds.
     * Please mind that the parentheses after looper are omitted when using attach.
     */
-    log_timer.attach(looper, 0.01);
+    log_timer.attach(looper, 0.005);
     while(1) //Loop
     {
       /*Empty!*/