simple QEI library. no return speed, only return angle.
Dependents: WRS_mechanamu_test
QEI.h@1:6fa863d09d45, 2018-11-14 (annotated)
- Committer:
- sgrsn
- Date:
- Wed Nov 14 02:18:58 2018 +0000
- Revision:
- 1:6fa863d09d45
- Parent:
- 0:bffc97496048
Add getDisAngle for Odmetry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sgrsn | 0:bffc97496048 | 1 | #ifndef QEI_H |
sgrsn | 0:bffc97496048 | 2 | #define QEI_H |
sgrsn | 0:bffc97496048 | 3 | |
sgrsn | 0:bffc97496048 | 4 | #include "mbed.h" |
sgrsn | 0:bffc97496048 | 5 | |
sgrsn | 0:bffc97496048 | 6 | class QEI { |
sgrsn | 0:bffc97496048 | 7 | |
sgrsn | 0:bffc97496048 | 8 | public: |
sgrsn | 0:bffc97496048 | 9 | |
sgrsn | 1:6fa863d09d45 | 10 | QEI(PinName A, PinName B, int ppr, Timer *t); |
sgrsn | 0:bffc97496048 | 11 | |
sgrsn | 0:bffc97496048 | 12 | float getAngle(); |
sgrsn | 1:6fa863d09d45 | 13 | float getSpeed(); |
sgrsn | 1:6fa863d09d45 | 14 | float getDisAngle(); |
sgrsn | 1:6fa863d09d45 | 15 | void reset(); |
sgrsn | 0:bffc97496048 | 16 | |
sgrsn | 0:bffc97496048 | 17 | private: |
sgrsn | 0:bffc97496048 | 18 | |
sgrsn | 0:bffc97496048 | 19 | void encode(void); |
sgrsn | 0:bffc97496048 | 20 | |
sgrsn | 0:bffc97496048 | 21 | InterruptIn channelA; |
sgrsn | 0:bffc97496048 | 22 | InterruptIn channelB; |
sgrsn | 1:6fa863d09d45 | 23 | Timer *timer; |
sgrsn | 1:6fa863d09d45 | 24 | |
sgrsn | 0:bffc97496048 | 25 | float angle; |
sgrsn | 0:bffc97496048 | 26 | int currState; |
sgrsn | 0:bffc97496048 | 27 | int prevState; |
sgrsn | 0:bffc97496048 | 28 | int position; |
sgrsn | 1:6fa863d09d45 | 29 | int last_position; |
sgrsn | 0:bffc97496048 | 30 | float _ppr; |
sgrsn | 1:6fa863d09d45 | 31 | float time; |
sgrsn | 0:bffc97496048 | 32 | }; |
sgrsn | 0:bffc97496048 | 33 | |
sgrsn | 0:bffc97496048 | 34 | #endif |