🛠 First wiring and initialization of the 4-Encoder Motor Driver
Objectifs
This tutorial aims to perform a safe first boot of the 4-Encoder Motor Driver Unit. Unlike simple modules, this device integrates an STM32F030C8T6 microcontroller and four DRV8837DSGR H-bridges. The goal is to validate the power chain, I2C communication, and encoder integrity before any movement command. We will cover external voltage management and I2C address configuration.
Matériel nécessaire
- M5Stack 4-Encoder Motor Driver Unit.
- External DC power source (6V to 12V), ideally a 3S LiPo battery or current-limited supply.
- I2C-compatible host controller (e.g., M5Stack Core2, ESP32, or Arduino).
- 6-wire geared motor or TT motor with encoder (3-15 PPR).
- Grove HY2.0-4P cables and PH2.0-6P connectors.
- Multimeter for voltage checks.
Étapes
- Power Source Preparation: The module accepts a DC input of 6 to 12V. Never connect a voltage higher than 12V. For a first test, use a 7.4V (2S LiPo) adjustable supply to limit inrush current. Check polarity on the external power connector.
- Motor Connection: Connect a 6-wire geared motor to PH2.0-6P connector #1. Follow standard pinout: two wires for the motor (OUT1/OUT2), two for encoder power (VCC/GND), and two for encoder signals (A/B). Motor wire inversion is harmless, but encoder wire inversion will reverse reading direction.
- Host Connection: Connect the module to the controller via a Grove HY2.0-4P cable. This port carries I2C (SDA/SCL) and 5V. The module has an internal DC-DC converter providing up to 5V @ 8A, but ensure your host is independently powered if needed.
- Hardware Verification: Before sending commands, use a multimeter to verify 5V presence on Grove connector VCC pins. Check if the WS2812C RGB LED lights up (it may blink or stay off depending on initial firmware).
- I2C Scan: Run an I2C scan on your host. The default address is 0x24. If the module does not respond, check SDA/SCL connections and common ground. The address is configurable between 0x08 and 0x77 but requires a specific command once communication is established.
Vérification
- The RGB LED should react to test commands (if firmware allows).
- The I2C scan must detect address 0x24.
- Manual motor rotation should change encoder values read via I2C (register read commands).
Pour aller plus loin
Once communication is established, explore advanced control modes like closed-loop speed regulation. You will need to configure PID registers via I2C to compensate for deviations between the setpoint and the actual position measured by the encoders.
Other tutorials for this board
- First Connection and Startup of the 4-Encoder Motor Driver
- Discovering I/O: RGB LED and Encoder Reading
- Automate a Robot Chassis with the 4-Encoder Driver
- First connection and startup of the 4-Encoder Motor Driver
- GPIO and RGB LED Control on the 4-Encoder Motor Driver
- Closed-Loop Automation with the 4-Encoder Driver
Code examples for this board
i2c-motor-spin.inoarduinoclosed-loop-speed-control.inoarduinorelative-position-move.inoarduinorgb-led-status-indicator.inoarduinodifferential-drive-robot.inoarduinoi2c_basic_motor_control.pyPython