Skip to content

Instantly share code, notes, and snippets.

View Microzod's full-sized avatar

David Microzod

  • Svea Rike
  • 15:01 (UTC +02:00)
View GitHub Profile
#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>
@Microzod
Microzod / espidf.c
Created June 24, 2025 08:57
ChatGPT espidf PI-Loop
#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;
@Microzod
Microzod / sketch.ino
Last active June 24, 2025 08:54
Latest ino PI-Loop
#include <encoderEncoderPCNT.h>
#include <Bounce2.h>
#include <MCPWM_DUAL_PWM.h>
#include <cmath> // for roundf()
extern "C"
{
#include "driver/mcpwm_prelude.h"
}
@Microzod
Microzod / .ino
Last active June 13, 2025 15:43
new gist
#include <PulseCounter.h>
#include <RotaryEncoderPCNT.h>
#include <Bounce2.h>
#include <MCPWM_PWM_ENCODER.h>
extern "C"
{
#include "driver/mcpwm_prelude.h"
}
@Microzod
Microzod / .ino
Last active June 13, 2025 13:24
ESP32-S3-PICO MCPWM encoder PI Loop
#include <PulseCounter.h>
#include <RotaryEncoderPCNT.h>
#include <Bounce2.h>
#include <MCPWM_PWM_ENCODER.h>
extern "C"
{
#include "driver/mcpwm_prelude.h"
}
@Microzod
Microzod / gist:06e2430dcd54d87c0de6c36a351b508c
Last active May 13, 2025 03:55
Arduino sketch for controlling 2 motors usiing L298 and the MCPWM module of ESP32-S3
#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 =====
// 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"
}
@Microzod
Microzod / gist:743e571d897de88c134da17feda25d10
Last active June 7, 2025 14:54
ESP32-S3 MCPWM and L298 code
#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 };