tommag / TMC4210_Arduino

Arduino library for TMC4210 "Motion controller for stepper motor driver" IC.
MIT License
0 stars 1 forks source link

Stepper Frequencies over 32KHz didn't work #1

Open Frohnix opened 1 year ago

Frohnix commented 1 year ago

The stepper driver does not get above 32Khz in conjunction with an ATMega4809. 16MHz are at the clock input of the TMC4210 (measured with oscilloscope)

Frohnix commented 1 year ago

The problem seems to be the spiTransfer function. It only returns signed int (-32768 -> +32768). Probably it also writes only signed int. This would explain why the lib (on the ATMega4809 with MegaCoreX) can't handle large numbers.

tommag commented 1 year ago

I don't think I have used this lib with AVR platform and I've already had issues in the past with this platform having "small" data types. You may want to try using explicit int32_t instead of long and int64_t instead of long long. If you do so and it works feel free to submit a PR :)

Also watch out that the internal architecture of the TMC4210 chip (clock dividers for the ramp generators) means that you should be careful in the choice of the maxSpeed and maxAccel when initializing. Don't set accel too low IIRC.

Frohnix commented 1 year ago

I have tried everything. INT32/64,,,, All reasonable combinations. The main problem seems to be SPI read/write. Only signed integers are transferred. And there is an end at +/- 32k. I will save my life time and convert my project to the ESP32. Actually it's a pity, because the ATMega4809 doesn't need any external circuitry, so it can be easily used on a PCB, without external components.