Cristian Castro
/
D04-F407_Encoder1
Uso de la clase Motor para el control de velocidad de un motor continuo con encoder.
main.cpp
- Committer:
- CCastrop1012
- Date:
- 2021-09-03
- Revision:
- 0:75421f27540e
File content as of revision 0:75421f27540e:
#include "mbed.h" #include "Motor.h" Serial Mbed(PB_6, PB_7); //Serial Mbed(PA_2, PA_3); InterruptIn Encoder(PC_9); DigitalOut LED(PA_5); DigitalIn Button(PA_0); MotorContinuo Mizq(PD_13, PD_11, PB_15, NC,NC,0); long x = 0; long muestras[200]; int t = 10; int escalon_1 = 10, escalon_2 = 80, escalon_3 = 30, escalon_4 = 50, escalon_5 = 65, escalon_6 = 5, escalon_7 = 20, escalon_8 = 40; void interrupt() { x ++; } int main() { Mbed.printf("Hello World\n!"); Encoder.rise(&interrupt); long temp = 0; int duty = 10; while(1) { //////// Giro sentido 1 Mbed.printf("Motor Velocidad = %d%% : ",duty); LED = 1; Mizq.Forward(); Mizq.SpeedDuty(duty); x = 0; temp = 0; wait(1); temp = x; Mbed.printf("PPS = %d : \n",temp); LED = 0; if(Button == 0) { duty++; if(duty > 100) duty = 10; } wait(1); } }