Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r782cbace651eebeccbbfd3e2f2b607436269ee7f -r8822f86705a24d1c7dd305b584a95ae3d3c406b8 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 782cbace651eebeccbbfd3e2f2b607436269ee7f) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 8822f86705a24d1c7dd305b584a95ae3d3c406b8) @@ -389,6 +389,11 @@ BOOL isPressureMax = ( actualPressure >= MAX_ALLOWED_MEASURED_PRESSURE_PSI ? TRUE : FALSE ); BOOL isDutyCylceOutOfRange = FALSE; + // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V + // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). + roPumpFeedbackDutyCyclePct.data = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); + isDutyCylceOutOfRange = ( fabs( getROFeedbackDutyCycle() - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_RO_PUMP_PRESSURE_OUT_OF_RANGE, isPressureMax, actualPressure, MAX_ALLOWED_MEASURED_PRESSURE_PSI ); if ( ( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) > NEARLY_ZERO ) && ( VALVE_STATE_CLOSED == getValveStateName( VBF ) ) ) @@ -461,11 +466,6 @@ if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { - // The feedback voltage is on the 0V line so when the duty cycle is 0, the feedback is 2.5V - // The duty cycle is calculated by getting the 1 - (ratio of feedback / to the voltage at 0 percent duty cycle). - roPumpFeedbackDutyCyclePct.data = 1.0F - ( roFeedbackVoltage / ROP_FEEDBACK_0_PCT_DUTY_CYCLE_VOLTAGE ); - isDutyCylceOutOfRange = ( fabs( getROFeedbackDutyCycle() - roPumpDutyCyclePctSet ) > ROP_DUTY_CYCLE_OUT_OF_RANGE_TOLERANCE ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_DG_RO_PUMP_DUTY_CYCLE_OUT_OF_RANGE, isDutyCylceOutOfRange, getROFeedbackDutyCycle(), roPumpDutyCyclePctSet ); // Check if it the alarm has timed out and if the pump is supposed to be off but it is still on, activate the safety shutdown Index: firmware/App/Modes/ModeROPermeateSample.c =================================================================== diff -u -rad272a524906daa67d4de0aa41ac401dd33afc8f -r8822f86705a24d1c7dd305b584a95ae3d3c406b8 --- firmware/App/Modes/ModeROPermeateSample.c (.../ModeROPermeateSample.c) (revision ad272a524906daa67d4de0aa41ac401dd33afc8f) +++ firmware/App/Modes/ModeROPermeateSample.c (.../ModeROPermeateSample.c) (revision 8822f86705a24d1c7dd305b584a95ae3d3c406b8) @@ -47,8 +47,8 @@ #define RSRVR_DRAIN_TARGET_RPM 2400 ///< Reservoir drain target RPM. #define RSRVR_MIX_DRAIN_TIMEOUT_MS ( 4 * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoirs 1 & 2 mix drain timeout in ms. #define RSRVR_FILL_TARGET_FILL_ML 1850.0F ///< Reservoir fill target in mL. -#define RSRVR_DRAIN_BEFORE_SAMPLE_COLLECTION_MS ( 4.25F * SEC_PER_MIN * MS_PER_SECOND ) ///< Reservoir drain before collection samples in milliseconds. -#define RO_PUMP_TARGET_DISPENSE_FLOW_RATE_LPM 0.6F ///< RO pump target flow rate during dispensing in L/min. +#define RSRVR_DRAIN_BEFORE_SAMPLE_COLLECTION_MS ( 0.25F * SEC_PER_MIN * MS_PER_SECOND ) //TODO 4.25 ///< Reservoir drain before collection samples in milliseconds. +#define RO_PUMP_TARGET_DISPENSE_FLOW_RATE_LPM 0.4F ///< RO pump target flow rate during dispensing in L/min. #define TARGET_DISPENSE_VOLUME_ML 70.0F ///< Target dispense volume in milliliters. /// Dispense message status enum @@ -73,7 +73,7 @@ static DISPENSE_MSG_STATUS_T dispenseMessageStatus; ///< Mode RO permeate sample dispense message status. /// Conversion coefficient from flow in L/min to volume in milliliters. -static const F32 FLOW_LPM_TO_VOL_ML_CONVERSION = ( ML_PER_LITER * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ); +static const F32 FLOW_LPM_TO_VOL_ML_CONVERSION = (F32)( ML_PER_LITER * TASK_GENERAL_INTERVAL ) / (F32)( SEC_PER_MIN * MS_PER_SECOND ); // ********** private function prototypes ********** @@ -425,7 +425,8 @@ if ( TRUE == didTimeout( stateStartTimeMS, RSRVR_DRAIN_BEFORE_SAMPLE_COLLECTION_MS ) ) { - state = DG_RO_PERM_SAMPLE_STATE_COLLECT_SAMPLE; + stateStartTimeMS = getMSTimerCount(); + state = DG_RO_PERM_SAMPLE_STATE_COLLECT_SAMPLE; setROPermeateSampleStateTransition( state ); } } @@ -462,15 +463,17 @@ break; case DISPENSE_MSG_CANCEL: - state = DG_RO_PERM_SAMPLE_STATE_COMPLETE; // TODO go to drain once testing is done + state = DG_RO_PERM_SAMPLE_STATE_DRAIN_R1; setROPermeateSampleStateTransition( state ); break; case DISPENSE_MSG_DISPENSE: + dispenseMessageStatus = DISPENSE_MSG_DISPENSE; + if ( FALSE == isROPumpRunning() ) { - dispenseMessageStatus = DISPENSE_MSG_DISPENSING; setROPermeateSampleStateTransition( state ); + dispenseMessageStatus = DISPENSE_MSG_DISPENSING; } break; @@ -490,7 +493,8 @@ { // Done with dispensing fluid // Message HD that DG is ready for the next command (either dispense more or cancel the run) - dispenseMessageStatus = DISPENSE_MSG_READY; + dispenseMessageStatus = DISPENSE_MSG_READY; + roPermeateSampledispensedVolumeML = 0.0F; setROPermeateSampleStateTransition( state ); handleSendROPermeateSampleDispenseReadyToHD(); // TODO should we send this multiple times until confirmation? } @@ -627,6 +631,7 @@ data.overallElapsedTimeMS = calcTimeSince( overallROPermeateSampleTimer ); data.stateElapsedTimeMS = calcTimeSince( stateStartTimeMS ); data.roPermeateSampleDispensedVolML = roPermeateSampledispensedVolumeML; + data.dispenseMessageStatus = (U32)dispenseMessageStatus; broadcastData( MSG_ID_DG_RO_PERMEATE_SAMPLE_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( MODE_RO_PERMEATE_SAMPLE_DATA_T ) ); Index: firmware/App/Modes/ModeROPermeateSample.h =================================================================== diff -u -r43f57e52a9a31e5154579178e847db3a6917b93c -r8822f86705a24d1c7dd305b584a95ae3d3c406b8 --- firmware/App/Modes/ModeROPermeateSample.h (.../ModeROPermeateSample.h) (revision 43f57e52a9a31e5154579178e847db3a6917b93c) +++ firmware/App/Modes/ModeROPermeateSample.h (.../ModeROPermeateSample.h) (revision 8822f86705a24d1c7dd305b584a95ae3d3c406b8) @@ -22,7 +22,8 @@ U32 roPermeateSampleState; ///< RO permeate sample mode state. U32 overallElapsedTimeMS; ///< RO permeate sample mode overall elapsed time in milliseconds. U32 stateElapsedTimeMS; ///< RO permeate sample mode current state elapsed time in milliseconds. - F32 roPermeateSampleDispensedVolML; ///< RO permeate sample mode dispensed volume in milliliters.. + F32 roPermeateSampleDispensedVolML; ///< RO permeate sample mode dispensed volume in milliliters. + U32 dispenseMessageStatus; ///< RO permeate sample mode dispense message status. } MODE_RO_PERMEATE_SAMPLE_DATA_T; // ********** public function prototypes ********** Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rad272a524906daa67d4de0aa41ac401dd33afc8f -r8822f86705a24d1c7dd305b584a95ae3d3c406b8 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ad272a524906daa67d4de0aa41ac401dd33afc8f) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8822f86705a24d1c7dd305b584a95ae3d3c406b8) @@ -1869,7 +1869,7 @@ memcpy( payloadPtr, &dispenseReady, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_REQUIRED ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); }