Ради вашего удобства наш сайт использует cookies! Узнать больше! Мы используем cookies

AFEC - Advanced Adaptive ECU

AFEC - Adaptive Feedback-Based Engine Controller This is AFAC (Adaptive Feedback Engine Control), a fully feedback-based ECU for Stormworks modular engines. It's a complete closed-loop engine management system that handles RPM targeting, throttle control, air/fuel mixture correction, adaptive clutch engagement, stall recovery, and overheat protection, all in one microcontroller. Designed to be dropped into any modular engine build and work out of the box with minimal tuning. Disclaimer: This controller is experimental and under active development. Since it's a closed-loop feedback system, there are inherent limitations. I'll be trying to improve it in the future, so feedback and bug reports are welcome. —————————————————————————————————— Features Refer to the project slides for performance graphs showing behavior under load, high-RPM stability, adaptive clutch engagement, and side-by-side comparisons against other popular workshop ECUs. - Closed-loop PID RPM control with velocity-augmented error and anti-windup - Automatic engine size adaptation via fuel-flow gain tracking - Stoichiometric air/fuel mixture correction with NA/turbo detection - Adaptive smart clutch that gates on throttle headroom and backs off on stall - Confidence-based starter hold that extends after repeated stalls - Progressive overheat protection with force override - Adjustable throttle response curves for both control modes - Supports both direct throttle and RPS target control - Adapts to any cylinder count modular engine —————————————————————————————————— Why Feedback? Most Stormworks ECUs use either pure PID or feed-forward lookup. PID only reacts to RPM error and often needs retuning when the engine changes. Feed-forward avoids this, but it can struggle to adapt to new conditions. This controller aims to solve both of those issues. PID handles RPM, while adaptive layers adjust gains based on fuel use, correct mixture in real time, and limit setpoints to what the engine can physically achieve. The downside is added complexity and delay; the feedback only knows what's happening at the moment and can't compute gains in advance, as a feedforward would. But for Stormworks, where engine setups vary widely, it can be worth using this kind of model. —————————————————————————————————— Architecture The controller runs six subsystems every tick: [b]Setpoint profiler[/b] takes the raw RPS target and smooths it with an adaptive slew rate. The rate slows down when the engine is falling behind, preventing the target from running away from the actual RPM. [b]Gain adaptation[/b] tracks the ratio between actual fuel consumption and commanded fuel flow, then uses it to compute a gain multiplier that scales the entire PID. This is what lets it auto-tune for different engine sizes without touching the PID constants. [b]PID controller[/b] computes throttle from the profiled setpoint vs actual RPM. Uses a 2-tick averaged P term to suppress Nyquist jitter, a nonlinear P-boost for large errors, load scheduling to reduce gain at steady state, and conditional integration that only winds up when output is unsaturated. [b]Stoichiometry controller[/b] runs in parallel, integrating the mixture error between a filtered AFR reading and the computed air/fuel ratio. Filter speeds adapt based on whether the engine is NA or charged (detected from manifold pressure). Its output biases the final air/fuel split in the manifold. [b]Rate limiter[/b] smooths the throttle output with an adaptive slew that scales with the gain multiplier and gets extra bandwidth during large load steps. [b]Clutch and starter[/b] run as downstream consumers. Smart clutch gates engage on throttle headroom and disengage on stall. Starter uses a confidence counter with an adaptive hold time that extends after each stall. —————————————————————————————————— Instructions [b]Setup:[/b] Connect everything to the controller and make sure the composite signal comes straight from the cylinder. Manifold pressure is optional; you can split a pressure sensor off the air manifold if you'd like to utilize it. Microcontroller Property Description Control Method Toggle between direct throttle or throttle-to-RPS target mapping RPS at Min Throttle RPS target at 0 throttle input (idle). Controller interpolates between min and max. RPS at Max Throttle RPS target at full throttle input (max power) Direct Throttle Min Minimum throttle output in direct mode. Never drops below this. Direct Throttle Max Maximum throttle output in direct mode Direct Throttle Curve Strength Shapes the response curve. 0 = linear, 10 = max curve. Better low-end precision. RPS Target Curve Strength Same curve shaping, applied to the RPS target mapping instead Overheat Prevention Mode Enables progressive throttle reduction above the threshold. Force override by pushing the throttle forward more. Overheat Prevention Threshold Temperature where protection kicks in. The throttle reduces progressively over the next 10 °C. Smart Clutch Mode Adaptive clutch that gates on throttle headroom and backs off on stall. Disable for forced fixed-rate ramp. Clutch Ramp Rate Rate of clutch engagement. Higher = faster. Applies to both smart and forced modes. Engine P / I / D PID tuning constants. Shouldn't need to change because gain adaptation handles engine sizing, but it's tunable just in case. Advanced Debug Stats Displays tooltips on the controller with real-time internals: gain mult, error terms, stoich integrator, filtered values. —————————————————————————————————— Credits [b]Creations Used[/b] [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2531669451&searchtext=pre+made+modular+engines]Thumbnail Engines[/url] [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3297781076]Thumbail XML Engine[/url] —————————————————————————————————— Usage You can use this controller and its code in any of your builds and modify it however you'd like. All I ask is that you credit me or link the page in your workshop description. —————————————————————————————————— Tags (ignore) modular engine controller, ECU, engine controller, throttle controller, RPS controller, adaptive ECU, modular engine ECU, stormworks ECU, engine logic, vehicle controller, FADEC, PID controller, clutch controller, feedback ECU, closed loop ECU