feat: add simple stall detection with threshold + debounce

- Add STALL_THRESHOLD (8A) and STALL_CONFIRM_SAMPLES (3) config
- Add 500ms stabilization delay after direction change to prevent false positives
- Add stall warning banner in web UI
- Stop motor and pingpong when stall detected

Algorithm: If active current > 8A for 3 consecutive samples (300ms),
and motor has been running for at least 500ms, trigger stall callback.
This commit is contained in:
devdesk
2026-02-05 21:29:38 +02:00
parent 3aec7250c9
commit dffb859826
5 changed files with 119 additions and 2 deletions

View File

@@ -4,6 +4,13 @@
#include "motor.h"
#include "webserver.h"
// Called when motor stall is detected
void onMotorStall() {
Serial.println("Stall callback triggered - stopping motor!");
motor.stop();
motor.stopPingpong();
}
void setupWiFi() {
Serial.println("Connecting to WiFi...");
@@ -39,11 +46,12 @@ void setup() {
Serial.println("\n=============================");
Serial.println(" BTS7960 Motor Controller");
Serial.println(" (Stall Detection Removed)");
Serial.println(" Simple Stall Detection");
Serial.println("=============================\n");
// Initialize motor controller
motor.begin();
motor.setStallCallback(onMotorStall);
// Connect to WiFi
setupWiFi();