Stufin
Home Quick Cart Profile

M5Stack Stepmotor Module with MEGA328P (DRV8825)

Buy Now on Stufin

Microstepping

The module supports microstepping, which allows for smoother and more precise motor movement.

Current control

The module can limit the maximum current supplied to the motor, ensuring safe and efficient operation.

Direction and speed control

Users can control the direction and speed of the motor using simple commands.

Key Features

--------------

### Hardware Features

DRV8825 stepper motor driver ICA high-performance, low-noise driver IC capable of handling high currents and supporting microstepping.
MEGA328P microcontrollerA popular and widely-supported microcontroller with 32KB of flash memory and 2KB of SRAM.

Onboard voltage regulator

A built-in voltage regulator ensures stable power supply to the microcontroller and motor driver.

Two-phase bipolar stepper motor interfaceSupports connection of a two-phase bipolar stepper motor.

UART interface

Allows for communication with the microcontroller using a UART interface.

GROVE connector

A GROVE connector provides a convenient and easy-to-use interface for connecting sensors and other peripherals.

### Software Features

Arduino compatibility

The module is compatible with the Arduino IDE, making it easy to develop applications using the popular Arduino platform.

Example code and libraries

M5Stack provides example code and libraries to help users get started with developing their applications.

### Performance Specifications

Maximum motor current

2A per phase

Output voltage

5V to 35V

Microstepping resolution

Up to 1/16 microsteps

UART baud rate

Up to 115200 bps

Applications

--------------

The M5Stack Stepmotor Module with MEGA328P (DRV8825) is suitable for a wide range of applications, including

Robotics and automation

CNC machines and 3D printers

Industrial automation and control systems

Home automation and security systems

Scientific instruments and research equipment

Conclusion

----------

The M5Stack Stepmotor Module with MEGA328P (DRV8825) is a powerful and versatile module that simplifies stepper motor control and provides a range of features and benefits. Its compact size, ease of use, and Arduino compatibility make it an ideal choice for developers, makers, and professionals alike.

Pin Configuration

  • M5Stack Stepmotor Module with MEGA328P (DRV8825) Pinout Documentation
  • The M5Stack Stepmotor Module with MEGA328P (DRV8825) is a compact and versatile module designed for controlling stepper motors in various IoT and robotics applications. This documentation provides a detailed explanation of the module's pins, their functions, and how to connect them.
  • Pinout Structure:
  • The module has a total of 14 pins, divided into two rows of 7 pins each. The pins are labeled as follows:
  • Row 1:
  • 1. VCC: Power supply pin (3.3V or 5V)
  • Connect to a power source (e.g., a battery or a voltage regulator) to provide power to the module.
  • 2. GND: Ground pin
  • Connect to the ground pin of the power source and the microcontroller board.
  • 3. EN: Enable pin ( ACTIVE LOW )
  • Connect to a digital output pin on the microcontroller board to control the stepper motor driver's enable/disable function.
  • When EN is LOW, the driver is enabled, and when EN is HIGH, the driver is disabled.
  • 4. DIR: Direction pin
  • Connect to a digital output pin on the microcontroller board to control the stepper motor's direction of rotation.
  • When DIR is HIGH, the motor rotates in one direction, and when DIR is LOW, it rotates in the opposite direction.
  • 5. STEP: Step pin
  • Connect to a digital output pin on the microcontroller board to control the stepper motor's step sequence.
  • Each pulse on the STEP pin advances the motor by one step.
  • 6. MS1: Microstep resolution pin 1
  • Connect to a digital output pin on the microcontroller board to set the microstep resolution of the stepper motor driver.
  • MS1 and MS2 pins together determine the microstep resolution (see table below).
  • 7. MS2: Microstep resolution pin 2
  • Connect to a digital output pin on the microcontroller board to set the microstep resolution of the stepper motor driver.
  • Microstep Resolution Table:
  • | MS1 | MS2 | Microstep Resolution |
  • | --- | --- | --- |
  • | LOW | LOW | Full step (1/1) |
  • | HIGH | LOW | Half step (1/2) |
  • | LOW | HIGH | Quarter step (1/4) |
  • | HIGH | HIGH | Eighth step (1/8) |
  • Row 2:
  • 1. M1: Motor phase 1 pin
  • Connect to one of the motor's phase wires (e.g., red or black).
  • 2. M2: Motor phase 2 pin
  • Connect to the other motor phase wire (e.g., green or yellow).
  • 3. M3: Motor phase 3 pin
  • Connect to one of the motor's phase wires (e.g., blue or white).
  • 4. M4: Motor phase 4 pin
  • Connect to the other motor phase wire (e.g., orange or brown).
  • 5. RST: Reset pin ( ACTIVE LOW )
  • Connect to a digital output pin on the microcontroller board to reset the stepper motor driver.
  • When RST is LOW, the driver is reset, and when RST is HIGH, the driver is normal.
  • 6. SG: Status pin
  • This pin is an open-drain output that indicates the driver's status:
  • + HIGH: Driver is working normally.
  • + LOW: Driver has encountered an error or is in an undervoltage condition.
  • 7. NC: Not Connected pin
  • Leave this pin unconnected.
  • Connection Guidelines:
  • 1. Connect the VCC pin to a power source (3.3V or 5V).
  • 2. Connect the GND pin to the ground pin of the power source and the microcontroller board.
  • 3. Connect the EN pin to a digital output pin on the microcontroller board.
  • 4. Connect the DIR pin to a digital output pin on the microcontroller board.
  • 5. Connect the STEP pin to a digital output pin on the microcontroller board.
  • 6. Connect the MS1 and MS2 pins to digital output pins on the microcontroller board to set the microstep resolution.
  • 7. Connect the M1, M2, M3, and M4 pins to the corresponding phase wires of the stepper motor.
  • 8. Connect the RST pin to a digital output pin on the microcontroller board (optional).
  • 9. Connect the SG pin to a digital input pin on the microcontroller board (optional).
  • 10. Leave the NC pin unconnected.
  • Important Notes:
  • Ensure that the power supply voltage matches the recommended voltage for the stepper motor and the module.
  • Use a suitable microcontroller board and programming language to control the stepper motor module.
  • Consult the datasheet and application notes for the DRV8825 stepper motor driver IC for more detailed information on its operation and configuration.

