Just a few updates:
Full-Step Microstepping does work with the code below.
The issue is that the speed setting, which is done via the "VACTUAL" command seems to top out at around a value of "1200". After that, the stepper stalls and hums. Now, "VACTUAL" actually apparently refers to something related to the velocity, rather than the speed specifically - and it's unclear exactly to me what the correlation is with step-pulses.
I'm also noticing that the current maximum is set at 1200 and I'm wondering a bit about the correlation there. I know that the TMC is spec'd for a max of 2.8a - and I believe that the motor is spec'd at a max of 2a per phase (with two phases)... but with my particular TMC2209, it seems to max out at a voltage reading of 1.54v, when adjusting the trim - this means only a max current of 1.2a. Can anyone else confirm this?
More later.
#include "FastAccelStepper.h"
#include <TMCStepper.h>
#define STEP_PIN 2
#define DIR_PIN 15
#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
int current = 1200;
int stall = 10;
int accel = 800;
int max_speed = 19000;
int tcools = (3089838.00 * pow(float(max_speed), -1.00161534)) * 1.5; //*64 after max speed
int motor_microsteps = 16;
int motor_steps_per_rev = 200;
void setup() {
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
// INTITIALIZE SERIAL0 ITERFACE
Serial.begin(115200);
delay(500);
Serial.println(F("---------------------------------------------------"));
Serial.println(F("UART0 serial output interface intitialized @ 115200"));
// INITIALIZE SERIAL2 UART FOR TMC2209
SERIAL_PORT_2.begin(115200); // INITIALIZE UART TMC2209, SERIAL_8N1, 16, 17
Serial.println(F("UART2 interface for TMC2209 intitialized @ 115200"));
Serial.println(F("---------------------------------------------------"));
//TMCSTEPPER SETTINGS
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(current); // 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.mstep_reg_select(true);
read_ms();
driver.microsteps(motor_microsteps); //note that MicroPlyer will interpolate to 256
read_ms();
driver.TCOOLTHRS(tcools);
driver.seimin(1); // minimum current for smart current control 0: 1/2 of IRUN 1: 1/4 of IRUN
driver.semin(0);
driver.iholddelay(3); // 0 - 15 smooth current drop
driver.shaft(SHAFT);
driver.intpol(true); // interpolate to 256 microsteps
driver.SGTHRS(stall);
driver.pwm_autoscale(true); // Needed for stealthChop
driver.en_spreadCycle(false); // false = StealthChop / true = SpreadCycle, Spreadcycle can have higher RPM but is louder
driver.internal_Rsense(false);
driver.TPWMTHRS(0);
engine.init();
stepper = engine.stepperConnectToPin(STEP_PIN);
stepper->setDirectionPin(DIR_PIN);
stepper->setAutoEnable(true);
stepper->setSpeedInHz(max_speed);
stepper->setAcceleration(accel);
}
//***********************************************************************
void read_ms() {
uint16_t msread = driver.microsteps();
Serial.print("Microsteps: ");
Serial.println(msread);
}
//***********************************************************************
void loop() {
driver.microsteps(0);
read_ms();
driver.VACTUAL(1200); //SET SPEED OF MOTOR
delay(3000); // MOTOR MOVES 2 SEC THEN STOPS
driver.VACTUAL(0); //STOP MOTOR BY SETTING SPEED TO 0
delay(1000);
driver.microsteps(0);
read_ms();
driver.VACTUAL(-1200); //SET SPEED OF MOTOR
delay(3000); // MOTOR MOVES 2 SEC THEN STOPS
driver.VACTUAL(0); //STOP MOTOR BY SETTING SPEED TO 0
delay(1000);
}