haruki hasegawa
/
akituki_motor_encoder
akituki Motor read encoder by stm32F446re
Diff: main.cpp
- Revision:
- 0:c28f99ca60aa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jan 18 11:56:51 2020 +0000 @@ -0,0 +1,17 @@ +#include "QEI.h" +#include "mbed.h" +Serial pc(USBTX, USBRX); + +#define ROTATE_PER_REVOLUTIONS 24 +//Use X4 encoding. +QEI wheel(D6, D7, NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING); +//Use X2 encoding by default. +//QEI wheel (p30, p29, NC, 624); + +int main() { + while(1){ + wait(0.1); + pc.printf("Pulses: %07d\t", wheel.getPulses()); + pc.printf("Rotate: %04.3f\n", (double)wheel.getPulses()/(ROTATE_PER_REVOLUTIONS*4)); + } +} \ No newline at end of file