Opzetje

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Revision:
5:9f097dde857f
Parent:
4:86872b89b21c
--- a/main.cpp	Fri Sep 20 09:32:39 2019 +0000
+++ b/main.cpp	Mon Sep 23 09:48:32 2019 +0000
@@ -1,23 +1,38 @@
 #include "mbed.h"
-#include "MODSERIAL.h";
-#include "FastPWM.h" ;
+#include "MODSERIAL.h"
+#include "FastPWM.h" 
+#include "QEI.h" 
 
 Serial pc(USBTX,USBRX);
 
 InterruptIn button1(PTC2);
 InterruptIn button2(PTC3);
-InterruptIn button3(PTA4);
-InterruptIn button4(PTC6);
+
+//motorcontrol
+AnalogIn pot(PTB2);
+FastPWM motor(D5);
+DigitalOut direction(D4);
 
-AnalogIn pot(PTB2);
+int p_rev = 4200;
+QEI encoder(D13,D12,NC,p_rev);
 
-FastPWM motor(D5);
+int void() // set direction
+{
+    direction.write(0);
+}
 
-int main(){ 
-    printf("Controll with dial\n");    
-        while(true){
+int main()
+{ 
+    printf("Control with dial\n");
+    wait(3.0);    
+        while(true)
+        {
+            wait(0.6);
+            printf("motor speed is (%f)\n\r",pot.read()); 
             wait(0.1);
-            printf("motor speed is (%f)\n\r",pot.read()); wait(0.1);
+            printf("aantal revoluties (%f)\n\r",encoder.getRevolutions());
+            printf("aantal pulses (%f)\n\r",encoder.getPulses());
+            wait(0.01);
             motor.write(pot);
-            }
+        }
     }