
エンコーダ用プログラム
Diff: main.cpp
- Revision:
- 0:e543236c8336
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 14 15:36:20 2016 +0000 @@ -0,0 +1,17 @@ +#include "QEI.h" + +Serial pc(USBTX, USBRX); + +#define ROTATE_PER_REVOLUTIONS 500 +//Use X4 encoding. +QEI wheel(dp17, dp18, dp26, 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\n", wheel.getPulses()); + pc.printf("Rotate: %04.3f\r\n", (double)wheel.getPulses()/(ROTATE_PER_REVOLUTIONS*4)); + } +} \ No newline at end of file