Skip to content

tmc: Support sensorless homing via SPI - #992

Open
rogerlz wants to merge 1 commit into
mainfrom
rogerlz/spi-sensorless
Open

rogerlz wants to merge 1 commit into
mainfrom
rogerlz/spi-sensorless

Conversation

@rogerlz

@rogerlz rogerlz commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When no diag0_pin/diag1_pin is set on an SPI TMC driver (2130, 2240, 5160/2160), sensorless homing polls the stallguard flag over SPI instead of a DIAG pin. The MCU polls the stallguard flag (sg2 bit of the SPI status byte) at 1kHz during homing and triggers trsync directly.
  • Polling starts once the axis has reached homing speed (accel time + 50ms), since the flag is stale at standstill and noisy while accelerating.
  • Host TMC register reads are held off while the poll runs, so they don't interleave with it on the bus. Daisy chains are supported.
  • UART drivers keep raising the existing error.

Test plan

  • Unit tests for the chain status offset and the lock handling (test/test_tmc_homing.py)
  • tmc.test with no diag pin on the tmc5160, run locally with a freshly built atmega2560 dict. Not added to CI because the CI image dicts lack the new command.
  • Firmware builds for stm32h723 and atmega2560 with no warnings
  • Voron Trident (corexy), TMC5160 on software SPI, 0.8A, SGT 2, 60mm/s: three full G28 in a row; 30mm approaches repeat within 0.01mm (X) and 0.06mm (Y)
  • TMC2130 / TMC2240, hardware SPI, daisy chain (untested on hardware)

@dalegaard

Copy link
Copy Markdown
Contributor

I don't think there's any downside to always enabling this feature. Then if the user leaves out the diag pin, we register stall guard using SPI, and otherwise we keep the old functionality.

Over time, we should deprecate pin polling, as SPI is strictly better and makes auto configuration of stall guard sensitivity much easier to implement.

/Lasse

@rogerlz
rogerlz force-pushed the rogerlz/spi-sensorless branch from de25d89 to fcf8bd6 Compare October 5, 2026 07:59
@rogerlz rogerlz changed the title tmc: Support sensorless homing without a DIAG pin tmc: Support sensorless homing via SPI Oct 5, 2026
When no diag pin is configured on an SPI driver, the virtual_endstop
makes the mcu poll the stallguard flag from the SPI status byte during
homing and trigger trsync directly, for boards without the DIAG line
wired.

Signed-off-by: Rogerio Goncalves <rogerlz@gmail.com>
@rogerlz
rogerlz force-pushed the rogerlz/spi-sensorless branch from fcf8bd6 to 113e33a Compare October 5, 2026 12:29

This branch has not been deployed

No deployments
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.

2 participants