How to enable pins

3,098 views
Skip to first unread message

brent

unread,
Mar 10, 2012, 7:08:18 PM3/10/12
to accelstepper
Hello,

I'm attempting to drive three stepper motors using an arduino mega and
quadstepper from sparkfun. I need to enable them in order for them to
move. How do I set my enable pins? The following is my code:

#include <AccelStepper.h>

// Define some steppers and the pins the will use
AccelStepper stepper1(1, 2, 23);
AccelStepper stepper2(1, 4, 27);
AccelStepper stepper3(1, 5, 29);

void setup()
{
stepper1.setMaxSpeed(11000.0);
stepper1.setAcceleration(10000.0);
stepper1.moveTo(6000);
stepper1.enableOutputs();

stepper2.setMaxSpeed(11000.0);
stepper2.setAcceleration(10000.0);
stepper2.moveTo(6000);
stepper2.enableOutputs();

stepper3.setMaxSpeed(11000.0);
stepper3.setAcceleration(10000.0);
stepper3.moveTo(6000);
stepper3.enableOutputs();
}

void loop()
{
// Change direction at the limits
if (stepper1.distanceToGo() == 0)
stepper1.moveTo(-stepper1.currentPosition());
if (stepper2.distanceToGo() == 0)
stepper2.moveTo(-stepper2.currentPosition());
if (stepper3.distanceToGo() == 0)
stepper3.moveTo(-stepper3.currentPosition());
stepper1.run();
stepper2.run();
stepper3.run();
}


Thank you,
Brent

Mike McCauley

unread,
Mar 10, 2012, 7:42:50 PM3/10/12
to accels...@googlegroups.com
Hello,

enableOutputs() sets the configured pins to output mode, so for example for
your stepper1 the call to stepper1.enableOutputs() sets pins 2 and 23 to
output mode and then uses them for pulsing the stepper.

Cheers.

--
Mike McCauley mi...@open.com.au
Open System Consultants Pty. Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia http://www.open.com.au
Phone +61 7 5598-7474 Fax +61 7 5598-7070

Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.

brent

unread,
Mar 10, 2012, 7:58:00 PM3/10/12
to accelstepper
Mike,

I believe the quadstepper requires the use of enable pins (that need
to be defined) in order to work. I've tried running the code that I
posted above with no results.. are you saying that it should work?

brent

unread,
Mar 10, 2012, 9:05:32 PM3/10/12
to accelstepper
I should have asked: how do I incorporate setEnablePin for each motor
into the code i posted above?

Mike McCauley

unread,
Mar 11, 2012, 3:29:39 AM3/11/12
to accels...@googlegroups.com
Hello,

AccelStepper does not manage enable pins for steppers,. You should set them
yourself.

Cheers.

Mike McCauley

unread,
Mar 12, 2012, 2:52:44 AM3/12/12
to accels...@googlegroups.com
Hi again,


Sorry, I gave the wrong answer.

If you configure an enable pin eg:
stepper.setEnablePin(7)

then pin 7 will be set/cleared when you call enableOutputs()/disableOutputs()

Cheers.

Reply all
Reply to author
Forward
0 new messages