Hello, I was experimenting with a Nema 23 motor and a TB6600 microstepper driver along with the "Bounce" example from the AccelStepper library. I had wired up my components as shown here (scroll down a bit until you reach "Arduino and Stepper Motor Hookup" section). The only difference is that I'm not using a push button and a potentiometer, and also I hooked up the DIR- to pin 3 and PUL- to pin 5. I didn't connect the enable pins because I was following the example in the dronebotworkshop website. The gentleman suggested in the website that I didn't need to hook up the enable pins so that they are kept floating. I followed the instructions in the website exactly.
Upon turning on my power supply however, the motor won't rotate whatsoever. What could be the reason for this?
nashsth:
(scroll down a bit until you reach "Arduino and Stepper Motor Hookup" section). The only difference is that I'm not using a push button and a potentiometer, and also I hooked up the DIR- to pin 3 and PUL- to pin 5.
Sorry but that's no help.
Just make a simple pencil drawing showing exactly how YOU have connected everything and post a photo of the drawing. The business of making the drawing may even throw up something you have missed.
I didn't connect the enable pins because I was following the example in the dronebotworkshop website. The gentleman suggested in the website that I didn't need to hook up the enable pins so that they are kept floating.
Maybe he was wrong. It would only take a few minutes to try it with the enable pin set HIGH or LOW.
// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper(1,3,4); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
int EnPin = 2;
void setup()
{
// Change these to suit your stepper if you want
pinMode(EnPin, OUTPUT);
stepper.setMaxSpeed(100);
stepper.setAcceleration(20);
stepper.moveTo(500);
digitalWrite(EnPin,HIGH);
}
void loop()
{
// If at the end of travel go to the other end
if (stepper.distanceToGo() == 0)
stepper.moveTo(-stepper.currentPosition());
stepper.run();
}
Thank you for your response. I actually had connected the power supply ground to the arduino ground via a breadboard (which I neglected to draw; apologies for that -- I wanted to avoid cluttering the picture). This way, everything would be referenced to the same ground. My "3" happened to look like a "1" in the figure so I apologize for that as well. To clarify, pin 4 is connected to the PUL- pin, and Pin 3 is connected to the DIR- pin. Finally, pin 2 is connected to the EN- pin.
You were right that I mixed up the syntax for creating an AccelStep motor instant. In the website I linked, the gentleman stated that the way to create a stepper motor instance was to write AccelStepper mystepper(1,direction,step) whereas the actual code, according to this website is AccelStepper mystepper(1,step,direction)
Upon making the changes, my motor worked as expected.
Finally, the "1" in mystepper(1, step, direction) doesn't refer to a physical pin in the arduino -- instead, the "1" refers to the fact that I'm using a dedicated driver to drive my motor, and that the proper way to interface the AccelStep library with the driver is to use "1".
Thank you for your help! I will be sure to play around with your example code as well.
nashsth:
Finally, the "1" in mystepper(1, step, direction) doesn't refer to a physical pin in the arduino -- instead, the "1" refers to the fact that I'm using a dedicated driver to drive my motor, and that the proper way to interface the AccelStep library with the driver is to use "1".
No, use the defined constant the library supplies for you:
That is certainly the best way to use the library.
But, to avoid any confusion in the mind of the OP, the defined constant AccelStepper::DRIVER produces the value 1 which is why AccelStepper mystepper (1, step, direction) ; works