Encoder read code
Dependencies: mbed encoderKRTMI Motornew millis
Revision 0:8c90db18512f, committed 2019-02-23
- Comitter:
- SalbiFaza
- Date:
- Sat Feb 23 11:17:09 2019 +0000
- Commit message:
- bismillah
Changed in this revision
diff -r 000000000000 -r 8c90db18512f Motor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Sat Feb 23 11:17:09 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/KRAI-2018/code/Motornew/#1d0887244f8b
diff -r 000000000000 -r 8c90db18512f encoderKRTMI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/encoderKRTMI.lib Sat Feb 23 11:17:09 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/KRTMI-2019/code/encoderKRTMI/#fd29d4db8c40
diff -r 000000000000 -r 8c90db18512f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Feb 23 11:17:09 2019 +0000 @@ -0,0 +1,33 @@ +//library +#include "mbed.h" +#include "encoderKRTMI.h" +#include "millis.h" +#include "Motor.h" + +//Konstanta + +//Roda KRTMI = 0.61313625 +#define PULSE_TO_JARAK 0.61313625 //jarak yang ditempuh oleh roda (keliling roda) + +// PX1 diganti Pin yang dipakai, PY1 diganti Pin yang dipakai, 538 banyaknya pulse (spesifikasi dari encoder), X4_ENCODING dari library, +// PX2 diganti Pin yang dipakai, PY2 diganti Pin yang dipakai, 538 banyaknya pulse (spesifikasi dari encoder), X4_ENCODING dari library, +encoderKRTMI encoderMotorX (PB_1, PC_2, 538, encoderKRTMI::X4_ENCODING); +encoderKRTMI encoderMotorY (PB_3, PC_4, 538, encoderKRTMI::X4_ENCODING); + +Serial pc(USBTX, USBRX); + +//variabel global +float timeSampling; +double pulseX; // pulseX diganti dengan pulse nama motor +double pulseY; // pulseY diganti dengan pulse nama motor + +// +int main (){ + pc.baud(115200); + while(1){ + pulseX = (double) encoderMotorX.getPulses()*PULSE_TO_JARAK; + pulseY = (double) encoderMotorY.getPulses()*PULSE_TO_JARAK; + pc.printf("X: $if\t Y: $if\n",pulseX,pulseY); + wait(0.2); + } +} \ No newline at end of file
diff -r 000000000000 -r 8c90db18512f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Feb 23 11:17:09 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file
diff -r 000000000000 -r 8c90db18512f millis.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/millis.lib Sat Feb 23 11:17:09 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/DFRobot/code/millis/#736e6cc31bcd