Output Devices

Week 10

Stepper Motors, DRV8825 Driver & PCB Design

Schematic Editor

Group Page

  • Measure the power consumption of an output device.
  • Document your work on the group work page and reflect on your individual page what you learned.
Group Page

What I knew before this week:

  • Thanks to previous weeks, I was already familiar with the board fabrication process.
  • I had never worked with any type of motor, although I knew their internal workings from a previous course.
  • I had no prior experience with output devices, so this topic is completely new to me.

Board Purpose: The purpose of the board is to control two stepper motors using DRV8825 drivers.

Software Used

# Software Use
1 KiCad Board design (Schematic Capture & PCB Design).
2 Modsproject CE Converting SVG files to machine files (MonoFab).
3 VPanel for SRM-20 Operating the MonoFab machine.
4 Arduino IDE Software to program my ESP32 S3.

Materials

Component Qty Value / Model Library / Footprint
A2_M2, A3_M1B12Pololu Breakout DRV8825Module:Pololu_Breakout-16
C1110 μF (C_1206)PCM_fab:C_1206
C2, C32Electrolytic 100uF (Panasonic)PCM_fab:CP_Elec_100uF
J11Screw Terminal (01x02)PCM_fab:TerminalBlock_OnShore
J2, J3, J43Pin Header 1x04 (Vertical)PCM_fab:PinHeader_01x04_P2.54mm
J61Pin Header 1x02 (Vertical)PCM_fab:PinHeader_01x02_P2.54mm
M11XIAO ESP32-C3PCM_fab:SeeedStudio_XIAO_ESP32C3
R1 - R1010Resistor 1206 (0 Ω for jumpers)PCM_fab:R_1206
U11AMS1117 RegulatorPackage_TO_SOT_SMD:SOT-223

DRV8825 Driver

For this project, the DRV8825 driver was used, which features 16 pins with specific functions for motor control:

  • Enable: Connected to an output on the XIAO ESP32-C6.
  • M0, M1, M2: Control micro-stepping; each goes to a different digital output on the XIAO.
  • Reset & Sleep: Connected together internally to the 3.3V source.
  • Step: Receives the step count from a XIAO pin.
  • Dir: Defines the rotation direction from a XIAO pin.
  • VMOT: Direct power input (12V) for the motors.
  • GND: Two common grounds connected together.
  • B2, B1, A1, A2: Outputs connected to the stepper motor coils.
DRV8825 Connection

Breadboard Testing

Recommendation: When working with unknown components, always check the datasheet for connection diagrams and test the circuit on a breadboard first to verify functionality before manufacturing the PCB.

Breadboard test 1 Breadboard test 2

Final Schematic

Board Schematic

Board Editor

KiCad Optimization: I discovered an option to pre-configure track widths, which saves significant time during design.

Predefined tracks

Predefined track configuration.

Design rules must set the minimum value among all defaults to avoid errors.

Design Rules

New Techniques Applied

Trace Widths: I configured 0.8 mm for signal lines (ESP32S3 and 3.3V) and 1.5 mm for power lines (12V and GND) to handle higher current loads and prevent overheating.

Board Setup

"Flip" Technique for Through-hole Components

To make soldering easier on a single-sided board, I placed the female pins (for drivers and MCU) on the back side. This allows the pins to pass through the board to be soldered comfortably on the copper side.

Design Note: This must be done before routing, as flipping creates a mirror effect on the pin layout.

Pin layout before flip
Pin layout before flip

Pin layout after applying the flip technique.

Routing Challenges

Managing connections for the DRV8825 was the biggest challenge due to the high density of pins, which caused traces to cross frequently.

Final Board Layout

Final PCB Layout

Results

Soldered Board

[Video 1: Board in operation]

[Video 2: Arduino IDE app Screen]

Power consumption

Power Control and Calibration: DRV8825

To control the NEMA 17 stepper motors (model 17HS4401), I used the DRV8825 driver[cite: 1]. One of the fundamental characteristics of this module is its ability to manage independent power supplies: a low-voltage logic signal for communication with the microcontroller and a high-power supply for motor movement[cite: 1].

Power management

Current Adjustment via Vref

To ensure optimal operation and avoid thermal damage, it is crucial to limit the current that the driver delivers to the motor[cite: 1]. The DRV8825 features a precision potentiometer (adjustable with a screwdriver) that regulates the reference voltage (Vref)[cite: 1]:

  • Clockwise: Reduces the amperage delivered[cite: 1].
  • Counter-clockwise: Increases the amperage delivered[cite: 1].

Theoretical Calculation of Reference Voltage (Vref)

