Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r60165f6d155831cfce06560fb45abaaaadea9798 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 60165f6d155831cfce06560fb45abaaaadea9798) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -39,8 +39,6 @@ #define BAL_CHAMBER_FILL_VOLUME_ML 30.0F ///< Balancing chamber fill/drain volume per batch operation. #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. -#define TEST_ACID_VOLUME_ML 0.67F ///< Acid concentrate volume in ml. -#define TEST_BICARB_VOLUME_ML 1.15F ///< Bicarb concentrate volume in ml. /// Payload record structure for balancing chamber switch only request typedef struct @@ -411,7 +409,8 @@ BAL_CHAMBER_EXEC_STATE_T state; // On dosing completion, transition to next state based on the current switching state - if ( TRUE == IsConcentratePumpDosingCompleted() ) + if ( ( TRUE == getConcentratePumpDosingStatus( D11_PUMP ) ) && + ( TRUE == getConcentratePumpDosingStatus( D10_PUMP ) ) ) { if ( BAL_CHAMBER_SW_STATE1 == balChamberSWState ) { Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -rf8bb43e62a4d10b64d8b197e372a56adfcfb88b9 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision f8bb43e62a4d10b64d8b197e372a56adfcfb88b9) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -589,6 +589,28 @@ /*********************************************************************//** * @brief + * The getConcentratePumpDosingStatus function returns the dosing status + * for a given concentrate pump. + * @details \b Inputs: concentratePumps + * @details \b Outputs: none + * @param pumpId concentrate pump id to get current dosing status + * @return the current doisng status/state for the given conecntrate pump. + *************************************************************************/ +BOOL getConcentratePumpDosingStatus( CONCENTRATE_PUMPS_T pumpId ) +{ + BOOL state = FALSE; + + //On dosing completion,state transition to off state + if ( CONCENTRATE_PUMP_OFF_STATE == concentratePumps[ pumpId ].execState ) + { + state = TRUE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The getPumpTargetSpeed function gets the current target spped for the given * concentrate pump. * @details \b Inputs: pumpTargetSpeed @@ -698,28 +720,6 @@ /*********************************************************************//** * @brief - * The IsConcentratePumpDosingCompleted function gets the concentrate pump - * dosing completion status. - * @details \b Inputs: execState - * @details \b Outputs: none - * @return true when dosing completed,otherwise false. - *************************************************************************/ -BOOL IsConcentratePumpDosingCompleted( void ) -{ - BOOL result = FALSE; - - // Check doisng completed status - if ( ( concentratePumps[D11_PUMP].execState == CONCENTRATE_PUMP_OFF_STATE ) && - ( concentratePumps[D10_PUMP].execState == CONCENTRATE_PUMP_OFF_STATE ) ) - { - result = TRUE; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getConcPumpCurrentMeasuredRevolutionCount function gets the concentrate pump * current measured revolution count. * @details \b Inputs: pumpMesauredRevCnt Index: firmware/App/Controllers/ConcentratePumps.h =================================================================== diff -u -rc4ea2fbaae71d7beca3879c0970d488f169ebae4 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision c4ea2fbaae71d7beca3879c0970d488f169ebae4) +++ firmware/App/Controllers/ConcentratePumps.h (.../ConcentratePumps.h) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -32,6 +32,8 @@ // ********** public definitions ********** #define CONCENTRATE_PUMP_MAX_SPEED 48.0F ///< Maximum speed for concentrate pump in mL/min +#define TEST_ACID_VOLUME_ML 0.67F ///< Acid concentrate volume in ml. +#define TEST_BICARB_VOLUME_ML 1.15F ///< Bicarb concentrate volume in ml. #define PARK_CONC_PUMPS TRUE ///< For park parameter to requestConcentratePumpOff(). #define NO_PARK_CONC_PUMPS FALSE ///< For park parameter to requestConcentratePumpOff(). @@ -90,7 +92,7 @@ U16 getConcPumpCurrentMeasuredRevolutionCount( CONCENTRATE_PUMPS_T pumpId ); BOOL handleConcentratePumpParkRequest( void ); BOOL isConcPumpParkInProgress( CONCENTRATE_PUMPS_T pumpId ); -BOOL IsConcentratePumpDosingCompleted( void ); +BOOL getConcentratePumpDosingStatus( CONCENTRATE_PUMPS_T pumpId ); BOOL testConcentratePumpDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testConcentratePumpTargetSpeedOverride( MESSAGE_T *message ); Index: firmware/App/Controllers/DialysatePumps.c =================================================================== diff -u -r60165f6d155831cfce06560fb45abaaaadea9798 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision 60165f6d155831cfce06560fb45abaaaadea9798) +++ firmware/App/Controllers/DialysatePumps.c (.../DialysatePumps.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -45,7 +45,7 @@ #define DIALYSATE_PUMP_DATA_PUB_INTERVAL ( 50 / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the dialysate pump data is published on the CAN bus. #endif #define DATA_PUBLISH_COUNTER_START_COUNT 60 ///< Data publish counter start count. -#if __OPENSPDTEST__ +#ifdef __OPENSPDTEST__ #define DIALYSATE_PUMP_EXEC_INTERVAL ( 2000 / TASK_GENERAL_INTERVAL ) #define DIALYSATE_PUMP_SPEED_INCREMENT 200.0F ///< Speed increase when controlling dialysate pump to target step speed. #endif @@ -144,8 +144,8 @@ static BOOL dialPumpsReadyToControl; ///< Flag use to indicate the minimum control interval is met for pump control //Testing -#if __OPENSPDTEST__ -static U32 dialysatePumpExecTimerCounter; ///< Used to schedule dialysate pump data publication to CAN bus. +#ifdef __OPENSPDTEST__ +static U32 dialysatePumpExecTimerCounter[ NUM_OF_DIALYSATE_PUMPS ]; ///< Used to schedule dialysate pump data publication to CAN bus. #endif //For testing @@ -175,8 +175,9 @@ { DIALYSATE_PUMPS_T pumpId; //Testing -#if __OPENSPDTEST__ - dialysatePumpExecTimerCounter = 9900; +#ifdef __OPENSPDTEST__ + dialysatePumpExecTimerCounter[ D12_PUMP ] = 9900; + dialysatePumpExecTimerCounter[ D48_PUMP ] = 9900; #endif #ifdef __PITEST__ @@ -559,8 +560,8 @@ for ( pumpId = DIALYSATE_PUMPS_FIRST; pumpId < NUM_OF_DIALYSATE_PUMPS; pumpId++ ) { -#if __OPENSPDTEST__ - if ( ++dialysatePumpExecTimerCounter >= DIALYSATE_PUMP_EXEC_INTERVAL ) +#ifdef __OPENSPDTEST__ + if ( ++dialysatePumpExecTimerCounter[ pumpId ] >= DIALYSATE_PUMP_EXEC_INTERVAL ) { #endif switch ( dialysatePumps[ pumpId ].dialysatePumpState ) @@ -582,8 +583,8 @@ dialysatePumps[ pumpId ].dialysatePumpState = DIALYSATE_PUMP_OFF_STATE; break; } -#if __OPENSPDTEST__ - dialysatePumpExecTimerCounter = 0; +#ifdef __OPENSPDTEST__ + dialysatePumpExecTimerCounter[ pumpId ] = 0; } #endif } @@ -988,7 +989,6 @@ dialPump.d12PumpTargetRPM = pIControlSignal[ 0 ]; dialPump.d48PumpTargetRPM = pIControlSignal[ 1 ]; #endif - dialPump.d12PumpMeasuredSpeed = getDialysatePumpMeasuredSpeed( D12_PUMP ); dialPump.d48PumpMeasuredSpeed = getDialysatePumpMeasuredSpeed( D48_PUMP ); dialPump.d12PumpCurrentSpeed = dialysatePumps[ D12_PUMP ].currentPumpSpeed; Index: firmware/App/Controllers/PistonPumpControl.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/PistonPumpControl.c (.../PistonPumpControl.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Controllers/PistonPumpControl.c (.../PistonPumpControl.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -17,6 +17,7 @@ #include "ConcentratePumps.h" #include "FpgaDD.h" +#include "Level.h" #include "Messaging.h" #include "PistonPumpControl.h" #include "TaskGeneral.h" @@ -35,7 +36,8 @@ #define PISTON_PUMP_FILL_PERIOD ( 4000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the piston pump filling cycle time #define PISTON_PUMP_DISPENSE_PERIOD ( 4000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the piston pump dispense cycle time #define PISTON_PUMP_MIN_SPEED 3.0F ///< Piston pump minimum speed in ml/min. -#define PISTON_PUMP_MAX_SPEED 48.0F ///< Maximum speed for piston pump in mL/min +#define PISTON_PUMP_NOMINAL_SPEED 40.0F ///< Nominal piston pump speed in ml/min. +#define PISTON_PUMP_MAX_SPEED 48.0F ///< Maximum speed for piston pump in mL/min. /// Enumeration of piston pump states. typedef enum PistonPumpState @@ -63,12 +65,13 @@ static PISTON_PUMP_EXEC_STATE_T pistonPumpExecState[ NUM_OF_PISTON_PUMPS ]; ///< Current piston pump control executive state. static F32 pistonPumpSetSpeed[ NUM_OF_PISTON_PUMPS ]; ///< Current piston pump set speed. static F32 pistonPumpVolumeinMl[ NUM_OF_PISTON_PUMPS ]; ///< Current piston pump set volume to deliver. -static U32 pistonPumpFillPeriod; ///< Piston pump fill period -static U32 pistonPumpDispensePeriod; ///< Piston pump dispense period static U32 pistonPumpCycleCount[ NUM_OF_PISTON_PUMPS ]; ///< Number of piston pump (fill and dispense) cycle count -static U32 currentPistonPumpSwitchingCounter[ NUM_OF_PISTON_PUMPS ]; ///< Counter (in task interval) to monitor the piston pump fill/drain operation. -static U32 pistonPumpControlDataPublicationTimerCounter; ///< Used to schedule piston pump control data publication to CAN bus. static OVERRIDE_U32_T pistonPumpControlDataPublishInterval; ///< Piston Pump control data publish interval. +static OVERRIDE_U32_T pistonPumpFillAfterDispense; ///< Piston Pump fill after dispense on each cycle. +static U32 currentDosingTriggerStatus; ///< Read Current Dosing Trigger status +static U32 prevDosingTriggerStatus; ///< Previous Current Dosing status +static U32 pistonPumpControlDataPublicationTimerCounter; ///< Piston pump data publish timer counter +static BOOL readyToDose[ NUM_OF_PISTON_PUMPS ]; ///< Ready to dose status // ********** private function prototypes ********** @@ -80,6 +83,7 @@ static PISTON_PUMP_EXEC_STATE_T handlePistonPumpDispenseCompleteState( PISTON_PUMPS_T pumpId ); static U32 getPistonPumpControlDataPublishInterval( void ); static void publishPistonPumpControlData( void ); +static U32 getPistonPumpFillafterDispenseControl( void ); /*********************************************************************//** * @brief @@ -94,24 +98,28 @@ pistonPumpExecState[ PISTONPUMPS_ACID ] = PISTON_PUMP_OFF_STATE; pistonPumpExecState[ PISTONPUMPS_BICARB ] = PISTON_PUMP_OFF_STATE; pistonPumpExecState[ PISTONPUMPS_UF ] = PISTON_PUMP_OFF_STATE; - currentPistonPumpSwitchingCounter[ PISTONPUMPS_ACID ] = 0; - currentPistonPumpSwitchingCounter[ PISTONPUMPS_BICARB ] = 0; - currentPistonPumpSwitchingCounter[ PISTONPUMPS_UF ] = 0; pistonPumpCycleCount[ PISTONPUMPS_ACID ] = 0; pistonPumpCycleCount[ PISTONPUMPS_BICARB ] = 0; pistonPumpCycleCount[ PISTONPUMPS_UF ] = 0; - pistonPumpVolumeinMl[ PISTONPUMPS_ACID ] = 0.0F; - pistonPumpVolumeinMl[ PISTONPUMPS_BICARB ] = 0.0F; + pistonPumpVolumeinMl[ PISTONPUMPS_ACID ] = TEST_ACID_VOLUME_ML; + pistonPumpVolumeinMl[ PISTONPUMPS_BICARB ] = TEST_BICARB_VOLUME_ML; pistonPumpVolumeinMl[ PISTONPUMPS_UF ] = 0.0F; - pistonPumpSetSpeed[ PISTONPUMPS_ACID ] = PISTON_PUMP_MIN_SPEED; - pistonPumpSetSpeed[ PISTONPUMPS_BICARB ] = PISTON_PUMP_MIN_SPEED; - pistonPumpSetSpeed[ PISTONPUMPS_UF ] = PISTON_PUMP_MIN_SPEED; + pistonPumpSetSpeed[ PISTONPUMPS_ACID ] = PISTON_PUMP_NOMINAL_SPEED; + pistonPumpSetSpeed[ PISTONPUMPS_BICARB ] = PISTON_PUMP_NOMINAL_SPEED; + pistonPumpSetSpeed[ PISTONPUMPS_UF ] = PISTON_PUMP_NOMINAL_SPEED; pistonPumpControlDataPublishInterval.data = PISTON_PUMP_CONTROL_DATA_PUBLISH_INTERVAL; pistonPumpControlDataPublishInterval.ovData = PISTON_PUMP_CONTROL_DATA_PUBLISH_INTERVAL; pistonPumpControlDataPublishInterval.ovInitData = 0; pistonPumpControlDataPublishInterval.override = OVERRIDE_RESET; - pistonPumpFillPeriod = PISTON_PUMP_FILL_PERIOD; - pistonPumpDispensePeriod = PISTON_PUMP_DISPENSE_PERIOD; + pistonPumpFillAfterDispense.data = TRUE; + pistonPumpFillAfterDispense.ovData = TRUE; + pistonPumpFillAfterDispense.ovInitData = 0; + pistonPumpFillAfterDispense.override = OVERRIDE_RESET; + currentDosingTriggerStatus = 0; + prevDosingTriggerStatus = 0; + readyToDose[ PISTONPUMPS_ACID ] = FALSE; + readyToDose[ PISTONPUMPS_BICARB ] = FALSE; + readyToDose[ PISTONPUMPS_UF ] = FALSE; pistonPumpControlDataPublicationTimerCounter = 0; } @@ -129,9 +137,6 @@ for ( pumpId = PISTONPUMPS_FIRST; pumpId < NUM_OF_PISTON_PUMPS; pumpId++ ) { - // Increment free running counter - currentPistonPumpSwitchingCounter [ pumpId ]++; - switch ( pistonPumpExecState[pumpId] ) { case PISTON_PUMP_OFF_STATE: @@ -210,6 +215,32 @@ /*********************************************************************//** * @brief + * The processPistonPumpDosingTrigger function sets the dosing trigger + * status for given pump. + * @details \b Inputs: Dosing pump trigger. + * @details \b Outputs: readyToDose. + * @return none. + *************************************************************************/ +void processPistonPumpDosingTrigger( void ) +{ + currentDosingTriggerStatus = getLevelStatus( PUMP_TRIG_LEVEL ); + + if ( currentDosingTriggerStatus != prevDosingTriggerStatus ) + { + // Trigger dosing only high to low transition + if ( ( LEVEL_STATE_HIGH == prevDosingTriggerStatus ) && ( LEVEL_STATE_LOW == currentDosingTriggerStatus ) ) + { + readyToDose[ PISTONPUMPS_ACID ] = TRUE; + readyToDose[ PISTONPUMPS_BICARB ] = TRUE; + readyToDose[ PISTONPUMPS_UF ] = TRUE; + } + + prevDosingTriggerStatus = currentDosingTriggerStatus; + } +} + +/*********************************************************************//** + * @brief * The startPistonPumpCycle function sets the given piston pump parameters * for dosing/UF operations. * @details \b Inputs: none @@ -227,7 +258,6 @@ pistonPumpCycleCount[ pumpId ] = cycleCount; pistonPumpVolumeinMl[ pumpId ] = targetVolume_ml; pistonPumpSetSpeed[ pumpId ] = speed; - pistonPumpExecState[ pumpId ] = PISTON_PUMP_OFF_STATE; } else { @@ -278,12 +308,17 @@ { PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_OFF_STATE; - // Initiate piston pump control when cycle count is more than 1. + // Initiate piston pump control when cycle count is more than 1 or + // fill cycle to be completed for dispensing when asked. // Will redefine the off state later if required - if ( pistonPumpCycleCount[ pumpId ] > 0 ) + if ( ( pistonPumpCycleCount[ pumpId ] > 0 ) || + ( TRUE == (BOOL)getPistonPumpFillafterDispenseControl() ) ) { state = PISTON_PUMP_FILL_START_STATE; - pistonPumpCycleCount[ pumpId ]--; + if ( pistonPumpCycleCount[ pumpId ] > 0 ) + { + pistonPumpCycleCount[ pumpId ]--; + } } return state; @@ -300,8 +335,7 @@ *************************************************************************/ static PISTON_PUMP_EXEC_STATE_T handlePistonPumpFillStartState( PISTON_PUMPS_T pumpId ) { - PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_FILL_START_STATE; - currentPistonPumpSwitchingCounter [ pumpId ] = 0; + PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_FILL_START_STATE; // Open Inlet and Outlet valve pistonPumpInletOutletValveControl( pumpId, VALVE_STATE_OPEN, VALVE_STATE_CLOSED ); @@ -320,19 +354,16 @@ * @brief * The handlePistonPumpFillCompleteState function check for the piston pump * fill complete and close the currently opened valve. - * @details \b Inputs: currentPistonPumpSwitchingCounter,pistonPumpFillPeriod - * @details \b Outputs: currentPistonPumpSwitchingCounter + * @details \b Inputs: None + * @details \b Outputs: None * @param pumpId pump id to actuate valves pair and control stepper motor * @return next piston pump control state. *************************************************************************/ static PISTON_PUMP_EXEC_STATE_T handlePistonPumpFillCompleteState( PISTON_PUMPS_T pumpId ) { PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_FILL_COMPLETE_STATE; - // TODO: The FPGA status register for step revolution count - downcounter to be monitered here - // to confirm the motor stop. Once FPGA status register issue is fixed, we can bring that here. - // Till then go with some guess timing for filling and dispensing. - if ( currentPistonPumpSwitchingCounter[ pumpId ] >= pistonPumpFillPeriod ) + if ( TRUE == getConcentratePumpDosingStatus( (CONCENTRATE_PUMPS_T)pumpId ) ) { // Close Inlet and Outlet valve pistonPumpInletOutletValveControl( pumpId, VALVE_STATE_CLOSED, VALVE_STATE_CLOSED ); @@ -360,39 +391,45 @@ static PISTON_PUMP_EXEC_STATE_T handlePistonPumpDispenseStartState( PISTON_PUMPS_T pumpId ) { PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_DISPENSE_START_STATE; - currentPistonPumpSwitchingCounter[ pumpId ] = 0; - F32 pumpSpeed = pistonPumpSetSpeed[ pumpId ] * -1.0 ; // This is to rotate motor in reverse direction - // Close Inlet and Open Outlet valve - pistonPumpInletOutletValveControl( pumpId, VALVE_STATE_CLOSED, VALVE_STATE_OPEN ); + // On regular piston pump cycle continue to dispense or when dosing trigger initiated + if ( ( FALSE == (BOOL)getPistonPumpFillafterDispenseControl() ) || + ( ( TRUE == (BOOL)getPistonPumpFillafterDispenseControl() && + ( TRUE == readyToDose[ pumpId ] ) ) ) ) + { + F32 pumpSpeed = pistonPumpSetSpeed[ pumpId ] * -1.0 ; // This is to rotate motor in reverse direction - // start stepper motor with the expected quantity - setConcentratePumpTargetSpeed( (CONCENTRATE_PUMPS_T)pumpId, pumpSpeed, pistonPumpVolumeinMl[ pumpId ] ); - requestConcentratePumpOn( (CONCENTRATE_PUMPS_T)pumpId ); + // Close Inlet and Open Outlet valve + pistonPumpInletOutletValveControl( pumpId, VALVE_STATE_CLOSED, VALVE_STATE_OPEN ); - //Move to next state - state = PISTON_PUMP_DISPENSE_COMPLETE_STATE; + // start stepper motor with the expected quantity + setConcentratePumpTargetSpeed( (CONCENTRATE_PUMPS_T)pumpId, pumpSpeed, pistonPumpVolumeinMl[ pumpId ] ); + requestConcentratePumpOn( (CONCENTRATE_PUMPS_T)pumpId ); + //Reset the dosing flag + readyToDose[ pumpId ] = FALSE; + + //Move to next state + state = PISTON_PUMP_DISPENSE_COMPLETE_STATE; + } + return state; } /*********************************************************************//** * @brief * The handlePistonPumpDispenseCompleteState function check for the piston pump * dispense complete and close the currently opened valve. - * @details \b Inputs: currentPistonPumpSwitchingCounter,pistonPumpDispensePeriod - * @details \b Outputs: currentPistonPumpSwitchingCounter + * @details \b Inputs: None + * @details \b Outputs: None * @param pumpId pump id to actuate valves pair and control stepper motor * @return next piston pump control state. *************************************************************************/ static PISTON_PUMP_EXEC_STATE_T handlePistonPumpDispenseCompleteState( PISTON_PUMPS_T pumpId ) { PISTON_PUMP_EXEC_STATE_T state = PISTON_PUMP_DISPENSE_COMPLETE_STATE; - // TODO: The FPGA status register for step revolution count - downcounter to be monitered here - // to confirm the motor stop. Once FPGA status register issue is fixed, we can bring that here. - // Till then go with some guess timing for filling and dispensing. - if ( currentPistonPumpSwitchingCounter[ pumpId ] >= pistonPumpDispensePeriod ) + if ( TRUE == getConcentratePumpDosingStatus( (CONCENTRATE_PUMPS_T)pumpId ) ) { // Close Inlet and Outlet valve pistonPumpInletOutletValveControl( pumpId, VALVE_STATE_CLOSED, VALVE_STATE_CLOSED ); @@ -429,6 +466,26 @@ /*********************************************************************//** * @brief + * The getPistonPumpFillafterDispenseControl function gets the piston pump + * fill after dispense control. + * @details \b Inputs: pistonPumpFillAfterDispense + * @details \b Outputs: none + * @return the fill after dispense control status. + *************************************************************************/ +static U32 getPistonPumpFillafterDispenseControl( void ) +{ + U32 result = pistonPumpFillAfterDispense.data; + + if ( OVERRIDE_KEY == pistonPumpFillAfterDispense.override ) + { + result = pistonPumpFillAfterDispense.ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief * The publishPistonPumpControlData function broadcasts the piston pump * control execution data at defined interval. * @details \b Inputs: pistonPumpControlDataPublicationTimerCounter @@ -446,9 +503,9 @@ data.acidPumpControlExecState = (U32)pistonPumpExecState[ PISTONPUMPS_ACID ]; data.bicarbPumpControlExecState = (U32)pistonPumpExecState[ PISTONPUMPS_BICARB ]; data.ufPumpControlExecState = (U32)pistonPumpExecState[ PISTONPUMPS_UF ]; - data.acidPistonPumpSwCounter = currentPistonPumpSwitchingCounter[ PISTONPUMPS_ACID ]; - data.bicarbPistonPumpSwCounter = currentPistonPumpSwitchingCounter[ PISTONPUMPS_BICARB ]; - data.ufPistonPumpSwCounter = currentPistonPumpSwitchingCounter[ PISTONPUMPS_UF ]; + data.acidPistonPumpSwCounter = (U32)readyToDose[ PISTONPUMPS_ACID ]; + data.bicarbPistonPumpSwCounter = (U32)readyToDose[ PISTONPUMPS_BICARB ]; + data.ufPistonPumpSwCounter = (U32)readyToDose[ PISTONPUMPS_UF ]; data.acidPistonPumpCycleCount = pistonPumpCycleCount[ PISTONPUMPS_ACID ]; data.bicarbPistonPumpCycleCount = pistonPumpCycleCount[ PISTONPUMPS_BICARB ]; data.ufPistonPumpCycleCount = pistonPumpCycleCount[ PISTONPUMPS_UF ]; @@ -511,8 +568,7 @@ // Handle start command if ( ( TRUE == payload.startStop ) && ( ( payload.speed >= PISTON_PUMP_MIN_SPEED ) && ( payload.speed <= PISTON_PUMP_MAX_SPEED ) ) && - ( payload.volume > 0.0 ) && - ( payload.cycleCount > 0 ) ) + ( payload.volume > 0.0 ) ) { startPistonPumpCycle( (PISTON_PUMPS_T)payload.pumpId, payload.cycleCount, payload.volume, payload.speed ); result = TRUE; @@ -531,6 +587,23 @@ return result; } +/*********************************************************************//** + * @brief + * The testDDPistonPumpFillAfterDispenseOverride function sets the override value + * of the piston pump fill after dispense control. + * @details Inputs: pistonPumpFillAfterDispense + * @details Outputs: pistonPumpFillAfterDispense + * @param message Override message from Dialin which includes the read + * counter value to override for the piston pump fill after dispense control. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testDDPistonPumpFillAfterDispenseOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &pistonPumpFillAfterDispense, 0, 1 ); + + return result; +} + /**@}*/ #endif Index: firmware/App/Controllers/PistonPumpControl.h =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/PistonPumpControl.h (.../PistonPumpControl.h) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Controllers/PistonPumpControl.h (.../PistonPumpControl.h) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -63,9 +63,11 @@ void execPistonPumpController( void ); // Execute the piston pump control state machine void startPistonPumpCycle( PISTON_PUMPS_T pumpId, U32 cycleCount, F32 targetVolume_ml, F32 speed ); // Set the piston pump parameters void stopPistonPumpCycle( PISTON_PUMPS_T pumpId ); // Stop the piston pump +void processPistonPumpDosingTrigger( void ); // Process doding pump trigger control BOOL testDDPistonPumpControlDataPublishIntervalOverride( MESSAGE_T *message ); // To override the piston pump control data publish interval BOOL testDDPistonPumpStartStopOverride( MESSAGE_T *message ); // To override the piston pump start/stop control +BOOL testDDPistonPumpFillAfterDispenseOverride( MESSAGE_T *message ); // To override the piston pump fill after dispense control /**@}*/ Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -532,7 +532,7 @@ VALVES_T valve; BOOL result = FALSE; - memcpy( (U08*)(&payload), message, sizeof( DD_BC_VALVE_OVERRIDE_PAYLOAD_T ) ); + memcpy( (U08*)(&payload), message->payload, sizeof( DD_BC_VALVE_OVERRIDE_PAYLOAD_T ) ); for ( valve = FIRST_BC_VALVE; valve <= LAST_BC_VALVE; valve++ ) { U32 mask = 0x1 << (valve - FIRST_BC_VALVE); Index: firmware/App/DDCommon.h =================================================================== diff -u -r60165f6d155831cfce06560fb45abaaaadea9798 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/DDCommon.h (.../DDCommon.h) (revision 60165f6d155831cfce06560fb45abaaaadea9798) +++ firmware/App/DDCommon.h (.../DDCommon.h) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -43,7 +43,7 @@ //#define __PITEST__ 1 //Dialysate speed Open loop speed and pressure test -//#define __OPENSPDTEST__ 1 +#define __OPENSPDTEST__ 1 #include Index: firmware/App/Monitors/Level.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Monitors/Level.c (.../Level.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -22,6 +22,11 @@ #include "TaskPriority.h" #include "Timers.h" +#ifdef __PUMPTEST__ +#include "gio.h" +#include "PistonPumpControl.h" +#endif + /** * @addtogroup Level * @{ @@ -40,6 +45,11 @@ #define LEVEL_DEBOUNCE_TIME_MS ( MS_PER_SECOND / 10 ) ///< Level debounce time in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 7 ///< Data publish counter start count. +#ifdef __PUMPTEST__ +#define DOSING_TRIGGER_GIO_PORT_PIN 6U ///< GPIO pin ID on port A for dosing trigger input signal. +#define GET_PUMP_DOSING_TRIGGER() (PIN_SIGNAL_STATE_T)(gioGetBit(gioPORTA, DOSING_TRIGGER_GIO_PORT_PIN)) ///< Macro to get dosing trigger state. +#endif + /// Level status structure typedef struct { @@ -120,6 +130,12 @@ currentLevelStatus = ( processLevelCount( getFPGAD46LevelSensor() ) == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); break; +#ifdef __PUMPTEST__ + case PUMP_TRIG_LEVEL: + currentLevelStatus = ( GET_PUMP_DOSING_TRIGGER() == 0 ? LEVEL_STATE_LOW : LEVEL_STATE_HIGH ); + break; +#endif + #ifndef _VECTORCAST_ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_LEVEL_SELECTED, i ); @@ -151,6 +167,11 @@ case D46_LEVL: SEND_EVENT_WITH_2_U32_DATA( DD_EVENT_D46_LEVL_CHANGE, (U32)status[ i ].data, (U32)currentLevelStatus ); break; +#ifdef __PUMPTEST__ + case PUMP_TRIG_LEVEL: + // TODO: Will handle event later if required + break; +#endif #ifndef _VECTORCAST_ default: @@ -171,7 +192,13 @@ levelsStatus[i].priorRawLevel = currentLevelStatus; } +#ifdef __PUMPTEST__ + // Handle dosing trigger + processPistonPumpDosingTrigger(); +#endif publishLevelsData(); + + } /*********************************************************************//** @@ -283,7 +310,11 @@ data.d6Level = (U32)getLevelStatus( D6_LEVL ); data.d63Level = (U32)getLevelStatus( D63_LEVL ); +#ifndef __PUMPTEST__ data.d46Level = (U32)getLevelStatus( D46_LEVL ); +#else + data.d46Level = (U32)getLevelStatus( PUMP_TRIG_LEVEL ); +#endif levelsDataPublicationCounter = 0; Index: firmware/App/Monitors/Level.h =================================================================== diff -u -r313982ccc772f1bbe182877dff7e00381b04e0f4 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Monitors/Level.h (.../Level.h) (revision 313982ccc772f1bbe182877dff7e00381b04e0f4) +++ firmware/App/Monitors/Level.h (.../Level.h) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -38,6 +38,9 @@ D6_LEVL = 0, ///< floater switch low, medium and high status D63_LEVL, ///< bicarb level low or high status D46_LEVL, ///< Spent dialysate air separation chamber level low or high status +#ifdef __PUMPTEST__ + PUMP_TRIG_LEVEL, ///< Trigger for piston pump dosing ( high or low input signal) +#endif NUM_OF_LEVELS ///< Number of levels } LELVEL_T; Index: firmware/App/Monitors/Pressure.c =================================================================== diff -u -r60165f6d155831cfce06560fb45abaaaadea9798 -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision 60165f6d155831cfce06560fb45abaaaadea9798) +++ firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -35,14 +35,14 @@ #define PRESSURES_DATA_PUB_INTERVAL ( 50 / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the pressures data is published on the CAN bus. #endif #define DATA_PUBLISH_COUNTER_START_COUNT ( 5 ) ///< Data publish counter start count. -#define PRESSURE_SAMPLE_FILTER_MS ( 50 ) ///< Filter pressure data for given time +#define PRESSURE_SAMPLE_FILTER_MS ( 50 ) ///< Filter pressure data for given time #define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 50 ) -//#define PRESSURE_SAMPLE_FILTER_MS ( 200 ) ///< Filter pressure data for given time -//#define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 200 ) ///< Filter temperature data for given time +//#define PRESSURE_SAMPLE_FILTER_MS ( 200 ) ///< Filter pressure data for given time +//#define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 200 ) ///< Filter temperature data for given time #define SIZE_OF_PRESSURE_ROLLING_AVG ( PRESSURE_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure moving average. #define SIZE_OF_PRESSURETEMP_ROLLING_AVG ( PRESSURE_TEMP_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure temprature w/ 1 second moving average. #define MMHG_TO_PSI_CONVERSION 0.0193368F ///< MMHG to PSI conversion. -#define BAR_TO_PSI_CONVERSION 14.5038F ///< MMHG to PSI conversion. +#define BAR_TO_PSI_CONVERSION 14.5038F ///< MMHG to PSI conversion. #define MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG 20.0F ///< Minimum allowed Input low pressure value in psig. #define MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG 80.0F ///< Maximum allowed Input high pressure value in psig. @@ -500,11 +500,11 @@ data.d18PresTemp = getFilteredPressureSensorTemperature( D18_PRES ); data.d41PresTemp = getFilteredPressureSensorTemperature( D41_PRES ); #else - data.m1PresTemp = getPressure( M1_PRES ); - data.m3PresTemp = getPressure( M3_PRES ); + data.m1PresTemp = (F32)getPressureSensorErrorCount( D9_PRES ); + data.m3PresTemp = (F32)getPressureSensorReadCount( D9_PRES ); data.d9PresTemp = getPressure( D9_PRES ); - data.d66PresTemp = getPressure( D66_PRES ); - data.d51PresTemp = getPressure( D51_PRES ); + data.d66PresTemp = (F32)getPressureSensorErrorCount( D18_PRES ); + data.d51PresTemp = (F32)getPressureSensorReadCount( D18_PRES ); data.d18PresTemp = getPressure( D18_PRES ); data.d41PresTemp = getPressure( D41_PRES ); #endif Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -re0fc678329b0cb25dd76fa5e23cc1f487851f0ec --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision e0fc678329b0cb25dd76fa5e23cc1f487851f0ec) @@ -146,6 +146,7 @@ #ifdef __PUMPTEST__ MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST, MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST, + MSG_ID_DD_PISTON_PUMP_FILL_AFTER_DISPENSE_OVERRIDE_REQUEST, #endif }; @@ -212,6 +213,7 @@ #ifdef __PUMPTEST__ &testDDPistonPumpControlDataPublishIntervalOverride, &testDDPistonPumpStartStopOverride, + &testDDPistonPumpFillAfterDispenseOverride, #endif };