Uso de la clase Motor para el control de velocidad de un motor continuo con encoder.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "Motor.h" 00003 00004 Serial Mbed(PB_6, PB_7); 00005 //Serial Mbed(PA_2, PA_3); 00006 InterruptIn Encoder(PC_9); 00007 DigitalOut LED(PA_5); 00008 DigitalIn Button(PA_0); 00009 MotorContinuo Mizq(PD_13, PD_11, PB_15, NC,NC,0); 00010 00011 00012 long x = 0; 00013 long muestras[200]; 00014 int t = 10; 00015 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; 00016 00017 00018 00019 00020 00021 void interrupt() 00022 { 00023 x ++; 00024 00025 } 00026 00027 00028 00029 int main() { 00030 00031 Mbed.printf("Hello World\n!"); 00032 Encoder.rise(&interrupt); 00033 00034 long temp = 0; 00035 int duty = 10; 00036 00037 00038 00039 while(1) 00040 { 00041 00042 //////// Giro sentido 1 00043 00044 Mbed.printf("Motor Velocidad = %d%% : ",duty); 00045 LED = 1; 00046 00047 Mizq.Forward(); 00048 Mizq.SpeedDuty(duty); 00049 x = 0; temp = 0; 00050 wait(1); 00051 temp = x; 00052 Mbed.printf("PPS = %d : \n",temp); 00053 LED = 0; 00054 if(Button == 0) { duty++; if(duty > 100) duty = 10; } 00055 wait(1); 00056 00057 00058 00059 00060 } 00061 }
Generated on Wed Sep 7 2022 01:54:55 by
1.7.2