This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <inttypes.h> | |
#include <stdio.h> | |
#include "nvs_flash.h" | |
#include "nvs.h" | |
#include "nvs_handle.hpp" | |
#include "esp_system.h" | |
#include <encoderEncoderPCNT.h> | |
#include <Bounce2.h> | |
#include <ESP32_L298N.h> | |
#include <MCPWM_DUAL_PWM.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include "freertos/FreeRTOS.h" | |
#include "freertos/task.h" | |
#include "driver/gpio.h" | |
#include "driver/mcpwm_prelude.h" | |
#include "driver/pulse_cnt.h" | |
// ─── pin definitions ─────────────────────────────────────────────────────────── | |
static constexpr gpio_num_t IN1_PIN = GPIO_NUM_5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <encoderEncoderPCNT.h> | |
#include <Bounce2.h> | |
#include <MCPWM_DUAL_PWM.h> | |
#include <cmath> // for roundf() | |
extern "C" | |
{ | |
#include "driver/mcpwm_prelude.h" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <PulseCounter.h> | |
#include <RotaryEncoderPCNT.h> | |
#include <Bounce2.h> | |
#include <MCPWM_PWM_ENCODER.h> | |
extern "C" | |
{ | |
#include "driver/mcpwm_prelude.h" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <PulseCounter.h> | |
#include <RotaryEncoderPCNT.h> | |
#include <Bounce2.h> | |
#include <MCPWM_PWM_ENCODER.h> | |
extern "C" | |
{ | |
#include "driver/mcpwm_prelude.h" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
extern "C" | |
{ | |
#include "driver/mcpwm_prelude.h" | |
} | |
enum Motor { MOTOR_A = 0, MOTOR_B = 1 }; | |
enum Direction { STOP = 0, FORWARD = 1, BACKWARD = 2 }; | |
// ===== L298 Control Pins ===== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ESP32‑S3 Dual‑Channel MCPWM (new prelude API) to control a L298 Motor Driver with encoders. | |
// – 20 kHz PWM (500 µs period) | |
// – 10‑bit integer resolution for duty [0…RESOLUTION] | |
#include <Arduino.h> | |
extern "C" { | |
#include "driver/mcpwm_prelude.h" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RotaryEncoderPCNT.h> | |
#include <Bounce2.h> | |
#include <MCPWM_PWM_ENCODER.h> | |
extern "C" | |
{ | |
#include "driver/mcpwm_prelude.h" | |
} | |
enum Motor { MOTOR_A = 0, MOTOR_B = 1 }; |