mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-15 11:26:45 +00:00
ESP-IDF RC Motors Controls
This commit is contained in:
0
ESP-IDF_Robot/build/.ninja_lock
Normal file
0
ESP-IDF_Robot/build/.ninja_lock
Normal file
@@ -1 +1 @@
|
|||||||
a0ba0146a84aa699a66776554556f7893459dfc9
|
921c2ffdf8237ac07b10843b5ca9541be434bfee
|
||||||
|
159
ESP-IDF_Robot/build/local_components_list.temp.yml
Normal file
159
ESP-IDF_Robot/build/local_components_list.temp.yml
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
components:
|
||||||
|
- name: "app_trace"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/app_trace"
|
||||||
|
- name: "app_update"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/app_update"
|
||||||
|
- name: "bootloader"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/bootloader"
|
||||||
|
- name: "bootloader_support"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/bootloader_support"
|
||||||
|
- name: "bt"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/bt"
|
||||||
|
- name: "cmock"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/cmock"
|
||||||
|
- name: "console"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/console"
|
||||||
|
- name: "cxx"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/cxx"
|
||||||
|
- name: "driver"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/driver"
|
||||||
|
- name: "efuse"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/efuse"
|
||||||
|
- name: "esp-tls"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp-tls"
|
||||||
|
- name: "esp_adc"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_adc"
|
||||||
|
- name: "esp_app_format"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_app_format"
|
||||||
|
- name: "esp_bootloader_format"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_bootloader_format"
|
||||||
|
- name: "esp_coex"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_coex"
|
||||||
|
- name: "esp_common"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_common"
|
||||||
|
- name: "esp_eth"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_eth"
|
||||||
|
- name: "esp_event"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_event"
|
||||||
|
- name: "esp_gdbstub"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_gdbstub"
|
||||||
|
- name: "esp_hid"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_hid"
|
||||||
|
- name: "esp_http_client"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_http_client"
|
||||||
|
- name: "esp_http_server"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_http_server"
|
||||||
|
- name: "esp_https_ota"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_https_ota"
|
||||||
|
- name: "esp_https_server"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_https_server"
|
||||||
|
- name: "esp_hw_support"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_hw_support"
|
||||||
|
- name: "esp_lcd"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_lcd"
|
||||||
|
- name: "esp_local_ctrl"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_local_ctrl"
|
||||||
|
- name: "esp_mm"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_mm"
|
||||||
|
- name: "esp_netif"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_netif"
|
||||||
|
- name: "esp_netif_stack"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_netif_stack"
|
||||||
|
- name: "esp_partition"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_partition"
|
||||||
|
- name: "esp_phy"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_phy"
|
||||||
|
- name: "esp_pm"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_pm"
|
||||||
|
- name: "esp_psram"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_psram"
|
||||||
|
- name: "esp_ringbuf"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_ringbuf"
|
||||||
|
- name: "esp_rom"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_rom"
|
||||||
|
- name: "esp_system"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_system"
|
||||||
|
- name: "esp_timer"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_timer"
|
||||||
|
- name: "esp_wifi"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esp_wifi"
|
||||||
|
- name: "espcoredump"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/espcoredump"
|
||||||
|
- name: "esptool_py"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/esptool_py"
|
||||||
|
- name: "fatfs"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/fatfs"
|
||||||
|
- name: "freertos"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/freertos"
|
||||||
|
- name: "hal"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/hal"
|
||||||
|
- name: "heap"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/heap"
|
||||||
|
- name: "http_parser"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/http_parser"
|
||||||
|
- name: "idf_test"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/idf_test"
|
||||||
|
- name: "ieee802154"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/ieee802154"
|
||||||
|
- name: "json"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/json"
|
||||||
|
- name: "linux"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/linux"
|
||||||
|
- name: "log"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/log"
|
||||||
|
- name: "lwip"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/lwip"
|
||||||
|
- name: "mbedtls"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/mbedtls"
|
||||||
|
- name: "mqtt"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/mqtt"
|
||||||
|
- name: "newlib"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/newlib"
|
||||||
|
- name: "nvs_flash"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/nvs_flash"
|
||||||
|
- name: "nvs_sec_provider"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/nvs_sec_provider"
|
||||||
|
- name: "openthread"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/openthread"
|
||||||
|
- name: "partition_table"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/partition_table"
|
||||||
|
- name: "perfmon"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/perfmon"
|
||||||
|
- name: "protobuf-c"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/protobuf-c"
|
||||||
|
- name: "protocomm"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/protocomm"
|
||||||
|
- name: "pthread"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/pthread"
|
||||||
|
- name: "riscv"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/riscv"
|
||||||
|
- name: "sdmmc"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/sdmmc"
|
||||||
|
- name: "soc"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/soc"
|
||||||
|
- name: "spi_flash"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/spi_flash"
|
||||||
|
- name: "spiffs"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/spiffs"
|
||||||
|
- name: "tcp_transport"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/tcp_transport"
|
||||||
|
- name: "touch_element"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/touch_element"
|
||||||
|
- name: "ulp"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/ulp"
|
||||||
|
- name: "unity"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/unity"
|
||||||
|
- name: "usb"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/usb"
|
||||||
|
- name: "vfs"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/vfs"
|
||||||
|
- name: "wear_levelling"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/wear_levelling"
|
||||||
|
- name: "wifi_provisioning"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/wifi_provisioning"
|
||||||
|
- name: "wpa_supplicant"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/wpa_supplicant"
|
||||||
|
- name: "xtensa"
|
||||||
|
path: "/home/abobkov/esp/esp-idf/components/xtensa"
|
||||||
|
- name: "main"
|
||||||
|
path: "/home/abobkov/MyProjects/ESP-Nodes/ESP-IDF_Robot/main"
|
@@ -78,19 +78,6 @@ static const char *TAG = "ESP IDF Robot";
|
|||||||
#define MTR_FRONT_RIGHT_REV_DUTY (3361)
|
#define MTR_FRONT_RIGHT_REV_DUTY (3361)
|
||||||
|
|
||||||
|
|
||||||
// LED
|
|
||||||
/*#define LEDC_TIMER LEDC_TIMER_0
|
|
||||||
#define LEDC_MODE LEDC_LOW_SPEED_MODE // LEDC_LOW_SPEED_MODE
|
|
||||||
#define LEDC_OUTPUT_IO (5) // Define the output GPIO
|
|
||||||
|
|
||||||
#define LEDC_CHANNEL LEDC_CHANNEL_0 // Right side motors
|
|
||||||
#define MTR_CHANNEL_L LEDC_CHANNEL_1 // Left side motors
|
|
||||||
#define LEDC_DUTY_RES LEDC_TIMER_13_BIT //*/
|
|
||||||
/*
|
|
||||||
TIMER RESOLUTION MAX VALUE HALF-DUTY
|
|
||||||
10 1023 511
|
|
||||||
13 8191 4095
|
|
||||||
*/
|
|
||||||
#define LEDC_DUTY (3361)//7820) // 8068, 7944, 7820, 7696, 7572, *7680*, 7424, 7168, 6144, 512, 768
|
#define LEDC_DUTY (3361)//7820) // 8068, 7944, 7820, 7696, 7572, *7680*, 7424, 7168, 6144, 512, 768
|
||||||
#define LEDC_FREQUENCY (5000)//8192)//4000) // For LED the freuqncy of 500Hz seems to be sufficient. // Frequency in Hertz. For DC motor, set frequency at 5 kHz
|
#define LEDC_FREQUENCY (5000)//8192)//4000) // For LED the freuqncy of 500Hz seems to be sufficient. // Frequency in Hertz. For DC motor, set frequency at 5 kHz
|
||||||
|
|
||||||
@@ -121,10 +108,6 @@ static TaskHandle_t s_task_handle;
|
|||||||
//static adc_channel_t channel[2] = {ADC_CHANNEL_2, ADC_CHANNEL_3};
|
//static adc_channel_t channel[2] = {ADC_CHANNEL_2, ADC_CHANNEL_3};
|
||||||
static adc_channel_t channel[2] = {ADC_CHANNEL_0, ADC_CHANNEL_1};
|
static adc_channel_t channel[2] = {ADC_CHANNEL_0, ADC_CHANNEL_1};
|
||||||
|
|
||||||
//static int adc_raw[2][10];
|
|
||||||
//static int voltage[2][10];
|
|
||||||
//static bool adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_atten_t atten, adc_cali_handle_t *out_handle);
|
|
||||||
//static void adc_calibration_deinit(adc_cali_handle_t handle);
|
|
||||||
|
|
||||||
#define ESP_INTR_FLAG_DEFAULT 0
|
#define ESP_INTR_FLAG_DEFAULT 0
|
||||||
|
|
||||||
@@ -251,13 +234,6 @@ static void nav_key_task (void* arg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*static void configure_led(void)
|
|
||||||
{
|
|
||||||
ESP_LOGI(TAG, "Configured to blink GPIO LED!");
|
|
||||||
gpio_reset_pin(BLINK_GPIO);
|
|
||||||
// Set the GPIO as a push/pull output
|
|
||||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static void configure_button (void) {
|
static void configure_button (void) {
|
||||||
ESP_LOGI(TAG, "Configured on-board push button");
|
ESP_LOGI(TAG, "Configured on-board push button");
|
||||||
@@ -265,21 +241,6 @@ static void configure_button (void) {
|
|||||||
//gpio_set_direction(PUSH_BTN_GPIO, GPIO_MODE_INPUT);
|
//gpio_set_direction(PUSH_BTN_GPIO, GPIO_MODE_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void configure_dc_mc (void) {
|
|
||||||
|
|
||||||
mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0A, MTR_FL_GPIO);
|
|
||||||
|
|
||||||
mcpwm_config_t mcpwm_config;
|
|
||||||
|
|
||||||
mcpwm_config.frequency = 4000;
|
|
||||||
mcpwm_config.cmpr_a = 50;
|
|
||||||
mcpwm_config.counter_mode = MCPWM_UP_COUNTER;
|
|
||||||
mcpwm_config.duty_mode = MCPWM_DUTY_MODE_0;
|
|
||||||
ESP_ERROR_CHECK(mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_0, &mcpwm_config));
|
|
||||||
ESP_ERROR_CHECK(mcpwm_set_duty_type(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A, MCPWM_DUTY_MODE_0));
|
|
||||||
ESP_ERROR_CHECK(mcpwm_set_duty(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_OPR_A, 50));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
static void motors_init (void) {
|
static void motors_init (void) {
|
||||||
|
|
||||||
m.motor1_rpm_pcm = 0;
|
m.motor1_rpm_pcm = 0;
|
||||||
@@ -368,55 +329,7 @@ static void ledc_init (void) {
|
|||||||
.hpoint = 0,
|
.hpoint = 0,
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_4));
|
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_4));
|
||||||
|
|
||||||
//ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
|
|
||||||
//ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
|
||||||
|
|
||||||
/*// MOTOR FRONT RIGHT
|
|
||||||
ledc_timer_config_t ledc_timer_1 = {
|
|
||||||
.speed_mode = LEDC_MODE,
|
|
||||||
.duty_resolution = LEDC_DUTY_RES,
|
|
||||||
.timer_num = MTR_FRONT_RIGHT_TMR,// LEDC_TIMER,
|
|
||||||
.freq_hz = LEDC_FREQUENCY,
|
|
||||||
.clk_cfg = LEDC_APB_CLK
|
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer_1));
|
|
||||||
ledc_channel_config_t ledc_channel_1 = {
|
|
||||||
.speed_mode = LEDC_MODE,
|
|
||||||
.channel = MTR_FRONT_RIGHT,// LEDC_CHANNEL_0,// MTR_FRONT_RIGHT,
|
|
||||||
.timer_sel = MTR_FRONT_RIGHT_TMR,// LEDC_TIMER,
|
|
||||||
.intr_type = LEDC_INTR_DISABLE,
|
|
||||||
.gpio_num = LEDC_OUTPUT_IO,
|
|
||||||
.duty = LEDC_DUTY,
|
|
||||||
.hpoint = 0,
|
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_1));
|
|
||||||
|
|
||||||
// MOTOR FRONT LEFT
|
|
||||||
ledc_timer_config_t ledc_timer_2 = {
|
|
||||||
.speed_mode = LEDC_MODE,
|
|
||||||
.duty_resolution = LEDC_DUTY_RES,
|
|
||||||
.timer_num = LEDC_TIMER,
|
|
||||||
.freq_hz = LEDC_FREQUENCY,
|
|
||||||
.clk_cfg = LEDC_APB_CLK
|
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer_2));
|
|
||||||
ledc_channel_config_t ledc_channel_2 = {
|
|
||||||
.speed_mode = LEDC_MODE,
|
|
||||||
.channel = MTR_FRONT_LEFT,
|
|
||||||
.timer_sel = LEDC_TIMER,
|
|
||||||
.intr_type = LEDC_INTR_DISABLE,
|
|
||||||
.gpio_num = LEDC_OUTPUT_IO,
|
|
||||||
.duty = LEDC_DUTY,
|
|
||||||
.hpoint = 0,
|
|
||||||
};
|
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_2));
|
|
||||||
//ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
|
|
||||||
//ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));*/
|
|
||||||
}
|
}
|
||||||
/*static void update_pwm (uint8_t pwm) {
|
|
||||||
ESP_ERROR_CHECK(ledc_set_duty_and_update(LEDC_MODE, LEDC_CHANNEL, pwm, 0));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* ESP-NOW */
|
/* ESP-NOW */
|
||||||
// Wi-Fi should start before using ESP-NOW
|
// Wi-Fi should start before using ESP-NOW
|
||||||
|
Reference in New Issue
Block a user