Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCPWM Implementation update for ESP-IDF 5.0 #90

Merged
merged 11 commits into from
Feb 1, 2024
4 changes: 3 additions & 1 deletion CMakeLists.txt
RISHI27-dot marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
set(srcs "src/i2cdev.c" "src/adc.c" "src/bar_graph.c" "src/switches.c" "src/lsa.c" "src/motor_driver.c" "src/mpu6050.c" "src/servo.c" "src/utils.c")
cmake_minimum_required(VERSION 3.22)

set(srcs "src/i2cdev.c" "src/adc.c" "src/bar_graph.c" "src/switches.c" "src/lsa.c" "src/mcpwm_interface.c" "src/mpu6050.c" "src/servo.c" "src/utils.c" "src/motor_driver.c")
set(include_dirs include)

if(CONFIG_ENABLE_OLED)
Expand Down
32 changes: 13 additions & 19 deletions examples/motor_driver_normal/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@
#include "freertos/task.h"
#include "sra_board.h"

static const char* TAG_SWITCH_CONTROL_MOTOR = "switch_control";
RISHI27-dot marked this conversation as resolved.
Show resolved Hide resolved
static const char* TAG = "MOTOR";
RISHI27-dot marked this conversation as resolved.
Show resolved Hide resolved

void app_main(void)
{
enable_motor_driver(a, NORMAL_MODE); // Enable motor driver A in Normal Mode
while(1)
{
// Rotate Motors A_0 and A_1 in FORWARD direction
set_motor_speed(MOTOR_A_0, MOTOR_FORWARD, 80);
ESP_LOGI(TAG_SWITCH_CONTROL_MOTOR, "MOTOR_A_0 FORWARD");
set_motor_speed(MOTOR_A_1, MOTOR_FORWARD, 80);
ESP_LOGI(TAG_SWITCH_CONTROL_MOTOR, "MOTOR_A_1 FORWARD");

vTaskDelay(2000 / portTICK_PERIOD_MS);

// Rotate Motors A_0 and A_1 in BACKWARD direction
set_motor_speed(MOTOR_A_0, MOTOR_BACKWARD, 80);
ESP_LOGI(TAG_SWITCH_CONTROL_MOTOR, "MOTOR_A_0 BACKWARD");
set_motor_speed(MOTOR_A_1, MOTOR_BACKWARD, 80);
ESP_LOGI(TAG_SWITCH_CONTROL_MOTOR, "MOTOR_A_1 BACKWARD");

vTaskDelay(2000 / portTICK_PERIOD_MS);
motor_handle_t motor1;
RISHI27-dot marked this conversation as resolved.
Show resolved Hide resolved
enable_motor_driver(&motor1, MOTOR_A_1);
while(1){
set_motor_speed(motor1, MOTOR_FORWARD, 60);
ESP_LOGI(TAG, "Forward");
vTaskDelay(1000 / portTICK_PERIOD_MS);
set_motor_speed(motor1, MOTOR_BACKWARD, 60);
ESP_LOGI(TAG, "Backward");
vTaskDelay(1000 / portTICK_PERIOD_MS);
set_motor_speed(motor1, MOTOR_STOP, 0);
ESP_LOGI(TAG, "Stop");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
Loading
Loading