Skip to content

tmc5262: Add stepper driver support#892

Open
rogerlz wants to merge 2 commits into
mainfrom
tmc5262-impl
Open

tmc5262: Add stepper driver support#892
rogerlz wants to merge 2 commits into
mainfrom
tmc5262-impl

Conversation

@rogerlz

@rogerlz rogerlz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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 support

New [tmc5262] driver module, with the notable differences from TMC2240/TMC5160 handled:

  • Mandatory PLL init via a klippy:connect handler
  • No GLOBALSCALER — current is set via CURRENT_RANGE + CURRENT_RANGE_SCALE + IRUN, auto-ranged to fit run_current
  • GCONF.step_dir set for external step/dir mode
  • Stall signal via DO_CONF.do0_stall / do1_stall (not GCONF.diag*_stall)
  • Temperature monitoring via the new temp_from_adc hook

Includes the driver module, unit tests, a klippy integration test pair (test/klippy/tmc5262.{cfg,test}), and a new [tmc5262] section in docs/Config_Reference.md.

tmc: Allow drivers to provide a chip-specific ADC->°C conversion

TMCErrorCheck.get_status() previously hardcoded the TMC2240 ADC formula (adc_value - 2038) / 7.7 for any driver exposing an adc_temp field. This adds an optional temp_from_adc(adc_value) -> celsius callable that a driver can attach to its mcu_tmc; if absent the default formula is used unchanged. No behavior change for any existing driver.

Test plan

  • Validated on hardware — NorthPrint3D TMC5262 stepstick on a BTT Octopus Pro V1.1
  • Running in production — 2x TMC5262 replacing TMC2240 on the X/Y axes
  • pytest test/test_tmc5262.py — 53 passed
  • klippy integration test pair (test/klippy/tmc5262.{cfg,test})

🤖 Generated with Claude Code

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
rogerlz force-pushed the tmc5262-impl branch 2 times, most recently from 6ea488b to d7a97a7 Compare June 17, 2026 02:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant