Experimental Zumy code for interfacing with encoders (as well as IMU as in abuchan's code base).

Dependencies:   MPU6050IMU QEI RPCInterface mbed

Fork of zumy_mbed by Austin Buchan

Revision:
4:b8eeb59b62d4
Parent:
3:8b5700499eb8
--- a/main.cpp	Tue Oct 06 17:25:53 2015 +0000
+++ b/main.cpp	Tue Nov 24 19:53:03 2015 +0000
@@ -1,10 +1,13 @@
 #include "mbed.h"
 #include "SerialRPCInterface.h"
 #include "MPU6050.h"
+#include "QEI.h"
 
 SerialRPCInterface SerialRPC(USBTX, USBRX, 115200);
+//Serial pc(USBTX, USBRX); // tx, rx
 
 float accel_x, accel_y, accel_z, gyro_x, gyro_y, gyro_z;
+int r_enc, l_enc;
 
 RPCVariable<float> rpc_accel_x(&accel_x, "accel_x");
 RPCVariable<float> rpc_accel_y(&accel_y, "accel_y");
@@ -12,6 +15,10 @@
 RPCVariable<float> rpc_gryo_x(&gyro_x, "gyro_x");
 RPCVariable<float> rpc_gryo_y(&gyro_y, "gyro_y");
 RPCVariable<float> rpc_gryo_z(&gyro_z, "gyro_z");
+RPCVariable<int>   rpc_r_enc(&r_enc, "r_enc");
+RPCVariable<int>   rpc_l_enc(&l_enc, "l_enc");
+QEI l_wheel (p29, p30, NC, 624);
+QEI r_wheel (p11, p12, NC, 624);
 
 MPU6050 mpu6050;
 
@@ -52,6 +59,11 @@
     while(1) {
         wait_ms(10);
         
+        // Handle the encoders
+        r_enc=r_wheel.getPulses();
+        l_enc=l_wheel.getPulses();
+        //pc.printf("Pulses are: %i, %i\r\n", l_enc,r_enc);
+        
         if (!(--loop_count)) {
             loop_count = 10;
             main_loop = !main_loop;