QEIx4 Example

Dependencies:   QEIx4 mbed

Files at this revision

API Documentation at this revision

Comitter:
jocis
Date:
Tue Sep 02 18:24:13 2014 +0000
Child:
1:d084d4165f5c
Commit message:
Added documentation

Changed in this revision

QEIx4.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEIx4.lib	Tue Sep 02 18:24:13 2014 +0000
@@ -0,0 +1,1 @@
+QEIx4#46b8d5680f66
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 02 18:24:13 2014 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "QEIx4.h"
+
+DigitalOut myled(LED1);
+Timer t;
+
+// ports for nxp LPC 1768
+QEIx4 qei1(p30, p29, p28);          // QEI with index signal for zeroing
+QEIx4 qei2(p27, p26, NC);           // QEI only with AB signals
+QEIx4 qei3(p25, p24, NC, false);    // QEI without interrups for polling mode
+
+int main() {
+    t.start();
+
+    qei1.SetZeroOnIndex(true);      // Set the flag to zero counter on next index signal rises
+
+    while(1) 
+    {
+        qei3.poll();   // poll manually without interrupt - sampling in this loop with about 2kHz
+        
+        if ( t.read_ms() > 500 )   // every half second
+        {
+            t.reset();
+            t.start();
+            myled = !myled;
+            
+            printf ( "\r\n%6d %6d %6d", (int)qei1, (int)qei2, (int)qei3 );   // print counter values
+        }
+
+    wait_us(500);   // for about 2kHz
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Sep 02 18:24:13 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file