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

Files at this revision

API Documentation at this revision

Comitter:
DavidMcP555
Date:
Tue Nov 24 19:53:03 2015 +0000
Parent:
3:8b5700499eb8
Commit message:
Added encoder support for reading and communication to Zumy ROS through RPC

Changed in this revision

QEI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8b5700499eb8 -r b8eeb59b62d4 QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Tue Nov 24 19:53:03 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
diff -r 8b5700499eb8 -r b8eeb59b62d4 main.cpp
--- 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;