Interface for the encoder of the red fischertechnik motors

Dependencies:   NeedfulThings

Simple Interface for the simple encoder of the red fischertechnik motors.

The interface counts both, rising and falling edges, resulting in 150 counts per revolution. The interface also provides a speed measurement updated with each edge.

Connect the green wire to GND, the red one to +3.3V and the black signal line to any of mbed numbered pins. Additionally connect the signal line via a pullup resitor to +3.3V. A 10K resistor works fine.

Revision:
2:1bf9f7b6bf29
Parent:
1:9e595056c3da
--- a/FtEncoder.cpp	Wed Mar 20 21:42:39 2013 +0000
+++ b/FtEncoder.cpp	Mon Mar 25 21:08:56 2013 +0000
@@ -43,8 +43,8 @@
     m_cursor &= c_nTmStmps-1;
     m_timeStamps[m_cursor] = getCurrentTimeStamp();
     // restart the timeout
-    m_tmOut.detach();
-    m_tmOut.attach_us(this, &FtEncoder::timeoutISR, m_standStillTimeout);
+    m_tmOut.remove();
+    m_tmOut.insert(m_timeStamps[m_cursor]+m_standStillTimeout);
     ++m_cnt;
     m_callBack.call();
 }