Hi,
I am trying to get the Accel_Constanspeed example to work with my motorshield v2.3.
The example uses both the Accelstepper and adafruit motorshield libraries, and I have the most recent versions of both.
When I run the sketch with the default settings, Astepper1.setSpeed(50); the stepper motor ticks slowly one step at a time. If I change the setSpeed value to 500 or 5000 or whatever I get the same result as with 50.
I have tried this with both a nema17 stepper from adafruit and one of a different brand.
I have no problem running the StepperTest example, so I know the stepper motor is connected correctly.
What am i missing?
Motorshield v2.3 Accel_Constanspeed example
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_carter
- Posts: 29483
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Motorshield v2.3 Accel_Constanspeed example
That's this example?
https://github.com/adafruit/Adafruit_Mo ... tSpeed.ino
Since it seems related to the AccelStepper library, please try asking that library author. See here for general info:
http://www.airspayce.com/mikem/arduino/ ... index.html
There's a link there to this, which appears to b where they handle support:
http://groups.google.com/group/accelstepper
https://github.com/adafruit/Adafruit_Mo ... tSpeed.ino
Since it seems related to the AccelStepper library, please try asking that library author. See here for general info:
http://www.airspayce.com/mikem/arduino/ ... index.html
There's a link there to this, which appears to b where they handle support:
http://groups.google.com/group/accelstepper
- hcgilje
- Posts: 75
- Joined: Fri Aug 15, 2008 8:51 am
Re: Motorshield v2.3 Accel_Constanspeed example
Hi,
thanks for the links.
I found a thread in the google group that pointed me to the problem:
https://groups.google.com/g/accelsteppe ... T11PfWAAAJ
For some reason the max speed defaults to 1 step per second, which is why I got the same ticking motion no matter which value the speed had.
So these lines have to be included in setup() before setting the speed:
I suggest you update the example included with motorshield library to reflect this.
I have a few related comments regarding controlling speed of a stepper motor using the motorshield v2.3
1.
I originally tried to change the speed in the StepperTest.ino example using
There seems to be no relation between the number given to SetSpeed and RPM as is claimed in the comment of the code. In fact there seems to be no correspondence between the the value of SetSpeed and the actual speed of the stepper motor.
2.
back to the Accel_Constantspeed example, which now works with the modification mentioned above.
If I change the stepmode from SINGLE to INTERLEAVE or MICROSTEP this affects the speed obviously.
I found in Adafruit_MotorShield.h that MICROSTEP defaults to 16 (can also be set to 8).
If I understood the code in Adafruit_MotorShield.cpp correctly INTERLEAVE halves the speed?
It would be nice if this was included in the comments for the stepperTest.ino code.
thanks for the links.
I found a thread in the google group that pointed me to the problem:
https://groups.google.com/g/accelsteppe ... T11PfWAAAJ
For some reason the max speed defaults to 1 step per second, which is why I got the same ticking motion no matter which value the speed had.
So these lines have to be included in setup() before setting the speed:
Code: Select all
Wire.setClock(400000L); //to allow for speeds up to 1000 steps/second
Astepper1.setMaxSpeed(1000.0f);
I have a few related comments regarding controlling speed of a stepper motor using the motorshield v2.3
1.
I originally tried to change the speed in the StepperTest.ino example using
Code: Select all
myMotor->setSpeed(10); // 10 rpm
There seems to be no relation between the number given to SetSpeed and RPM as is claimed in the comment of the code. In fact there seems to be no correspondence between the the value of SetSpeed and the actual speed of the stepper motor.
2.
back to the Accel_Constantspeed example, which now works with the modification mentioned above.
If I change the stepmode from SINGLE to INTERLEAVE or MICROSTEP this affects the speed obviously.
I found in Adafruit_MotorShield.h that MICROSTEP defaults to 16 (can also be set to 8).
If I understood the code in Adafruit_MotorShield.cpp correctly INTERLEAVE halves the speed?
It would be nice if this was included in the comments for the stepperTest.ino code.
- adafruit_support_carter
- Posts: 29483
- Joined: Tue Nov 29, 2016 2:45 pm
Re: Motorshield v2.3 Accel_Constanspeed example
Cool. Glad you figured it out. For updating the example, would you mind opening an issue in the Github repo:
https://github.com/adafruit/Adafruit_Mo ... ary/issues
You can add your other comments there as well.
https://github.com/adafruit/Adafruit_Mo ... ary/issues
You can add your other comments there as well.
Please be positive and constructive with your questions and comments.