This is how i have wired everything up (i am using a 12V PSU for the stepper motor which is 30watt / 2.5A)
the issue im having is the motor will spin one direction for x amount of them and then randomly it will spin in the opposite direction for 1/2 turns and then back to normal and for the life of me i cant figure out why. im using some very basic code from a tutorial i followed.
// Include the Stepper library:
#include <Stepper.h>
// Define number of steps per revolution:
const int stepsPerRevolution = 600;
// Initialize the stepper library on pins 8 through 11:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// Set the motor speed (RPMs):
myStepper.setSpeed(100);
}
void loop() {
// Step one revolution in one direction:
myStepper.step(200);
delay(2000);
}
// Step on revolution in the other direction:
// myStepper.step(-200);
// delay(2000);
// }
What you are seeing could be a resonance effect. That can be mitigated by microsteppnig the motor. Unfortunately that driver will not allow microstepping.
The L298 is NOT an appropriate driver for a modern bipolar stepper motor despite all the pages on the internet that use them. The L298 is a crappy ancient technology and inefficient DC motor driver and even worse as a stepper driver.
Please post a data sheet for the motor and we can help you to choose a better driver. If the coil current is lower than 2A the DRV8825 stepper driver is a good choice.
The drv8825 is good to 1.5A without a heat sink and active cooling (fan). With a heat sink (usually supplied with the driver) and a small fan for cooling the DRV8825 is good for up to 2.2A. You do not have to run the motor at max coil current. Running the motor at less than max will allow for cooler running of the motor and driver and extend their lives.
If you use the DRV8825 (or any other current controlling driver), make sure to set the coil current properly before use. The Pololu page has good instructions for setting the coil current on each of their product pages.
im not sure if the stepper motor will even have enough torque to be honest, this is just a project im playing with, im basically creating a automatic BB loader for my airsoft guns,
set amount of BBs via a roaary encoder, with number displayed on a oled screen, press enter and then either the stepper motor or another motor loads X amount of BBs
ive already got a 3d printed system so all i need to do is attach a 20tooth cog to either a stepper or dc motor and off i go
however it needs enough power / torque for when it gets towards the end of the magazine as a spring compresses.
To get maximum torque from the motor use a supply voltage that is as high as possible (45V for the DRV8825) and use the least microstepping possible. The driver will control the current. If you still don't have enough torque, there is always gearing. You can buy geared steppers with many ratios. A 5:1 gearbox will multiply your torque by 5 (but reduce speed proportionally).
Steppers are not efficient at all. They consume as much current when stopped as when running. Not the best choice for battery powered projects.
Do you need precise positioning? How precise?
For a battery powered device you may want to consider a geared DC motor with an encoder for positional feedback. You can get the positioning and torque, but with much better efficiency.
Not a DRV8825. Those are for steppers. You would need a driver for the motor, though. If the motor does not need to be reversed, you could use a simple MOSFET motor driver. Choose a MOSFET that can handle the stall current of the motor. The stall current should be listed on the motor's data sheet.
If the motor needs to be run in both directions, an H-bridge driver will be required. Pololu has a great line of DC motor drivers as well. You will need to pick a driver that will, gracefully, handle the stall current and motor power voltage to pick an H-bridge driver.