
mencari respon motor launcher dengan fungsi step
Dependencies: Motor mbed millis
Fork of transfer_function_motor by
Diff: main.cpp
- Revision:
- 0:be14d75c8037
- Child:
- 1:3a234ff1442b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Feb 16 16:24:30 2017 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" +#include "encoderKRAI.h" +#include "Motor.h" +#include "millis.h" + +encoderKRAI encoder( PB_13, PB_14, 14, encoderKRAI::X2_ENCODING); +Serial pc(USBTX,USBRX); +Motor motor(PA_8,PC_1,PC_2); + +unsigned long int previousMillis = 0; +unsigned long int currentMillis; +double rpm; + + + +int main() { + +startMillis(); +motor.speed(0.5); + + while(1) { + + currentMillis = millis(); + + + if (currentMillis-previousMillis>=100) + { + rpm = (double)encoder.getPulses(); + + + + + encoder.reset(); + pc.printf("%.04lf\n",rpm); + + previousMillis = currentMillis; + + } + + + + } +}