Working Stepper Library for Arduino Due

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Working Stepper Library for Arduino Due

Postby titous » Sat Dec 29, 2012 6:59 pm

Hey ya'll,

I wrote up a quick library that will get steppers running on your Arduino Due with the fantastic Adafruit motor shield. Right now I've only got interleave stepping incorporated; in the future I plan on adding options for acceleration and possibly other features for those that want. The library isn't as pretty as the Adafruit one (agh I don't know how to do bitwise manipulations! :cry: ). However, this should get people going until someone comes out with a more complete library.

Just download the zip (below), open the Arduino IDE, click on Sketch --> Import Library... and select the downloaded zip! I even included a little example for you all to play with :)

Enjoy and let me know what you think!

Stepper.zip
v1.0
(2.38 KiB) Downloaded 141 times
titous
 
Posts: 62
Joined: Thu Jun 21, 2012 8:19 am

Re: Working Stepper Library for Arduino Due

Postby adafruit_support_bill » Sun Dec 30, 2012 6:27 am

Cool! Thanks for posting. :)
User avatar
adafruit_support_bill
 
Posts: 16072
Joined: Sat Feb 07, 2009 9:11 am

Re: Working Stepper Library for Arduino Due

Postby daremick » Fri Jan 04, 2013 8:24 pm

titous wrote:Hey ya'll,

I wrote up a quick library that will get steppers running on your Arduino Due with the fantastic Adafruit motor shield. Right now I've only got interleave stepping incorporated; in the future I plan on adding options for acceleration and possibly other features for those that want. The library isn't as pretty as the Adafruit one (agh I don't know how to do bitwise manipulations! :cry: ). However, this should get people going until someone comes out with a more complete library.

Just download the zip (below), open the Arduino IDE, click on Sketch --> Import Library... and select the downloaded zip! I even included a little example for you all to play with :)

Enjoy and let me know what you think!

Stepper.zip


That's awesome thanks so much for posting, I'm working on putting together a manual for this shield (http://arduino.cc/forum/index.php/topic,140631.0.html) Would it be OK if I include this library and credit you?
daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 9:17 pm

Re: Working Stepper Library for Arduino Due

Postby daremick » Fri Jan 04, 2013 9:24 pm

Quick question though, I loaded your code and tried to Verify before loading to the board and It came up with tons of errors.

---------------------------------

Code: Select all
StepperTest:10: error: no matching function for call to 'Stepper::Stepper(int)'
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:53: note: candidates are: Stepper::Stepper(int, int, int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:52: note:                 Stepper::Stepper(int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:49: note:                 Stepper::Stepper(const Stepper&)
StepperTest.cpp: In function 'void setup()':
StepperTest:15: error: 'class Stepper' has no member named 'enable'
StepperTest.cpp: In function 'void loop()':
StepperTest:20: error: 'class Stepper' has no member named 'stepOne'



---------------------------------


However when I made a few adjustments in compiled fine and loaded with no errors. Not sure what the difference is as I'm new to programming and sourced a few different places for stepper codes. Let me know if anyone can figure out what the deal is? lol.

-------------
The code after I adjusted it.


Code: Select all
// Example code to get a stepper to run on the Adafruit motorshield
// Send any questions to Constantino: constantino@photocs.net
// http://www.photocs.net


#include <Stepper.h>
const int stepsPerRevolution = 200;
long timeDelay = 900; // this variable controls speed; its the time (in microseconds) since the last step after which another step should occur.  adjust to the specs of your stepper
boolean dir = false; // controls the direction of spin
Stepper motor (stepsPerRevolution, 8,9,10,11);


void setup() {
  Serial.begin(9600);
  Serial.println("Yay steppers work on the Due!");
  motor.setSpeed(60); // get the motor ready
}


void loop() {
  motor.step (stepsPerRevolution); // let's keep looping through the step function!
  delay(200);
}
daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 9:17 pm

Re: Working Stepper Library for Arduino Due

Postby adafruit_support_rick » Sat Jan 05, 2013 12:50 pm

daremick wrote:Let me know if anyone can figure out what the deal is?


You seem to be compiling titous's example file with some other library named 'Stepper':
Code: Select all
StepperTest:10: error: no matching function for call to 'Stepper::Stepper(int)'
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:53: note: candidates are: Stepper::Stepper(int, int, int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:52: note:                 Stepper::Stepper(int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:49: note:                 Stepper::Stepper(const Stepper&)

This error is telling you that the library has no constructor that takes a single int argument, but that there are constructors that take 5 ints, or 3 ints, or a reference to another Stepper object.

But titous's library only has the single constructor taking a single int. So, you aren't actually using his library.
User avatar
adafruit_support_rick
 
Posts: 2907
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Working Stepper Library for Arduino Due

Postby titous » Sat Jan 05, 2013 12:54 pm

driverblock wrote:
daremick wrote:Let me know if anyone can figure out what the deal is?


You seem to be compiling titous's example file with some other library named 'Stepper':
Code: Select all
StepperTest:10: error: no matching function for call to 'Stepper::Stepper(int)'
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:53: note: candidates are: Stepper::Stepper(int, int, int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:52: note:                 Stepper::Stepper(int, int, int)
C:\Users\pc\Desktop\PHOTOS\arduino-1.0.1\libraries\Stepper/Stepper.h:49: note:                 Stepper::Stepper(const Stepper&)

This error is telling you that the library has no constructor that takes a single int argument, but that there are constructors that take 5 ints, or 3 ints, or a reference to another Stepper object.

But titous's library only has the single constructor taking a single int. So, you aren't actually using his library.


yep, you aren't using my library, you are using the standard Stepper library which was written for boards like the Uno... I should probably have named it something else, then again this library doesn't exist for the Due. Good luck!
titous
 
Posts: 62
Joined: Thu Jun 21, 2012 8:19 am

Re: Working Stepper Library for Arduino Due

Postby daremick » Sat Jan 05, 2013 6:31 pm

titous wrote:
yep, you aren't using my library, you are using the standard Stepper library which was written for boards like the Uno... I should probably have named it something else, then again this library doesn't exist for the Due. Good luck!


Oh, duh. I see that in your post now that it's for the Due and yes I am using the UnoR3 with the Stepper Library installed. That makes sense. Great code and I wish I had the Due to try it out, I'd still love to include it in the Motor Shield manual, If that's ok?
daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 9:17 pm

Re: Working Stepper Library for Arduino Due

Postby TheKitty » Sun Feb 10, 2013 9:36 pm

Probably a simplistic question on my part but is the 3v3 Due compatible with the voltages expected by the motor shield for signaling (data pins)?
Blog: http://21stdigitalhome.blogspot.com/ featuring microcontroller projects, including Arduino Esplora
TheKitty
 
Posts: 20
Joined: Sat Mar 24, 2012 7:56 pm
Location: Mid-Atlantic

Re: Working Stepper Library for Arduino Due

Postby titous » Sun Feb 10, 2013 11:10 pm

TheKitty wrote:Probably a simplistic question on my part but is the 3v3 Due compatible with the voltages expected by the motor shield for signaling (data pins)?


yep, i've run it successfully on the Due (that's why i wrote the library) ;)
titous
 
Posts: 62
Joined: Thu Jun 21, 2012 8:19 am


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: No registered users and 5 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [108]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[24]
 
XBee[10]
More Dev Boards[31]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[34]
LCDs & Displays[48]
Components & Parts[70]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[111]
 
Wireless[14]
Cables[62]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]