TMCStepper
TMCStepper copied to clipboard
Unable to get StallGuard to work
Hi, I'm using a TMC2209 v1.2 from Bigtreetech. I want to setup StallGuard and CoolStep. So far this is the code. I'm unable to get any StallGuard result, it just displays 0. Getting StallGuard and CoolStep up and running would be really helpful. Thanks.
#include <AccelStepper.h>
#include <MultiStepper.h>
AccelStepper stepper1(1, 11, 12);
MultiStepper StepperControl;
int position=0;
int Sleep = 13;
#include <TMCStepper.h>
TMC2209Stepper driver(&Serial1, 0.11f, 0b00);
using namespace TMC2209_n;
void setup()
{
pinMode(Sleep, OUTPUT);
digitalWrite(Sleep, LOW);
Serial.begin(115200);
Serial1.begin(115200);
driver.begin();
driver.toff(5);
driver.sedn(0b00);
driver.rms_current(1000);
driver.I_scale_analog(false);
driver.en_spreadCycle(false);
driver.intpol(true);
driver.microsteps(0);
driver.ihold(2);
driver.irun(10);
driver.iholddelay(5);
driver.TCOOLTHRS(0xFFFFF);
driver.semin(5);
driver.semax(2);
driver.sedn(0b01);
driver.SGTHRS(60);
driver.VACTUAL(500);
delay(300);
}
void loop()
{
Serial.println(driver.SG_RESULT());
delay(100);
}
StallGuard is quite complex and really needs to be deeply understood before you can make it work.
I made this Udemy course on the topic and cover StallGuard in great detail.
I wish I could help you really fast, but StallGuard is too complex to simply explain here, but my Udemy course does a very good job at it
And FYI, you can't use StallGuard AND CoolStep at the same time. It's one or the other