board
Network cabinet fan controller
Public Unreviewedby matt
Two independently controlled 12 V fans, Ethernet and Wi-Fi, and an RGB speed display in a custom printed puck. Routed development preview, not approved for manufacture.
main
matt
Add MTA-156 input revision and document enclosure and cable-fit limits
16485bb
#pragma once
#include <cmath>
#include <cstdint>
#include <algorithm>
namespace fan_controller {
// Proposed curve for commissioning: never stop the fans; verify cabinet thermal performance.
struct Result { float duty; bool fault; };
inline Result decide(float temperature, uint32_t age_ms, uint32_t uptime_ms,
float rpm1, float rpm2, bool sensor_seen, bool full_override) {
bool stale = !sensor_seen || age_ms > 15000u;
bool bad_temp = !std::isfinite(temperature) || temperature < -20.0f || temperature > 100.0f;
// Ignore RPM during startup. Once established, missing/stalled tach forces maximum demand.
bool bad_tach = uptime_ms > 20000u &&
(!std::isfinite(rpm1) || !std::isfinite(rpm2) || rpm1 < 100.0f || rpm2 < 100.0f);
bool fault = stale || bad_temp || bad_tach;
if (fault || full_override || uptime_ms < 10000u) return {1.0f, fault};
float duty = std::clamp(0.35f + (temperature - 25.0f) * (0.65f/15.0f), 0.35f, 1.0f);
return {duty,false};
}
}