Interface for the encoder of the red fischertechnik motors
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.
Diff: FtEncoder.h
- Revision:
- 2:1bf9f7b6bf29
- Parent:
- 1:9e595056c3da
diff -r 9e595056c3da -r 1bf9f7b6bf29 FtEncoder.h --- a/FtEncoder.h Wed Mar 20 21:42:39 2013 +0000 +++ b/FtEncoder.h Mon Mar 25 21:08:56 2013 +0000 @@ -4,7 +4,7 @@ #include "InterruptIn.h" #include "us_ticker_api.h" #include "FunctionPointer.h" -#include "Timeout.h" +#include "TimeoutTweaked.h" using namespace mbed; @@ -21,12 +21,12 @@ static const int c_nTmStmps = 1<<2; /// size of ringbuffer: Has to be 2^x InterruptIn m_encIRQ; - Timeout m_tmOut; + TimeoutTweaked m_tmOut; volatile unsigned int m_cnt; /// edge counter unsigned int m_standStillTimeout; volatile unsigned int m_cursor; /// ringbuffer cursor - uint32_t m_timeStamps[c_nTmStmps]; /// ringbuffer of edge timestamps + volatile uint32_t m_timeStamps[c_nTmStmps]; /// ringbuffer of edge timestamps FunctionPointer m_callBack;