QEI fork

Dependents:   Nucleo_pwm_example MM_rat_Assignment4 MM_rat_Assignment4-newwest MicroMousewithFloodFill

Fork of QEI by Aaron Berk

Files at this revision

API Documentation at this revision

Comitter:
Showboo
Date:
Mon Nov 20 01:14:31 2017 +0000
Parent:
0:5c2ad81551aa
Child:
2:08e7120349cd
Commit message:
Code for Micromouse updated for Assignment 4 (Left Wheel isn't moving right now, maybe someone can debug this)

Changed in this revision

main_rev.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main_rev.cpp	Mon Nov 20 01:14:31 2017 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "QEI.h"
+#include "header.h"
+
+inline void pulse_ir(int in){
+        LeftIR = in;
+        FrontLeftIR = in;
+        FrontRightIR = in;
+        RightIR = in;
+}
+
+int main() {
+    pid lman, rman;
+    lman.kp = .004f;
+    lman.ki = .0f;
+    lman.kd = .0f;
+    rman.kp = .5f;
+    rman.ki = .1f;
+    rman.kd = .4f;
+    
+    lpwmf.period(0.01f);
+    lpwmf = 0; //Previously started on, replace with lpwmf = lbase to make it start on (not a good idea)
+    rpwmf.period(0.01f);
+    rpwmf = 0;
+    pid ir_lman, ir_rman;
+    ir_lman.kp = .004f;
+    ir_lman.ki = .0f;
+    ir_lman.kd = .0f;
+    ir_rman.kp = .5f;
+    ir_rman.ki = .1f;
+    ir_rman.kd = .4f;    
+    t_time.start();
+    while(1){       
+       float dt = t_time.read();
+       float lspeed, rspeed;
+       pulse_ir(1);
+       ProcessIR(dt, ir_lman, lspeed, rspeed);
+       lpwmb = 0; rpwmb = 0;
+       //lpwmf = lspeed; rpwmf = rspeed;
+       pulse_ir(0);
+       t_time.reset();
+    }
+}