Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

Motorshield v2.3 Accel_Constanspeed example
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Motorshield v2.3 Accel_Constanspeed example

by hcgilje on Wed Apr 07, 2021 3:54 pm

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?

hcgilje
 
Posts: 65
Joined: Fri Aug 15, 2008 8:51 am
Location: Norway

Re: Motorshield v2.3 Accel_Constanspeed example

by adafruit_support_carter on Wed Apr 07, 2021 5:41 pm

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

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: Motorshield v2.3 Accel_Constanspeed example

by hcgilje on Thu Apr 08, 2021 4:01 am

Hi,
thanks for the links.
I found a thread in the google group that pointed me to the problem:
https://groups.google.com/g/accelstepper/c/DObiJe74L9k/m/8nT11PfWAAAJ
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 | TOGGLE FULL SIZE
Wire.setClock(400000L);  //to allow for speeds up to 1000 steps/second
Astepper1.setMaxSpeed(1000.0f);

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
Code: Select all | TOGGLE FULL SIZE
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.

hcgilje
 
Posts: 65
Joined: Fri Aug 15, 2008 8:51 am
Location: Norway

Re: Motorshield v2.3 Accel_Constanspeed example

by adafruit_support_carter on Thu Apr 08, 2021 10:26 am

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.

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.