Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rc9cb494c004e390155ce7c8b3cda96cf8c1b5fa7 -r186d10f0644b9726f1a632197a0ccfba7b00bf48 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision c9cb494c004e390155ce7c8b3cda96cf8c1b5fa7) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 186d10f0644b9726f1a632197a0ccfba7b00bf48) @@ -39,15 +39,15 @@ // ********** private definitions ********** -#define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///> interval (ms/task time) at which the dialIn flow data is published on the CAN bus +#define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialIn flow data is published on the CAN bus -#define MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE 0.01 ///> duty cycle TODO - fixed or parameterized or set in motor controller? -#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///> controller will error if PWM duty cycle > 90%, so set max to 88% -#define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///> controller will error if PWM duty cycle < 10%, so set min to 12% +#define MAX_DIAL_IN_PUMP_PWM_STEP_CHANGE 0.01 ///< duty cycle TODO - fixed or parameterized or set in motor controller? +#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88% +#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 ( 1000 / 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_CONTROL_INTERVAL ( 1000 / 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_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). @@ -64,28 +64,28 @@ #define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. -#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///> motor controller current should not exceed this when pump should be stopped -#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///> motor controller current should always exceed this when pump should be running -#define DIP_MAX_CURR_WHEN_RUNNING_MA 1000.0 ///> motor controller current should not exceed this when pump should be running -#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///> motor controller current errors persisting beyond this duration will trigger an alarm +#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< motor controller current should not exceed this when pump should be stopped +#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< motor controller current should always exceed this when pump should be running +#define DIP_MAX_CURR_WHEN_RUNNING_MA 1000.0 ///< motor controller current should not exceed this when pump should be running +#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///< motor controller current errors persisting beyond this duration will trigger an alarm -#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///> conversion factor from ADC counts to RPM for dialIn pump motor -#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///> conversion factor from ADC counts to mA for dialIn pump motor +#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< conversion factor from ADC counts to RPM for dialIn pump motor +#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< conversion factor from ADC counts to mA for dialIn pump motor -#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_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 ) ///> +#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_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 ) ///< -#define DIAL_IN_PUMP_ADC_FULL_SCALE_V 3.0 ///> BP analog signals are 0-3V (while int. ADC ref V may be different) -#define DIAL_IN_PUMP_ADC_ZERO 1998 ///> Mid-point (zero) for ADC readings. -#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_ZERO ) ///> Macro converts a 12-bit ADC reading to a signed 16-bit value. +#define DIAL_IN_PUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref V may be different) +#define DIAL_IN_PUMP_ADC_ZERO 1998 ///< Mid-point (zero) for ADC readings. +#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_ZERO ) ///< Macro converts a 12-bit ADC reading to a signed 16-bit value. -#define DIAL_IN_FLOW_SAMPLE_FREQ ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///> -#define SIZE_OF_ROLLING_AVG ( DIAL_IN_FLOW_SAMPLE_FREQ * 2 ) ///> measured dialIn flow is filtered w/ moving average -#define MAX_FLOW_FILTER_INTERVAL 5 ///> slowest sample interval for filter is every 5th sample +#define DIAL_IN_FLOW_SAMPLE_FREQ ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< +#define SIZE_OF_ROLLING_AVG ( DIAL_IN_FLOW_SAMPLE_FREQ * 2 ) ///< measured dialIn flow is filtered w/ moving average +#define MAX_FLOW_FILTER_INTERVAL 5 ///< slowest sample interval for filter is every 5th sample /// Enumeration of dialysate inlet pump states. typedef enum DialInPump_States