ding

Dependencies:   Encoder HIDScope mbed

Revision:
5:93ccec91a4ae
Parent:
4:055913d9c737
Child:
6:0403c2e276c2
--- a/main.cpp	Wed Oct 29 16:45:46 2014 +0000
+++ b/main.cpp	Thu Oct 30 11:27:04 2014 +0000
@@ -2,7 +2,7 @@
 #include "encoder.h"
 
 #define K_P (0.1)
-#define K_I (0.00001)
+#define K_I (0.0001)
 #define K_D (0.0005 /TSAMP)
 #define TSAMP 0.001
 #define I_LIMIT 1.
@@ -17,7 +17,7 @@
 int32_t enc = 0,enca2 =0,enca1=0, encp=0, counts =0;
 float speed = 0.1, out =0;
 int pos =0,zero =0, fout;
-
+float v=0;
 
 void clamp(float * in, float min, float max)
 {
@@ -26,6 +26,7 @@
 
 
 
+
 float pid(float setpoint, float measurement)
 {
     float error;
@@ -46,7 +47,6 @@
 
 float getv(float delta_t)
 {
-    float v;
     int n =0 ;
     while(n<3) {
         wait(delta_t);
@@ -62,25 +62,34 @@
     return v;
 }
 
+ float reset(){
+        
+        return pwm;
+        }
+
 
 
 int main()
 {
     while(1) {
-        float velocity =1;
-        while(velocity !=0) {
+       pwm = 1;
+       cout<<"voor de loop"<<endl;
+        
+        while(v !=0) {
 
             dir = 0;
             pwm.write(0.1);
-            velocity =getv(0.2);
+            v =getv(0.2);
         }
         pwm = 0;
         dir =1;
-
         encoderA.setPosition(0);
-        zero = encoderA.getPosition();
+         zero = encoderA.getPosition();
         cout<<"zero encoder: "<<zero<<endl;
 
+       
+     
+       
         cout<<"positie in encoder bits: "<<endl;
         cin>>pos;
         cout<<"enc in: "<<pos<<endl;