- 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
3.0 KiB
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_THRESHOLDSTALL_EMA_ALPHASTALL_EMA_BASELINESTALL_STABILIZE_MSSTALL_CONFIRM_MSDISABLE_STALL_DETECTSTALL_UNDERCURRENT_THRESHOLDSTALL_UNDERCURRENT_MSSTALL_CANDIDATE_COUNTSTALL_CANDIDATE_WINDOW_MS
motor.h / motor.cpp
checkStall()function (~115 lines)resetStallDetection()functionisStalled()methodsetStallCallback()methodgetPingpongStallReturn()method- All stall-related member variables
webserver.cpp
- Stall warning UI banner
- "Return on stall only" checkbox
stalledandppStallReturnfrom status JSON
main.cpp
onMotorStall()callback function
What Was Added
CURRENT_LOG_INTERVAL_MSconfig (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
- Clear separation: Running ~2A vs Stall ~17A = 8.5x difference
- Fast transition: Stall spike happens within 1-2 samples (100-200ms)
- Initial spike: Can see 3.77A or 5.35A briefly before full stall current
- 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 |