Nema 17 Stepper Motor Issues

Hi there,

I am an extreme noob to Arduino as well as stepper motors, so please bear with me and use simple words in the replies. I’m currently a Mechanical Engineering student working on an autonomous recycling sorter project for a class. I’m having issues getting my motor to turn both ways. The way I have the code and wiring set up, the motor will currently only turn clockwise but if I switch the polarity of the wiring, it will rotate counter-clockwise. I need it to rotate one direction and then pause for 1 second and rotate back the other direction. Is the issue with my code or with the way I have it wired? I’ve attached both set ups below. Thanks for the help, I appreciate it.

This is my code:

const int stepPin = 12;

const int dirPin = 11;

void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

}

void loop() {

stepperFWD();
for(int i = 0; i < 1000; i++){
motorStep();
delay(1);
}
delay(1000);
stepperREV();
for(int i = 0; i < 1000; i++){
motorStep();
delay(1);
}
delay(1000);
}

void stepperFWD(){
digitalWrite(dirPin, HIGH);
}

void stepperREV(){
digitalWrite(dirPin, LOW);
}

void motorStep(){
digitalWrite(stepPin, HIGH);
delay(1);
digitalWrite(stepPin, LOW);
}

You need to post a link to the datasheet for your motor. There are hundreds of different Nema 17 motors.

Also, what stepper motor driver are you using and what stepper motor power supply do you have (volts and amps).

Make a pencil drawing showing how you have connected everything and post a photo of the drawing.

...R
Stepper Motor Basics
Simple Stepper Code

Here is the link to where we purchased the motor pack: https://www.amazon.com/dp/B072N4FMRN/ref=sspa_dk_detail_3?psc=1&pd_rd_i=B072N4FMRN&pd_rd_wg=rQrCj&pd_rd_r=VKA1QJ6ZZYMCTDQ993FA&pd_rd_w=q8fK7

Here are the motor specifications:
Model No.:17HD48002H-22B
Step Angle: 1.8 deg
Holding Torque: 59Ncm(84 oz.in)
Rated Current/phase: 1.7A
Frame Size: 41 x 41mm
Body Length: 47mm
Shaft Diameter: 5mm
Shaft Length: 22mm
Weight: 380g

I’m using the drv8825 stepper motor driver and a battery pack of 8 alkaline AA batteries giving off 12 V. I can’t find out how many amps it gives off, but seems to be somewhere between 2400-3200 mAh.

The arduino is also plugged into my laptop for power.

Thanks for all the help, I’ve attached my drawing for you.

You need to check:

  1. Battery pack voltage isn't drooping significantly under load.
  2. Those hookup wires are able to handle the current (some are only rated for signals, not power)
  3. That your dirpin signal is making it onto the DRV8825 board (use a multimeter).

Image from Reply #2 so we don’t have to download it. See this Image Guide

628f97f50e5e19bbef9524733a54f1b2d3ac5180.jpg

…R

The DRV8825 is probably going to struggle with a 1.7 amp motor - you may need a heat sink and a cooling fan.

A motor that draws 1.7 amps per coil won't be long depleting some AA batteries. Stepper motors are very inefficient and not suited to battery power - unless you have something the size of a car battery.

...R

MarkT:
You need to check:

  1. Battery pack voltage isn't drooping significantly under load.
  2. Those hookup wires are able to handle the current (some are only rated for signals, not power)
  3. That your dirpin signal is making it onto the DRV8825 board (use a multimeter).

The battery pack voltage is dropping under load, this is an issue but I don't believe the one causing the motor to not rotate both ways. My group is looking into alternative ways to power the motor within the rules of the design project.

I think you may be on to something on the hookup wires, I just got them out of my roommate's electrical pack. I'm going to try to switch up the wires later today and see if anything changes. I will also use a multimeter to check the dirpin signal. Thanks for the help.

Not enough battery to finish the reply?

Robin2:
The DRV8825 is probably going to struggle with a 1.7 amp motor - you may need a heat sink and a cooling fan.

A motor that draws 1.7 amps per coil won't be long depleting some AA batteries. Stepper motors are very inefficient and not suited to battery power - unless you have something the size of a car battery.

...R

I have a heat sink on the DRV8825, and it seems to be staying at a relatively cool temperature while running. Do you have any recommendations on a different power source? We aren't allowed to use a car battery or an outlet.

I decided to rewire the system and switch around which wires I used for the dirpin, and it now turns both ways! Thanks to both of you for the help!!!

brianm4:
Do you have any recommendations on a different power source?

I guess you could use two or more packs of AA cells in parallel.

You may be able to get a high capacity LiPo battery pack but then you need a suitable LiPo charger because they can easily go on fire if mistreated - which included over-discharging them.

...R