to send emg signal to motor with test programm

Dependencies:   HIDScope biquadFilter mbed

Fork of EMGvoorjan by Roy Theussing

Revision:
33:84d986230e15
Parent:
32:3832f732f17a
Child:
34:008bd226d37e
--- a/main.cpp	Thu Oct 26 07:49:21 2017 +0000
+++ b/main.cpp	Thu Oct 26 07:55:14 2017 +0000
@@ -15,6 +15,7 @@
 DigitalOut motor2MagnitudePin(D5); // magnitude motor 2
 DigitalOut motor2DirectionPin(D4); // direction of the motor 2
 InterruptIn MotorOn(D10);
+InterruptIn SpeedUp(D12);
 
 
  int P= 200; // aantal test punten voor de moving average
@@ -27,6 +28,7 @@
  int MotorLock = 0;
  double EMGInput;
  float ErrorZero = 3; 
+ double MotorSpeed = 0.5;
  
  // Filters 
 BiQuadChain bqc;
@@ -146,6 +148,15 @@
     }
 }
 
+void TestMotorSpeed() {
+    if (MotorSpeed == 0.5) {
+        MotorSpeed = 1.0;
+    }
+    else if (MotorSpeed == 1.0) {
+        MotorSpeed == 0.5;   
+    }
+}
+
 int main()
 {  
 ledB = 1;
@@ -157,6 +168,8 @@
     while(1) {
         MotorOn.rise(&MotorLocker);
         motor2DirectionPin = 1;
-        SetMotor2(FeedForwardControl(GetReferenceVelocity()));
+        //SetMotor2(FeedForwardControl(GetReferenceVelocity()));
+        SpeedUp.rise(&TestMotorSpeed);
+        motor2MagnitudePin = MotorSpeed;
     }
 }
\ No newline at end of file