-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
TMC2240 Stepper Driver fix and tune #27901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bugfix-2.1.x
Are you sure you want to change the base?
TMC2240 Stepper Driver fix and tune #27901
Conversation
5abd0b7
to
0e7d5e3
Compare
0e7d5e3
to
70ca79b
Compare
Can we host I'll get these changes pulled down and try out sensorless homing on the BX again. I've also pinged gonzo in the #trinamic channel on Discord to see if reboots are fixed for them. |
Tested with thinkyhead@70ca79b I cleared the M122 output after booting (Z1 & Z2 are active):
M122 report after a G28 and X & Y motors can move freely by hand / drivers are shutdown:
|
I don't have any plan to commit it. It is here in this PR for reference. |
This PR is for experimentation, so please try various adjustment to the TMC2240 initialization values to see if you can get to a point where it doesn't shut down when attempting to move a stepper by any distance at boot (e.g., The
It's not typically triggered by bad settings, but there are edge cases where driver settings might lead to false positives or exacerbate electrical conditions that trigger this:
More likely causes (hardware/wiring):
What to check:
|
I can command motors to move after a fresh boot without issue. The problem is that as soon as I try to home, X & Y drivers shut down. |
I can confirm reboot from leveling bed to event after G29 has been fixed. Drivers also act normal and run like a scalded dog. Name change another long story. |
We should remove the I also verified that |
The TMC2240 reference should be dropped from the first column since sensitivity values are -64 to 63 based on testing & the datasheet (h/t to @ellensp for confirming): Marlin/Marlin/Configuration_adv.h Lines 3470 to 3472 in 8230148
I moved a couple TMC2240s from my BX to my MK3S Bear and I'm experiencing the same issue with sensorless homing except motors stay engaged and drivers don't shutdown. They just trigger instantly on any value from -64 all the way to 63. Motors can be commanded to move after a homing attempt, but sometimes they buzz/don't move correctly. If I switch back to 5160s on my Bear, everything works as expected. |
Issue is not so simple. Marlin/Marlin/Configuration_adv.h Lines 3470 to 3472 in 8230148
tmc2240 has stallguard2 which is -64 to 64 current code does update sgt, which is stallguard2 |
e5e6067
to
f5c29c1
Compare
We'll get Stallguard2 sorted out before we get into Stallguard4, which has some extra complexities but also some extra goodies that could be useful in the future. |
Does Note: The opposite DIAG state required for TMC2209 might not apply to TMC2209 modules from every vendor, but currently it seems to be the standard. |
Indeed.
|
f5c29c1
to
112b79e
Compare
So we have some suggestions provided by ChatGPT. I will boil them down. Let me know how the driver behaves after experimenting with some of these suggestions.
What about the settings borrowed from Makerbase, you may ask? So I did. pwmconf.pwm_ofs = 29;
pwmconf.pwm_grad = 30;
pwmconf.pwm_freq = 0b00;
pwmconf.pwm_autoscale = true;
pwmconf.pwm_autograd = true;
pwmconf.freewheel = 0;
pwmconf.pwm_meas_sd_enable = false;
pwmconf.pwm_dis_reg_stst = false;
pwmconf.pwm_reg = 4;
pwmconf.pwm_lim = 12;
👍 Why this is better:
These values match what Trinamic shows in application notes for StealthChop-enabled axes (like X, Y, or Z) in 3D printing or CNC. 🛠 SuggestionTry using these PWM settings in your TMC2240 init, especially in combination with:
Also, log or monitor the |
Diag0 defaults to open drain, does the endstop pin have a pullup, and is the endstop configured as active low? Otherwise set the diag0_pushpull bit of the gconf register to 1 which also makes it active high. |
3791e7d
to
6ea4a16
Compare
112b79e
to
1f2e1f7
Compare
f73d12f
to
d81c359
Compare
The TMC2240 drivers I ordered will arrive tomorrow and then I can put them through various tests to find the best defaults for PWM, stealthChop, etc. I will also compare our settings to those of other softwares that support this model of stepper driver. And perhaps I can even get advice from a Trinamic engineer. I hear they are very friendly. |
b863484
to
4db4730
Compare
6acbd11
to
ec8497b
Compare
ec8497b
to
4cb7674
Compare
TMC2240 is brand new and there are still a lot of details to sort out with initialization, etc. This PR is for testing and feedback of TMC2240 performance until we can achieve optimum settings.