Index: firmware/App/Drivers/PeristalticPump.c =================================================================== diff -u -raa6d45143096dfab776ce2ed7c775cfe2dd6db18 -r395522dffef1348e176564925656012f529c1910 --- firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision aa6d45143096dfab776ce2ed7c775cfe2dd6db18) +++ firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision 395522dffef1348e176564925656012f529c1910) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* Copyright (c) 2024-2026 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file PeristalticPump.c * -* @author (last) Sean -* @date (last) 03-Oct-2024 +* @author (last) Dara Navaei +* @date (last) 25-Sep-2025 * -* @author (original) Sean -* @date (original) 03-Oct-2024 +* @author (original) Sean Nash +* @date (original) 24-Oct-2024 * ***************************************************************************/ @@ -27,7 +27,6 @@ // ********** private definitions ********** -#define MAX_PUMP_SPEED_RPM 3080U ///< Maximum speed (in RPM) that a peristaltic pump can be set to. #define H4_PUMP_CMD_GAIN 0.9F ///< Gain for blood pump commanded RPM that must be applied before sending to FPGA. #define H4_PUMP_CMD_OFFSET 80.0F ///< Offset for blood pump commanded RPM that must be applied before sending to FPGA. #define H4_PUMP_CMD_CAL(r) ((r) * H4_PUMP_CMD_GAIN + H4_PUMP_CMD_OFFSET ) ///< Macro to calibrate a commanded blood pump RPM before sending to FPGA. @@ -43,8 +42,6 @@ #define H4_ROT_PERIOD_TO_HZ(p) ( 1.0F / (F32)((S32)(p) * H4_ROT_PERIOD_SEC) ) ///< Blood pump rotor period to Hz conversion macro. #define H4_ROT_PERIOD_TO_RPM(p) ((H4_ROT_PERIOD_TO_HZ(p)) * (F32)SEC_PER_MIN) ///< Blood pump rotor period to RPM conversion macro. -#define H4_HOME_SPEED_RPM 400 ///< Blood pump set speed for rotor homing operation. - #define H6_STATUS_HOME_BIT_POS 0x1 ///< Bit position in H6 status register that indicates whether rotor is in home position. // ********** private data ********** @@ -53,6 +50,7 @@ static F32 pumpMeasSpeedRPM; ///< Latest measured pump speed (in RPM). static F32 pumpMeasRotSpeedRPM; ///< Latest measured pump rotor speed (in RPM). static BOOL pumpHomeInProgress; ///< Flag indicates a pump home operation is in progress. +static BOOL pumpHomeLowSignalSeen; ///< Flag indicates a pump home operation has seen a "not home" signal. // ********** private function prototypes ********** @@ -66,10 +64,11 @@ *************************************************************************/ void initPeristalticPumpDriver(void) { - pumpHomeInProgress = FALSE; - pumpSetSpeedRPM = 0; - pumpMeasSpeedRPM = 0.0F; - pumpMeasRotSpeedRPM = 0.0F; + pumpHomeInProgress = FALSE; + pumpHomeLowSignalSeen = FALSE; + pumpSetSpeedRPM = 0; + pumpMeasSpeedRPM = 0.0F; + pumpMeasRotSpeedRPM = 0.0F; setH4Direction( MOTOR_DIR_FORWARD ); setH4SetSpeed( 0 ); @@ -122,11 +121,15 @@ } // monitor home command status if in progress, stop pump if rotor is in home position - if ( ( TRUE == pumpHomeInProgress ) && ( TRUE == isPeristalticPumpHome() ) ) + if ( ( TRUE == pumpHomeInProgress ) && ( TRUE == isPeristalticPumpHome() ) && ( TRUE == pumpHomeLowSignalSeen ) ) { - pumpHomeInProgress = FALSE; setPeristalticPumpSetSpeed( 0 ); + pumpHomeInProgress = FALSE; } + else if ( isPeristalticPumpHome() != TRUE ) + { + pumpHomeLowSignalSeen = TRUE; + } } /*********************************************************************//** @@ -145,6 +148,7 @@ { result = TRUE; pumpHomeInProgress = TRUE; + pumpHomeLowSignalSeen = ( isPeristalticPumpHome() != TRUE ? TRUE : FALSE ); setPeristalticPumpSetSpeed( H4_HOME_SPEED_RPM ); } @@ -153,6 +157,18 @@ /*********************************************************************//** * @brief + * The cancelPeristalticPumpHome function cancels a pump home operation. + * @details \b Inputs: none + * @details \b Outputs: pumpHomeInProgress + * @return none + *************************************************************************/ +void cancelPeristalticPumpHome( void ) +{ + pumpHomeInProgress = FALSE; +} + +/*********************************************************************//** + * @brief * The isPeristalticPumpHome function determines whether the rotor is currently * in the home position. * @details \b Inputs: FPGA @@ -161,14 +177,27 @@ *************************************************************************/ BOOL isPeristalticPumpHome( void ) { - U08 status = getH6Status() & H6_STATUS_HOME_BIT_POS; + U08 status = getH6RotorStatus() & H6_STATUS_HOME_BIT_POS; BOOL result = ( status != 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief + * The isPumpHomeInProgress function determines whether a home operation is + * currently in progress. + * @details \b Inputs: pumpHomeInProgress + * @details \b Outputs: none + * @return pumpHomeInProgress + *************************************************************************/ +BOOL isPumpHomeInProgress( void ) +{ + return pumpHomeInProgress; +} + +/*********************************************************************//** + * @brief * The setPeristalticPumpSetSpeed function sets the target pump speed (in RPM). * @note A negative set speed indicates reverse (CCW) direction. * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given set speed is out @@ -207,6 +236,19 @@ /*********************************************************************//** * @brief + * The setPeristalticPumpHardStop function stops the pump and holds the torque + * of the pump. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ +void setPeristalticPumpHardStop( void ) +{ + setH4BrakeAndHoldTorque(); +} + +/*********************************************************************//** + * @brief * The getPeristalticPumpSetSpeed function gets the current pump set * speed in RPM. * @note A negative speed indicates reverse direction.