Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r1a1aa235cfb5d13555d8cf943825cd99e36c97fb -r6b96f1a18ab2f93068daddbf24178fbbae7cc570 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 1a1aa235cfb5d13555d8cf943825cd99e36c97fb) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 6b96f1a18ab2f93068daddbf24178fbbae7cc570) @@ -42,13 +42,13 @@ #define MAX_SETTABLE_BLOOD_FLOW_RATE 700 ///< Maximum settable blood flow rate (in mL/min). -#define BP_CONTROL_INTERVAL_SEC 10 ///< Blood pump control interval (in seconds). +#define BP_CONTROL_INTERVAL_SEC 2 ///< Blood pump control interval (in seconds). /// Interval (ms/task time) at which the blood pump is controlled. static const U32 BP_CONTROL_INTERVAL = ( BP_CONTROL_INTERVAL_SEC * MS_PER_SECOND / TASK_GENERAL_INTERVAL ); -#define BP_P_COEFFICIENT 0.0001F ///< P term for blood pump control -#define BP_I_COEFFICIENT 0.00075F ///< I term for blood pump control +#define BP_P_COEFFICIENT 0.5F ///< P term for blood pump control +#define BP_I_COEFFICIENT 1.5F ///< I term for blood pump control #define BP_HOME_SPEED 400 ///< Target pump speed (in RPM) for homing. #define BP_HOME_TIMEOUT_MS ( 12 * MS_PER_SECOND ) ///< Maximum time (in ms) allowed for homing to complete. @@ -277,7 +277,6 @@ bloodPumpDirectionSet = dir; bloodPumpControlMode = mode; bloodPumpRampToSpeedRPM = BP_RPM_FROM_RATE( flowRate ); - isBloodPumpOn = ( 0 == flowRate ? FALSE : isBloodPumpOn ); if ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) { @@ -361,7 +360,7 @@ void signalBloodPumpHardStop( void ) { targetBloodFlowRate = 0; - bloodPumpState = BLOOD_PUMP_OFF_STATE; // TODO SEAN: Are you changing the state directly here? + bloodPumpState = BLOOD_PUMP_OFF_STATE; bloodPumpSetSpeedRPM = 0; isBloodPumpOn = FALSE; bpControlTimerCounter = 0; @@ -714,21 +713,14 @@ { F32 tgtFlow = (F32)targetBloodFlowRate; F32 actFlow = getMeasuredBloodFlowRate(); - F32 newRPM = bloodPumpSetSpeedRPM; // TODO - don't set speed here when control is implemented below. + F32 newRPM= runPIController( PI_CONTROLLER_ID_BLOOD_FLOW, tgtFlow, actFlow ); - newRPM = runPIController( PI_CONTROLLER_ID_BLOOD_FLOW, tgtFlow, actFlow ); - newRPM = ( newRPM < 0.0F ? 0.0F : newRPM ); bloodPumpSetSpeedRPM = (U32)((S32)(newRPM)); setPeristalticPumpSetSpeed( BP_SIGNED_SET_SPEED ); } bpControlTimerCounter = 0; } - if ( FALSE == isBloodPumpOn ) - { - result = BLOOD_PUMP_OFF_STATE; - } - return result; }