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:
10
src/main.cpp
10
src/main.cpp
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user