Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -rd74b98a3b101ec827cc7da59dd617df9435d79e3 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision d74b98a3b101ec827cc7da59dd617df9435d79e3) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -18,6 +18,7 @@ #include "ConcentratePumps.h" #include "FPGA.h" +#include "MessageSupport.h" #include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" @@ -165,11 +166,21 @@ calcMeasuredPumpsSpeed( CONCENTRATEPUMPS_CP1_ACID, getFPGACP1HallSensePulseWidth() ); calcMeasuredPumpsSpeed( CONCENTRATEPUMPS_CP2_BICARB, getFPGACP2HallSensePulseWidth() ); - data.cp1CurrentSetSpeed = concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed; - data.cp1MeasuredSpeed = getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ); - data.cp2CurrentSetSpeed = concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed; - data.cp2MeasuredSpeed = getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ); + // Get CP1 specifications + U08 cp1Direction = concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].direction; + F32 cp1SetSpeed = concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed; + F32 cp1Speed = getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ); + // Get CP2 specifications + U08 cp2Direction = concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].direction; + F32 cp2SetSpeed = concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed; + F32 cp2Speed = getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ); + + data.cp1CurrentSetSpeed = ( CONCENTRATE_PUMP_REVERSE_DIR == cp1Direction ? cp1SetSpeed * -1.0 : cp1SetSpeed ); + data.cp1MeasuredSpeed = ( CONCENTRATE_PUMP_REVERSE_DIR == cp1Direction ? cp1Speed * -1.0 : cp1Speed ); + data.cp2CurrentSetSpeed = ( CONCENTRATE_PUMP_REVERSE_DIR == cp1Direction ? cp2SetSpeed * -1.0 : cp2SetSpeed ); + data.cp2MeasuredSpeed = ( CONCENTRATE_PUMP_REVERSE_DIR == cp2Direction ? cp2Speed * -1.0 : cp2Speed ); + #ifndef DISABLE_DIALYSATE_CHECK F32 const cp1Error = fabs( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) - concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed ) / concentratePumps[ CONCENTRATEPUMPS_CP1_ACID ].currentPumpSpeed; F32 const cp2Error = fabs( getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) - concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed ) / concentratePumps[ CONCENTRATEPUMPS_CP2_BICARB ].currentPumpSpeed; @@ -179,7 +190,7 @@ #endif concentratePumpMonitorTimerCounter = 0U; - broadcastConcentratePumpData( &data ); + broadcastData( MSG_ID_DG_CONCENTRATE_PUMP_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( CONCENTRATE_PUMP_DATA_T ) ); } } Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r2c4dfa08ac8ead07939b4f6aba3b0073e0997706 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 2c4dfa08ac8ead07939b4f6aba3b0073e0997706) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -324,8 +324,12 @@ { U16 roFlowReading = getFPGAROPumpFlowRate(); - // Update sum for flow average calculation - measuredFlowReadingsSum += (S32)roFlowReading; + // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that the flow is 0. + if ( FLOW_SENSOR_ZERO_READING != roFlowReading ) + { + // Update sum for flow average calculation + measuredFlowReadingsSum += (S32)roFlowReading; + } // Read the pressure at the sensor. The pump cannot be more that the maximum allowed pressure // to make sure the hardware (especially the ROF) is not damaged. If it is the case, we need to stop immediately @@ -749,7 +753,8 @@ roPumpDutyCyclePctSet = roPumpPWMDutyCyclePct; roPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; - setROPumpControlSignalDutyCycle( roPumpOpenLoopTargetDutyCycle ); // TODO remove + // Set the new duty cycle of the pump + setROPumpControlSignalDutyCycle( roPumpOpenLoopTargetDutyCycle ); } /*********************************************************************//** Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -r2c4dfa08ac8ead07939b4f6aba3b0073e0997706 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 2c4dfa08ac8ead07939b4f6aba3b0073e0997706) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -54,7 +54,7 @@ #define FLUSH_DIALYSATE_WAIT_TIME_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Flush dialysate wait time in milliseconds. // Flush concentrate straws state defines -#define FLUSH_CONCENTRATE_STRAWS_TIME_MS ( 2 * 1 * MS_PER_SECOND ) ///< Flush concentrate straws wait time in milliseconds. todo was 3 minutes +#define FLUSH_CONCENTRATE_STRAWS_TIME_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Flush concentrate straws wait time in milliseconds. todo was 3 minutes #define ACID_PUMP_SPEED_ML_PER_MIN -30.0 ///< Acid pump speed in mL/min. // The bicarb pump is 2% faster than the acid pump to create a flow from acid to bicarb line during flush #define BICARB_PUMP_SPEED_ML_PER_MIN 30.6 ///< Bicarb pump speed in mL/min. @@ -65,7 +65,7 @@ #define RSRVRS_FULL_STABLE_TIME_COUNT ( ( 4 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Reservoirs 1 & 2 full stable time in counts. #define RSRVRS_FILL_UP_TIMEOUT_MS ( 5 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 full fill up timeout in ms. #define RSRVRS_PARTIAL_FILL_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 partial fill up timeout in ms. -#define RSRVRS_DRAIN_TIMEOUT_MS ( 3 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 drain timeout in ms. +#define RSRVRS_DRAIN_TIMEOUT_MS ( 2 * 60 * MS_PER_SECOND ) ///< Reservoirs 1 & 2 drain timeout in ms. #define FINAL_DRAIN_RO_PUMP_FLOW_LPM 0.6 ///< Final drain RO pump flow rate in L/min. This is used to flush the drain line during drain. // Flush drain line state defines Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r2c4dfa08ac8ead07939b4f6aba3b0073e0997706 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2c4dfa08ac8ead07939b4f6aba3b0073e0997706) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -1205,10 +1205,10 @@ break; case MSG_ID_DG_RO_FLOW_RATE_OVERRIDE: - handleTestMeasuredROFlowRateOverride( message ); + handleTestROMeasuredFlowOverrideRequest( message ); break; - case MSG_ID_DG_RO_PUMP_TARGET_FLOW_OVERRIDE: + case MSG_ID_DG_SET_RO_PUMP_TARGET_FLOW: handleTestROPumpTargetFlowOverride( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r09302f3dffa9eb6c0637af5ec77c1274ecad1cf2 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 09302f3dffa9eb6c0637af5ec77c1274ecad1cf2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -519,35 +519,6 @@ /*********************************************************************//** * @brief - * The broadcastConcentratePumpData function sends out concentrate pumps' data. - * @details Inputs: none - * @details Outputs: concentrate pump data msg constructed and queued - * @param cp1TgtSpeed target speed for concentrate pump CP1 - * @param measuredCP1Speed measured speed for concentrate pump CP1 using hall sense - * @param cp2TgtSpeed target speed for concentrate pump CP2 - * @param measuredCP2Speed measured speed for concentrate pump CP2 using hall sense - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastConcentratePumpData( void * concentratePumpDataPtr ) -{ - BOOL result; - MESSAGE_T msg; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_PUMP_DATA; - msg.hdr.payloadLen = sizeof( CONCENTRATE_PUMP_DATA_T ); - - memcpy( &msg.payload, concentratePumpDataPtr, sizeof( CONCENTRATE_PUMP_DATA_T ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The broadcastPressureSensorsData function sends out DG pressure data. * @details Inputs: none * @details Outputs: Pressure data msg constructed and queued @@ -2984,38 +2955,6 @@ /*********************************************************************//** * @brief -* The handleTestROFlowRateOverride function handles a request to override -* the RO flow rate. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*******************************************************************/ -void handleTestMeasuredROFlowRateOverride( MESSAGE_T *message ) -{ - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); - if ( FALSE == payload.reset ) - { - result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredROFlowRateOverride(); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** -* @brief * The handleTestThermistorsValueOverride function handles a request to * override a thermistor's value. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r033c0a8a34377fdc9a4d681877f7be1e103857f0 -r81dc975f13b9308e40aa0e33e0eca2d407276d44 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 033c0a8a34377fdc9a4d681877f7be1e103857f0) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 81dc975f13b9308e40aa0e33e0eca2d407276d44) @@ -88,9 +88,6 @@ // MSG_ID_DRAIN_PUMP_DATA BOOL broadcastDrainPumpData( DRAIN_PUMP_DATA_T *drainPumpData ); -// MSG_ID_DG_CONCENTRATE_PUMP_DATA -BOOL broadcastConcentratePumpData( void * concentratePumpDataPtr ); - // MSG_ID_DG_PRESSURES_DATA BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut ); @@ -339,9 +336,6 @@ // MSG_ID_DG_RO_PUMP_DUTY_CYCLE_OVERRIDE void handleTestROPumpDutyCycleOverride( MESSAGE_T *message ); -// MSG_ID_DG_RO_FLOW_RATE_OVERRIDE -void handleTestMeasuredROFlowRateOverride( MESSAGE_T *message ); - // MSG_ID_DG_RO_PUMP_TARGET_FLOW_OVERRIDE void handleTestROPumpTargetFlowOverride( MESSAGE_T *message );