Can you use AccelStepper with Arduino Motor Shield Rev 3?

2,141 views
Skip to first unread message

Per Ejeklint

unread,
Aug 25, 2012, 10:24:49 AM8/25/12
to accels...@googlegroups.com
Heya, total newbie on stepper motors here. Can you use this library with Arduino Motor Shield rev 3? I've tested a little but am not sure how to configure AccelStepper with this shield. I have a 4 wire bipolar stepper motor I want to drive. It *kind of* works, but not as smooth as I think it should.

Anyone has some insight to share? How do I initialize the AccelStepper for this board?

/Per

Mike McCauley

unread,
Aug 26, 2012, 4:36:44 PM8/26/12
to accels...@googlegroups.com
Hi,

If its kinda working but not smoothly, you may have your wiring sequence wrong
way round.

See http://www.stepperworld.com/Tutorials/pgBipolarTutorial.htm

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.

Ejeklint Per

unread,
Aug 27, 2012, 6:05:26 AM8/27/12
to accels...@googlegroups.com
I figured it out, eventually. Initialize with

AccelStepper stepper(2, 12, 13); // dir_a and dir_b pins used

and set the pwm outputs to HIGH and brakes to LOW in the setup function. Now it works just fine.

/Per

tony

unread,
Jan 3, 2013, 5:50:38 PM1/3/13
to accels...@googlegroups.com, per.ej...@gmail.com
What exactly did you do to get your stepper to work with the official arduino motor shield? i have a 4 wire nema 17 stepper motor and i'm trying to hook it up to the A, and B terminals on the board. 

jowan sebastian

unread,
Sep 4, 2013, 11:47:33 AM9/4/13
to accels...@googlegroups.com, per.ej...@gmail.com
took me a while !

but so glad to :

A - get rid of the very limited arduino stepper.h and use adaindusties accelstepper
B - be able to use actually use the 'official' arduino stepper shield for more than turning a motor round or thowing it in the bin




#include <AccelStepper.h>

AccelStepper stepper(2,12,13);

const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 8;
const int brakeB = 9;


void setup()

 
  pinMode(pwmA, OUTPUT);
  pinMode(pwmB, OUTPUT);
  pinMode(brakeA, OUTPUT);
  pinMode(brakeB, OUTPUT);
 
  digitalWrite(pwmA, HIGH);
  digitalWrite(pwmB, HIGH);
  digitalWrite(brakeA, LOW);
  digitalWrite(brakeB, LOW);
 
  stepper.setMaxSpeed(200);
  stepper.setSpeed(200);
 
  stepper.setAcceleration(200);
  stepper.moveTo(300);
 
 
}

void loop(){ 

  if (stepper.distanceToGo() == 0) {
    stepper.run();                   // let the AccelStepper to disable motor current after stop
    delay(2000);                     // wait 2 sec in final position
    stepper.moveTo(-stepper.currentPosition());
  }
  stepper.run();

}
Reply all
Reply to author
Forward
0 new messages