From 58648f980e5aac9b4a5d24f03830994a75d24509 Mon Sep 17 00:00:00 2001 From: RicardoEA <ricardo@focus.uy> Date: Thu, 27 Oct 2022 21:30:45 -0300 Subject: [PATCH] 2 Motor rotating and moving forward --- Robotito/src/main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Robotito/src/main.c b/Robotito/src/main.c index 4e2c27a..3c7c29f 100644 --- a/Robotito/src/main.c +++ b/Robotito/src/main.c @@ -33,28 +33,34 @@ void app_main(void) { //1. mcpwm gpio initialization - motor_h_t *mot; + motor_h_t *mot0; + motor_h_t *mot2; - motor_install(26,27, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot); + 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(mot); //Configure PWM0A & PWM0B with above settings - + motor_start(mot0); //Configure PWM0A & PWM0B with above settings + motor_start(mot2); int inc = 10; while (1) { - motor_set_speed(mot, inc); + motor_set_speed(mot0, inc); + motor_set_speed(mot2, inc); vTaskDelay(2000 / portTICK_RATE_MS); - motor_stop(mot); + motor_stop(mot0); + motor_stop(mot2); vTaskDelay(2000 / portTICK_RATE_MS); - motor_set_speed(mot, -inc); + motor_set_speed(mot0, inc); + motor_set_speed(mot2, -inc); vTaskDelay(2000 / portTICK_RATE_MS); - motor_stop(mot); + motor_stop(mot0); + motor_stop(mot2); vTaskDelay(2000 / portTICK_RATE_MS); inc++; -- GitLab