The follow code does seem to work better. I misinterpreted the "setSpeedInUs" control at first, it needs to be descending in value (in microseconds)..
Using this code, the motor seems to eventually reach a speed that it finds unsustainable and starts to crash out, for lack of a better term. It gets substantially noisier and more "vocal" when this happens.
Just to make sure I understand a few things correctly:
//this sets a maximum or target speed?
stepper->setSpeedInUs(90); // the parameter is us/step !!!
//does this perpetually accelerate, even once the max speed is reached?
stepper->setAcceleration(1000);
//this is the total number of steps before the motor just stops ? is it necessary?
stepper->move(100000);
I will look a little closer at the documentation for FastAccelStepper to hopefully answer these questions. Full code below for people playing along at home.
#include "FastAccelStepper.h"
#include <TMCStepper.h>
// As in StepperDemo for Motor 1 on AVR
//#define dirPinStepper 5
//#define enablePinStepper 6
//#define stepPinStepper 9 // OC1A in case of AVR
// As in StepperDemo for Motor 1 on ESP32
#define dirPinStepper 15
#define stepPinStepper 2
#define RXD2 16
#define TXD2 17
#define SHAFT true
#define SERIAL_PORT_2 Serial2 // TMC2208/TMC2224 HardwareSerial port - pins 16 & 17
#define DRIVER_ADDRESS_1 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f // E_SENSE for current calc, SilentStepStick series use 0.11
FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;
TMC2209Stepper driver(&SERIAL_PORT_2, R_SENSE, DRIVER_ADDRESS_1); // Create TMC driver
void setup() {
driver.begin();
driver.pdn_disable(true); // Use PDN/UART pin for communication
driver.toff(5); // [1..15] enable driver in software
driver.blank_time(24); // [16, 24, 36, 54]
driver.I_scale_analog(false); // Use internal voltage reference
driver.rms_current(1500); // motor RMS current (mA) "rms_current will by default set ihold to 50% of irun but you can set your own ratio with additional second argument; rms_current(1000, 0.3)."
driver.microsteps(1);
engine.init();
stepper = engine.stepperConnectToPin(stepPinStepper);
if (stepper) {
stepper->setDirectionPin(dirPinStepper);
//stepper->setEnablePin(enablePinStepper);
stepper->setAutoEnable(true);
// If auto enable/disable need delays, just add (one or both):
// stepper->setDelayToEnable(50);
// stepper->setDelayToDisable(1000);
stepper->setSpeedInUs(90); // the parameter is us/step !!!
stepper->setAcceleration(1000);
stepper->move(1000000);
}
}
void loop() {}