AccelStepper running at 20Mhz?

47 views
Skip to first unread message

Ross Waddell

unread,
Jun 13, 2025, 6:56:55 PMJun 13
to accelstepper
I’m using a TMC2208 SilentStepStick and would like to use the maximum micro stepping available to achieve 60rpm using a 10:1 gear reduction motor, but at 16Mhz I think the max micro stepping value is 8 - could I get to 16 with 20Mhz?

Geoff Smith

unread,
Jun 13, 2025, 7:58:00 PMJun 13
to accels...@googlegroups.com
If I'm reading your question correctly...
200 x 10 x 8 = 16,000 steps per second are required.

Typical MCU stepping speeds

run()          runSpeed()     MCU              MHz ?
4,191         14,865           UNO                8
3,851         12,130 ?        MEGA            16  
14,159       31,167           DUE               80
44,280        75,953          ESP32           240 
95,000                             Teensy 4        600

On Sat, 14 Jun 2025 at 08:56, Ross Waddell <ross.a....@gmail.com> wrote:
I’m using a TMC2208 SilentStepStick and would like to use the maximum micro stepping available to achieve 60rpm using a 10:1 gear reduction motor, but at 16Mhz I think the max micro stepping value is 8 - could I get to 16 with 20Mhz?

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/accelstepper/7e85a904-461d-4484-a1a7-2d52e18db9d5n%40googlegroups.com.


--
Regards

Geoff Smith

Jim Larson

unread,
Jun 14, 2025, 9:43:29 PMJun 14
to accelstepper
Geoff - 
Do you have a sketch that you could share to generate those numbers - and test other MCUs/"Arduinos"? It would be very useful!
Thanks!
             -jim
Message has been deleted

gjgsm...@gmail.com

unread,
Jun 15, 2025, 12:49:35 AMJun 15
to accelstepper
(Re-posted to correct small compile issue)

Jim,

This worked for me when I needed it but I haven't looked at it for a long time so it's offered 'as is'. Feel free to play with it as you want.
As you would know, because we are only inrterested in the MCU's stepping rate, no drivers or motors need to be connected, just enter your own parameters, open the serial monitor and run the program.

Geoff

/* Stepper Motor Performance Test
* Created by Geoff Smith 2019
* No Copyright
*
* Performance data only recorded for stepper1.
* Other steppers are included to load up the mcu stepping rate. REM out as required.
* ----------------------------------------------------------------------------------- */

#include <Arduino.h>
#include <AccelStepper.h>

int S1_dir1 = 18;
int S1_pul1 = 19;

int S2_dir1 = 32;
int S2_pul1 = 33;

int S3_dir1 = 25;
int S3_pul1 = 26;

int S4_dir1 = 16;
int S4_pul1 = 17;

AccelStepper stepper1(AccelStepper::DRIVER, S1_pul1, S1_dir1);
AccelStepper stepper2(AccelStepper::DRIVER, S2_pul1, S2_dir1);
AccelStepper stepper3(AccelStepper::DRIVER, S3_pul1, S3_dir1);
AccelStepper stepper4(AccelStepper::DRIVER, S4_pul1, S4_dir1);

uint32_t start_time = 0;
uint32_t accel_time = 0;

long i = 0;
long spd1 = 0;
long spd1Max = 0;
long nomSpeed = 0; // Speed recorded at the nominated step position.
long maxSpeedPosition = 0;
long finishPosition = 0;
long pulsesPerRevolution = 400; // User to set according to: motor_steps + gearing + microstepping.


// Enter your stepper variables here. ---------------------
long nomPosition; // nominated position at which the speed is recorded.
long targetPosition1 = 32000;
long acceleration1 = 20000; // Big number to get the stepper1 recorded 'spd1Max'
long maxSpeed1 = 20000; // Big number to get the stepper1 recorded 'spd1Max'
int travel_time = 0;

long targetPosition2 = 18000;
long acceleration2 = 24000;
long maxSpeed2 = 24000;

long targetPosition3 = 2000;
long acceleration3 = 8000;
long maxSpeed3 = 8000;

long targetPosition4 = 4000;
long acceleration4 = 8000;
long maxSpeed4 = 8000;

