motor aansturing moet lineair zijn is het niet

Dependencies:   MODSERIAL Encoder mbed HIDScope

Revision:
9:f907915f269c
Parent:
8:83d522d8f2b8
Child:
10:b2742f42de44
--- a/main.cpp	Mon Sep 28 12:28:33 2015 +0000
+++ b/main.cpp	Fri Oct 02 10:56:17 2015 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 #include "MODSERIAL.h"
-#include "QEI.h"
-
+#include "encoder.h"
 
 Serial pc(USBTX,USBRX);
 
@@ -22,9 +21,9 @@
 // einde motor 1
 //EINDE MOTOR
 
-// ENcoDER
-QEI motor1_enc(D12,D11,NC,64);
-QEI motor2_enc(D10,D9,NC,64);
+// ENCODER
+Encoder motor1_enc(D12,D11);
+Encoder motor2_enc(D10,D9);
 
 
 //POTMETERS
@@ -34,6 +33,7 @@
 DigitalIn button(PTA4);
 int button_on = 0;
 
+
 void move_mot1(double left)
 {
     if(left < 0.400)
@@ -78,13 +78,12 @@
     }
 }  
 
-
 void send()
 {
-    int countsl = motor1_enc.getPulses();
-    int countsr = motor2_enc.getPulses();
-    pc.printf("motor 1 counts %d motor 2 counts %d \n", countsl, countsr);
-}
+    int counts1 = motor1_enc.getPosition();
+    int counts2 = motor2_enc.getPosition();
+    pc.printf("motor 1 counts, %d motor 2 counts %d \n", counts1, counts2);
+    }
 
 
 int main()
@@ -94,16 +93,15 @@
     while(true)
     {
         double left = potleft.read();
-        double right = potright.read();
-        // pc.printf("%f \n",left);
+        double right = potright.read();        
         move_mot1(left);
         move_mot2(right);
-        if(button.read() == button_on)
+        if( button.read() == button_on)
         {
-            motor1_enc.reset();
-            motor2_enc.reset();
+            motor1_enc.setPosition(0);
+            motor2_enc.setPosition(0);
         }
-        wait(0.01f);
+        wait(0.01f);            // is noodzakelijk voor functioneren gradual increase, waarom????
     
     }
 }