Basis aansturing projectgroep 3

Dependencies:   Biquad HIDScope MODSERIAL QEI mbed

Revision:
7:075ba23f3147
Parent:
6:aa62e6650559
Child:
8:656b0c493a45
diff -r aa62e6650559 -r 075ba23f3147 main.cpp
--- a/main.cpp	Mon Oct 31 11:16:29 2016 +0000
+++ b/main.cpp	Tue Nov 01 10:15:18 2016 +0000
@@ -31,7 +31,7 @@
 //Variables
 
 volatile double Signal = 0.0;
-const int SampleFrequency = 100;
+const int SampleFrequency = 400;
 const double AnglePerPulse = 2*pi/4200; //Soms doet dit een beetje vaag, dus dit moet wel af en toe uitgetest worden
 volatile double Position_L = 0.0; //The position of the left motor in radiants
 volatile double Position_R = 0.0; //The position of the right motor in radiants
@@ -52,7 +52,7 @@
 double EMG_R;
 double EMG_Change; 
 //-------------------Hidscope----------------------------------
-HIDScope scope(4); // Sending two sets of data
+
 
 //--------------------------------------------------------------
 //--------------------All Motors--------------------------------
@@ -144,7 +144,7 @@
  
 
  // Controller gains (motor1−Kp,−Ki,...)
- const double Kpm= 0.1, Kim = 0.05;
+ const double Kpm= 0.1, Kim = 0*0.05;
  double er_int = 0;
  
     double Controller_L(int direction, double signal, double reference ){
@@ -206,10 +206,10 @@
    if (Movement_Flag == true){
        if (EMG_Change > 0.5f ){
             check += 1;
-               if (check <= 6 and check > 1 ){
+               if (check <= 10 and check > 1 ){
                     grip1 = 1;
                 }
-               if (check > 6){
+               if (check > 10){
                      grip2 =1;
                 }
             } else {
@@ -249,14 +249,15 @@
 BiQuad bq1_Change( 9.35527e-01, -1.87105e+00, 9.35527e-01, -1.86689e+00, 8.75215e-01 );
 BiQuad bq2_Change( 9.90278e-01, -1.40046e+00, 9.90278e-01, -1.40046e+00, 9.80555e-01 );
 BiQuad bq3_Change( 2.20594e-05, 4.41189e-05, 2.20594e-05, -1.98667e+00, 9.86760e-01 );
-
+HIDScope scope(5); // Sending two sets of data
 void getEMG(){
      
  
     EMG_Change = bqc_Change.step(Change.read());
     EMG_Change = fabs(EMG_Change);
-    EMG_Change = bq3_Change.step(EMG_Change)*1.0;
-         scope.set(0,EMG_Change);//=------------------------------------------------------------------------Scope         
+    EMG_Change = bq3_Change.step(EMG_Change)*50;
+         scope.set(0,EMG_Change);//=------------------------------------------------------------------------Scope     
+                             scope.set(4,Change.read());     
      if (EMG_Change < 0.3){
         EMG_Change=0;
     } else {
@@ -266,8 +267,9 @@
             
     EMG_L =   bqc_L.step(Left.read());
     EMG_L= fabs(EMG_L);
-    EMG_L= bq3_L.step( EMG_L)*1.0;
-                    scope.set(1,EMG_L);//=------------------------------------------------------------------------Scope         
+    EMG_L= bq3_L.step( EMG_L)*10;
+                    scope.set(1,EMG_L);//=------------------------------------------------------------------------Scope  
+      
     if (EMG_L < 0.3){
         EMG_L=0;
     } else {
@@ -278,7 +280,7 @@
   
     EMG_R =  bqc_R.step(Right.read());
     EMG_R= fabs(EMG_R);
-    EMG_R= bq3_R.step( EMG_R)*1.0;        
+    EMG_R= bq3_R.step( EMG_R)*10;        
           scope.set(2,EMG_R);//=------------------------------------------------------------------------Scope                  
     if (EMG_R < 0.3){
         EMG_R=0;
@@ -314,6 +316,7 @@
     Tick_Sample.attach(Set_Sample_Flag, 1.0/SampleFrequency);    Tick_Controller.attach(Set_controller_Flag, 1.0/SampleFrequency);
     Tick_Movement.attach(Set_movement_Flag, 0.25);
     OnOff.fall(Start_Stop);
+    
     }
 
     
@@ -333,7 +336,7 @@
             getEMG();
               //  EMG_Change = getEMG(  bqc.step(Change.read()));
             Signal = pi*(EMG_R-EMG_L);
-                scope.set(3,Signal);
+                scope.set(3,Signal);//------------------------------------------------------------scope
 
                          scope.send();
             Sample_Flag = false;