Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r8e72441bc5cd51272b1dc6b14d6c95b4888d6301 -r2652d50bbc5e78ed6fe3ad9ccbca0be6f802f1ff --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 8e72441bc5cd51272b1dc6b14d6c95b4888d6301) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 2652d50bbc5e78ed6fe3ad9ccbca0be6f802f1ff) @@ -38,21 +38,24 @@ // ********** private definitions ********** -#define RO_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO Pump data is published on the CAN bus. -#define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO pump is controlled. +#define RO_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO Pump data is published on the CAN bus. +#define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO pump is controlled. -#define ROP_FLOW_CONTROL_P_COEFFICIENT 0.15F ///< P term for RO pump flow control. -#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.65F ///< I term for RO pump flow control. -#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_CONTROL_P_COEFFICIENT 0.15F ///< P term for RO pump flow control. +#define ROP_FLOW_CONTROL_I_COEFFICIENT 0.65F ///< I term for RO pump flow control. +#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.5F ///< Slope of flow to PWM line equation. -#define ROP_FLOW_TO_PWM_INTERCEPT 0.0F ///< 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 ROP_FLOW_TO_PWM_SLOPE 0.5F ///< Slope of flow to PWM line equation. +#define ROP_FLOW_TO_PWM_INTERCEPT 0.0F ///< 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 DATA_PUBLISH_COUNTER_START_COUNT 10 ///< Data publish counter start count. +#define ROP_FLOW_TO_PWM(flow) ( ROP_FLOW_TO_PWM_SLOPE * flow + ROP_FLOW_TO_PWM_INTERCEPT ) ///< PWM line equation for flow. +#define ROP_PRESSURE_TO_PWM(pres) ( ROP_PRESSURE_TO_PWM_SLOPE * pres + ROP_PRESSURE_TO_PWM_INTERCEPT )///< PWM line equation for pressure. + // ********** private data ********** static RO_PUMP_STATE_T roPumpState; ///< Current state of pump controller state machine. @@ -264,21 +267,21 @@ RO_PUMP_STATE_T state = RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE; // Check if need to switch control modes - if ( getTargetROPumpPressure() > 0.0F && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) + if ( ( getTargetROPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) { // Transition to target pressure resetPIController( PI_CONTROLLER_ID_RO_PUMP_PRES, roPumpDutyCyclePctSet, 0 ); state = RO_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; } - else if ( getTargetROPumpDutyCyclePCT() > 0.0F && ( PUMP_CONTROL_MODE_OPEN_LOOP == roPumpControlMode ) ) + else if ( ( getTargetROPumpDutyCyclePCT() > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == roPumpControlMode ) ) { setFluidPumpPctToPWMDutyCycle( P12_PUMP, getTargetROPumpDutyCyclePCT() ); roPumpDutyCyclePctSet = getTargetROPumpDutyCyclePCT(); state = RO_PUMP_OPEN_LOOP_STATE; } // Control at set interval or shut off - if ( getTargetROPumpFlowRateMLPM() == 0.0F && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) + if ( ( getTargetROPumpFlowRateMLPM() == 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) { signalROPumpHardStop(); } @@ -305,20 +308,20 @@ RO_PUMP_STATE_T state = RO_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; // Check if we are changing control - if ( getTargetROPumpFlowRateMLPM() > 0 && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) + if ( ( getTargetROPumpFlowRateMLPM() > 0 ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) { resetPIController( PI_CONTROLLER_ID_RO_PUMP_FLOW, roPumpDutyCyclePctSet, 0 ); state = RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE; } - else if ( getTargetROPumpDutyCyclePCT() > 0.0F && ( PUMP_CONTROL_MODE_OPEN_LOOP == roPumpControlMode ) ) + else if ( ( getTargetROPumpDutyCyclePCT() > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == roPumpControlMode ) ) { setFluidPumpPctToPWMDutyCycle( P12_PUMP, getTargetROPumpDutyCyclePCT() ); roPumpDutyCyclePctSet = getTargetROPumpDutyCyclePCT(); state = RO_PUMP_OPEN_LOOP_STATE; } // Control at set interval or shut off - if ( getTargetROPumpPressure() == 0.0F && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) + if ( ( getTargetROPumpPressure() == 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == roPumpControlMode ) ) { signalROPumpHardStop(); } @@ -737,5 +740,4 @@ return result; } - /**@}*/