Micromouse 18
/
encoder
encoder
main.cpp@0:b9e03a03e580, 2017-11-08 (annotated)
- Committer:
- kensterino
- Date:
- Wed Nov 08 01:17:49 2017 +0000
- Revision:
- 0:b9e03a03e580
- Child:
- 1:1b18e69bf50f
encoder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kensterino | 0:b9e03a03e580 | 1 | #include "mbed.h" |
kensterino | 0:b9e03a03e580 | 2 | #include "QEI.h" |
kensterino | 0:b9e03a03e580 | 3 | Serial pc (PA_2, PA_3); //serial comm enabled on pins pa_2 and pa_3 |
kensterino | 0:b9e03a03e580 | 4 | QEI encoder_Right(PB_3, PA_15, NC, 360, QEI::X4_ENCODING); |
kensterino | 0:b9e03a03e580 | 5 | QEI encoder_Left(PA_1, PC_4, NC, 360, QEI::X4_ENCODING); //forward increases pulses |
kensterino | 0:b9e03a03e580 | 6 | |
kensterino | 0:b9e03a03e580 | 7 | //QEI functions |
kensterino | 0:b9e03a03e580 | 8 | /* |
kensterino | 0:b9e03a03e580 | 9 | void reset (void) |
kensterino | 0:b9e03a03e580 | 10 | Reset the encoder. |
kensterino | 0:b9e03a03e580 | 11 | int getCurrentState (void) |
kensterino | 0:b9e03a03e580 | 12 | Read the state of the encoder. |
kensterino | 0:b9e03a03e580 | 13 | int getPulses (void) |
kensterino | 0:b9e03a03e580 | 14 | Read the number of pulses recorded by the encoder. |
kensterino | 0:b9e03a03e580 | 15 | int getRevolutions (void) |
kensterino | 0:b9e03a03e580 | 16 | Read the number of revolutions recorded by the encoder on the index channel. |
kensterino | 0:b9e03a03e580 | 17 | */ |
kensterino | 0:b9e03a03e580 | 18 | |
kensterino | 0:b9e03a03e580 | 19 | int main() |
kensterino | 0:b9e03a03e580 | 20 | { |
kensterino | 0:b9e03a03e580 | 21 | |
kensterino | 0:b9e03a03e580 | 22 | while(1) { |
kensterino | 0:b9e03a03e580 | 23 | wait(0.1); |
kensterino | 0:b9e03a03e580 | 24 | pc.printf("Pulses is: %i\n", encoder_Right.getPulses()); |
kensterino | 0:b9e03a03e580 | 25 | //pc.printf("Pulses is: %i\n", encoder_Left.getPulses()); |
kensterino | 0:b9e03a03e580 | 26 | } |
kensterino | 0:b9e03a03e580 | 27 | |
kensterino | 0:b9e03a03e580 | 28 | } |