Using HIDScope for P(I)D controller

Dependencies:   FastPWM HIDScope MODSERIAL QEI biquadFilter mbed

Fork of PES_tutorial_5 by BMT Module 9 Group 4

Revision:
4:49c5fd62a192
Parent:
3:ea819bcf667f
Child:
5:a1fb2d2fb2d0
diff -r ea819bcf667f -r 49c5fd62a192 main.cpp
--- a/main.cpp	Mon Oct 15 09:24:44 2018 +0000
+++ b/main.cpp	Mon Oct 15 09:39:06 2018 +0000
@@ -1,13 +1,14 @@
 #include "mbed.h"
 #include "FastPWM.h"    // FastPWM library
 #include "MODSERIAL.h"
+#include "QEI.h"
 MODSERIAL pc(USBTX, USBRX);
 DigitalOut motor1_direction(D7);
 AnalogIn pot1(A4);
 InterruptIn but2(D3);
 FastPWM motor1_pwm(D6); //FastPWM input, PES lecture 2
 Ticker MotorInterrupt;
-  
+pc.baud(115200);
 void Motor()
 {
     // Aflezen Potentiometers voor PWM
@@ -18,7 +19,7 @@
 {
     motor1_direction = 1 - motor1_direction;
     float motor1_velocity = pot1.read() *2.0;
-    pc.baud(115200);
+   
     pc.printf("Velocity is %f \n", motor1_velocity);
 }
 
@@ -26,6 +27,10 @@
 {
     motor1_pwm.period_us(60.0); // 60 microseconds PWM period, 16.7 kHz, defines all PWM pins (only needs to done once), FastPWM variabele
     MotorInterrupt.attach(Motor, 0.5); // Ticker die de functie Motor aanroept elke halve seconde, meer tijd is tragere respons op potmeter
-    but2.rise(buttonpress); 
+    but2.rise(buttonpress);
+    int counts;
+    QEI Encoder (D12, D13, NC, 64, QEI::X4_ENCODING);
+    counts = Encoder.getPulses();
+    pc.printf("%i\r\n", counts);
     while(true){} // Endless loop  
 }
\ No newline at end of file