I've been searching the forums and the web on how to properly use the step, direction, and enable inputs of my stepper driver and to program them accordingly for use with the AccelStepper library.
Using the code below my stepper does not move at all.
Also I was wondering for:
stepper.enableOutputs();
Does .enableOutput need a pin assigned to it or is the goal of this just to enable/disable the stepper motor?
//accelstepper constant speed example has been altered and is being used
// not using default 4 wires setup, but instead using step, direction, and enable pins
// using TB6600 4A 9-42V stepper driver at 6400 pulses/rev (32 microsteps)
#include <AccelStepper.h>
// defines pins numbers
const int stepPin = 3;
const int directionPin = 4;
const int enablePin = 5;
// Define a stepper and the pins it will use
// 1 or AccelStepper::DRIVER means a stepper driver (with Step and Direction pins)
AccelStepper stepper(AccelStepper::DRIVER, stepPin, directionPin);
void setup()
{
Serial.begin(9600);
stepper.setEnablePin(enablePin);
stepper.enableOutputs();
stepper.setMaxSpeed(1000);
stepper.setSpeed(50);
}
void loop()
{
stepper.runSpeed();
}
knightridar:
I also used enableOutputs() in the setup code.
However, nothing moves at all.
Do you have any program that makes the motor move? If so please post that.
I never know whether the enable pin should be HIGH or LOW to make the motor move. You need to try both options.
This Simple Stepper Code can be used for testing - it does not use any library. If you don't have a program that gets the motor moving start with the first of my examples and stick with that until the motor moves properly. Always start with a very slow step rate.
I remembered I had a similar issue with an encoder stepper driver.
It had to do with the wiring and calling a LOW or HIGH based on how the stepper was wired.
Someone suggested it on the forum and that fixed it.
//accelstepper constant speed example has been altered and is being used
// not using default 4 wires setup, but instead using step, direction, and enable pins
// using TB6600 4A 9-42V stepper driver at 6400 pulses/rev (32 microsteps)
#include <AccelStepper.h>
// defines pins numbers
const int stepPin = 3;
const int directionPin = 4;
const int enablePin = 5;
// Define a stepper and the pins it will use
// 1 or AccelStepper::DRIVER means a stepper driver (with Step and Direction pins)
AccelStepper stepper(AccelStepper::DRIVER, stepPin, directionPin);
void setup()
{
Serial.begin(9600);
stepper.setEnablePin(enablePin);
stepper.setPinsInverted(false, false, true);
stepper.enableOutputs();
stepper.setMaxSpeed(1000);
stepper.setSpeed(200);
}
void loop()
{
stepper.runSpeed();
}