🛠 First connection and startup of the 4-Encoder Motor Driver
Objectives
This tutorial guides you through the initial setup of the 4-Encoder Motor Driver (DRV8837DSGR). The goal is to understand the power architecture, correctly connect an encoder motor, and verify I2C communication with an M5Stack host. We will cover the distinction between logic and motor power, which is crucial for preventing failures.
Required Materials
- An M5Stack host board (Core2, Core Basic, or Atom Lite with Grove).
- The 4-Encoder Motor Driver Unit (DRV8837DSGR).
- A 6-wire gear motor (TT or N20 type) with an integrated encoder.
- An external DC power supply (6V to 12V) or a USB cable for the host.
- Grove HY2.0-4P cable.
Steps
- Host Preparation: Install the host board on your computer and verify that the serial port driver is recognized. Ensure the base firmware is flashed.
- I2C Connection: Connect the host's Grove I2C port to one of the two Grove HY2.0-4P ports on the Motor Driver Unit. The default I2C address is 0x24.
- Motor Powering: For a simple first test, you can use the 5V power via the Grove port if the motor is small. However, to avoid voltage drops, it is recommended to use the external DC input (6-12V) on the dedicated connector. The integrated DC-DC converter regulates this voltage for the motors and can power the host if configured.
- Motor Wiring: Identify the motor wires. The 6 wires are divided into two pairs for current (motor) and two pairs for the encoder. Connect the motor pair to the M1+ and M1- terminals of the PH2.0-6P connector. Connect the encoder pair to the corresponding A and B terminals. Respect polarity for consistent rotation direction.
- Hardware Verification: The WS2812C RGB LED on the module usually lights up blue or green upon successful initialization, indicating that the STM32 microcontroller is receiving logic power.
Verification
To confirm communication, use a simple I2C scanner via the Arduino IDE or UIFlow. If address 0x24 appears in the list of detected devices, the physical link is correct. You can then send a test command to spin the motor at a low speed. If the motor does not spin, check the external power supply voltage and the PH2.0 connector connections.
Going Further
Once the connection is validated, explore advanced control modes such as closed-loop speed regulation. You can then configure the I2C address if you are using multiple modules on the same bus.
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
- GPIO and RGB LED Control on the 4-Encoder Motor Driver
- Closed-Loop Automation with the 4-Encoder Driver
- First wiring and initialization of the 4-Encoder Motor 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