Need Help Running a Nema 17 Stepper Motor

Hey guys, im at my wits end here trying to run a Nema 17 Stepper Motor off a 12 V 3 A battery pack. I followed this tutorial here from How To Mechatronics

Specs:
Motor: Nema 17 12 V 2 Amp Stepper Motor (17HS19-2004S1)
Driver Board: A4988 Driver
Arduino: Arduino (elegoo) Uno R3
Battery: Rechargable 12 V 3 Amp Battery Pack

The goal here is to make the stepper rotate 90 degrees every 2 hours for a total of 8 hours. However, even running code in the tutorial the motor either just vibrates or begins moving erratically, changing direction and speed at its own will. I have very little experience working with electronics before this so I know I am probably doing something stupid. If anyone could give me some advice id be very happy.
As of right now I have the arduino powered by cable from my computer and the driver board logic being powered by the 5 V from the arduino and the battery pack going into the VMOT and ground of the driver. Eventually I want the battery to power both but thats a later problem. I attached a picture of my circuit.

Please post schematics, not Fritzing type bird nests.
Please post code, alla according to: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Are you sure you want to do this with a battery? Your stepper motor must be fully powered the entire time or is will loose track of where the last setting was made.

yeah I have to, its for a school project and it has to be battery powered

Below is the diagram, minus the capacitor because I do not have one

Below is the example code from the tutorial that I am trying to run

const int stepPin = 3; 
const int dirPin = 4; 
 
void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(500); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(500); 
  }
  delay(1000); // One second delay
  
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}

Then you are going to turn off all the power except for a small time every two hours?

Edit: I just looked up the actual motor you have. Shows 2 amperes per phase/winding. The motor has 2 windings, the the normal, continuous current draw is 4 Amperes. Do you have the controller set properly for that current? That could certainly explain your problem!

1 Like

No the idea is that the battery will last long enough - once we get this working we are going to test that theory. If it doesn't last then yes, we will have to do something like that

No I do not! Thank you im going to look into that!!!

No that's not a diagram, rather what You were ask to not to post. "No Fritzing type"......
Pin positions on the circuit boards tells nothing. Pin labels, pin names do.
No powering of the Mega....

Hi,
What will the stepper shaft be driving?
When it is stationary is there any torque back from the load?

Tom.. :smiley: :+1: :coffee: :australia: