Skip to content

tmc2240: sin/cos phase offset calibration#7183

Draft
nefelim4ag wants to merge 1 commit intoKlipper3d:masterfrom
nefelim4ag:tmc2240-offset90
Draft

tmc2240: sin/cos phase offset calibration#7183
nefelim4ag wants to merge 1 commit intoKlipper3d:masterfrom
nefelim4ag:tmc2240-offset90

Conversation

@nefelim4ag
Copy link
Collaborator

@nefelim4ag nefelim4ag commented Jan 31, 2026

Coils can be unequal due to factory tolerances
This calibration allows us to make the motor symmetric, which will reduce rotor oscillation during rotation

For now, for easier testing.
Happy path looks like so:

G28
TMC_PHASE_OFFSET_CALIBRATE STEPPER=stepper_z
G0 Z105 F600
G0 Z5 F600
G0 Z105 F600
<output stabilizes at some value>
TMC_PHASE_OFFSET_CALIBRATE STEPPER=stepper_z
SAVE_CONFIG

For better results motor should be unloaded, for Z it is movement down.
For me, it stabilizes around:

// Test offset: -11 ~ 82 degree

*I have only one TMC2240, if I remember correctly, on the X motor, it was about the same value

I think it is a good idea to validate the accelerometer output before and after the offset with low accelerations.
To sample the whole speed/rotational range.

Thanks,
-Timofey


Testing can be done with:

git fetch origin pull/7183/head
git checkout FETCH_HEAD
sudo systemctl restart klipper

or by a simple copy of tmc2240.py content

Coils can be unequal due to factory tolerances
This calibration allows us to make the motor symmetric
Which will reduce rotor oscillation during rotation

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
@nefelim4ag
Copy link
Collaborator Author

nefelim4ag commented Feb 1, 2026

Just for the record, from available testing.
There is some dependency on speed, which is not intuitive to me.
So, the right speed is an open question.

*1RPS
OFFSET_90 does a thing, if calibrated wrong, rotor phases oscillate more:
image

At some point in calibration, it looks weird. I can't say it is better or worse; it seems smoother, but the amplitude is larger.
image

@nefelim4ag
Copy link
Collaborator Author

Okay, another data point, I though second time that they sound different, maybe better.
But I'm confused.
It is CoreXY, diagonal moves, on the one hand, I can count full steps and graphs are more smooth, there are less deep in the middle of the step, as in the graphs above.
On the other hand, again, the amplitude looks larger than before.

Stepper X
image

Stepper Y
image

@ifreislich
Copy link

Just some data. The results seem related to rotation speed.

3.3rps:
z: New offset: -1 ~ 89 degree
z1: New offset: -1 ~ 89 degree

2.4rps:
z: New offset: -9 ~ 84 degree
z1: New offset: -9 ~ 84 degree

2rps:
z: New offset: -2 ~ 89 degree
z1: New offset: -3 ~ 88 degree

1.5rps:
z: New offset: 1 ~ 91 degree
z1: New offset: 1 ~ 91 degree

@github-actions
Copy link

Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html

There are some steps that you can take now:

  1. Perform a self-review of your Pull Request by following the steps at: https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review
    If you have completed a self-review, be sure to state the results of that self-review explicitly in the Pull Request comments. A reviewer is more likely to participate if the bulk of a review has already been completed.
  2. Consider opening a topic on the Klipper Discourse server to discuss this work. The Discourse server is a good place to discuss development ideas and to engage users interested in testing. Reviewers are more likely to prioritize Pull Requests with an active community of users.
  3. Consider helping out reviewers by reviewing other Klipper Pull Requests. Taking the time to perform a careful and detailed review of others work is appreciated. Regular contributors are more likely to prioritize the contributions of other regular contributors.

Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available.

Best regards,
~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants