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! ). 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!
Working Stepper Library for Arduino Due
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88087
- Joined: Sat Feb 07, 2009 10:11 am
Re: Working Stepper Library for Arduino Due
Cool! Thanks for posting.
-
- Posts: 25
- Joined: Wed Sep 26, 2012 10:17 pm
Re: Working Stepper Library for Arduino Due
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?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! ). 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!
-
- Posts: 25
- Joined: Wed Sep 26, 2012 10:17 pm
Re: Working Stepper Library for Arduino Due
Quick question though, I loaded your code and tried to Verify before loading to the board and It came up with tons of errors.
---------------------------------
---------------------------------
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
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);
}
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Working Stepper Library for Arduino Due
You seem to be compiling titous's example file with some other library named 'Stepper':daremick wrote:Let me know if anyone can figure out what the deal is?
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&)
But titous's library only has the single constructor taking a single int. So, you aren't actually using his library.
-
- Posts: 62
- Joined: Thu Jun 21, 2012 9:19 am
Re: Working Stepper Library for Arduino Due
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!driverblock wrote:You seem to be compiling titous's example file with some other library named 'Stepper':daremick wrote:Let me know if anyone can figure out what the deal is?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.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&)
But titous's library only has the single constructor taking a single int. So, you aren't actually using his library.
-
- Posts: 25
- Joined: Wed Sep 26, 2012 10:17 pm
Re: Working Stepper Library for Arduino Due
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?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!
- AnneBarela
- Learn User Page
- Posts: 757
- Joined: Sat Mar 24, 2012 8:56 pm
Re: Working Stepper Library for Arduino Due
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)?
-
- Posts: 62
- Joined: Thu Jun 21, 2012 9:19 am
Re: Working Stepper Library for Arduino Due
yep, i've run it successfully on the Due (that's why i wrote the library)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)?
-
- Posts: 2
- Joined: Wed Dec 11, 2013 11:14 pm
Re: Working Stepper Library for Arduino Due
Has anyone done this for regular dc motor driving with the v2.0 board? Or does it just work?
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Working Stepper Library for Arduino Due
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
This page of the tutorial shows you how to do it: http://learn.adafruit.com/adafruit-moto ... -dc-motors
-
- Posts: 2
- Joined: Wed Dec 11, 2013 11:14 pm
Re: Working Stepper Library for Arduino Due
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.
"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.
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Working Stepper Library for Arduino Due
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)?
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)?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Working Stepper Library for Arduino Due
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.
What problems are you seeing?
Edit: Yes, I have tried it now. And it just works.
- bmears
- Posts: 3
- Joined: Mon Oct 21, 2013 12:29 am
Re: Working Stepper Library for Arduino Due
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?
Please be positive and constructive with your questions and comments.