QUI test for the BioRobotics Shield and Pololu motor.

Dependencies:   QEI mbed

Files at this revision

API Documentation at this revision

Comitter:
Jankoekenpan
Date:
Tue Sep 27 15:35:14 2016 +0000
Commit message:
working qei :D

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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f7f02194f5d6 QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Tue Sep 27 15:35:14 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aberk/code/QEI/#5c2ad81551aa
diff -r 000000000000 -r f7f02194f5d6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 27 15:35:14 2016 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "QEI.h"
+
+Serial pc(USBTX, USBRX);
+InterruptIn reset_button(D2);
+
+const float ratio = 1.0f/131.25f;
+
+QEI qei(D13, D12, NC, 32);
+
+Ticker printer;
+volatile int seconds_passed = 0;
+
+void onTick() {
+    pc.printf("pulses = %d\r\n", qei.getPulses());
+    pc.printf("revolutions = %d\r\n", qei.getRevolutions());
+    pc.printf("angular velocity = %d degrees/second\r\n", (qei.getPulses() / ++seconds_passed) * (360/32));
+    pc.printf("\n\n");
+}
+
+void reset() {
+    seconds_passed = 0;
+    qei.reset();
+}
+
+int main()
+{
+    pc.baud(115200);
+    qei.reset();
+    printer.attach(onTick, 1);
+    reset_button.fall(reset); //there must be a better/cleaner way to do this.
+    while (true);
+}
\ No newline at end of file
diff -r 000000000000 -r f7f02194f5d6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 27 15:35:14 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85
\ No newline at end of file