Skip to content
Snippets Groups Projects
Commit 58648f98 authored by RicardoEA's avatar RicardoEA
Browse files

2 Motor rotating and moving forward

parent 72ecfa8f
No related branches found
No related tags found
No related merge requests found
......@@ -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++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment