Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r73fb20333b1987ed00456d32f41ecbf06b0d1b9e -r617a2fa278e4a4426bfbe22b39ae9defbcedd778 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 73fb20333b1987ed00456d32f41ecbf06b0d1b9e) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 617a2fa278e4a4426bfbe22b39ae9defbcedd778) @@ -14,6 +14,7 @@ * @date (original) 12-Nov-2024 * ***************************************************************************/ +#include // for log() #include "Flow.h" //#include "NVDataMgmt.h" @@ -44,17 +45,17 @@ #define ROP_PRESSURE_CONTROL_P_COEFFICIENT 0.15F ///< P term for RO pump pressure control. #define ROP_PRESSURE_CONTROL_I_COEFFICIENT 0.65F ///< I term for RO pump pressure control. -#define ROP_FLOW_TO_PWM_SLOPE 0.2427F ///< Slope of flow to PWM line equation. -#define ROP_FLOW_TO_PWM_INTERCEPT 146.23F ///< Intercept of flow to PWM line equation. +#define ROP_FLOW_TO_PWM_SLOPE 155.31F ///< Slope of flow to PWM line equation. +#define ROP_FLOW_TO_PWM_INTERCEPT -699.99F ///< Intercept of flow to PWM line equation. #define ROP_PRESSURE_TO_PWM_SLOPE 0.5F ///< Slope of pressure to PWM line equation. #define ROP_PRESSURE_TO_PWM_INTERCEPT 0.0F ///< Intercept of pressure to PWM line equation. #define DATA_PUBLISH_COUNTER_START_COUNT 10 ///< Data publish counter start count. -#define ROP_FLOW_TO_PWM_PCT(flow) ( ( ROP_FLOW_TO_PWM_SLOPE * flow + ROP_FLOW_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for flow converted to percentage. -#define ROP_PRESSURE_TO_PWM_PCT(pres) ( ( ROP_PRESSURE_TO_PWM_SLOPE * pres + ROP_PRESSURE_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for pressure. converted to percentage +#define ROP_PRESSURE_TO_PWM_PCT(pres) ( ( ROP_PRESSURE_TO_PWM_SLOPE * pres + ROP_PRESSURE_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for pressure. converted to percentage. -#define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * flow + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow converted to percentage. +#define ROP_FLOW_TO_PWM_PCT(flow) ( ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) / MAX_FLUID_PUMP_PWM_DUTY_CYCLE ) ///< PWM line equation for flow converted to percentage. +#define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * log(flow) + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow converted to percentage. // ********** private data ********** @@ -298,7 +299,7 @@ if( ( TRUE == roPumpStartControl ) || ( getFilteredFlow( P16_FLOW ) >= ( (F32)getTargetROPumpFlowRateMLPM() * ROP_MIN_FLOW_TO_CONTROL_PCT ) ) ) { nexttgtflow = runPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, (F32)getTargetROPumpFlowRateMLPM(), getFilteredFlow( P16_FLOW ) ); - nexttgtflow = MIN( ROP_FLOW_TO_PWM(nexttgtflow), ( MAX_FLUID_PUMP_PWM_DUTY_CYCLE* MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ); + nexttgtflow = (U16)MIN( ROP_FLOW_TO_PWM(nexttgtflow), ( MAX_FLUID_PUMP_PWM_DUTY_CYCLE* MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ); setFluidPumpPWMDutyCycle( P12_PUMP, nexttgtflow ); if ( FALSE == roPumpStartControl ) {