Encoder program for K64F microcontroller with 64 bit confic
Dependencies: MODSERIAL QEI mbed
Fork of Encoder_program by
Diff: main.cpp
- Revision:
- 1:b9fb9ec8a9e6
- Parent:
- 0:9b63614c20f3
- Child:
- 2:3e6f179dfe7d
--- a/main.cpp Wed Sep 23 09:35:07 2015 +0000 +++ b/main.cpp Wed Sep 23 12:08:31 2015 +0000 @@ -9,16 +9,24 @@ //QEI wheel(p29, p30, NC, 624, QEI::X4_ENCODING); //Use X2 encoding by default. QEI wheel (D11, D12, NC, 64,QEI::X4_ENCODING); // +Ticker flipper; + + void flip() { + motor2direction.write(0); + for(int i=0;i<21; i++) + { + wait(0.1); + pc.printf("Pulses is: %i\n", (wheel.getPulses()/((64*131)/360))); + } +} int main() { - + flipper.attach(&flip, 2.0); while(1){ - - motor2direction.write(1); motor2speed.write(0.2); wait(0.1); - pc.printf("Pulses is: %i\n", (wheel.getPulses()/(64*131))); + pc.printf("Pulses is: %i\n", (wheel.getPulses()/((64*131)/360))); } }