teemuatlut / TMCStepper

MIT License
503 stars 196 forks source link

Are the blank_time values in TMCStepper.cpp correct? #239

Open moerchel opened 2 years ago

moerchel commented 2 years ago

Hi,

I wanted to set the blank time (TBL) and found in the code (TMCStepper.cpp) the following possible values:

void TMCStepper::blank_time(uint8_t value) {
  switch (value) {
    case 16: tbl(0b00); break;
    case 24: tbl(0b01); break;
    case 36: tbl(0b10); break;
    case 54: tbl(0b11); break;
  }
}

uint8_t TMCStepper::blank_time() {
  switch (tbl()) {
    case 0b00: return 16;
    case 0b01: return 24;
    case 0b10: return 36;
    case 0b11: return 54;
  }
  return 0;
}

The documentation of the TMC2208 and TMC2209 state that the values have to be 16, 24, 32 or 40. So I'm wondering if the values in the code are correct or do I have to use another function to set the TBL. I think the function

void TMC2208Stepper::tbl    ( uint8_t  B )  { SET_REG(tbl);     }

can be used to set the TBL using the digits 0, 1, 2, 3 which should translate to the correct values as mentioned in the documentation of the stepper drivers.

SobhanAbedi commented 2 years ago

Hi. Even if the numbers are incorrect, since the switch-case is translating {16, 24, 36, 54} into binaries of {0, 1, 2, 3} you could still use these functions as well. The only problem would be that the values you have to use in your program won't match the datasheet. BTW you could always modify the functions in the library as well.

moerchel commented 2 years ago

Thank you for the clarification. I'm currently using the "TMC2208Stepper::tbl( uint8_t B )" function to directy set the values of {0, 1, 2, 3} in order to not confuse the values used in the function "TMCStepper::blank_time(uint8_t value)" with the values given in the TMC220X documentation. So, I suppose that the values {16, 24, 36, 54} are used in other stepper driver ICs.