Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r3ded5ffcbcade3f1da5d40c52936ab5f97fc6ec9 -rf4545d449a2a2f9353307a55d2bce9e150591c3d --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 3ded5ffcbcade3f1da5d40c52936ab5f97fc6ec9) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision f4545d449a2a2f9353307a55d2bce9e150591c3d) @@ -49,8 +49,8 @@ #define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12% #define DIP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the dialIn pump is controlled -#define DIP_P_COEFFICIENT 0.00005 ///< P term for dialIn pump control -#define DIP_I_COEFFICIENT 0.00015 ///< I term for dialIn pump control +#define DIP_P_COEFFICIENT 0.00035 ///< P term for dialIn pump control +#define DIP_I_COEFFICIENT 0.00035 ///< I term for dialIn pump control #define DIP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define DIP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). @@ -78,7 +78,7 @@ #define DIP_REV_PER_LITER 150.24 ///< rotor revolutions per liter #define DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( DIP_REV_PER_LITER / ML_PER_LITER ) ///< #define DIP_GEAR_RATIO 32.0 ///< dialIn pump motor to dialIn pump gear ratio -#define DIP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00035 ///< ~28 BP motor RPM = 1% PWM duty cycle +#define DIP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00028 //308 ///< ~28 BP motor RPM = 1% PWM duty cycle #define DIP_PWM_ZERO_OFFSET 0.1 ///< 10% PWM duty cycle = zero speed #define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + DIP_PWM_ZERO_OFFSET ) ///< @@ -360,7 +360,7 @@ { U16 dipRPM = getIntADCReading( INT_ADC_DIAL_IN_PUMP_SPEED ); U16 dipmA = getIntADCReading( INT_ADC_DIAL_IN_PUMP_MOTOR_CURRENT ); - F32 dipFlow = ( getFPGADialysateFlow() + dialInFlowCalOffset ) * dialInFlowCalGain; + F32 dipFlow = ( getFPGADialysateFlow() * dialInFlowCalGain ) + dialInFlowCalOffset; adcDialInPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipRPM)) * DIP_SPEED_ADC_TO_RPM_FACTOR; adcDialInPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipmA)) * DIP_CURRENT_ADC_TO_MA_FACTOR; @@ -1199,17 +1199,16 @@ { CALIBRATION_DATA_T cal; - if ( TRUE == getCalibrationData( &cal ) ) - { // keep locally and apply immediately - dialInFlowCalGain = gain; - dialInFlowCalOffset = offset; - // also update calibration record in non-volatile memory - cal.dialysateFlowGain = gain; - cal.dialysateFlowOffset_mL_min = offset; - if ( TRUE == setCalibrationData( cal ) ) - { - result = TRUE; - } + getCalibrationData( &cal ); + // keep locally and apply immediately + dialInFlowCalGain = gain; + dialInFlowCalOffset = offset; + // also update calibration record in non-volatile memory + cal.dialysateFlowGain = gain; + cal.dialysateFlowOffset_mL_min = offset; + if ( TRUE == setCalibrationData( cal ) ) + { + result = TRUE; } }