Motor Control

1. Introduction

In the steps of this tutorial

  1. the your droid Micro Servo 9g (“servo motor”) is controlled
  2. multiple PWM signals to control a dual motor h bridge and the servo motor are generated.

2. Prerequisites

3. Basics

The servo motor and the h bridge are controlled by PWM signals.

The basic of PWM are described on Wikipedia: https://en.wikipedia.org/wiki/Pulse-width_modulation

The Espressif ESP32C3 has a dedicated hardware module, which can generate PWM signals. The Espressif ESP32C3 PWM hardware module is called LED Control (LEDC) and described in the Espressif documentation: https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/api-reference/peripherals/ledc.html

The library to control the ESP32C3’s LED Control module is described in the Espressif’s GitHub repository: https://github.com/espressif/arduino-esp32/blob/master/docs/en/api/ledc.rst

4. Implementation

4.1 Servo Motor Control

Example code: servo_ledc

4.2 Drive Motor Control

Example code: hbridge_ledc_withSliders

4.3 Multi PWM Signal Generation

Example code: servo_hbridge_ledc