Based on the motor's datasheet, the maximum current is 1.7A[cite: 1]. However, to protect the driver and improve efficiency, it is recommended to work at a safety current (Ichop), usually calculated at 71% of the motor's total capacity[cite: 1].

Safety current calculation

We use the formula provided by the driver manufacturer[cite: 1]:

DRV8825 Formula

Where:

  • Rsense: Is the value of the sensing resistor on the module (commonly 0.100 in standard models)[cite: 1].
  • Ichop: Is 71% of the nominal current (1.7A × 0.71 = 1.207A)[cite: 1].
Current values

By knowing most values and solving for Vref (which is the value we must measure with the multimeter on the potentiometer), we ensure the driver's longevity[cite: 1]. If the value is too low, it won't work; if it's too high, there is a risk of burning the driver or the motor[cite: 1].

Vref calculation
Final Vref value

Final Vref value set to approximately 0.6V.

Importance of Calibration

Setting the Vref to approximately 0.6V is vital for two reasons[cite: 1]:

  • Undercurrent: If the voltage is too low, the motor will not have enough torque and will lose steps[cite: 1].
  • Overcurrent: If the voltage is excessive, the driver will overheat quickly, activating its thermal protection or permanently damaging the motor windings[cite: 1].

What I learned this week:

  • I learned to design a PCB to control two stepper motors with DRV8825 drivers, differentiating trace widths for signals (0.8 mm) and for 12V power/GND lines (1.5 mm) to handle higher current without overheating.
  • I learned the "Flip" technique in KiCad to place through-hole components on the back of the board, facilitating soldering from the copper side on single-sided boards.
  • I learned to calibrate the DRV8825 potentiometer by calculating the correct Vref (≈0.6V) using the datasheet formula, knowing that a voltage too low won't move the motor and one too high will burn the driver.

What I learned from the group page:

  • I learned that all motor types (DC, servo, and stepper) require an external power source and a driver IC, as they demand much more current than a GPIO pin can safely provide.
  • I understood that stepper motors consume current even at rest (holding current), which generates heat; therefore, it is advisable to disable the driver when holding is not necessary.
  • I learned to use three measurement instruments depending on the context: the USB Tester for USB-powered devices, the multimeter in series for measuring current in non-USB circuits, and the clamp meter for high currents without opening the circuit.

Code Used

Breadboard Test (Two Drivers)

Note: In this test, pins M0, M1, and M2 were not connected.

#include <AccelStepper.h>

#define STEP_PIN_1    D1
#define DIR_PIN_1     D0
#define ENABLE_PIN_1  D3
#define STEP_PIN_2    D8
#define DIR_PIN_2     D7
#define ENABLE_PIN_2  D6

#define FULL_STEPS_PER_REV 200
#define MICROSTEP          1

const long TEST_STEPS = FULL_STEPS_PER_REV * MICROSTEP;
const float MAX_SPEED  = 1000.0;
const float ACCEL      = 2000.0;
const float CONT_SPEED = 750.0;

AccelStepper stepper1(AccelStepper::DRIVER, STEP_PIN_1, DIR_PIN_1);
AccelStepper stepper2(AccelStepper::DRIVER, STEP_PIN_2, DIR_PIN_2);

bool continuousMode = false;

void enableDrivers(bool enable) {
  digitalWrite(ENABLE_PIN_1, enable ? LOW : HIGH);
  digitalWrite(ENABLE_PIN_2, enable ? LOW : HIGH);
}

void setup() {
  Serial.begin(115200);
  pinMode(ENABLE_PIN_1, OUTPUT);
  pinMode(ENABLE_PIN_2, OUTPUT);
  enableDrivers(true);
  stepper1.setMaxSpeed(MAX_SPEED);
  stepper1.setAcceleration(ACCEL);
  stepper2.setMaxSpeed(MAX_SPEED);
  stepper2.setAcceleration(ACCEL);
}

void loop() {
  if (Serial.available()) {
    char cmd = Serial.read();
    switch (cmd) {
      case '1': continuousMode = false; stepper1.moveTo(stepper1.currentPosition() + TEST_STEPS); stepper2.moveTo(stepper2.currentPosition() + TEST_STEPS); break;
      case '0': continuousMode = false; stepper1.stop(); stepper2.stop(); break;
    }
  }
  if (continuousMode) { stepper1.runSpeed(); stepper2.runSpeed(); }
  else { stepper1.run(); stepper2.run(); }
}

Files I used this week

These are the files I utilized for my assignments this week.

w10_output_files.zip

Output Devices Files

  • KiCad Project: Design files
  • SVG Files: For fabrication
  • Mods Files: RML for MonoFab
  • Arduino Code: Test scripts
Download Zip