Repository navigation
Feature/stallguard autotune - #6
Merged
Merged
Conversation
Continuously cross-check StallGuard against the accelerometer and nudge SGTHRS so the tune self-corrects between calibrations. New "StallGuard Auto-Tune" switch (advanced group, default OFF) gates it; requires StallGuard + Vibration Stall Detection both on. Two directions, both small (+/-1 register step), clamped, logged, and counted via a new "Auto-Tune Adjustments" diagnostic: - RAISE (high confidence): when the vibration detector trips (its sustained-judder threshold = a real stall) but StallGuard did NOT fire this travel, StallGuard was too insensitive -> SGTHRS += step (ceiling 60). - LOWER (conservative): a StallGuard trip is cross-checked in sg_autotune_eval. If peak vibration this travel stayed below half the Vibration Threshold AND the trip was mid-travel (not near an end stop), it is counted as a probable false trip. Only after THREE consecutive such quiet trips -> SGTHRS -= step (floor 2). A vibration-agreeing trip or a clean full travel (limit reached) resets the streak, so a single missed-judder stall can't desensitize StallGuard. State: vib_run_peak + sg_fired_this_move reset at motion start, tracked in the vibration interval / on_stall; sg_quiet_streak and a persisted sg_autotune_count. A fresh Auto-Calibrate always overrides whatever auto-tune has drifted to. Config valid; full compile OK. Default OFF so behaviour is unchanged until enabled.
…, raise cap Add a "Speed" preset select (Motion Tuning) mapping Slow/Medium/Fast to 1200 / 2600 / 5500 steps/s, and demote the raw Speed slider to the advanced group (mirrors the Ropener pattern). Raise stepper_max_speed 1200 -> 5500 so Fast is reachable. Values chosen from an accelerometer resonance sweep of this mechanism (external measurement tool, not shipped): vibration is flat and quiet across the range EXCEPT a violent drivetrain resonance at ~2900-3300 (worst 3000-3100, peak ~1 g). All three presets avoid parking in that band; ramps cross it only transiently, which measured harmless (clean position tracking). The motor holds torque with no step loss all the way to 9000, but 6000+ free-run vibration exceeds the vib-stall threshold, so the product cap sits at 5500 (Fast) to stay clear of false trips. The select reads/writes global_speed (single source of truth, restored on boot); changing speed auto-flags the StallGuard calibration stale (SG_RESULT is speed-dependent). Verified on hardware: Slow->1200, Medium->2600, Fast->5500.
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.
No description provided.