Data kecepatan motor thdp pwm Data kec motor thdp waktu

Dependencies:   mbed encoderKRAI Motor_new

Files at this revision

API Documentation at this revision

Comitter:
dwianiyulia
Date:
Mon Oct 28 12:52:13 2019 +0000
Commit message:
Ambil Data Motor

Changed in this revision

Motor.lib Show annotated file Show diff for this revision Revisions of this file
encoderKRAI.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Mon Oct 28 12:52:13 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Magang-KRAI-2019/code/Motor_new/#1d0887244f8b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/encoderKRAI.lib	Mon Oct 28 12:52:13 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Magang-KRAI-2019/code/encoderKRAI/#8a7fb008561c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 28 12:52:13 2019 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "Motor.h"
+#include "encoderKRAI.h"
+#include <stdio.h>
+
+Serial pc(USBTX, USBRX, 115200)
+
+//PinList
+Motor motorA(PB_7,PC_3,PC_0);
+EncoderKRAI encoderA(PB_1,PB_2,538,encoderKRAI::X4_ENCODING);// input pin
+
+//Define
+double pulse, total_pulse,velA;
+float pwm;
+typedef int IdxType;
+typedef int ElType;
+typedef struct{
+    ElType TI[IdxMax];
+    int Neff;
+}TabInt;
+TabInt A,B,C;
+IdxType i;
+const float  wheel_radius                           = 0.050;
+const float  PI                                     = 3.141592;
+float sample_time                                   = 10;
+
+void locomotionMovement();
+
+//Procedures Implementation
+int main(){
+    startMillis();
+    //gerak motor
+    while (1){
+        if (millis()- last_timer >= sample_time){
+            //read actual velocity (feedback)
+            velA   = (encoderA.getPulses()  * 2 * PI * wheel_radius)/(0.003*538);
+            //give pwm to motor
+            while (pwm<=0.8){
+                pwm=pwm+0.1
+            }    
+            motorA.speed(pwm);
+            //reset encoder
+            encoderA.reset();
+            last_timer = millis();
+            pc.printf("%d\n", velA));
+    }
+}     
+
+}    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 28 12:52:13 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file