MCU / Printerboard: tmc5160, all versions
Describe your issue:
The current TMC5160.py code hard sets the current sense values to 31. The datasheet for this driver is less than forthcoming on how to calculate the CS values. This issue may exist on other Trinamic drivers, but I have not investigated this.
The current code leaves CS out of the initial calculation of Globalscaler which has the result of effectively setting the CS value to 31 per page 74 of the datasheet, where (1+CS)/32 = 1.
The implications of this are that on some motor, driver, voltage combos, the correct hysteresis values can not be set in the driver. LDO 2804 motors particularly come to mind as many people implementing these motors at higher voltages find that they donāt run well, create VFAs at low speeds, are noisy, overheatā¦
Trinamic is not forthcoming with the fact that there is a tuning spreadsheet which gives us the CS value. The CS value needs to be set where the Rsense in cell C47 is +/-3% of the Rsense value. Once this is implemented, the rest of the spreadsheet can be used to effectively tune the chopper parameters.
For now I have created this code, which auto calculates the CS value based on Rsense.
There are likely to be negative consequences to implementing the code to auto calculate the CS value, after everyone has already tuned their drivers. Exposing the CS value as a user input would likely be the best option.
I would like feedback as to whether the code works as expected. Itās working on my machine, but I am using the drivers slightly outside of their recommendations. Please understand that drivers will need to be retuned when implementing this code. Failing to follow the tuning spreadsheet may result in device failure.
Spreadsheet here:
https://www.analog.com/media/en/engineering-tools/design-tools/TMC220x_TMC222x_Calculations.xlsx