Meike Froklage / Mbed 2 deprecated The_Claw_with_EMG_Control_Final

Dependencies:   HIDScope MODSERIAL Motordriver QEI Servo mbed

Fork of The_Claw_with_EMG_Control_PID by Meike Froklage

Files at this revision

API Documentation at this revision

Comitter:
meikefrok
Date:
Wed Nov 02 15:54:32 2016 +0000
Parent:
9:90227be52903
Child:
11:97f824629da5
Commit message:
vetgoed

Changed in this revision

HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HIDScope.lib	Wed Nov 02 15:54:32 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tomlankhorst/code/HIDScope/#188304906687
--- a/main.cpp	Wed Nov 02 15:30:54 2016 +0000
+++ b/main.cpp	Wed Nov 02 15:54:32 2016 +0000
@@ -4,6 +4,7 @@
 #include "motordriver.h"
 #include "QEI.h"
 #include "Servo.h"
+#include "HIDScope.h"
 
 //======== Serial Communication ================================================
 MODSERIAL pc(USBTX,USBRX);
@@ -23,6 +24,8 @@
 // servo
 Servo servo(D9);
 
+HIDScope    scope(2); //scope has two ports for the two EMG signals
+
 //======== Miscellaneous =======================================================
 // button
 InterruptIn btn(SW2);
@@ -47,7 +50,8 @@
 // ticker
 Ticker tick_part;                       // ticker to switch parts 
 Ticker tick_part_arm;    
-Ticker sampleTicker;   
+Ticker sampleTicker; 
+Ticker measureTicker;  
 
 //======== Variables ===========================================================
 // counters
@@ -276,11 +280,21 @@
     rhf_y = biquad_rhf(rno2_y, rhf_v1, rhf_v2, rhf_a1, rhf_a2, rhf_b0, rhf_b1, rhf_b2);
     rrect_y = fabs(rhf_y);
     rlf_y = biquad_rlf(rrect_y, rlf_v1, rlf_v2, rlf_a1, rlf_a2, rlf_b0, rlf_b1, rlf_b2)/0.2;
+    scope.set(1, llf_y);
+    scope.set(0, rlf_y);
+    scope.send();
     }
 
 
 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 //======== Functions and main ==============================================================
+void Measure(){
+     // encoder
+     position_cart = (Encoder_Cart.getPulses()*factor_cart) ;    
+     ain_cart = pot_cart.read();
+    
+}    
+
 
 // Switch between Cart, Arm and Claw
 
@@ -342,10 +356,6 @@
             led_g = not LedOn;
             led_b = not LedOn;     
             
-            // encoder
-            position_cart = (Encoder_Cart.getPulses()*factor_cart) ;    
-            ain_cart = pot_cart.read();
-   
             wait(0.1);
             pc.baud(115200);
             pc.printf("Distance in mm: %i\n", position_cart);
@@ -455,6 +465,7 @@
     tick_part.attach(&SwitchCart,kTimeToggle);
     tick_part_arm.attach(&SwitchArm,kTimeToggle);  
     sampleTicker.attach(scopeSend,0.01);
+    measureTicker.attach(Measure, 0.01);
    
     btn_cart.fall(&SetValue2);
     btn_arm.fall(&SetValue3);
--- a/mbed.bld	Wed Nov 02 15:30:54 2016 +0000
+++ b/mbed.bld	Wed Nov 02 15:54:32 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/2e9cc70d1897
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file