mencari respon motor launcher dengan fungsi step

Dependencies:   Motor mbed millis

Fork of transfer_function_motor by KRAI 2017

Committer:
Najib_irvani
Date:
Thu Feb 16 16:24:30 2017 +0000
Revision:
0:be14d75c8037
Child:
1:3a234ff1442b
mencari fungsi transfer motor dengan fungsi step

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Najib_irvani 0:be14d75c8037 1 #include "mbed.h"
Najib_irvani 0:be14d75c8037 2 #include "encoderKRAI.h"
Najib_irvani 0:be14d75c8037 3 #include "Motor.h"
Najib_irvani 0:be14d75c8037 4 #include "millis.h"
Najib_irvani 0:be14d75c8037 5
Najib_irvani 0:be14d75c8037 6 encoderKRAI encoder( PB_13, PB_14, 14, encoderKRAI::X2_ENCODING);
Najib_irvani 0:be14d75c8037 7 Serial pc(USBTX,USBRX);
Najib_irvani 0:be14d75c8037 8 Motor motor(PA_8,PC_1,PC_2);
Najib_irvani 0:be14d75c8037 9
Najib_irvani 0:be14d75c8037 10 unsigned long int previousMillis = 0;
Najib_irvani 0:be14d75c8037 11 unsigned long int currentMillis;
Najib_irvani 0:be14d75c8037 12 double rpm;
Najib_irvani 0:be14d75c8037 13
Najib_irvani 0:be14d75c8037 14
Najib_irvani 0:be14d75c8037 15
Najib_irvani 0:be14d75c8037 16 int main() {
Najib_irvani 0:be14d75c8037 17
Najib_irvani 0:be14d75c8037 18 startMillis();
Najib_irvani 0:be14d75c8037 19 motor.speed(0.5);
Najib_irvani 0:be14d75c8037 20
Najib_irvani 0:be14d75c8037 21 while(1) {
Najib_irvani 0:be14d75c8037 22
Najib_irvani 0:be14d75c8037 23 currentMillis = millis();
Najib_irvani 0:be14d75c8037 24
Najib_irvani 0:be14d75c8037 25
Najib_irvani 0:be14d75c8037 26 if (currentMillis-previousMillis>=100)
Najib_irvani 0:be14d75c8037 27 {
Najib_irvani 0:be14d75c8037 28 rpm = (double)encoder.getPulses();
Najib_irvani 0:be14d75c8037 29
Najib_irvani 0:be14d75c8037 30
Najib_irvani 0:be14d75c8037 31
Najib_irvani 0:be14d75c8037 32
Najib_irvani 0:be14d75c8037 33 encoder.reset();
Najib_irvani 0:be14d75c8037 34 pc.printf("%.04lf\n",rpm);
Najib_irvani 0:be14d75c8037 35
Najib_irvani 0:be14d75c8037 36 previousMillis = currentMillis;
Najib_irvani 0:be14d75c8037 37
Najib_irvani 0:be14d75c8037 38 }
Najib_irvani 0:be14d75c8037 39
Najib_irvani 0:be14d75c8037 40
Najib_irvani 0:be14d75c8037 41
Najib_irvani 0:be14d75c8037 42 }
Najib_irvani 0:be14d75c8037 43 }