This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Sensors/Encoders/Encoder.h@25:b16f1045108f, 2013-04-10 (annotated)
- Committer:
- madcowswe
- Date:
- Wed Apr 10 02:01:51 2013 +0000
- Revision:
- 25:b16f1045108f
- Parent:
- 20:70d651156779
Motion and motor works, but needs tuning
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
twighk | 0:200635fa1b08 | 1 | |
madcowswe | 20:70d651156779 | 2 | #ifndef ENCODER_H |
madcowswe | 20:70d651156779 | 3 | #define ENCODER_H |
twighk | 0:200635fa1b08 | 4 | |
twighk | 0:200635fa1b08 | 5 | #include "QEI.h" |
twighk | 0:200635fa1b08 | 6 | #include "mbed.h" |
madcowswe | 20:70d651156779 | 7 | #include "globals.h" |
twighk | 0:200635fa1b08 | 8 | |
twighk | 0:200635fa1b08 | 9 | class Encoder{ |
twighk | 0:200635fa1b08 | 10 | private: |
twighk | 0:200635fa1b08 | 11 | DigitalIn green, yellow; |
twighk | 0:200635fa1b08 | 12 | QEI wheel; |
twighk | 0:200635fa1b08 | 13 | |
twighk | 0:200635fa1b08 | 14 | public: |
twighk | 0:200635fa1b08 | 15 | Encoder(PinName pGreen, PinName pYellow) |
twighk | 0:200635fa1b08 | 16 | : green(pGreen) |
twighk | 0:200635fa1b08 | 17 | , yellow(pYellow) |
madcowswe | 5:56a5fdd373c9 | 18 | , wheel(pGreen,pYellow, NC, 0, QEI::X4_ENCODING) |
twighk | 0:200635fa1b08 | 19 | { |
twighk | 0:200635fa1b08 | 20 | green.mode(PullUp); |
twighk | 0:200635fa1b08 | 21 | yellow.mode(PullUp); |
twighk | 0:200635fa1b08 | 22 | } |
twighk | 0:200635fa1b08 | 23 | |
madcowswe | 20:70d651156779 | 24 | int getTicks(void){ |
twighk | 0:200635fa1b08 | 25 | return wheel.getPulses(); |
twighk | 0:200635fa1b08 | 26 | } |
twighk | 0:200635fa1b08 | 27 | |
twighk | 0:200635fa1b08 | 28 | void reset (void){ |
twighk | 0:200635fa1b08 | 29 | return wheel.reset(); |
twighk | 0:200635fa1b08 | 30 | } |
twighk | 0:200635fa1b08 | 31 | }; |
madcowswe | 20:70d651156779 | 32 | |
madcowswe | 20:70d651156779 | 33 | #ifdef ENABLE_GLOBAL_ENCODERS |
madcowswe | 20:70d651156779 | 34 | extern Encoder right_encoder; |
madcowswe | 20:70d651156779 | 35 | extern Encoder left_encoder; |
madcowswe | 20:70d651156779 | 36 | #endif |
madcowswe | 20:70d651156779 | 37 | |
madcowswe | 20:70d651156779 | 38 | #endif //ENCODER_H |