int button = 10; // Not used. Optional.


void setup()
{
   pinMode(button, INPUT_PULLUP);

   pinMode(S1_dir1, OUTPUT);
   pinMode(S1_pul1, OUTPUT);
   
   pinMode(S2_dir1, OUTPUT);
   pinMode(S2_pul1, OUTPUT);
   
   pinMode(S3_dir1, OUTPUT);
   pinMode(S3_pul1, OUTPUT);
   
   pinMode(S4_dir1, OUTPUT);
   pinMode(S4_pul1, OUTPUT);

   stepper1.setMinPulseWidth(20); // This is required for high speed MCU's. It's OK for all MCU's.
   stepper2.setMinPulseWidth(20);
   stepper3.setMinPulseWidth(20);
   stepper4.setMinPulseWidth(20);

   Serial.begin(9600);

   Serial.println();
   Serial.println();
   Serial.println("starting test");
   Serial.println();

   stepper1.setAcceleration(acceleration1);
   stepper1.setMaxSpeed(maxSpeed1);
   stepper1.moveTo(targetPosition1);

   stepper2.setAcceleration(acceleration2);
   stepper2.setMaxSpeed(maxSpeed2);
   stepper2.moveTo(targetPosition2);

   stepper3.setAcceleration(acceleration3);
   stepper3.setMaxSpeed(maxSpeed3);
   stepper3.moveTo(targetPosition3);

   stepper4.setAcceleration(acceleration4);
   stepper4.setMaxSpeed(maxSpeed4);
   stepper4.moveTo(targetPosition4);

   nomPosition = targetPosition1/2; // Halfway travel point, or modify as required.
   start_time = millis();
}


void loop()
{
   i = 0;
   spd1Max = 0;
   nomSpeed = 0;
   maxSpeedPosition = 0;
   finishPosition = 0;
   travel_time = 0;
   start_time = millis();

   while (stepper1.isRunning() || stepper2.isRunning() || stepper3.isRunning() || stepper4.isRunning())   //  || stepper2.isRunning() || stepper3.isRunning() || stepper4.isRunning()
   {
         i++;
          stepper1.run(); // User to modify if testing for 'runSpeed()'
          stepper2.run();
          stepper3.run();
          stepper4.run();

         if (stepper1.distanceToGo() == nomPosition)
            nomSpeed = stepper1.speed();

         if (stepper1.speed() > spd1Max)
            spd1Max = stepper1.speed();

         if (stepper1.speed() < maxSpeed1 && stepper1.currentPosition() < targetPosition1/2)
         {
            maxSpeedPosition = stepper1.currentPosition();
            accel_time = millis() - start_time;
         }

         if (stepper1.distanceToGo() == 0)  travel_time = millis() - start_time;
   }
   
   finishPosition = stepper1.currentPosition();  

Serial.print("Set Acceleration:\t");
   Serial.println(acceleration1);

   Serial.print("Set Max_Speed:\t\t");
   Serial.println(maxSpeed1);

   Serial.print("Stepper Pulses/REV:\t");
   Serial.println(pulsesPerRevolution);
   Serial.println();

   Serial.print("Target Position:\t");
   Serial.println(targetPosition1);

   Serial.print("Travel time:\t\t");
   Serial.println(travel_time);

   Serial.print("Main Loop count:\t");
   Serial.println(i);

   Serial.print("Max speed - Returned:\t");
   Serial.println(spd1Max);
   Serial.println();

   Serial.print("Nom Position:\t\t");
   Serial.println(nomPosition);

   Serial.print("Speed at Nom Position:\t");
   Serial.println(nomSpeed);
   Serial.print("Stepper rpm at Nom Pos:\t");
   Serial.println((nomSpeed*60.0/pulsesPerRevolution),0);
   Serial.println();

   Serial.print("Position: Max Speed:\t");
   Serial.println(maxSpeedPosition);

   Serial.print("Time to Max Speed:\t");
   Serial.println(accel_time);

   Serial.print("Finish Position: :\t");
   Serial.println(finishPosition);
   Serial.println();
   Serial.println();

 while(1);
}
Reply all
Reply to author
Forward
0 new messages