I am trying to do a similar thing as this post but for some reason my stepper motor won't spin. To summarize the problem-space, I am programming a mini-Rambo controller (basically a souped up Atmega2560) to control three NEMA 17 stepper motors. Right now, I am attempting to just drive on of them for testing. My sketch uploads just fine, but there is no movement from the motor. Below is the code I am uploading:
void AccelStepper::setEnablePin ( uint8_t enablePin = 0xff )
Sets the enable pin number for stepper drivers. 0xFF indicates unused (default). Otherwise, if a pin is set, the pin will be turned on when enableOutputs() is called and switched off when disableOutputs() is called.
void AccelStepper::enableOutputs ( )
Enable motor pin outputs by setting the motor pins to OUTPUT mode. Called automatically by the constructor. If the enable Pin is defined, sets it to OUTPUT mode and sets the pin to enabled.
This second one I call for sanity as it is called by the constructor by default.
I thought I saw/hear the stepper motor wiggle once when I went from setting the pin from HIGH to LOW, but I can't replicate the movement. I still seem to be stuck.
You should never be relying on code in a constructor to work driving pins, constructors are often called before the Arduino runtime itself is initialized. Constructors can initialize the value of instance variables, but not much more.
Try this Simple Stepper Code - with suitable adjustments for the pin numbers and the code for the enable pin.
Are you sure your stepper driver is not damaged. They are easily destroyed if the wire between the driver and the motor is disconnected even briefly while the driver is powered.
ordo1234:
Unfortunately the simple stepper code did not work. I tried some of the code from
That is what I call the scatter-gun approach to debugging. It doesn't work.
My simple stepper code works. If it doesn't work for you then trying another program just adds confusion without making any effort to pinpoint the problem.
ordo1234:
I only have this single driver. Are there any tests I can do with just this driver?
Not that I am aware of.
Buy a few more. And if the one you have is an A4988 I suggest you get DRV8825 drivers as they are plug compatible and can handle a bit more motor current for much the same price.