Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -ref0b3f0ec00fadc50f95e0db1a6477fb4b076ea1 -r2bb447181c2519690441d81f83563d17e0882ef2 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision ef0b3f0ec00fadc50f95e0db1a6477fb4b076ea1) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 2bb447181c2519690441d81f83563d17e0882ef2) @@ -38,7 +38,7 @@ #define MAX_BLOOD_FLOW_RATE 500 // mL/min #define MIN_BLOOD_FLOW_RATE 100 // mL/min -#define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.02 // duty cycle TODO - fixed or parameterized or set in motor controller? +#define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.005 // max duty cycle change when ramping #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% @@ -47,7 +47,7 @@ #define BP_I_COEFFICIENT 0.00002 // I term for blood pump control #define BP_MAX_ERROR_SUM 10.0 // for anti-wind-up in I term #define BP_MIN_ERROR_SUM -10.0 -#define BP_MAX_PWM_DC_DELTA 0.01 // prevents large steps in PWM duty cycle +#define BP_MAX_PWM_DC_DELTA 0.01 // prevents large steps in PWM duty cycle while controlling #define BP_MIN_PWM_DC_DELTA -0.01 #define BP_MAX_CURR_WHEN_STOPPED_MA 150.0 // motor controller current should not exceed this when pump should be stopped @@ -61,7 +61,7 @@ #define BP_REV_PER_LITER 124.0 // rotor revolutions per liter #define BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( BP_REV_PER_LITER / ML_PER_LITER ) #define BP_GEAR_RATIO 32.0 // blood pump motor to blood pump gear ratio -#define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.0003717 // ~27 BP motor RPM = 1% PWM duty cycle +#define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.000369 //717 // ~27 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 ) @@ -90,7 +90,7 @@ NUM_OF_BLOOD_FLOW_SELF_TEST_STATES } BLOOD_FLOW_SELF_TEST_STATE_T; -// CAN3 port pin assignments for pump stop and direction outputs +// pin assignments for pump stop and direction outputs #define STOP_CAN3_PORT_MASK 0x00000002 // (Tx - re-purposed as output GPIO for blood pump stop signal) #define DIR_CAN3_PORT_MASK 0x00000002 // (Rx - re-purposed as output GPIO for blood pump direction signal) // blood pump stop and direction macros @@ -339,7 +339,7 @@ if ( getTargetBloodFlowRate() != 0 ) { // set initial PWM duty cycle - bloodPumpPWMDutyCyclePctSet = MAX_BLOOD_PUMP_PWM_STEP_CHANGE; + bloodPumpPWMDutyCyclePctSet = BP_PWM_ZERO_OFFSET + MAX_BLOOD_PUMP_PWM_STEP_CHANGE; etpwmSetCmpA( etpwmREG1, (U32)FLOAT_TO_INT_WITH_ROUND( bloodPumpPWMDutyCyclePctSet * (F32)(etpwmREG1->TBPRD) ) ); // allow blood pump to run in requested direction setBloodPumpDirection( bloodPumpDirection );