Working Stepper Library for Arduino Due

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
titous
 
Posts: 62
Joined: Thu Jun 21, 2012 9:19 am

Working Stepper Library for Arduino Due

Post by titous »

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 1021 times

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Working Stepper Library for Arduino Due

Post by adafruit_support_bill »

Cool! Thanks for posting. :)

daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm

Re: Working Stepper Library for Arduino Due

Post by daremick »

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 10:17 pm

Re: Working Stepper Library for Arduino Due

Post by daremick »

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: [email protected]
// 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);
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Working Stepper Library for Arduino Due

Post by adafruit_support_rick »

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.

titous
 
Posts: 62
Joined: Thu Jun 21, 2012 9:19 am

Re: Working Stepper Library for Arduino Due

Post by titous »

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!

daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm

Re: Working Stepper Library for Arduino Due

Post by daremick »

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?

User avatar
AnneBarela
Learn User Page
 
Posts: 757
Joined: Sat Mar 24, 2012 8:56 pm

Re: Working Stepper Library for Arduino Due

Post by AnneBarela »

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)?

titous
 
Posts: 62
Joined: Thu Jun 21, 2012 9:19 am

Re: Working Stepper Library for Arduino Due

Post by titous »

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) ;)

ThaHypnotoad
 
Posts: 2
Joined: Wed Dec 11, 2013 11:14 pm

Re: Working Stepper Library for Arduino Due

Post by ThaHypnotoad »

Has anyone done this for regular dc motor driving with the v2.0 board? Or does it just work?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Working Stepper Library for Arduino Due

Post by adafruit_support_mike »

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

ThaHypnotoad
 
Posts: 2
Joined: Wed Dec 11, 2013 11:14 pm

Re: Working Stepper Library for Arduino Due

Post by ThaHypnotoad »

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.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: Working Stepper Library for Arduino Due

Post by adafruit_support_mike »

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)?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Working Stepper Library for Arduino Due

Post by adafruit_support_rick »

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
bmears
 
Posts: 3
Joined: Mon Oct 21, 2013 12:29 am

Re: Working Stepper Library for Arduino Due

Post by bmears »

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?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”