Working Stepper Library for Arduino Due

by titous on 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 442 times
titous
 
Posts: 62
Joined: Thu Jun 21, 2012 8:19 am

Re: Working Stepper Library for Arduino Due

by adafruit_support_bill on Sun Dec 30, 2012 6:27 am

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

Re: Working Stepper Library for Arduino Due

by daremick on 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

by daremick on 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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
// 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

by adafruit_support_rick on 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 | TOGGLE FULL SIZE
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: 11425
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Working Stepper Library for Arduino Due

by titous on 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 | TOGGLE FULL SIZE
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

by daremick on 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

by thekitty on 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)?
thekitty
 
Posts: 598
Joined: Sat Mar 24, 2012 7:56 pm
Location: Mid-Atlantic

Re: Working Stepper Library for Arduino Due

by titous on 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

Re: Working Stepper Library for Arduino Due

by ThaHypnotoad on Wed Dec 11, 2013 10:17 pm

Has anyone done this for regular dc motor driving with the v2.0 board? Or does it just work?
ThaHypnotoad
 
Posts: 2
Joined: Wed Dec 11, 2013 10:14 pm

Re: Working Stepper Library for Arduino Due

by adafruit_support_mike on Thu Dec 12, 2013 2:10 am

If you mean, "does the V2 Motor Shield just work for DC motors?" the answer is yes.

This page of the tutorial shows you how to do it: http://learn.adafruit.com/adafruit-moto ... -dc-motors
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9021
Joined: Thu Feb 11, 2010 1:51 pm

Re: Working Stepper Library for Arduino Due

by ThaHypnotoad on Fri Dec 13, 2013 12:40 am

No. No that is not what I meant at all. I thought that the general context of the thread would make it quite clear, but I guess I was wrong. What I meant was:
"Has anyone made a similar library for regular dc motor driving with the v2.0 board? Or does it just work with the due?"

The latter I have already found to be false. It doesn't just work with the due.
So does anyone have an answer to the former?

I guess I COULD try to make one, but being a highschooler during finals week I doubt I would have the time or strength to learn all the low level coding that would be necessary to do it.
ThaHypnotoad
 
Posts: 2
Joined: Wed Dec 11, 2013 10:14 pm

Re: Working Stepper Library for Arduino Due

by adafruit_support_mike on Fri Dec 13, 2013 4:32 am

Let me ask another question for clarification:

Do you want a library that runs on the Due and makes the v2 Motor Shield control DC motors, or do you want a library for some other platform (like the Uno)?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.
User avatar
adafruit_support_mike
 
Posts: 9021
Joined: Thu Feb 11, 2010 1:51 pm

Re: Working Stepper Library for Arduino Due

by adafruit_support_rick on Fri Dec 13, 2013 9:37 am

The V2 motor shield and the Adafruit_MotorShield library should work with the Due. I haven't tried it, but the code is written to work with the Due, and the shield itself is compatible.
What problems are you seeing?

Edit: Yes, I have tried it now. And it just works.
User avatar
adafruit_support_rick
 
Posts: 11425
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Working Stepper Library for Arduino Due

by bmears on Mon Jan 20, 2014 6:50 pm

Is it necessary to modify the motor shield to work with the 3.3V circuitry on the Arduino Due or will the shield auto-detect the correct level?
bmears
 
Posts: 3
Joined: Sun Oct 20, 2013 11:29 pm