Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rfff308d96794e7df7e91149173c3760ff3fda10c -r933a18d740285e70be9d00696ed0f5a5381bc8e4 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision fff308d96794e7df7e91149173c3760ff3fda10c) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 933a18d740285e70be9d00696ed0f5a5381bc8e4) @@ -8,7 +8,7 @@ * @file BloodFlow.c * * @author (last) Sean Nash -* @date (last) 08-Sep-2020 +* @date (last) 13-Oct-2020 * * @author (original) Sean Nash * @date (original) 07-Nov-2019 @@ -24,33 +24,36 @@ #include "DialInFlow.h" #include "PresOccl.h" +#include "BloodFlow.h" #include "FPGA.h" #include "InternalADC.h" #include "NVDataMgmt.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "PIControllers.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" -#include "BloodFlow.h" /** * @addtogroup BloodFlow * @{ */ // ********** private definitions ********** + +/// interval (ms/task time) at which the blood flow data is published on the CAN bus. +#define BLOOD_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) -#define BLOOD_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the blood flow data is published on the CAN bus - #define MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE 0.008 ///< max duty cycle change when ramping up ~ 100 mL/min/s. #define MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE 0.016 ///< max duty cycle change when ramping down ~ 200 mL/min/s. #define MAX_BLOOD_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88% #define MIN_BLOOD_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12% - -#define BP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the blood pump is controlled + +/// interval (ms/task time) at which the blood pump is controlled. +#define BP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) #define BP_P_COEFFICIENT 0.00035 ///< P term for blood pump control #define BP_I_COEFFICIENT 0.00035 ///< I term for blood pump control @@ -63,36 +66,44 @@ #define BP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. #define BP_MAX_ROTOR_SPEED_RPM 100.0 ///< maximum rotor speed allowed for blood pump. -#define BP_MAX_FLOW_VS_SPEED_DIFF_ML_MIN 50.0 ///< maximum difference between measured flow and flow implied by measured motor speed. +#define BP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< maximum difference between measured speed and speed implied by measured flow. #define BP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< maximum motor speed (RPM) while motor is commanded off. #define BP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< maximum difference in speed between motor and rotor (in rotor RPM). #define BP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< maximum difference in speed between measured and commanded RPM. -#define BP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for flow vs. motor speed error condition. -#define BP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. -#define BP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. -#define BP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. +#define BP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for flow vs. motor speed error condition. +#define BP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. +#define BP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. +#define BP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. +#define BP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) pump direction error condition. +#define BP_MAX_ROTOR_SPEED_ERROR_PERSIST ((1 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) blood pump rotor speed too fast error condition. #define BP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< motor controller current should not exceed this when pump should be stopped #define BP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< motor controller current should always exceed this when pump should be running -#define BP_MAX_CURR_WHEN_RUNNING_MA 1000.0 ///< motor controller current should not exceed this when pump should be running +#define BP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< motor controller current should not exceed this when pump should be running #define BP_MAX_CURR_ERROR_DURATION_MS 2000 ///< motor controller current errors persisting beyond this duration will trigger an alarm #define BP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< conversion factor from ADC counts to RPM for blood pump motor #define BP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< conversion factor from ADC counts to mA for blood pump motor -#define BP_REV_PER_LITER 150.24 ///< rotor revolutions per liter +#define BP_REV_PER_LITER 150.0 ///< rotor revolutions per liter #define BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( BP_REV_PER_LITER / ML_PER_LITER ) ///< conversion factor from mL/min to motor RPM. #define BP_GEAR_RATIO 32.0 ///< blood pump motor to blood pump gear ratio #define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00028 ///< ~28 BP motor RPM = 1% PWM duty cycle #define BP_PWM_ZERO_OFFSET 0.1 ///< 10% PWM duty cycle = zero speed -#define BP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * BP_GEAR_RATIO * BP_MOTOR_RPM_TO_PWM_DC_FACTOR + BP_PWM_ZERO_OFFSET ) ///< conversion factor from mL/min to estimated PWM duty cycle %. +/// conversion factor from mL/min to estimated PWM duty cycle %. +#define BP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * BP_GEAR_RATIO * BP_MOTOR_RPM_TO_PWM_DC_FACTOR + BP_PWM_ZERO_OFFSET ) #define BLOODPUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref may be different) #define BLOODPUMP_ADC_ZERO 1998 ///< Blood pump ADC channel zero offset. -#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) ///< macro converts 12 bit ADC value to signed 16-bit value. +/// macro converts 12 bit ADC value to signed 16-bit value. +#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) +/// measured blood flow is filtered w/ moving average +#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) + +/// blood flow sensor signal strength low alarm persistence. +#define FLOW_SIG_STRGTH_ALARM_PERSIST ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 5 ) +#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). -#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) ///< measured blood flow is filtered w/ moving average - /// Enumeration of blood pump controller states. typedef enum BloodPump_States { @@ -140,30 +151,34 @@ static F32 bloodFlowCalGain = 1.0; ///< blood flow calibration gain. static F32 bloodFlowCalOffset = 0.0; ///< blood flow calibration offset. -/// Interval (in ms) at which to publish blood flow data to CAN bus +/// Interval (in task intervals) at which to publish blood flow data to CAN bus. static OVERRIDE_U32_T bloodFlowDataPublishInterval = { BLOOD_FLOW_DATA_PUB_INTERVAL, BLOOD_FLOW_DATA_PUB_INTERVAL, BLOOD_FLOW_DATA_PUB_INTERVAL, 0 }; static S32 targetBloodFlowRate = 0; ///< requested blood flow rate static OVERRIDE_F32_T measuredBloodFlowRate = { 0.0, 0.0, 0.0, 0 }; ///< measured blood flow rate static OVERRIDE_F32_T bloodPumpRotorSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured blood pump rotor speed static OVERRIDE_F32_T bloodPumpSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured blood pump motor speed static OVERRIDE_F32_T adcBloodPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured blood pump motor controller speed static OVERRIDE_F32_T adcBloodPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< measured blood pump motor controller current +static OVERRIDE_F32_T bloodFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< measured blood flow signal strength (%) static U32 bpControlTimerCounter = 0; ///< determines when to perform control on blood flow -static U32 bpRotorRevStartTime = 0; ///< blood pump rotor rotation start time (in ms) +static U32 bpRotorRevStartTime = 0; ///< blood pump rotor rotation start time (in ms) +static U32 bloodPumpRotorCounter = 0; ///< running counter for blood pump rotor revolutions static BOOL bpStopAtHomePosition = FALSE; ///< stop blood pump at next home position static U32 bpHomeStartTime = 0; ///< when did blood pump home command begin? (in ms) -static U16 bpLastMotorHallSensorCounts[ BP_SPEED_CALC_BUFFER_LEN ]; ///< last hall sensor count for the blood pump motor +static U32 bloodPumpMotorEdgeCount = 0; ///< running counter for blood pump motor revolutions +static U16 bpLastMotorHallSensorCounts[ BP_SPEED_CALC_BUFFER_LEN ]; ///< last hall sensor readings for the blood pump motor static U32 bpMotorSpeedCalcIdx = 0; ///< index into 1 second buffer of motor speed hall sensor counts -static MOTOR_DIR_T bpMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; ///< pump direction according to hall sensor count static U32 bpMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating blood pump motor speed from hall sensor count. static U32 errorBloodFlowVsMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for flow vs. motor speed error condition. static U32 errorBloodMotorOffPersistTimerCtr = 0; ///< persistence timer counter for motor off check error condition. static U32 errorBloodMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for motor speed error condition. -static U32 errorBloodRotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for rotor speed error condition. +static U32 errorBloodRotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for rotor speed error condition. +static U32 errorBloodPumpDirectionPersistTimerCtr = 0; ///< persistence timer counter for pump direction error condition. +static U32 errorBloodPumpRotorTooFastPersistTimerCtr = 0; ///< persistence timer counter for pump rotor too fast error condition. static F32 flowReadings[ SIZE_OF_ROLLING_AVG ]; ///< holds flow samples for a rolling average static U32 flowReadingsIdx = 0; ///< index for next sample in rolling average array @@ -193,15 +208,15 @@ static void checkBloodPumpDirection( void ); static void checkBloodPumpSpeeds( void ); static void checkBloodPumpFlowAgainstSpeed( void ); -static void checkBloodPumpMCCurrent( void ); +static void checkBloodPumpMCCurrent( void ); +static void checkBloodFlowSensorSignalStrength( void ); static DATA_GET_PROTOTYPE( U32, getPublishBloodFlowDataInterval ); /*********************************************************************//** * @brief * The initBloodFlow function initializes the BloodFlow module. - * @details - * Inputs : none - * Outputs : BloodFlow module initialized. + * @details Inputs: none + * @details Outputs: BloodFlow module initialized. * @return none *************************************************************************/ void initBloodFlow( void ) @@ -224,16 +239,20 @@ // initialize blood flow PI controller initializePIController( PI_CONTROLLER_ID_BLOOD_FLOW, MIN_BLOOD_PUMP_PWM_DUTY_CYCLE, BP_P_COEFFICIENT, BP_I_COEFFICIENT, - MIN_BLOOD_PUMP_PWM_DUTY_CYCLE, MAX_BLOOD_PUMP_PWM_DUTY_CYCLE ); + MIN_BLOOD_PUMP_PWM_DUTY_CYCLE, MAX_BLOOD_PUMP_PWM_DUTY_CYCLE ); + + // initialize persistent alarm for flow sensor signal strength too low + initPersistentAlarm( PERSISTENT_ALARM_BLOOD_FLOW_SIGNAL_STRENGTH, + ALARM_ID_BLOOD_FLOW_SIGNAL_STRENGTH_TOO_LOW, + FALSE, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); } /*********************************************************************//** * @brief * The setBloodPumpTargetFlowRate function sets a new target flow rate and * pump direction. - * @details - * Inputs : isBloodPumpOn, bloodPumpDirectionSet - * Outputs : targetBloodFlowRate, bloodPumpdirection, bloodPumpPWMDutyCyclePct + * @details Inputs: isBloodPumpOn, bloodPumpDirectionSet + * @details Outputs: targetBloodFlowRate, bloodPumpdirection, bloodPumpPWMDutyCyclePct * @param flowRate new target blood flow rate * @param dir new blood flow direction * @param mode new control mode @@ -298,9 +317,8 @@ /*********************************************************************//** * @brief * The signalBloodPumpHardStop function stops the blood pump immediately. - * @details - * Inputs : none - * Outputs : Blood pump stopped, set point reset, state changed to off + * @details Inputs: none + * @details Outputs: Blood pump stopped, set point reset, state changed to off * @return none *************************************************************************/ void signalBloodPumpHardStop( void ) @@ -318,15 +336,17 @@ * The signalBloodPumpRotorHallSensor function handles the blood pump rotor * hall sensor detection. Calculates rotor speed (in RPM). Stops pump if * there is a pending request to home the pump. - * @details - * Inputs : bpRotorRevStartTime, bpStopAtHomePosition - * Outputs : bpRotorRevStartTime, bloodPumpRotorSpeedRPM + * @details Inputs: bpRotorRevStartTime, bpStopAtHomePosition + * @details Outputs: bpRotorRevStartTime, bloodPumpRotorSpeedRPM * @return none *************************************************************************/ void signalBloodPumpRotorHallSensor( void ) { U32 rotTime = getMSTimerCount(); - U32 deltaTime = calcTimeBetween( bpRotorRevStartTime, rotTime ); + U32 deltaTime = calcTimeBetween( bpRotorRevStartTime, rotTime ); + + // increment rotor counter + bloodPumpRotorCounter++; // calculate rotor speed (in RPM) bloodPumpRotorSpeedRPM.data = ( 1.0 / (F32)deltaTime ) * (F32)MS_PER_SECOND * (F32)SEC_PER_MIN; @@ -343,9 +363,8 @@ /*********************************************************************//** * @brief * The homeBloodPump function initiates a blood pump home operation. - * @details - * Inputs : bloodPumpState - * Outputs : bpStopAtHomePosition, bpHomeStartTime, blood pump started (slow) + * @details Inputs: bloodPumpState + * @details Outputs: bpStopAtHomePosition, bpHomeStartTime, blood pump started (slow) * @return none *************************************************************************/ BOOL homeBloodPump( void ) @@ -360,32 +379,72 @@ } return result; +} + +/*********************************************************************//** + * @brief + * The getBloodPumpMotorCount function returns the current count for the + * blood pump motor revolution counter. + * @details Inputs: bloodPumpMotorCount + * @details Outputs: none + * @return bloodPumpMotorCount + *************************************************************************/ +U32 getBloodPumpMotorCount( void ) +{ + return bloodPumpMotorEdgeCount / BP_HALL_EDGE_COUNTS_PER_REV; +} + +/*********************************************************************//** + * @brief + * The getBloodPumpRotorCount function returns the current count for the + * blood pump rotor revolution counter. + * @details Inputs: bloodPumpRotorCounter + * @details Outputs: none + * @return bloodPumpRotorCounter + *************************************************************************/ +U32 getBloodPumpRotorCount( void ) +{ + return bloodPumpRotorCounter; +} + +/*********************************************************************//** + * @brief + * The isBloodPumpRunning function returns whether the blood pump is currently + * running or not. + * @details Inputs: isBloodPumpOn + * @details Outputs: none + * @return isBloodPumpOn + *************************************************************************/ +BOOL isBloodPumpRunning( void ) +{ + return isBloodPumpOn; } /*********************************************************************//** * @brief * The execBloodFlowMonitor function executes the blood flow monitor. - * @details - * Inputs : none - * Outputs : measuredBloodFlowRate, adcBloodPumpMCSpeedRPM, adcBloodPumpMCCurrentmA + * @details Inputs: none + * @details Outputs: measuredBloodFlowRate, adcBloodPumpMCSpeedRPM, adcBloodPumpMCCurrentmA * @return none *************************************************************************/ void execBloodFlowMonitor( void ) -{ +{ + HD_OP_MODE_T opMode = getCurrentOperationMode(); U16 bpRPM = getIntADCReading( INT_ADC_BLOOD_PUMP_SPEED ); U16 bpmA = getIntADCReading( INT_ADC_BLOOD_PUMP_MOTOR_CURRENT ); F32 bpFlow = ( ( getFPGABloodFlow() * -1.0 ) * bloodFlowCalGain ) + bloodFlowCalOffset; // blood flow sensor installed backwards on HD adcBloodPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpRPM)) * BP_SPEED_ADC_TO_RPM_FACTOR; - adcBloodPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpmA)) * BP_CURRENT_ADC_TO_MA_FACTOR; + adcBloodPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpmA)) * BP_CURRENT_ADC_TO_MA_FACTOR; + bloodFlowSignalStrength.data = getFPGABloodFlowSignalStrength(); filterBloodFlowReadings( bpFlow ); // calculate blood pump motor speed/direction from hall sensor count updateBloodPumpSpeedAndDirectionFromHallSensors(); // don't start enforcing checks until out of init/POST mode - if ( getCurrentOperationMode() != MODE_INIT ) + if ( opMode != MODE_INIT ) { // check pump direction checkBloodPumpDirection(); @@ -395,8 +454,10 @@ checkBloodPumpSpeeds(); checkBloodPumpFlowAgainstSpeed(); // check for home position, zero/low speed - checkBloodPumpRotor(); - } + checkBloodPumpRotor(); + // check flow sensor signal strength + checkBloodFlowSensorSignalStrength(); + } // publish blood flow data on interval publishBloodFlowData(); @@ -405,9 +466,8 @@ /*********************************************************************//** * @brief * The execBloodFlowController function executes the blood flow controller. - * @details - * Inputs : bloodPumpState - * Outputs : bloodPumpState + * @details Inputs: bloodPumpState + * @details Outputs: bloodPumpState * @return none *************************************************************************/ void execBloodFlowController( void ) @@ -440,9 +500,8 @@ * @brief * The handleBloodPumpOffState function handles the blood pump off state * of the blood pump controller state machine. - * @details - * Inputs : targetBloodFlowRate, bloodPumpDirection - * Outputs : bloodPumpPWMDutyCyclePctSet, bloodPumpDirectionSet, isBloodPumpOn + * @details Inputs: targetBloodFlowRate, bloodPumpDirection + * @details Outputs: bloodPumpPWMDutyCyclePctSet, bloodPumpDirectionSet, isBloodPumpOn * @return next state *************************************************************************/ static BLOOD_PUMP_STATE_T handleBloodPumpOffState( void ) @@ -469,9 +528,8 @@ * @brief * The handleBloodPumpRampingUpState function handles the ramp up state * of the blood pump controller state machine. - * @details - * Inputs : bloodPumpPWMDutyCyclePctSet - * Outputs : bloodPumpPWMDutyCyclePctSet + * @details Inputs: bloodPumpPWMDutyCyclePctSet + * @details Outputs: bloodPumpPWMDutyCyclePctSet * @return next state *************************************************************************/ static BLOOD_PUMP_STATE_T handleBloodPumpRampingUpState( void ) @@ -514,17 +572,16 @@ * @brief * The handleBloodPumpRampingDownState function handles the ramp down state * of the blood pump controller state machine. - * @details - * Inputs : bloodPumpPWMDutyCyclePctSet - * Outputs : bloodPumpPWMDutyCyclePctSet + * @details Inputs: bloodPumpPWMDutyCyclePctSet + * @details Outputs: bloodPumpPWMDutyCyclePctSet * @return next state *************************************************************************/ static BLOOD_PUMP_STATE_T handleBloodPumpRampingDownState( void ) { BLOOD_PUMP_STATE_T result = BLOOD_PUMP_RAMPING_DOWN_STATE; // have we essentially reached zero speed - if ( bloodPumpPWMDutyCyclePctSet < (MAX_BLOOD_PUMP_PWM_STEP_UP_CHANGE + BP_PWM_ZERO_OFFSET) ) + if ( bloodPumpPWMDutyCyclePctSet < (MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE + BP_PWM_ZERO_OFFSET) ) { stopBloodPump(); result = BLOOD_PUMP_OFF_STATE; @@ -557,9 +614,8 @@ * @brief * The handleBloodPumpControlToTargetState function handles the "control to * target" state of the blood pump controller state machine. - * @details - * Inputs : none - * Outputs : bloodPumpState + * @details Inputs: none + * @details Outputs: bloodPumpState * @return next state *************************************************************************/ static BLOOD_PUMP_STATE_T handleBloodPumpControlToTargetState( void ) @@ -589,9 +645,8 @@ * @brief * The setBloodPumpControlSignalPWM function sets the PWM duty cycle for * the blood pump to a given %. - * @details - * Inputs : none - * Outputs : blood pump stop signal activated, PWM duty cycle zeroed + * @details Inputs: none + * @details Outputs: blood pump stop signal activated, PWM duty cycle zeroed * @param newPWM new duty cycle % to apply to PWM * @return none *************************************************************************/ @@ -603,9 +658,8 @@ /*********************************************************************//** * @brief * The stopBloodPump function sets the blood pump stop signal. - * @details - * Inputs : none - * Outputs : blood pump stop signal activated, PWM duty cycle zeroed + * @details Inputs: none + * @details Outputs: blood pump stop signal activated, PWM duty cycle zeroed * @return none *************************************************************************/ static void stopBloodPump( void ) @@ -619,9 +673,8 @@ /*********************************************************************//** * @brief * The releaseBloodPumpStop function clears the blood pump stop signal. - * @details - * Inputs : none - * Outputs : blood pump stop signal + * @details Inputs: none + * @details Outputs: blood pump stop signal * @return none *************************************************************************/ static void releaseBloodPumpStop( void ) @@ -633,9 +686,8 @@ * @brief * The setBloodPumpDirection function sets the set blood pump direction to * the given direction. - * @details - * Inputs : bloodPumpState - * Outputs : bloodPumpState + * @details Inputs: bloodPumpState + * @details Outputs: bloodPumpState * @param dir blood pump direction to set * @return none *************************************************************************/ @@ -663,9 +715,8 @@ * @brief * The getPublishBloodFlowDataInterval function gets the blood flow data * publication interval. - * @details - * Inputs : bloodFlowDataPublishInterval - * Outputs : none + * @details Inputs: bloodFlowDataPublishInterval + * @details Outputs: none * @return the current blood flow data publication interval (in task intervals). *************************************************************************/ U32 getPublishBloodFlowDataInterval( void ) @@ -684,9 +735,8 @@ * @brief * The getMeasuredBloodFlowRate function gets the measured blood flow * rate. - * @details - * Inputs : measuredBloodFlowRate - * Outputs : none + * @details Inputs: measuredBloodFlowRate + * @details Outputs: none * @return the current blood flow rate (in mL/min). *************************************************************************/ F32 getMeasuredBloodFlowRate( void ) @@ -701,13 +751,32 @@ return result; } +/*********************************************************************//** + * @brief + * The getMeasuredBloodFlowSignalStrength function gets the measured blood flow + * signal strength. + * @details Inputs: bloodFlowSignalStrength + * @details Outputs: none + * @return the current blood flow signal strength (in %). + *************************************************************************/ +F32 getMeasuredBloodFlowSignalStrength( void ) +{ + F32 result = bloodFlowSignalStrength.data; + + if ( OVERRIDE_KEY == bloodFlowSignalStrength.override ) + { + result = bloodFlowSignalStrength.ovData; + } + + return result; +} + /*********************************************************************//** * @brief * The getMeasuredBloodPumpRotorSpeed function gets the measured blood flow * rate. - * @details - * Inputs : bloodPumpRotorSpeedRPM - * Outputs : none + * @details Inputs: bloodPumpRotorSpeedRPM + * @details Outputs: none * @return the current blood flow rate (in mL/min). *************************************************************************/ F32 getMeasuredBloodPumpRotorSpeed( void ) @@ -726,9 +795,8 @@ * @brief * The getMeasuredBloodPumpSpeed function gets the measured blood flow * rate. - * @details - * Inputs : bloodPumpSpeedRPM - * Outputs : none + * @details Inputs: bloodPumpSpeedRPM + * @details Outputs: none * @return the current blood flow rate (in mL/min). *************************************************************************/ F32 getMeasuredBloodPumpSpeed( void ) @@ -747,9 +815,8 @@ * @brief * The getMeasuredBloodPumpMCSpeed function gets the measured blood pump * speed. - * @details - * Inputs : adcBloodPumpMCSpeedRPM - * Outputs : none + * @details Inputs: adcBloodPumpMCSpeedRPM + * @details Outputs: none * @return the current blood pump speed (in RPM). *************************************************************************/ F32 getMeasuredBloodPumpMCSpeed( void ) @@ -768,9 +835,8 @@ * @brief * The getMeasuredBloodPumpMCCurrent function gets the measured blood pump * current. - * @details - * Inputs : adcBloodPumpMCCurrentmA - * Outputs : none + * @details Inputs: adcBloodPumpMCCurrentmA + * @details Outputs: none * @return the current blood pump current (in mA). *************************************************************************/ F32 getMeasuredBloodPumpMCCurrent( void ) @@ -789,42 +855,27 @@ * @brief * The publishBloodFlowData function publishes blood flow data at the set * interval. - * @details - * Inputs : target flow rate, measured flow rate, measured MC speed, + * @details Inputs: target flow rate, measured flow rate, measured MC speed, * measured MC current - * Outputs : Blood flow data is published to CAN bus. + * @details Outputs: Blood flow data is published to CAN bus. * @return none *************************************************************************/ static void publishBloodFlowData( void ) { // publish blood flow data on interval -#ifndef FLOW_DEBUG if ( ++bloodFlowDataPublicationTimerCounter >= getPublishBloodFlowDataInterval() ) -#endif - { - S32 flowStPt = targetBloodFlowRate; - F32 measFlow = getMeasuredBloodFlowRate(); - F32 measRotSpd = getMeasuredBloodPumpRotorSpeed(); - F32 measSpd = getMeasuredBloodPumpSpeed(); - F32 measMCSpd = getMeasuredBloodPumpMCSpeed(); - F32 measMCCurr = getMeasuredBloodPumpMCCurrent(); - F32 pumpPWMPctDutyCycle = bloodPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; -#ifdef FLOW_DEBUG - // TODO - temporary debug code - remove later - char debugFlowStr[ 256 ]; - - F32 measFlowSig = getFPGABloodFlowSignalStrength() * 100.0; - F32 dialFlow = getMeasuredDialInFlowRate(); - F32 dialFlowSig = getFPGADialysateFlowSignalStrength() * 100.0; - F32 bldOccl = getMeasuredBloodPumpOcclusion(); - F32 dpiOccl = getMeasuredDialInPumpOcclusion(); - F32 dpoOccl = getMeasuredDialOutPumpOcclusion(); - - sprintf( debugFlowStr, "Blood: %5.1f, %6.1f, %6.1f Dial-I: %5.1f, %6.1f, %6.1f Dial-O: %6.1f\n", measFlowSig, measFlow, bldOccl, dialFlowSig, dialFlow, dpiOccl, dpoOccl ); - sendDebugData( (U08*)debugFlowStr, strlen(debugFlowStr) ); -#else - broadcastBloodFlowData( flowStPt, measFlow, measRotSpd, measSpd, measMCSpd, measMCCurr, pumpPWMPctDutyCycle ); -#endif + { + BLOOD_PUMP_STATUS_PAYLOAD_T payload; + + payload.setPoint = targetBloodFlowRate; + payload.measFlow = getMeasuredBloodFlowRate(); + payload.measRotorSpd = getMeasuredBloodPumpRotorSpeed(); + payload.measPumpSpd = getMeasuredBloodPumpSpeed(); + payload.measMCSpd = getMeasuredBloodPumpMCSpeed(); + payload.measMCCurr = getMeasuredBloodPumpMCCurrent(); + payload.pwmDC = bloodPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; + payload.flowSigStrength = getMeasuredBloodFlowSignalStrength() * FRACTION_TO_PERCENT_FACTOR; + broadcastBloodFlowData( &payload ); bloodFlowDataPublicationTimerCounter = 0; } } @@ -833,9 +884,8 @@ * @brief * The resetBloodFlowMovingAverage function re-initializes the blood flow * moving average sample buffer. - * @details - * Inputs : none - * Outputs : flowReadingsTotal, flowReadingsIdx, flowReadingsCount all set to zero. + * @details Inputs: none + * @details Outputs: flowReadingsTotal, flowReadingsIdx, flowReadingsCount all set to zero. * @return none *************************************************************************/ static void resetBloodFlowMovingAverage( void ) @@ -849,9 +899,8 @@ /*********************************************************************//** * @brief * The filterBloodFlowReadings function adds a new flow sample to the filter. - * @details - * Inputs : none - * Outputs : flowReadings[], flowReadingsIdx, flowReadingsCount, flowReadingsTotal + * @details Inputs: none + * @details Outputs: flowReadings[], flowReadingsIdx, flowReadingsCount, flowReadingsTotal * @param flow newest blood flow sample * @return none *************************************************************************/ @@ -877,9 +926,8 @@ * The updateBloodPumpSpeedAndDirectionFromHallSensors function calculates * the blood pump motor speed and direction from hall sensor counter on * a 1 second interval. - * @details - * Inputs : bpLastMotorHallSensorCount, bpMotorSpeedCalcTimerCtr, current count from FPGA - * Outputs : bpMotorDirectionFromHallSensors, bloodPumpSpeedRPM + * @details Inputs: bpLastMotorHallSensorCount, bpMotorSpeedCalcTimerCtr, current count from FPGA + * @details Outputs: bpMotorDirectionFromHallSensors, bloodPumpSpeedRPM * @return none *************************************************************************/ static void updateBloodPumpSpeedAndDirectionFromHallSensors( void ) @@ -897,16 +945,15 @@ // determine blood pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { - bpMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; delta = incDelta; bloodPumpSpeedRPM.data = ( (F32)delta / (F32)BP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN; } else { - bpMotorDirectionFromHallSensors = MOTOR_DIR_REVERSE; delta = decDelta; bloodPumpSpeedRPM.data = ( (F32)delta / (F32)BP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; - } + } + bloodPumpMotorEdgeCount += delta; // update last count for next time bpLastMotorHallSensorCounts[ nextIdx ] = bpMotorHallSensorCount; @@ -920,9 +967,8 @@ * The checkBloodPumpRotor function checks the rotor for the blood * pump. If homing, this function will stop when hall sensor detected. If pump * is off or running very slowly, rotor speed will be set to zero. - * @details - * Inputs : bpStopAtHomePosition, bpHomeStartTime, bpRotorRevStartTime - * Outputs : pump may be stopped if homing, bloodPumpRotorSpeedRPM may be set to zero. + * @details Inputs: bpStopAtHomePosition, bpHomeStartTime, bpRotorRevStartTime + * @details Outputs: pump may be stopped if homing, bloodPumpRotorSpeedRPM may be set to zero. * @return none *************************************************************************/ static void checkBloodPumpRotor( void ) @@ -940,7 +986,14 @@ // ensure rotor speed below maximum if ( rotorSpeed > BP_MAX_ROTOR_SPEED_RPM ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH, rotorSpeed ) + if ( ++errorBloodPumpRotorTooFastPersistTimerCtr >= BP_MAX_ROTOR_SPEED_ERROR_PERSIST ) + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH, rotorSpeed ) + } + } + else + { + errorBloodPumpRotorTooFastPersistTimerCtr = 0; } // if pump is stopped or running very slowly, set rotor speed to zero @@ -954,25 +1007,47 @@ * @brief * The checkBloodPumpDirection function checks the set direction vs. * the direction implied by the sign of the measured MC speed. - * @details - * Inputs : - * Outputs : + * @details Inputs: + * @details Outputs: * @return none *************************************************************************/ static void checkBloodPumpDirection( void ) { - MOTOR_DIR_T bpMCDir; - if ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) { - // check set direction vs. direction from hall sensors or sign of motor controller speed - bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); - if ( ( bloodPumpDirectionSet != bpMCDir ) || ( bloodPumpDirectionSet != bpMotorDirectionFromHallSensors ) ) + MOTOR_DIR_T bpMCDir, bpDir; + + bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + bpDir = ( getMeasuredBloodPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + + // check set direction vs. direction from hall sensors + if ( bloodPumpDirectionSet != bpDir ) { + if ( ++errorBloodPumpDirectionPersistTimerCtr >= BP_DIRECTION_ERROR_PERSIST ) + { #ifndef DISABLE_PUMP_DIRECTION_CHECKS - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, (U32)bloodPumpDirectionSet, (U32)bpMotorDirectionFromHallSensors ) -#endif - } + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, (U32)bloodPumpDirectionSet, (U32)bpDir ) +#endif + } + } + // check set direction vs. direction from sign of motor controller speed + else if ( bloodPumpDirectionSet != bpMCDir ) + { + if ( ++errorBloodPumpDirectionPersistTimerCtr >= BP_DIRECTION_ERROR_PERSIST ) + { +#ifndef DISABLE_PUMP_DIRECTION_CHECKS + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, (U32)bloodPumpDirectionSet, (U32)bpMCDir ) +#endif + } + } + else + { + errorBloodPumpDirectionPersistTimerCtr = 0; + } + } + else + { + errorBloodPumpDirectionPersistTimerCtr = 0; } } @@ -984,14 +1059,13 @@ * 2. while pump is controlling, measured motor speed should be within allowed range of commanded speed. * 3. measured motor speed should be within allowed range of measured rotor speed. * All 3 checks have a persistence time that must be met before an alarm is triggered. - * @details - * Inputs : targetBloodFlowRate, bloodPumpSpeedRPM, bloodPumpRotorSpeedRPM - * Outputs : alarm(s) may be triggered + * @details Inputs: targetBloodFlowRate, bloodPumpSpeedRPM, bloodPumpRotorSpeedRPM + * @details Outputs: alarm(s) may be triggered * @return none *************************************************************************/ static void checkBloodPumpSpeeds( void ) { - F32 measMotorSpeed = getMeasuredBloodPumpSpeed(); + F32 measMotorSpeed = fabs( getMeasuredBloodPumpSpeed() ); S32 cmdRate = targetBloodFlowRate; // check for pump running while commanded off @@ -1002,8 +1076,8 @@ if ( ++errorBloodMotorOffPersistTimerCtr >= BP_OFF_ERROR_PERSIST ) { #ifndef DISABLE_PUMP_SPEED_CHECKS - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_BLOOD_PUMP_OFF_CHECK, measMotorSpeed ); - activateSafetyShutdown(); + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_BLOOD_PUMP_OFF_CHECK, measMotorSpeed ); + activateSafetyShutdown(); #endif } } @@ -1068,9 +1142,8 @@ * against the implied flow of the measured pump speed when in treatment mode * and controlling to target flow. If a sufficient difference persists, a * flow vs. motor speed check error is triggered. - * @details - * Inputs : measuredBloodFlowRate, bloodPumpSpeedRPM, errorBloodFlowVsMotorSpeedPersistTimerCtr - * Outputs : alarm may be triggered + * @details Inputs: measuredBloodFlowRate, bloodPumpSpeedRPM, errorBloodFlowVsMotorSpeedPersistTimerCtr + * @details Outputs: alarm may be triggered * @return none *************************************************************************/ static void checkBloodPumpFlowAgainstSpeed( void ) @@ -1079,16 +1152,16 @@ if ( ( MODE_TREA == getCurrentOperationMode() ) && ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) ) { F32 flow = getMeasuredBloodFlowRate(); - F32 speed = getMeasuredBloodPumpSpeed(); - F32 impliedFlow = ( ( speed / BP_GEAR_RATIO ) / BP_REV_PER_LITER ) * (F32)ML_PER_LITER; - F32 delta = fabs( flow - impliedFlow ); + F32 speed = getMeasuredBloodPumpSpeed(); + F32 impliedSpeed = ( flow / (F32)ML_PER_LITER ) * BP_REV_PER_LITER * BP_GEAR_RATIO; + F32 delta = fabs( speed - impliedSpeed ); - if ( delta > BP_MAX_FLOW_VS_SPEED_DIFF_ML_MIN ) + if ( delta > BP_MAX_FLOW_VS_SPEED_DIFF_RPM ) { if ( ++errorBloodFlowVsMotorSpeedPersistTimerCtr >= BP_FLOW_VS_SPEED_PERSIST ) { #ifndef DISABLE_PUMP_FLOW_CHECKS - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, impliedFlow ); + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, speed ); #endif } } @@ -1107,9 +1180,8 @@ * @brief * The checkBloodPumpMCCurrent function checks the measured MC current vs. * the set state of the blood pump (stopped or running). - * @details - * Inputs : - * Outputs : + * @details Inputs: + * @details Outputs: * @return none *************************************************************************/ static void checkBloodPumpMCCurrent( void ) @@ -1154,15 +1226,38 @@ bpCurrErrorDurationCtr = 0; } } +} + +/*********************************************************************//** + * @brief + * The checkBloodFlowSensorSignalStrength function checks the measured blood + * flow sensor signal strength is sufficient for accurate flow sensing. + * @details Inputs: + * @details Outputs: + * @return none + *************************************************************************/ +static void checkBloodFlowSensorSignalStrength( void ) +{ +#ifndef DISABLE_PUMP_FLOW_CHECKS + HD_OP_MODE_T opMode = getCurrentOperationMode(); + + // check flow sensor signal strength when appropriate TODO - in pre-treatment, must be far enough along for fluid to be in tubing + if ( MODE_TREA == opMode || ( MODE_PRET == opMode && FALSE ) ) + { + F32 sigStrength = getMeasuredBloodFlowSignalStrength(); + BOOL outOfRange = ( sigStrength < MIN_FLOW_SIG_STRENGTH ? TRUE : FALSE ); + + checkPersistentAlarm( PERSISTENT_ALARM_BLOOD_FLOW_SIGNAL_STRENGTH, outOfRange, sigStrength, MIN_FLOW_SIG_STRENGTH ); + } +#endif } /*********************************************************************//** * @brief * The execBloodFlowTest function executes the state machine for the * BloodFlow self-test. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @return the current state of the BloodFlow self-test. *************************************************************************/ SELF_TEST_STATUS_T execBloodFlowTest( void ) @@ -1207,9 +1302,8 @@ * @brief * The setBloodFlowCalibration function sets the blood flow calibration * factors and has them stored in non-volatile memory. - * @details - * Inputs : none - * Outputs : bloodFlowCalGain, bloodFlowCalOffset + * @details Inputs: none + * @details Outputs: bloodFlowCalGain, bloodFlowCalOffset * @param gain gain calibration factor for blood flow sensor * @param offset offset calibration factor for blood flow sensor * @return TRUE if calibration factors successfully set/stored, FALSE if not @@ -1242,9 +1336,8 @@ * @brief * The getBloodFlowCalibration function retrieves the current blood flow * calibration factors. - * @details - * Inputs : bloodFlowCalGain, bloodFlowCalOffset - * Outputs : none + * @details Inputs: bloodFlowCalGain, bloodFlowCalOffset + * @details Outputs: none * @param gain value to populate with gain calibration factor for blood flow sensor * @param offset value to populate with offset calibration factor for blood flow sensor * @return none @@ -1259,9 +1352,8 @@ * @brief * The testSetBloodFlowDataPublishIntervalOverride function overrides the * blood flow data publish interval. - * @details - * Inputs : none - * Outputs : bloodFlowDataPublishInterval + * @details Inputs: none + * @details Outputs: bloodFlowDataPublishInterval * @param value override blood flow data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1285,9 +1377,8 @@ * @brief * The testResetBloodFlowDataPublishIntervalOverride function resets the override * of the blood flow data publish interval. - * @details - * Inputs : none - * Outputs : bloodFlowDataPublishInterval + * @details Inputs: none + * @details Outputs: bloodFlowDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetBloodFlowDataPublishIntervalOverride( void ) @@ -1308,9 +1399,8 @@ * @brief * The testSetTargetBloodFlowRateOverride function overrides the target * blood flow rate. - * @details - * Inputs : none - * Outputs : targetBloodFlowRate + * @details Inputs: none + * @details Outputs: targetBloodFlowRate * @param value override target blood flow rate (in mL/min) * @param ctrlMode override pump control mode to this mode (0 = closed loop, 1 = open loop) * @return TRUE if override successful, FALSE if not @@ -1345,9 +1435,8 @@ * @brief * The testResetMeasuredBloodFlowRateOverride function overrides the measured * blood flow rate. - * @details - * Inputs : none - * Outputs : measuredBloodFlowRate + * @details Inputs: none + * @details Outputs: measuredBloodFlowRate * @param value override measured blood flow rate (in mL/min) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1369,9 +1458,8 @@ * @brief * The testResetOffButtonStateOverride function resets the override of the * measured blood flow rate. - * @details - * Inputs : none - * Outputs : measuredBloodFlowRate + * @details Inputs: none + * @details Outputs: measuredBloodFlowRate * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredBloodFlowRateOverride( void ) @@ -1392,9 +1480,8 @@ * @brief * The testSetMeasuredBloodPumpRotorSpeedOverride function overrides the measured * blood pump rotor speed. - * @details - * Inputs : none - * Outputs : bloodPumpRotorSpeedRPM + * @details Inputs: none + * @details Outputs: bloodPumpRotorSpeedRPM * @param value override measured blood pump rotor speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1416,9 +1503,8 @@ * @brief * The testResetMeasuredBloodPumpRotorSpeedOverride function resets the override of the * measured blood pump rotor speed. - * @details - * Inputs : none - * Outputs : bloodPumpRotorSpeedRPM + * @details Inputs: none + * @details Outputs: bloodPumpRotorSpeedRPM * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredBloodPumpRotorSpeedOverride( void ) @@ -1439,9 +1525,8 @@ * @brief * The testSetMeasuredBloodPumpSpeedOverride function overrides the measured * blood pump motor speed. - * @details - * Inputs : none - * Outputs : bloodPumpSpeedRPM + * @details Inputs: none + * @details Outputs: bloodPumpSpeedRPM * @param value override measured blood pump motor speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1463,9 +1548,8 @@ * @brief * The testResetMeasuredBloodPumpSpeedOverride function resets the override of the * measured blood pump motor speed. - * @details - * Inputs : none - * Outputs : bloodPumpSpeedRPM + * @details Inputs: none + * @details Outputs: bloodPumpSpeedRPM * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredBloodPumpSpeedOverride( void ) @@ -1486,9 +1570,8 @@ * @brief * The testSetMeasuredBloodPumpMCSpeedOverride function overrides the measured * blood pump motor speed. - * @details - * Inputs : none - * Outputs : adcBloodPumpMCSpeedRPM + * @details Inputs: none + * @details Outputs: adcBloodPumpMCSpeedRPM * @param value override measured blood pump speed (in RPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1510,9 +1593,8 @@ * @brief * The testResetMeasuredBloodPumpMCSpeedOverride function resets the override of the * measured blood pump motor speed. - * @details - * Inputs : none - * Outputs : adcBloodPumpMCSpeedRPM + * @details Inputs: none + * @details Outputs: adcBloodPumpMCSpeedRPM * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredBloodPumpMCSpeedOverride( void ) @@ -1533,9 +1615,8 @@ * @brief * The testSetMeasuredBloodPumpMCCurrentOverride function overrides the measured * blood pump motor current. - * @details - * Inputs : none - * Outputs : adcBloodPumpMCCurrentmA + * @details Inputs: none + * @details Outputs: adcBloodPumpMCCurrentmA * @param value override measured blood pump current (in mA) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -1557,9 +1638,8 @@ * @brief * The testResetMeasuredBloodPumpMCCurrentOverride function resets the override of the * measured blood pump motor current. - * @details - * Inputs : none - * Outputs : adcBloodPumpMCCurrentmA + * @details Inputs: none + * @details Outputs: adcBloodPumpMCCurrentmA * @return TRUE if reset successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredBloodPumpMCCurrentOverride( void ) @@ -1575,5 +1655,50 @@ return result; } + +/*********************************************************************//** + * @brief + * The testSetMeasuredBloodFlowSignalStrengthOverride function overrides the measured + * blood flow signal strength. + * @details Inputs: none + * @details Outputs: bloodFlowSignalStrength + * @param value override measured blood flow signal strength (in %) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetMeasuredBloodFlowSignalStrengthOverride( F32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + bloodFlowSignalStrength.ovData = value / 100.0; + bloodFlowSignalStrength.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetMeasuredBloodFlowSignalStrengthOverride function resets the override + * of the measured blood flow signal strength. + * @details Inputs: none + * @details Outputs: bloodFlowSignalStrength + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredBloodFlowSignalStrengthOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + bloodFlowSignalStrength.override = OVERRIDE_RESET; + bloodFlowSignalStrength.ovData = bloodFlowSignalStrength.ovInitData; + } + + return result; +} /**@}*/