Skip to content

Microstepping not having any effect #95

@fadion

Description

@fadion

I have a setup with 2 stepper motors and 2 Bigtreetech TMC2209 v1.3 connected to a Pi Pico (RP2040). The drivers are in bidirectional communication with the Pico using the RX and TX (via a 1kΩ resistor), and all is working fine. I can configure both drivers and read configuration options. Using AcceslStepper, I can also send step/dir pulses to run the motors. Motor power is 20v coming in from an external power supply.

The only thing that is baffling me is microstepping. No matter what microsteps I set, the motor speed is basically the same. It seems like the driver is stuck on the default configuration (1/8 I believe) and using setMicrostepsPerStep or setMicrostepsPerStepPowerOfTwo doesn't have any effect. I'm not doing any scientific way of testing, but setting the speed to 2000 steps per second should yield vastly different RPM for full step in contrast to 1/64. On my tests, they spin the same.

I'm upgrading from A4988 drivers and with those, the whole setup was working as intended. In full step, I was comfortably getting about 800 RPM, which is the target speed of one of the motors.

This is some test code I've isolated just to easily play around with the settings. Nothing out of the ordinary. Any ideas?

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

const byte spinEablePin = 10;
const byte spinDirPin = 6;
const byte spinStepPin = 7;
const byte carrEnablePin = 11;
const byte carrDirPin = 14;
const byte carrStepPin = 15;

AccelStepper spinStepper(AccelStepper::DRIVER, spinStepPin, spinDirPin);
AccelStepper carrStepper(AccelStepper::DRIVER, carrStepPin, carrDirPin);
SerialUART &serial = Serial1;
TMC2209 spinDriver;
TMC2209 carrDriver;

void setup() {
  Serial.begin(9600);
  pinMode(spinDirPin, OUTPUT);
  pinMode(spinStepPin, OUTPUT);
  pinMode(carrDirPin, OUTPUT);
  pinMode(carrStepPin, OUTPUT);

  spinDriver.setup(serial, 115200, TMC2209::SERIAL_ADDRESS_0, 13, 12);
  spinDriver.setHardwareEnablePin(spinEablePin);
  spinDriver.moveUsingStepDirInterface();
  spinDriver.setMicrostepsPerStepPowerOfTwo(0);
  spinDriver.setReplyDelay(5);
  spinDriver.enable();

  carrDriver.setup(serial, 115200, TMC2209::SERIAL_ADDRESS_1, 13, 12);
  carrDriver.setHardwareEnablePin(carrEnablePin);
  carrDriver.moveUsingStepDirInterface();
  carrDriver.setMicrostepsPerStep(8);
  carrDriver.setReplyDelay(5);
  carrDriver.enable();

  spinStepper.setMaxSpeed(3000);
  spinStepper.setAcceleration(1000);
  spinStepper.moveTo(-2000000);

  // carrStepper.setMaxSpeed(5000);
  // carrStepper.setAcceleration(500);
  // carrStepper.moveTo(2000000);
}

void loop() {
  spinStepper.run();
  // carrStepper.run();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions