simple QEI library. no return speed, only return angle.
Dependents: WRS_mechanamu_test
QEI.h
- Committer:
- sgrsn
- Date:
- 2018-08-20
- Revision:
- 0:bffc97496048
- Child:
- 1:6fa863d09d45
- Child:
- 2:62821df48957
File content as of revision 0:bffc97496048:
#ifndef QEI_H #define QEI_H #include "mbed.h" #define PREV_MASK 0x1 //Mask for the previous state in determining direction //of rotation. #define CURR_MASK 0x2 //Mask for the current state in determining direction //of rotation. #define INVALID 0x3 //XORing two states where both bits have changed. class QEI { public: QEI(PinName A, PinName B, int ppr); float getAngle(); private: void encode(void); InterruptIn channelA; InterruptIn channelB; float angle; int currState; int prevState; int position; float _ppr; }; #endif