Fixed CoolStep

This commit is contained in:
JonathanS 2019-01-01 21:09:14 +01:00
parent 158ba22514
commit 5ab406bd3c
1 changed files with 10 additions and 15 deletions

View File

@ -124,7 +124,7 @@ void setup(){
myStepper.set_seimin(1); // 1/4 of IRUN
myStepper.set_TCOOLTHRS(900);
myStepper.set_TCOOLTHRS(0xFFFFF);
myStepper.set_THIGH(100);
@ -137,7 +137,7 @@ void setup(){
myStepper.set_vhighchm(1);
myStepper.set_vhighfs(1);
myStepper.set_VDCMIN(300);
myStepper.set_VDCMIN(50);
myStepper.set_DCCTRL(dc_time, dc_sg);
@ -174,24 +174,19 @@ void loop(){
uint32_t current = (drv_status >> 16) & 0x1f;
if (gstat || (drv_status >> 24 & 0x0F)) {
Serial.print("ALARM: GSTAT=");
Serial.print(gstat, HEX);
uint32_t drv_status = 0;
myStepper.read_REG(TMC_REG_DRV_STATUS, &drv_status);
Serial.print(" DRV_STATUS>>24=");
Serial.println((drv_status >> 24) & 0x0F, HEX);
Serial.print("ALARM: DRV_ERR=");
Serial.print((drv_status >> 24 & 0x0F), HEX);
}
int32_t lost_steps;
myStepper.read_REG(TMC_REG_LOST_STEPS, &lost_steps);
myStepper.read_REG(TMC_REG_LOST_STEPS, &lost_steps);
uint32_t tstep;
myStepper.read_REG(TMC_REG_TSTEP, &tstep);
uint8_t sgflag = (drv_status >> 24) & 1;
if (sgflag) Serial.println("SG STOP!!!");
static int32_t last_lost_steps = 0;
@ -207,7 +202,7 @@ void loop(){
Serial.print(tstep);
Serial.print(" SGFLAG=");
Serial.print((drv_status >> 24) & 1);
Serial.print(sgflag);
Serial.print(" Stallguard =");
Serial.print(stallguard);