Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r5ce558e3f4df026c6a28bc03220d4c2641c4b5ff -r164caef29ce2882549068277843aae33298d6ef2 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 5ce558e3f4df026c6a28bc03220d4c2641c4b5ff) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 164caef29ce2882549068277843aae33298d6ef2) @@ -17,6 +17,7 @@ ***************************************************************************/ #include "string.h" // for memset(), memcpy() +#include "math.h" #include "gio.h" // hal headers #include "sci.h" @@ -769,24 +770,22 @@ void setFPGAD48PumpSpeed( U16 speed ) { #ifdef __MAXON_SPEED_UPDATE__ - { + #ifdef __NEW_D48_PUMP__ /* Diener Silencer 1000 pump (D48): map commanded RPM to FPGA PWM counts * using characterization: PWM(FPGA) = (D48_NEW_PUMP_PWM_SLOPE * RPM + D48_NEW_PUMP_PWM_INTERCEPT) * * D48_NEW_PUMP_PWM_FULL_SCALE. * This yields ~10% duty (≈120 RPM) at the low end and ~90% duty (≈2800 RPM) at the high end. */ F32 rpm = (F32)speed; - F32 pwmRatio = (D48_NEW_PUMP_PWM_SLOPE * rpm) + D48_NEW_PUMP_PWM_INTERCEPT; /* duty fraction (0.0–1.0) */ - F32 countsF = pwmRatio * D48_NEW_PUMP_PWM_FULL_SCALE; /* 0–full-scale counts */ - U16 currentSpeed = (U16)CLAMP( countsF, 0.0F, D48_NEW_PUMP_PWM_FULL_SCALE ); + F32 pwmRatio = (D48_NEW_PUMP_PWM_SLOPE * rpm) + D48_NEW_PUMP_PWM_INTERCEPT; + F32 currentSpeed = pwmRatio * D48_NEW_PUMP_PWM_FULL_SCALE; #else - /* Legacy mapping for Diener 2000 pump: keep existing scaling. */ + // for Diener 2000 pump U16 currentSpeed = (U16)( ( ( (F32)speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); #endif - fpgaActuatorSetPoints.fpgaD48PumpSpeed = currentSpeed; } + fpgaActuatorSetPoints.fpgaD48PumpSpeed = currentSpeed; #else - { - fpgaActuatorSetPoints.fpgaD48PumpSpeed = speed; } + fpgaActuatorSetPoints.fpgaD48PumpSpeed = speed; #endif }