Files
walker_control/plans/remove-stall-detection-branch.md
devdesk 3aec7250c9 Add branch plan documentation and sample current log data
- plans/remove-stall-detection-branch.md: Documents what was removed, data analysis, and next steps
- src/current_loggin.log: Sample current data showing clear stall signatures
2026-02-05 21:10:07 +02:00

3.0 KiB

Branch: feature/remove-stall-detection

Summary

Removed all stall detection logic to collect clean current data with new beefy PSU before reimplmenting simpler stall detection.

Problem

The original stall detection was overly complex with:

  • Delta-based spike detection with EMA averaging
  • Under-current detection
  • Repeated spike detection for oscillating patterns
  • Multiple timing thresholds and stabilization periods
  • 16 configuration parameters

This complexity was trying to compensate for a weak PSU that couldn't provide enough current, causing unreliable stall detection.

What Was Removed

config.h

  • STALL_DELTA_THRESHOLD
  • STALL_EMA_ALPHA
  • STALL_EMA_BASELINE
  • STALL_STABILIZE_MS
  • STALL_CONFIRM_MS
  • DISABLE_STALL_DETECT
  • STALL_UNDERCURRENT_THRESHOLD
  • STALL_UNDERCURRENT_MS
  • STALL_CANDIDATE_COUNT
  • STALL_CANDIDATE_WINDOW_MS

motor.h / motor.cpp

  • checkStall() function (~115 lines)
  • resetStallDetection() function
  • isStalled() method
  • setStallCallback() method
  • getPingpongStallReturn() method
  • All stall-related member variables

webserver.cpp

  • Stall warning UI banner
  • "Return on stall only" checkbox
  • stalled and ppStallReturn from status JSON

main.cpp

  • onMotorStall() callback function

What Was Added

  • CURRENT_LOG_INTERVAL_MS config (100ms)
  • Frequent current logging: CURRENT: R=%.2fA L=%.2fA dir=%d spd=%d
  • "Motor: STOPPED (manual)" message

Current Data Analysis

See src/current_loggin.log for sample data.

Running Current (motor moving freely)

  • Range: 0.67A - 2.64A
  • Average: ~1.5-2.0A

Stall Current (motor blocked at end stop)

  • Range: 16.8A - 21.0A
  • Average: ~17-18A

Key Observations

  1. Clear separation: Running ~2A vs Stall ~17A = 8.5x difference
  2. Fast transition: Stall spike happens within 1-2 samples (100-200ms)
  3. Initial spike: Can see 3.77A or 5.35A briefly before full stall current
  4. Gradual decay: Stall current trends down slightly over time (~21A → ~17A)

Next Step: Simple Stall Detection

Based on the clean data, implement a simple threshold-based stall detection:

Proposed Algorithm

IF motor is running (dir != 0 AND speed > 0):
    IF active_current > STALL_THRESHOLD for STALL_CONFIRM_SAMPLES:
        STALL DETECTED

Proposed Config (much simpler)

#define STALL_THRESHOLD 8.0f      // Amps - midpoint between 2A run and 17A stall
#define STALL_CONFIRM_SAMPLES 3   // Debounce: 3 samples = 300ms at 100ms interval

Why This Should Work

  • With beefy PSU, running current is stable ~2A
  • Stall current is clearly ~17A+
  • No need for EMA averaging or complex spike detection
  • Simple threshold + debounce is enough

Files Changed

File Lines Removed Lines Added
config.h 16 2
motor.h 26 0
motor.cpp 180 1
webserver.cpp 50 5
main.cpp 12 1
Total 284 9