Extend MKS servo module: auto-configure bus mode, status property, set_bitrate#199
Draft
Extend MKS servo module: auto-configure bus mode, status property, set_bitrate#199
Conversation
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>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Motivation
Make the
MksServoMotormodule usable on a multi-drop CAN bus without manual configuration, and expose enough status/control to diagnose and reconfigure drives from Lizard.SR_vFOCmode, which previously had to be set by the user before any motion would work.Implementation
Auto-configure bus mode and expose status (ebea0c4)
MODE_SR_vFOC(0x05) on startup so0xF5/0xF6work out of the box.0x05magicMAX_MODEwith namedMODE_CR_OPEN/CLOSE/vFOCandMODE_SR_OPEN/CLOSE/vFOCconstants;MAX_MODEis now defined in terms ofMODE_SR_vFOC.statusproperty (defaultSTATUS_OK). The0x82response handler validates the 3-byte CRC and setsSTATUS_SET_MODE_FAILEDwhen the drive rejects the mode change.set_bitratemethod (73a82c4)send_set_bitrate(rate)wraps the0x8ACAN command, clamped toMAX_BITRATE.set_bitrateis exposed to Lizard as a string argument ("125K"/"250K"/"500K"/"1M", case-insensitive). Unknown rates are logged viaechoand ignored.BITRATE_125K/250K/500K/1MandMAX_BITRATEconstants in the header.Progress