Skip to content

Extend MKS servo module: auto-configure bus mode, status property, set_bitrate#199

Draft
felixwrz wants to merge 6 commits intomainfrom
mks-module-dev
Draft

Extend MKS servo module: auto-configure bus mode, status property, set_bitrate#199
felixwrz wants to merge 6 commits intomainfrom
mks-module-dev

Conversation

@felixwrz
Copy link
Copy Markdown

@felixwrz felixwrz commented Apr 16, 2026

Motivation

Make the MksServoMotor module usable on a multi-drop CAN bus without manual configuration, and expose enough status/control to diagnose and reconfigure drives from Lizard.

  • The 0xF5/0xF6 bus motion commands silently do nothing unless the drive is in SR_vFOC mode, which previously had to be set by the user before any motion would work.
  • There was no way to observe when a mode-change was rejected by the drive.
  • The CAN bitrate (0x8A) could not be changed from Lizard, making it awkward to match a drive's bitrate to the rest of the bus.

Implementation

Auto-configure bus mode and expose status (ebea0c4)

  • Constructor now sends MODE_SR_vFOC (0x05) on startup so 0xF5/0xF6 work out of the box.
  • Replaced the 0x05 magic MAX_MODE with named MODE_CR_OPEN/CLOSE/vFOC and MODE_SR_OPEN/CLOSE/vFOC constants; MAX_MODE is now defined in terms of MODE_SR_vFOC.
  • Added a status property (default STATUS_OK). The 0x82 response handler validates the 3-byte CRC and sets STATUS_SET_MODE_FAILED when the drive rejects the mode change.

set_bitrate method (73a82c4)

  • New send_set_bitrate(rate) wraps the 0x8A CAN command, clamped to MAX_BITRATE.
  • set_bitrate is exposed to Lizard as a string argument ("125K"/"250K"/"500K"/"1M", case-insensitive). Unknown rates are logged via echo and ignored.
  • Added BITRATE_125K/250K/500K/1M and MAX_BITRATE constants in the header.

Progress

  • The implementation is complete.
  • Tested on hardware (or is not necessary).
  • Documentation has been updated (or is not necessary).

felixwrz and others added 3 commits April 16, 2026 10:53
Constructor now sends SR_vFOC (0x05) so 0xF5/0xF6 bus motion commands
work out of the box. Adds named MODE_* constants to replace the 0x05
magic number, plus a Lizard-readable "status" property that reports
a non-zero STATUS_SET_MODE_FAILED code when the 0x82 response
reports a failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exposes the CAN 0x8A command as a Lizard method accepting a
human-readable rate string ("125K", "250K", "500K", "1M",
case-insensitive). Named BITRATE_* constants in the header
replace raw enum codes at the call site.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@felixwrz felixwrz added this to the 0.12.0 milestone Apr 16, 2026
@felixwrz felixwrz added the enhancement New feature or request label Apr 16, 2026
@felixwrz felixwrz requested a review from JensOgorek April 17, 2026 12:39
felixwrz and others added 3 commits April 17, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants