diff --git a/Robotito/src/main.c b/Robotito/src/main.c index 3c7c29fc95a8c46ee3b392d205e452659c868e9d..1e9ecd8cb64f958a1aab1e21d96aedb38d1e806f 100644 --- a/Robotito/src/main.c +++ b/Robotito/src/main.c @@ -23,50 +23,52 @@ #define NMOTORS 3 #define OMNI_NRO_TIMER 0 - - -static void timer_func() { - printf("ECHO TIMER \n"); -} - void app_main(void) { - - //1. mcpwm gpio initialization - motor_h_t *mot0; - motor_h_t *mot2; - - motor_install(26,27, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot0); - motor_install(18,23, MCPWM_UNIT_1, MCPWM1A, MCPWM1B, MCPWM_TIMER_1, &mot2); - // pines de los motores - // Motor 0: 26,27 Encoder 0: 37, 39 - // Motor 1: 25,33 Encoder 1: 36, 38 - // Motor 2: 18,23 Encoder 2: 34, 35 - //2. initial mcpwm configuration printf("Configuring Initial Parameters of mcpwm...\n"); - motor_start(mot0); //Configure PWM0A & PWM0B with above settings - motor_start(mot2); - - int inc = 10; - while (1) { - - motor_set_speed(mot0, inc); - motor_set_speed(mot2, inc); - vTaskDelay(2000 / portTICK_RATE_MS); - motor_stop(mot0); - motor_stop(mot2); - vTaskDelay(2000 / portTICK_RATE_MS); - motor_set_speed(mot0, inc); - motor_set_speed(mot2, -inc); - vTaskDelay(2000 / portTICK_RATE_MS); - motor_stop(mot0); - motor_stop(mot2); - vTaskDelay(2000 / portTICK_RATE_MS); - - inc++; - if (inc == 30){ - inc = 10; + omni_init(); + omni_set_enable(true); + int vel; + while (1) { + for (size_t i = 100; 98 < i; i--) + { + vel = i; + printf("---------------------------------------------------------------------\n"); + printf("Busco vel=%d\n",vel); + printf("---------------------------------------------------------------------\n"); + omni_drive(vel,0,0,0); + vTaskDelay( 1000/ portTICK_RATE_MS); } - } -} - + omni_drive(0,0,0,0); + vTaskDelay(1000/ portTICK_RATE_MS); + for (size_t i = 100; 98 < i; i--) + { + vel = i; + printf("---------------------------------------------------------------------\n"); + printf("Busco vel=%d\n",vel); + printf("---------------------------------------------------------------------\n"); + omni_drive(0,vel,0,0); + vTaskDelay( 1000/ portTICK_RATE_MS); + } + for (size_t i = 100; 98 < i; i--) + { + vel = i; + printf("---------------------------------------------------------------------\n"); + printf("Busco vel=%d\n",vel); + printf("---------------------------------------------------------------------\n"); + omni_drive(-vel,0,0,0); + vTaskDelay( 1000/ portTICK_RATE_MS); + } + omni_drive(0,0,0,0); + vTaskDelay(1000/ portTICK_RATE_MS); + for (size_t i = 100; 98 < i; i--) + { + vel = i; + printf("---------------------------------------------------------------------\n"); + printf("Busco vel=%d\n",vel); + printf("---------------------------------------------------------------------\n"); + omni_drive(0,-vel,0,0); + vTaskDelay( 1000/ portTICK_RATE_MS); + } + } +} \ No newline at end of file