Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r3ec00e24074c1526f174af7e058906523ba10d33 -r7c3e70e76a480c56e52a181fb0d2d32f13847530 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 3ec00e24074c1526f174af7e058906523ba10d33) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 7c3e70e76a480c56e52a181fb0d2d32f13847530) @@ -7,8 +7,8 @@ * * @file BloodFlow.c * -* @author (last) Varshini Nagabooshanam -* @date (last) 26-Jan-2026 +* @author (last) Jashwant Gantyada +* @date (last) 13-Mar-2026 * * @author (original) Sean Nash * @date (original) 24-Oct-2024 @@ -78,11 +78,10 @@ #define BP_RAMP_STEP_SPEED_RPM 50 ///< Blood pump ramp step size (in RPM). -#define BP_ML_PER_ROTOR_REV 12.26F ///< Blood pump volume (mL) per rotor revolution. -#define BP_FLOW_ALPHA_Y_INTERCEPT 1.00F ///< Y intercept used for alpha flow coefficient calculation. -#define BP_FLOW_WEAR_A_TERM 0.000000F ///< A term used for wear portion of alpha flow coefficient. -#define BP_FLOW_WEAR_B_TERM 0.000000F ///< B term used for wear portion of alpha flow coefficient. -#define BP_MAX_ROTOR_COUNT_FOR_WEAR 25000 ///< Maximum rotor count for determining wear of the cartridge (negligible affect beyond this threshold). +#define BP_ML_PER_ROTOR_REV 12.26F ///< Default blood pump volume (mL) per rotor revolution. +#define BP_FLOW_WEAR_A_TERM -0.00000034F ///< Default wear term alpha used in blood flow estimation. +#define BP_FLOW_WEAR_B_TERM 1500.0F ///< Default wear term beta (offset) used in blood flow estimation. +#define BP_MAX_ROTOR_COUNT_FOR_WEAR 26000 ///< Default maximum rotor count for determining wear of the cartridge. #define BP_MIN_ART_PRESSURE_MMHG -200.0F ///< Minimum arterial pressure factored into blood flow calculation. #define BP_RATE_FROM_RPM( rpm ) ( rpm / ( BP_GEAR_RATIO / BP_ML_PER_ROTOR_REV ) ) ///< Macro to estimate a flow rate (mL/min) from a given speed (RPM). @@ -147,9 +146,10 @@ static OVERRIDE_U32_T bloodPumpRotorCounter; ///< Running counter for blood pump rotor revolutions. static BOOL bpHomeRequested; ///< Flag indicating a home operation has been requested. static U32 bpHomeStartTime; ///< When did blood pump home command begin? (in ms). -static OVERRIDE_F32_T bpFlowAlphaYIntercept; ///< Blood flow estimation term for alpha Y intercept. static OVERRIDE_F32_T bpFlowWearATerm; ///< Blood flow estimation term for wear slope. static OVERRIDE_F32_T bpFlowWearBTerm; ///< Blood flow estimation term for wear offset. +static OVERRIDE_F32_T bpStrokeVolumeMlPerRev; ///< Blood flow estimation term for stroke volume (mL per rotor rev). +static OVERRIDE_U32_T bpMaxRotorCountForWear; ///< Maximum rotor count used for cartridge wear estimation. //static TD_PUMPS_CAL_RECORD_T bloodPumpCalRecord; ///< Blood pump calibration record. @@ -169,6 +169,8 @@ static F32 getBPFlowAlphaYIntercept( void ); static F32 getBPFlowWearATerm( void ); static F32 getBPFlowWearBTerm( void ); +static F32 getBPStrokeVolume( void ); +static U32 getBPMaxRotorCountForWear( void ); static void resetBloodPumpRPMMovingAverage( void ); static void filterBloodPumpRPMReadings( F32 rpm ); static F32 calcBloodPumpTorque( void ); @@ -228,10 +230,6 @@ bloodPumpTorquemNm.ovData = 0.0F; bloodPumpTorquemNm.ovInitData = 0.0F; bloodPumpTorquemNm.override = OVERRIDE_RESET; - bpFlowAlphaYIntercept.data = BP_FLOW_ALPHA_Y_INTERCEPT; - bpFlowAlphaYIntercept.ovData = BP_FLOW_ALPHA_Y_INTERCEPT; - bpFlowAlphaYIntercept.ovInitData = BP_FLOW_ALPHA_Y_INTERCEPT; - bpFlowAlphaYIntercept.override = OVERRIDE_RESET; bpFlowWearATerm.data = BP_FLOW_WEAR_A_TERM; bpFlowWearATerm.ovData = BP_FLOW_WEAR_A_TERM; bpFlowWearATerm.ovInitData = BP_FLOW_WEAR_A_TERM; @@ -240,6 +238,14 @@ bpFlowWearBTerm.ovData = BP_FLOW_WEAR_B_TERM; bpFlowWearBTerm.ovInitData = BP_FLOW_WEAR_B_TERM; bpFlowWearBTerm.override = OVERRIDE_RESET; + bpStrokeVolumeMlPerRev.data = BP_ML_PER_ROTOR_REV; + bpStrokeVolumeMlPerRev.ovData = BP_ML_PER_ROTOR_REV; + bpStrokeVolumeMlPerRev.ovInitData = BP_ML_PER_ROTOR_REV; + bpStrokeVolumeMlPerRev.override = OVERRIDE_RESET; + bpMaxRotorCountForWear.data = BP_MAX_ROTOR_COUNT_FOR_WEAR; + bpMaxRotorCountForWear.ovData = BP_MAX_ROTOR_COUNT_FOR_WEAR; + bpMaxRotorCountForWear.ovInitData = BP_MAX_ROTOR_COUNT_FOR_WEAR; + bpMaxRotorCountForWear.override = OVERRIDE_RESET; // Initialize pump speed filter for ( i = 0; i < SIZE_OF_ROLLING_AVG; i++ ) @@ -357,22 +363,21 @@ /*********************************************************************//** * @brief * The calcBloodFlow function calculates an estimated blood flow rate from - * blood pump speed, arterial pressure and tubing wear (measured from count - * of rotor revolutions since cartridge install). - * @details \b Inputs: bloodPumpRotorCounter, arterial pressure + * blood pump speed and tubing wear (measured from count of rotor revolutions + * since cartridge install) using the simplified wear-only equation: + * Flow = [ Alpha * (RotorCnt + Beta) + 1 ] * RotorRPM * StrokeVolume. + * @details \b Inputs: bloodPumpRotorCounter, stroke volume and wear params * @details \b Outputs: none * @return calculated blood flow rate (mL/min) *************************************************************************/ static F32 calcBloodFlow( void ) { - F32 artPres = getLongFilteredArterialPressure(); - F32 artPresL= ( artPres > BP_MIN_ART_PRESSURE_MMHG ? artPres : BP_MIN_ART_PRESSURE_MMHG ); - F32 rotSpd = filteredBloodPumpSpeed / BP_GEAR_RATIO; - U32 r = getBloodPumpRotorCount(); - U32 rotCnt = CAP( r, BP_MAX_ROTOR_COUNT_FOR_WEAR ); - F32 wear = getBPFlowWearATerm() * (F32)rotCnt + getBPFlowWearBTerm(); - F32 alpha = wear * artPresL + getBPFlowAlphaYIntercept(); - F32 flow = BP_ML_PER_ROTOR_REV * rotSpd * alpha; + F32 rotSpd = filteredBloodPumpSpeed / BP_GEAR_RATIO; + U32 r = getBloodPumpRotorCount(); + U32 rotCnt = CAP( r, getBPMaxRotorCountForWear() ); + F32 alpha = ( getBPFlowWearATerm() * ( (F32)rotCnt + getBPFlowWearBTerm() ) ) + 1.0F; + F32 strokeVl = getBPStrokeVolume(); + F32 flow = alpha * rotSpd * strokeVl; return flow; } @@ -465,25 +470,25 @@ return result; } -///*********************************************************************//** -// * @brief -// * The resetBloodPumpRotorCount function resets the blood pump rotor counter -// * that is a proxy for cartridge wear. Call this function after a new cartridge -// * has been installed. -// * @details \b Inputs: none -// * @details \b Outputs: bloodPumpRotorCounter -// * @return none -// *************************************************************************/ -//void resetBloodPumpRotorCount( void ) -//{ +/*********************************************************************//** + * @brief + * The resetBloodPumpRotorCount function resets the blood pump rotor counter + * that is a proxy for cartridge wear. Call this function after a new cartridge + * has been installed. + * @details \b Inputs: none + * @details \b Outputs: bloodPumpRotorCounter + * @return none + *************************************************************************/ +void resetBloodPumpRotorCount( void ) +{ // bloodPumpRotorCounter.data = 0; -// -// if ( TRUE == getTestConfigStatus( TEST_CONFIG_USE_WORN_CARTRIDGE ) ) -// { -// bloodPumpRotorCounter.data = BP_MAX_ROTOR_COUNT_FOR_WEAR; -// } -//} + // if ( TRUE == getTestConfigStatus( TEST_CONFIG_USE_WORN_CARTRIDGE ) ) + { + bloodPumpRotorCounter.data = BP_MAX_ROTOR_COUNT_FOR_WEAR; + } +} + /*********************************************************************//** * @brief * The execBloodFlowMonitor function executes the blood flow monitor. @@ -829,21 +834,6 @@ /*********************************************************************//** * @brief - * The getBPFlowAlphaYIntercept function gets the blood pump flow alpha - * intercept for blood flow estimation. - * @details \b Inputs: bpFlowAlphaYIntercept - * @details \b Outputs: none - * @return the current blood flow alpha intercept term. - *************************************************************************/ -static F32 getBPFlowAlphaYIntercept( void ) -{ - F32 result = getF32OverrideValue( &bpFlowAlphaYIntercept ); - - return result; -} - -/*********************************************************************//** - * @brief * The getBPFlowWearATerm function gets the blood pump flow estimation * A term for wear. * @details \b Inputs: bpFlowWearATerm @@ -874,6 +864,36 @@ /*********************************************************************//** * @brief + * The getBPStrokeVolume function gets the blood pump stroke volume used + * for blood flow estimation (mL per rotor revolution). + * @details \b Inputs: bpStrokeVolumeMlPerRev + * @details \b Outputs: none + * @return the current stroke volume (mL per rotor rev). + *************************************************************************/ +static F32 getBPStrokeVolume( void ) +{ + F32 result = getF32OverrideValue( &bpStrokeVolumeMlPerRev ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getBPMaxRotorCountForWear function gets the maximum rotor count + * used for cartridge wear estimation. + * @details \b Inputs: bpMaxRotorCountForWear + * @details \b Outputs: none + * @return the maximum rotor count used for wear estimation. + *************************************************************************/ +static U32 getBPMaxRotorCountForWear( void ) +{ + U32 result = getU32OverrideValue( &bpMaxRotorCountForWear ); + + return result; +} + +/*********************************************************************//** + * @brief * The publishBloodFlowData function publishes blood flow data at the set * interval. * @details \b Message \b Sent: MSG_ID_TD_BLOOD_PUMP_DATA at set interval. @@ -1385,23 +1405,6 @@ /*********************************************************************//** * @brief - * The testBPFlowAlphaYInterceptOverride function overrides the Alpha Y - * intercept of the blood flow estimation equation. - * @details \b Inputs: none - * @details \b Outputs: bpFlowAlphaYIntercept - * @param message Override message from Dialin which includes the Alpha Y - * intercept value to override with. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testBPFlowAlphaYInterceptOverride( MESSAGE_T *message ) -{ - BOOL result = f32Override( message, &bpFlowAlphaYIntercept ); - - return result; -} - -/*********************************************************************//** - * @brief * The testBPFlowWearATermOverride function overrides the wear A term of the * blood flow estimation equation. * @details \b Inputs: none @@ -1434,4 +1437,21 @@ return result; } +/*********************************************************************//** + * @brief + * The testBPStrokeVolumeOverride function overrides the stroke volume + * (mL per rotor revolution) used in the blood flow estimation equation. + * @details \b Inputs: none + * @details \b Outputs: bpStrokeVolumeMlPerRev + * @param message Override message from Dialin which includes the stroke + * volume (mL per rotor revolution) to override with. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testBPStrokeVolumeOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &bpStrokeVolumeMlPerRev ); + + return result; +} + /**@}*/ Index: firmware/App/Controllers/BloodFlow.h =================================================================== diff -u -r3ec00e24074c1526f174af7e058906523ba10d33 -r7c3e70e76a480c56e52a181fb0d2d32f13847530 --- firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision 3ec00e24074c1526f174af7e058906523ba10d33) +++ firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision 7c3e70e76a480c56e52a181fb0d2d32f13847530) @@ -84,9 +84,9 @@ BOOL testBloodPumpRotorCountOverride( MESSAGE_T *message ); BOOL testHomeBloodPump( MESSAGE_T *message ); BOOL testHardStopBloodPump( MESSAGE_T *message ); -BOOL testBPFlowAlphaYInterceptOverride( MESSAGE_T *message ); BOOL testBPFlowWearATermOverride( MESSAGE_T *message ); BOOL testBPFlowWearBTermOverride( MESSAGE_T *message ); +BOOL testBPStrokeVolumeOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rc01e44290174eb4098c14b17031ac538d7560b03 -r7c3e70e76a480c56e52a181fb0d2d32f13847530 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision c01e44290174eb4098c14b17031ac538d7560b03) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 7c3e70e76a480c56e52a181fb0d2d32f13847530) @@ -168,9 +168,9 @@ { MSG_ID_TD_EJECTOR_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testEjectorDataPublishIntervalOverride }, { MSG_ID_TD_SET_AIR_TRAP_CONTROL, &testSetAirTrapControl }, { MSG_ID_TD_HOME_BLOOD_PUMP, &testHomeBloodPump }, - { MSG_ID_TD_BLOOD_FLOW_ALPHA_Y_INTERCEPT_OVERRIDE_REQUEST, &testBPFlowAlphaYInterceptOverride }, { MSG_ID_TD_BLOOD_FLOW_WEAR_A_TERM_OVERRIDE_REQUEST, &testBPFlowWearATermOverride }, { MSG_ID_TD_BLOOD_FLOW_WEAR_B_TERM_OVERRIDE_REQUEST, &testBPFlowWearBTermOverride }, + { MSG_ID_TD_BLOOD_FLOW_STROKE_VOLUME_OVERRIDE_REQUEST, &testBPStrokeVolumeOverride }, { MSG_ID_TD_SET_TEST_CONFIGURATION, &testSetTestConfiguration }, { MSG_ID_TD_GET_TEST_CONFIGURATION, &testGetTestConfiguration }, { MSG_ID_TD_RESET_ALL_TEST_CONFIGURATIONS, &testResetAllTestConfigurations },