Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Strange Stepper Speeds
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Strange Stepper Speeds

by royBattyJr on Sun Jul 12, 2020 8:41 pm

I'm using a NEMA-17 stepper (product 324) with a motor shield v2 (1438) and an Arduino Uno. I've experimented with a lot of different code, but this is the most basic version of what I'm running:

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include <Adafruit_MotorShield.h>

Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {

  AFMS.begin(9000);
  myMotor->setSpeed(18); //different results for the "setSpeed" value are listed later in this post

}

void loop() {
  myMotor->step(200, BACKWARD, DOUBLE);
}


The problem I'm having is that each RPM setting has a corresponding actual RPM output:

code RPMs - actual RPMs
1 - 34
2 - 48
3 - 55
4 - 23
5 - 21
6 - 66
7 - 23
8 - 37
9 - 71
10 - 18
11 - 21
12 - 26
13 - 30
14 - 35
15 - 42
16 - 55
17 - 60
18 - 74

All speeds above 18 are slower than 74 RPMs. There's no missed steps or slipping even with a load on it. If it were a clock speed problem, I would expect it to still ascend in speed rather than peaking at certain settings. I have multiple motor shields, steppers, power supplies, and arduinos I've tried it on so I don't think it's faulty hardware. Updating the libraries didn't make a difference. I'm out of ideas for things to try and figured it's time to ask for help. Mostly I'm looking for an explanation for why the speeds are weird. The weird speeds aren't a problem by themselves, but if whatever I'm doing wrong is preventing higher speeds, I'd like access to them.

royBattyJr
 
Posts: 1
Joined: Sun Jul 12, 2020 6:29 pm

Re: Strange Stepper Speeds

by adafruit_support_bill on Sun Jul 12, 2020 8:53 pm

The motor speed settings in the library are not very precise. The step rate calculations do not take into account the software or communications overhead. For more accurate timing, it is best to use millis() timing and OneStep, or the AccelStepper library.

There is also an upper limit imposed by the speed of the i2c bus. This is discussed in detail here: viewtopic.php?f=31&t=57041&p=292119

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.