Index: firmware/App/Drivers/PeristalticPump.c =================================================================== diff -u -rab35376c6b8ff81a4aa4095eb6c9bd33e1bf46d4 -r18783d138aec872e3f5b73e60e14e3c53bf740ec --- firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision ab35376c6b8ff81a4aa4095eb6c9bd33e1bf46d4) +++ firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision 18783d138aec872e3f5b73e60e14e3c53bf740ec) @@ -27,19 +27,22 @@ // ********** private definitions ********** -#define MAX_PUMP_SPEED_RPM 5000U ///< Maximum speed (in RPM) that a peristaltic pump can be set to. +#define MAX_PUMP_SPEED_RPM 3080U ///< Maximum speed (in RPM) that a peristaltic pump can be set to. +#define BP_PUMP_CMD_GAIN 0.9F ///< Gain for blood pump commanded RPM that must be applied before sending to FPGA. +#define BP_PUMP_CMD_OFFSET 80.0F ///< Offset for blood pump commanded RPM that must be applied before sending to FPGA. +#define BP_PUMP_CMD_CAL(r) ((r) * BP_PUMP_CMD_GAIN + BP_PUMP_CMD_OFFSET ) ///< Macro to calibrate a commanded blood pump RPM before sending to FPGA. -#define BP_PERIOD_SEC 0.00001F ///< Blood pump feedback period in seconds. -#define BP_HZ_TO_RPM_SCALAR 10.0F ///< Blood pump Hz to RPM scalar. -#define BP_PERIOD_TO_HZ(p) ( 1.0F / (F32)((S32)(p) * BP_PERIOD_SEC) ) ///< Blood pump period to Hz conversion macro. -#define BP_HZ_TO_RPM(h) ((h) * BP_HZ_TO_RPM_SCALAR) ///< Blood pump Hz to RPM conversion macro. -#define BP_ZERO_SPEED_PERIOD 0xFFFF ///< Blood pump period reported when pump is stopped. +#define BP_PERIOD_SEC 0.00001F ///< Blood pump feedback period in seconds. +#define BP_HZ_TO_RPM_SCALAR 10.0F ///< Blood pump Hz to RPM scalar. +#define BP_PERIOD_TO_HZ(p) ( 1.0F / (F32)((S32)(p) * BP_PERIOD_SEC) ) ///< Blood pump period to Hz conversion macro. +#define BP_HZ_TO_RPM(h) ((h) * BP_HZ_TO_RPM_SCALAR) ///< Blood pump Hz to RPM conversion macro. +#define BP_ZERO_SPEED_PERIOD 0xFFFF ///< Blood pump period reported when pump is stopped. // ********** private data ********** -static S32 pumpSetSpeedRPM; ///< Current set speed for the pump (in RPM). Negative indicates reverse direction. -static OVERRIDE_F32_T pumpMeasSpeedRPM; ///< Latest measured pump speed (in RPM). -static BOOL pumpHomeRequested; ///< Flag indicates a pump home operation has been requested. +static S32 pumpSetSpeedRPM; ///< Current set speed for the pump (in RPM). Negative indicates reverse direction. +static OVERRIDE_F32_T pumpMeasSpeedRPM; ///< Latest measured pump speed (in RPM). +static BOOL pumpHomeRequested; ///< Flag indicates a pump home operation has been requested. // ********** private function prototypes ********** @@ -78,14 +81,14 @@ *************************************************************************/ void readPeristalticPumps( void ) { - S16 period = (S16)getBPPeriod(); + U16 period = getBPPeriod(); F32 Hz = BP_PERIOD_TO_HZ(period); F32 rpm = BP_HZ_TO_RPM(Hz); // update measured pump speed if ( period != BP_ZERO_SPEED_PERIOD ) { - if ( pumpSetSpeedRPM < 0 ) + if ( pumpSetSpeedRPM < 0 ) // TODO - can we get a real measured direction to base measured speed sign on? { pumpMeasSpeedRPM.data = rpm * -1.0F; } @@ -137,7 +140,8 @@ if ( abs( rpm ) < MAX_PUMP_SPEED_RPM ) { - U16 setRpm = (U16)( abs( rpm ) ); + F32 calRpm = BP_PUMP_CMD_CAL( (F32)rpm ); + U16 setRpm = (U16)( abs( (S32)calRpm ) ); MOTOR_DIR_T dir = MOTOR_DIR_FORWARD; if ( rpm < 0 ) @@ -192,41 +196,5 @@ return result; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - -/*********************************************************************//** - * @brief - * The testSetPeristalticPumpSetSpeed function sets the pump to a given speed - * (RPM). A negative speed indicates reverse (CCW) direction. - * @details \b Inputs: none - * @details \b Outputs: pumpSetSpeedRPM - * @param message set message from Dialin which includes the speed (RPM) to set - * the peristaltic pump to. - * @return TRUE if set request is successful, FALSE if not - *************************************************************************/ -BOOL testSetPeristalticPumpSetSpeed( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // Verify tester has logged in with TD and override type is valid - if ( TRUE == isTestingActivated() ) - { - // Verify payload length is valid - if ( sizeof( S32 ) == message->hdr.payloadLen ) - { - S32 speed; - - memcpy( &speed, message->payload, sizeof(S32) ); - result = setPeristalticPumpSetSpeed( (S16)speed ); - } - } - - return result; -} - /**@}*/