Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r71e5d8968b369a4e94f65a40171f648f442b8f80 -r9725baecc8bf9720e4c27a4564b8aee3d62813e5 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 71e5d8968b369a4e94f65a40171f648f442b8f80) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 9725baecc8bf9720e4c27a4564b8aee3d62813e5) @@ -225,8 +225,12 @@ static DATA_GET_PROTOTYPE( U32, getPublishValvesDataInterval ); static void publishValvesData( VALVE_T valve ); static void setValveNextStep( VALVE_T valve, U32 stepChange ); + +// These functions will be used in debug only mode +#ifdef DEBUG_ENABLED static void setFPGAValvePWM( VALVE_T valve ); static void getValvesCurrentPWM( void ); +#endif /*********************************************************************//** * @brief @@ -411,10 +415,12 @@ case VALVE_STATE_IN_TRANSITION: state = handleValveStateInTransition( valve ); break; - +// PWM mode only used in debug mode +#ifdef DEBUG_ENABLED case VALVE_STATE_IN_BYPASS_MODE: state = handleValveStateInBypassMode( valve ); break; +#endif default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_VALVES_INVALID_EXEC_STATE, @@ -525,8 +531,13 @@ // If homing has been requested or POST is completed and the door has been close for the specified // period of time, start the homing - if ( ( valvesStatus[ valve ].hasHomingBeenRequested || valveSelfTestState == VALVE_SELF_TEST_COMPLETE ) - && isDoorClosed && ! valvesStatus[ valve ].hasHomingFailed ) + if ( ( valvesStatus[ valve ].hasHomingBeenRequested || valveSelfTestState == VALVE_SELF_TEST_COMPLETE ) && +// This is disabled for VectoCAST testing. Once the door +// driver was implemented, this build switch must be removed +#ifdef DEBUG_ENABLED + isDoorClosed && +#endif + ! valvesStatus[ valve ].hasHomingFailed ) { // Get ready for the energized state valvesStatus[ valve ].homingEdgeDetectionCounter = 0; @@ -695,7 +706,7 @@ } } // This option is only available in a debug build -#ifdef VALVES_PWM_CONTROL_ENABLED +#ifdef DEBUG_ENABLED // Check if the valves have been homed and a bypass mode has been requested else if ( valvesStatus[ valve ].hasValveBeenHomed && valvesStatus[ valve ].bypassModeStatus.hasBypassModeBeenRequeseted ) @@ -766,7 +777,7 @@ return state; } - +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The handleValveStateInBypassMode function handles the bypass mode @@ -803,7 +814,7 @@ return state; } - +#endif /*********************************************************************//** * @brief * The setValveControlMode function sets the valves control mode. @@ -853,7 +864,7 @@ // Get the current PWM values back. // This function is only available if the valves are in bypass mode -#ifdef VALVES_PWM_CONTROL_ENABLED +#ifdef DEBUG_ENABLED getValvesCurrentPWM(); #endif } @@ -1061,7 +1072,8 @@ { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_VALVE_CURRENT_OUT_OF_RANGE, (F32)valve, currentPostion ); //TODO is S16 ok with F32? } - else + else if ( abs( currentPostion - commandedPoistion ) < MAX_DEVIATION_FROM_TARGET_IN_COUNTS && + valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) { valvesStatus[ valve ].positionOutOfRangeCounter = 0; } @@ -1143,7 +1155,6 @@ static void setValveNextStep( VALVE_T valve, U32 stepChange ) { S16 nextStep = 0; - S16 targetPosition = 0; VALVE_POSITION_T currentPositionEnum = valvesStatus[ valve ].currentPosition; VALVE_POSITION_T commandedPositionEnum = valvesStatus[ valve ].commandedPosition; S16 currentPosition = valvesStatus[ valve ].currentPositionInCounts; @@ -1167,50 +1178,29 @@ if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { valvesStatus[ valve ].targetPositionInCounts = valvesStatus[ valve ].currentPositionInCounts + nextStep; - - if( nextStep < stepChange ) - { - targetPosition = valvesStatus[ valve ].targetPositionInCounts; - } - else - { - targetPosition = valvesStatus[ valve ].targetPositionInCounts; - } } if ( commandedPositionEnum == VALVE_POSITION_C_CLOSE ) { valvesStatus[ valve ].targetPositionInCounts = valvesStatus[ valve ].currentPositionInCounts - nextStep; - - targetPosition = valvesStatus[ valve ].targetPositionInCounts; } } // If the valve is currently in position B, subtract the defined number of steps for the next transition else if ( currentPositionEnum == VALVE_POSITION_B_OPEN ) { valvesStatus[ valve ].targetPositionInCounts = valvesStatus[ valve ].currentPositionInCounts - nextStep; - - targetPosition = valvesStatus[ valve ].targetPositionInCounts; } // If the valve is currently in position C, add the defined number of steps for the next transition else if ( currentPositionEnum == VALVE_POSITION_C_CLOSE ) { valvesStatus[ valve ].targetPositionInCounts = valvesStatus[ valve ].currentPositionInCounts + nextStep; - - if ( nextStep < HOMING_STEP_CHANGE_IN_COUNTS && commandedPositionEnum == VALVE_POSITION_B_OPEN ) - { - targetPosition = valvesStatus[ valve ].targetPositionInCounts; - } - else - { - targetPosition = valvesStatus[ valve ].targetPositionInCounts; - } } // Call the function to send the set point to FPGA. Current relaxation is not // enabled here, so it is always false - setFPGAValveSetPoint( valve, targetPosition, FALSE ); + setFPGAValveSetPoint( valve, valvesStatus[ valve ].targetPositionInCounts, FALSE ); } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The setFPGAValvePWM function checks whether the valve should be moving @@ -1297,7 +1287,7 @@ valvesStatus[ valve ].bypassModeStatus.currentPWMInPercent = currentPWM; } } - +#endif /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -1406,6 +1396,7 @@ return result; } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The testSetValvePWMOverride function overrides the valves PWM in bypass @@ -1476,5 +1467,6 @@ return result; } +#endif /**@}*/ Index: firmware/App/HDCommon.h =================================================================== diff -u -rb1c2d54d3d029ab1340d91193a7a4c81db8ba29d -r9725baecc8bf9720e4c27a4564b8aee3d62813e5 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision b1c2d54d3d029ab1340d91193a7a4c81db8ba29d) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 9725baecc8bf9720e4c27a4564b8aee3d62813e5) @@ -32,7 +32,6 @@ #ifndef _RELEASE_ #define UF_TEST_ENABLED 1 // ultrafiltration test build (hard codes treatment params, re-purposes off/stop buttons) #define UF_TEST_WITH_DG 1 // ultrafiltration test build (sets up DG in standby mode) -#define VALVES_PWM_CONTROL_ENABLED 1 // Control valves with PWM #ifndef _VECTORCAST_ // #define RM46_EVAL_BOARD_TARGET 1 // limited build runs on RM46 eval board // #define BREADBOARD_TARGET 1 // old breadboard system build - no longer used? Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r306243570641956ce4e2303380c9c0a02801726d -r9725baecc8bf9720e4c27a4564b8aee3d62813e5 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 306243570641956ce4e2303380c9c0a02801726d) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 9725baecc8bf9720e4c27a4564b8aee3d62813e5) @@ -1400,6 +1400,7 @@ return fpgaSensorReadings.VDiCurrent; } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The setFPGAValveDialyzerInletPWM function sets the PWM of VDI in counts. @@ -1427,6 +1428,7 @@ { return fpgaSensorReadings.VDiPWMTarget; } +#endif /*********************************************************************//** * @brief @@ -1471,6 +1473,7 @@ return fpgaSensorReadings.VDoCurrent; } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The setFPGAValveDialyzerOutletPWM function sets the PWM of VDO in counts. @@ -1498,6 +1501,7 @@ { return fpgaSensorReadings.VDoPWMTarget; } +#endif /*********************************************************************//** * @brief @@ -1542,6 +1546,7 @@ return fpgaSensorReadings.VBVCurrent; } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The setFPGAValveBloodVenousPWM function sets the PWM of VBV in counts. @@ -1568,6 +1573,7 @@ { return fpgaSensorReadings.VBVPWMTarget; } +#endif /*********************************************************************//** * @brief @@ -1612,6 +1618,7 @@ return fpgaSensorReadings.VBACurrent; } +#ifdef DEBUG_ENABLED /*********************************************************************//** * @brief * The setFPGAValveBloodArterialPWM function sets a PWM for VBA in counts. @@ -1639,6 +1646,7 @@ { return fpgaSensorReadings.VBAPWMTarget; } +#endif /*********************************************************************//** * @brief Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r306243570641956ce4e2303380c9c0a02801726d -r9725baecc8bf9720e4c27a4564b8aee3d62813e5 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 306243570641956ce4e2303380c9c0a02801726d) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 9725baecc8bf9720e4c27a4564b8aee3d62813e5) @@ -74,26 +74,30 @@ void setFPGAValveDialyzerInletPosition( S16 setPoint ); S16 getFPGAValveDialyzerInletPosition( void ); U16 getFPGAValveDialyzerInletCurrentCounts( void ); -void setFPGAValveDialyzerInletPWM( U16 count ); -U16 getFPGAValveDialyzerInletPWM( void ); void setFPGAValveDialyzerOutletPosition( S16 setPoint ); S16 getFPGAValveDialyzerOutletPosition( void ); U16 getFPGAValveDialyzerOutletCurrentCounts( void ); -void setFPGAValveDialyzerOutletPWM( U16 count ); -U16 getFPGAValveDialyzerOutletPWM( void ); void setFPGAValveBloodVenousPosition( S16 setPoint ); S16 getFPGAValveBloodVenousPosition( void ); U16 getFPGAValveBloodVenousCurrentCounts( void ); -void setFPGAValveBloodVenousPWM( U16 count ); -U16 getFPGAValveBloodVenousPWM( void ); void setFPGAValveBloodArterialPosition( S16 setPoint ); S16 getFPGAValveBloodArterialPosition( void ); U16 getFPGAValveBloodArterialCurrentCounts( void ); + +// The PWM functions only used during debugging +#ifdef DEBUG_ENABLED +void setFPGAValveDialyzerInletPWM( U16 count ); +U16 getFPGAValveDialyzerInletPWM( void ); +void setFPGAValveDialyzerOutletPWM( U16 count ); +U16 getFPGAValveDialyzerOutletPWM( void ); +void setFPGAValveBloodVenousPWM( U16 count ); +U16 getFPGAValveBloodVenousPWM( void ); void setFPGAValveBloodArterialPWM( U16 count ); U16 getFPGAValveBloodArterialPWM( void ); +#endif /**@}*/