charleslemaire0 / TeenAstro

an easy to build and use telescope controller
GNU General Public License v3.0
24 stars 21 forks source link

TMC5160 tuning #71

Open MasterPIC opened 1 year ago

MasterPIC commented 1 year ago

Hi Charles, I'm not sure about the value 64 used to switch from Stealth2 mode to SpreadCycle one

m_tmc5160->TPWMTHRS(64);

Let's assume 300 worm teeth and 4:1 reduction ratio.

  16MHz?
  t_clk=1/16e6 s

  // 24h - 3600s/h - 300 teeth - 4:1 red. ratio - 200 motor steps/rotation - 256 usteps
  1X (sid. speed) <-> ustep_period = 24*3600/300/4/200/256 = 0.001406 s
  t_step = 0.001406 s / t_clck = 22500 (= f_clk/f_usteps) @1X

  TPWMTHRS = 64 -> switch from Stealth2 to SpreadCycle @ 22500/64 X = 351.563X
  351.563X <-> 281RPM (1X <-> 0.8RPM)

  According to documentation possible jerk issues occur typically over 30 RPM (jerk is commonly neglected at 10-20-30RPM).

So let's assume to have jerk at 60X (48RPM) - TPWMTHRS = 64*351.563/60 = 375 I'd set m_tmc5160->TPWMTHRS(375);

More generally I see the need for taking into account the overall reduction ratio to properly set TPWMTHRS. So if you agree with me I would add a TMC5160 definition in TeenAstroCustomizations to allow TMC5160 tuning when desired.

charleslemaire0 commented 1 year ago

Hi Armando, I ask myself too what is the better value I assume it is better to switch wen the motors starts to rotate at high speed => this is not directly related to the gear Maybe before I change something could we have a discussion on the group with other user? Thanks