Skip to content

Commit

Permalink
MCPWM Implementation update for ESP-IDF 5.0 (#90)
Browse files Browse the repository at this point in the history
* Added new mcpwm interface

Updated MCPWM Interface, but stuck at an exception ( Guru Meditation Error: Core  0 panic'ed (InstrFetchError).

Updated small pointer error.

Fixed double pointer assignment error.

Cleaned Interface, fixed issue with mapping of duty cycle values

Fixed silly error in pindefs for motors

motor driver parallel example deleted

Small change in include files

* Update .gitignore

Delete .vscode directory

Uncommented out code and add license headers to header files

Add .gitignore entry for sdkconfig file

* Add get_motor_driver_status function

* update bitmask in bar_graph.c

* Fix header file include guards

* Update motor driver configuration to have macros for frequency and resolution

* Refactor motor driver code and remove unnecessary imports

* Add servo.h header file, which was removed by mistake

* Fix motor driver and remove unnecessary include

* Add esp_log.h include

* added description for mapping.
  • Loading branch information
SuperChamp234 authored Feb 1, 2024
1 parent d73559b commit 619695f
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 1,332 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
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";
static const char* TAG = "MOTOR";

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;
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

0 comments on commit 619695f

Please sign in to comment.