Code Examples

M5Stack Stepmotor Module with MEGA328P (DRV8825) Documentation
Overview
The M5Stack Stepmotor Module with MEGA328P (DRV8825) is a compact, high-performance stepper motor driver module designed for use with the M5Stack ecosystem. It is based on the DRV8825 stepper motor driver IC and features a built-in microcontroller, the MEGA328P, for easy control and integration. This module is suitable for various applications, including robotics, automation, and IoT projects.
Technical Specifications
Microcontroller: ATMEGA328P
 Stepper Motor Driver: DRV8825
 Step Resolution: 1/32, 1/16, 1/8, 1/4, 1/2, 1, 2
 Maximum Current: 2.5A per phase
 Supply Voltage: 4.5V to 35V
 Communication Interface: UART, I2C, SPI
Code Examples
### Example 1: Basic Stepper Motor Control using UART
This example demonstrates how to control the stepper motor using UART communication. We will use the M5Stack Core module as the host device.
Hardware Connection:
Connect the M5Stack Stepmotor Module to the M5Stack Core module using the UART interface.
 Connect the stepper motor to the M5Stack Stepmotor Module.
Software:
```c
#include <M5Stack.h>
#include <SoftwareSerial.h>
SoftwareSerial stepperSerial(16, 17); // RX, TX
void setup() {
  M5.begin();
  stepperSerial.begin(9600);
}
void loop() {
  // Set the stepper motor direction and speed
  stepperSerial.print("D1
"); // Set direction to clockwise
  stepperSerial.print("S1000
"); // Set speed to 1000 steps per second
  
  // Move the stepper motor 1000 steps
  for (int i = 0; i < 1000; i++) {
    stepperSerial.print("M1
"); // Move one step
    delay(10);
  }
  
  delay(1000);
  
  // Change direction and move 500 steps
  stepperSerial.print("D0
"); // Set direction to counter-clockwise
  for (int i = 0; i < 500; i++) {
    stepperSerial.print("M1
"); // Move one step
    delay(10);
  }
}
```
### Example 2: Stepper Motor Control using I2C
This example demonstrates how to control the stepper motor using I2C communication.
Hardware Connection:
Connect the M5Stack Stepmotor Module to the M5Stack Core module using the I2C interface.
 Connect the stepper motor to the M5Stack Stepmotor Module.
Software:
```c
#include <M5Stack.h>
#include <Wire.h>
#define STEPPER_ADDRESS 0x30 // Default I2C address of the stepper motor module
void setup() {
  M5.begin();
  Wire.begin();
}
void loop() {
  // Set the stepper motor direction and speed
  Wire.beginTransmission(STEPPER_ADDRESS);
  Wire.write(0x01); // Set direction to clockwise
  Wire.write(0x10); // Set speed to 1000 steps per second
  Wire.endTransmission();
  
  // Move the stepper motor 1000 steps
  for (int i = 0; i < 1000; i++) {
    Wire.beginTransmission(STEPPER_ADDRESS);
    Wire.write(0x02); // Move one step
    Wire.endTransmission();
    delay(10);
  }
  
  delay(1000);
  
  // Change direction and move 500 steps
  Wire.beginTransmission(STEPPER_ADDRESS);
  Wire.write(0x00); // Set direction to counter-clockwise
  Wire.endTransmission();
  for (int i = 0; i < 500; i++) {
    Wire.beginTransmission(STEPPER_ADDRESS);
    Wire.write(0x02); // Move one step
    Wire.endTransmission();
    delay(10);
  }
}
```
Note: In these examples, you may need to adjust the baud rate, step resolution, and other settings depending on your specific stepper motor and application requirements.