NEMA 17 Stepper Motor Test

Stepper Series — NaveTECH & UNIR Series — Episode # 13

J3
Jungletronics
3 min readFeb 2, 2024

--

Hello! Prepare your setup with a NEMA 17 stepper motor and a DRV8825 Driver. Arrange your protoboard in the following configuration:

See the connections schema for your convenience. CAUTION: When probing the pins, if a circuit is inadvertently closed, it can cause the driver to burn out. So, please be cautious!👀💥

To test the NEMA 17 12V stepper motor with your Arduino UNO board, you can use the following code. First, ensure you have the necessary connections set up correctly:

  • Connect the stepper motor’s control pins (MS1, MS2, MS3, STEP, and DIR) to the corresponding digital pins on your Arduino UNO.
  • Make sure the stepper motor is powered appropriately (12V DC like this).
  • Upload the code to your Arduino UNO board using the Arduino IDE or your preferred Arduino programming environment.
Controlling NEMA17 stepper motor without any library 👌. You got it!

This code is for controlling a stepper motor using an Arduino board, specifically for a NEMA17 stepper motor without any library and no gear reduction. Here’s a breakdown of the code:

  1. Pin Definitions: Pins ms1Pin, ms2Pin, and ms3Pin are defined to control the micro-stepping modes of the stepper motor driver; Pins stepPin and dirPin are defined to control the step and direction of the stepper motor;
  2. Constants: numSteps defines the number of steps required for a full 360-degree rotation of the stepper motor. In this case, it's set to 200 steps for a NEMA17 motor with a step angle of 1.8 degrees per step; rotations defines the number of rotations the motor should perform for each mode; delay1 sets the micro-delay between coil activations (in microseconds); delay2 sets the delay between subsequent rotations (in milliseconds);
  3. Setup Function: Initializes serial communication and sets the defined pins as output pins;
  4. Loop Function: The loop function contains several sections, each corresponding to a different micro-stepping mode; For each micro-stepping mode (full step, half step, quarter step, eighth step, sixteenth step, and thirty-second step), the direction pin is set, and the appropriate micro-stepping pins are configured; A for loop then generates the required number of steps for each mode, toggling the step pin on and off with the specified micro-delay between steps.
  5. Serial Output: Serial print statements provide feedback indicating the current micro-stepping mode.

Overall, this code allows you to test different micro-stepping modes of the stepper motor by adjusting the pin configurations and delays accordingly. Adjustments can be made to suit your specific motor and application requirements.

Crono the time ⏱ : Full (0.82s) — Half (0.94s) — Quarter (1.07s) — Eighth (2.09s) — Sixteenth (4.92s) — Thirty-second (9.07s); please compare with the 28BYJ48 on the previous episode #11.

That’s all folks!

👉GitHub (Projects #46)

Related Post:

12#Episode — 28BYJ-48 12 V Stepper Motor Test — Stepper Series — NaveTECH & UNIR Series

Credits & References:

12#Episode — 228BYJ-48 12 V Stepper Motor Test — Stepper Series — NaveTECH & UNIR Series

09#basicTronics — DRV8825 Driver & Stepper Motor 24BYJ48 — Operation & Theory

51#ArduSerie — Stepper Motors — Precise Position Control — The Great Benefit of Stepper Motors — No-H-Bridge or Closed Loop Needed

Stepper Motor — 28BYJ-48 By Achim Pieters

--

--

J3
Jungletronics

😎 Gilberto Oliveira Jr | 🖥️ Computer Engineer | 🐍 Python | 🧩 C | 💎 Rails | 🤖 AI & IoT | ✍️