tmc5262: Add stepper driver support#892
Open
rogerlz wants to merge 2 commits into
Open
Conversation
TMCErrorCheck.get_status() previously hardcoded the TMC2240 ADC formula `(adc_value - 2038) / 7.7` for any driver that exposes an `adc_temp` field. Drivers with a different ADC width or scaling - for example the TMC5262 (9-bit ADC, formula `1.042*v - 264.6`) - had no way to use the shared monitor without reporting bogus temperatures. This adds an optional `temp_from_adc(adc_value) -> celsius` callable that drivers can attach to their `mcu_tmc` instance. TMCErrorCheck reads it via `getattr` at construction; if absent (TMC2240 and all existing drivers), the default formula is used unchanged. No behavior change for any existing driver. Signed-off-by: Rogerio Goncalves <rogerlz@gmail.com>
rogerlz
force-pushed
the
tmc5262-impl
branch
2 times, most recently
from
June 17, 2026 02:50
6ea488b to
d7a97a7
Compare
Adds Kalico support for the ADI/Trinamic TMC5262 stepper driver:
65V/4.25A RMS, integrated MOSFETs, integrated current sense, SPI-only.
Validated on hardware (NorthPrint3D stepstick on Octopus Pro V1.1) and
in production (2x TMC5262 replacing TMC2240 on the X/Y axes).
Notable differences from TMC2240/TMC5160:
* Mandatory PLL init via klippy:connect handler.
* No GLOBALSCALER - current via CURRENT_RANGE + CURRENT_RANGE_SCALE +
IRUN, auto-ranged to fit run_current.
* GCONF.step_dir must be set for external step/dir mode.
* Stall signal via DO_CONF.do0_stall / do1_stall (not GCONF.diag*_stall).
* Temperature monitoring uses the new temp_from_adc hook.
Includes:
* klippy/extras/tmc5262.py - driver module
* test/test_tmc5262.py - unit tests
* test/klippy/tmc5262.{cfg,test} - integration test pair
* docs/Config_Reference.md - new [tmc5262] section
Signed-off-by: Rogerio Goncalves <rogerlz@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Kalico support for the ADI/Trinamic TMC5262 stepper driver (65V / 4.25A RMS, integrated MOSFETs, integrated current sense, SPI-only).
This branch is two commits:
tmc5262: Add stepper driver supportNew
[tmc5262]driver module, with the notable differences from TMC2240/TMC5160 handled:klippy:connecthandlerGLOBALSCALER— current is set viaCURRENT_RANGE+CURRENT_RANGE_SCALE+IRUN, auto-ranged to fitrun_currentGCONF.step_dirset for external step/dir modeDO_CONF.do0_stall/do1_stall(notGCONF.diag*_stall)temp_from_adchookIncludes the driver module, unit tests, a klippy integration test pair (
test/klippy/tmc5262.{cfg,test}), and a new[tmc5262]section indocs/Config_Reference.md.tmc: Allow drivers to provide a chip-specific ADC->°C conversionTMCErrorCheck.get_status()previously hardcoded the TMC2240 ADC formula(adc_value - 2038) / 7.7for any driver exposing anadc_tempfield. This adds an optionaltemp_from_adc(adc_value) -> celsiuscallable that a driver can attach to itsmcu_tmc; if absent the default formula is used unchanged. No behavior change for any existing driver.Test plan
pytest test/test_tmc5262.py— 53 passedtest/klippy/tmc5262.{cfg,test})🤖 Generated with Claude Code