Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r6b96f1a18ab2f93068daddbf24178fbbae7cc570 -r55147f11d199be6710172cafcde21547af1f7689 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 6b96f1a18ab2f93068daddbf24178fbbae7cc570) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 55147f11d199be6710172cafcde21547af1f7689) @@ -80,7 +80,7 @@ #define BP_ML_PER_ROTOR_REV 13.75F ///< 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.00000000000F ///< A term used for wear portion of alpha flow coefficient. +#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_MIN_ART_PRESSURE_MMHG -200.0F ///< Minimum arterial pressure factored into blood flow calculation. @@ -143,6 +143,9 @@ 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 TD_PUMPS_CAL_RECORD_T bloodPumpCalRecord; ///< Blood pump calibration record. @@ -159,6 +162,9 @@ static void checkBloodPumpSpeeds( void ); static F32 calcBloodFlow( void ); +static F32 getBPFlowAlphaYIntercept( void ); +static F32 getBPFlowWearATerm( void ); +static F32 getBPFlowWearBTerm( void ); static void resetBloodPumpRPMMovingAverage( void ); static void filterBloodPumpRPMReadings( F32 rpm ); @@ -213,6 +219,18 @@ bloodPumpRotorCounter.ovData = 0; bloodPumpRotorCounter.ovInitData = 0; bloodPumpRotorCounter.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; + bpFlowWearATerm.override = OVERRIDE_RESET; + bpFlowWearBTerm.data = BP_FLOW_WEAR_B_TERM; + bpFlowWearBTerm.ovData = BP_FLOW_WEAR_B_TERM; + bpFlowWearBTerm.ovInitData = BP_FLOW_WEAR_B_TERM; + bpFlowWearBTerm.override = OVERRIDE_RESET; // Initialize pump speed filter for ( i = 0; i < SIZE_OF_ROLLING_AVG; i++ ) @@ -343,9 +361,9 @@ F32 rotSpd = filteredBloodPumpSpeed / BP_GEAR_RATIO; U32 r = getBloodPumpRotorCount(); U32 rotCnt = CAP( r, BP_MAX_ROTOR_COUNT_FOR_WEAR ); - F32 wear = BP_FLOW_WEAR_A_TERM * (F32)rotCnt + BP_FLOW_WEAR_B_TERM; - F32 alpha = wear * artPresL + BP_FLOW_ALPHA_Y_INTERCEPT; - F32 flow = BP_ML_PER_ROTOR_REV * rotSpd; // * alpha; TODO + F32 wear = getBPFlowWearATerm() * (F32)rotCnt + getBPFlowWearBTerm(); + F32 alpha = wear * artPresL + getBPFlowAlphaYIntercept(); + F32 flow = BP_ML_PER_ROTOR_REV * rotSpd * alpha; return flow; } @@ -783,6 +801,51 @@ /*********************************************************************//** * @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 + * @details \b Outputs: none + * @return the current blood flow A term for wear. + *************************************************************************/ +static F32 getBPFlowWearATerm( void ) +{ + F32 result = getF32OverrideValue( &bpFlowWearATerm ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getBPFlowWearBTerm function gets the blood pump flow estimation + * B term for wear. + * @details \b Inputs: bpFlowWearBTerm + * @details \b Outputs: none + * @return the current blood flow B term for wear. + *************************************************************************/ +static F32 getBPFlowWearBTerm( void ) +{ + F32 result = getF32OverrideValue( &bpFlowWearBTerm ); + + 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. @@ -1252,4 +1315,55 @@ return result; } +/*********************************************************************//** + * @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 + * @details \b Outputs: bpFlowWearATerm + * @param message Override message from Dialin which includes the wear A term + * value to override with. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testBPFlowWearATermOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &bpFlowWearATerm ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testBPFlowWearBTermOverride function overrides the wear B term of the + * blood flow estimation equation. + * @details \b Inputs: none + * @details \b Outputs: bpFlowWearBTerm + * @param message Override message from Dialin which includes the wear B term + * value to override with. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testBPFlowWearBTermOverride( MESSAGE_T *message ) +{ + BOOL result = f32Override( message, &bpFlowWearBTerm ); + + return result; +} + /**@}*/