ding

Dependencies:   Encoder HIDScope mbed

Revision:
1:1709bd849df0
Parent:
0:7e81becf02c6
Child:
2:ca2573919cb5
--- a/main.cpp	Mon Oct 27 10:02:16 2014 +0000
+++ b/main.cpp	Mon Oct 27 11:18:50 2014 +0000
@@ -1,34 +1,29 @@
 #include "mbed.h"
 #include "encoder.h"
 #include "HIDScope.h"
-
-#define TSAMP 1
-#define K_P (0.1)
-#define K_I (0.03  *TSAMP)
-#define K_D (0.0005 /TSAMP)
-#define I_LIMIT 1.
+#include <iostream>
 
-#define M2_PWM PTC8
-#define M2_DIR PTC9
-#define M1_PWM PTA5
-#define M1_DIR PTA4
-DigitalIn encoderA(PTD0);
-DigitalIn encoderB(PTA2);
+Encoder encoderA(PTD0,PTD2);
+
 PwmOut pwm(PTA5);
 DigitalOut dir(PTA4);
 HIDScope scope(5);
-float encA, encB;
+
+float enca = 0, encb =0;
+float speed;
 
 int main(){
+      
     while(1){
-    pwm = 0.2;
-    dir = 1;
-    encA = encoderA.read();
-    encB = encoderB.read();
+    
+    cin>>speed;
+    pwm = 0.1;
+    enca = encoderA.getPosition();
     scope.set(0,pwm);
-    scope.set(1,encA);
-    scope.set(2,encB);
+    scope.set(1,enca);
     scope.send();
+  
+    wait(0.2);
     }
 }