Arduino-Controlled Stepper and DC Motor with Relay and DRV8825 Driver
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary of the Circuit
This circuit is designed to control a Nema 17 stepper motor using a DRV8825 stepper motor driver, which is interfaced with an Arduino UNO microcontroller. Additionally, the circuit includes a 5V 8-channel relay module to control a DC motor and a power supply to provide the necessary voltage and current to the system.
Component List
Nema 17 Stepper Motor (42-STH48)
- A stepper motor used for precise control of angular or linear position, velocity, and acceleration.
DRV8825 Stepper Motor Driver
- A module that allows for precise control of stepper motors through simple step and direction inputs.
Arduino UNO
- A microcontroller board based on the ATmega328P, used for controlling the logic of the circuit and interfacing with the stepper motor driver and relay module.
DC Motor
- An electric motor that converts electrical energy into mechanical motion.
5V 8-Channel Relay Module
- A module that allows the Arduino UNO to control multiple high-power devices, such as the DC motor.
Power Supply
- Provides the required electrical power to the circuit components.
Wiring Details
Nema 17 Stepper Motor (42-STH48)
- A2 (black) -> DRV8825 (2B)
- A1 (Green) -> DRV8825 (2A)
- B2 (Red) -> DRV8825 (1A)
- B1 (Blue) -> DRV8825 (1B)
DRV8825 Stepper Motor Driver
- ENABLE -> Arduino UNO (D5)
- VMOT -> 5V 8-Channel Relay (C)
- GND -> Arduino UNO (GND)
- 2B -> Nema 17 Stepper Motor (A2 - black)
- 2A -> Nema 17 Stepper Motor (A1 - Green)
- 1A -> Nema 17 Stepper Motor (B2 - Red)
- 1B -> Nema 17 Stepper Motor (B1 - Blue)
- STEP -> Arduino UNO (D3)
- DIR -> Arduino UNO (D4)
Arduino UNO
- D5 -> DRV8825 (ENABLE)
- GND -> DRV8825 (GND)
- D3 -> DRV8825 (STEP)
- D4 -> DRV8825 (DIR)
- 5V -> 5V 8-Channel Relay (VCC)
- GND -> 5V 8-Channel Relay (GND)
- D8 -> 5V 8-Channel Relay (IN2)
- D6 -> 5V 8-Channel Relay (IN1)
DC Motor
- Pin 1 -> 5V 8-Channel Relay (NC)
- Pin 2 -> 5V 8-Channel Relay (C)
5V 8-Channel Relay Module
- GND -> Arduino UNO (GND)
- IN1 -> Arduino UNO (D6)
- IN2 -> Arduino UNO (D8)
- VCC -> Arduino UNO (5V)
- NC -> Power Supply (+)
- C -> DRV8825 (VMOT)
- NC -> DC Motor (Pin 1)
- C -> DC Motor (Pin 2)
Power Supply
- (+) -> 5V 8-Channel Relay (NC)
- (-) -> Not connected in the provided net list
Documented Code
// Pin assignments
const int stepPin = 3; // Stepper motor step
const int dirPin = 4; // Stepper motor direction
const int relayPin = 6; // Relay for DC motor
void setup() {
// Initialize stepper motor pins
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
// Initialize relay pin
pinMode(relayPin, OUTPUT);
// Set initial direction for the stepper
digitalWrite(dirPin, HIGH);
}
void loop() {
// Stepper motor control
for (int i = 0; i < 200; i++) { // 200 steps for one revolution (depends on your motor/driver)
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000); // Control speed by changing delay
digitalWrite(stepPin, LOW);
delayMicroseconds(1000);
}
delay(1000); // Wait between revolutions
// DC motor control via relay
digitalWrite(relayPin, HIGH); // Turn on DC motor
delay(5000); // Run for 5 seconds
digitalWrite(relayPin, LOW); // Turn off DC motor
delay(1000); // Wait before next cycle
}
The code provided is for the Arduino UNO microcontroller. It initializes the pins connected to the DRV8825 stepper motor driver and the relay module. The loop function controls the stepper motor by sending pulses to the stepPin and toggles the direction using the dirPin. It also controls the DC motor by activating the relay connected to relayPin.