Encoder read code

Dependencies:   mbed encoderKRTMI Motornew millis

Files at this revision

API Documentation at this revision

Comitter:
SalbiFaza
Date:
Sat Feb 23 11:17:09 2019 +0000
Commit message:
bismillah

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
encoderKRTMI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
millis.lib Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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
--- /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
--- /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
--- /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