Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r1b83a4555c4040a45cecfbea45b6570812ab281e -re242484caff1834f355524ad75febbf64b81b229 --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 1b83a4555c4040a45cecfbea45b6570812ab281e) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision e242484caff1834f355524ad75febbf64b81b229) @@ -46,9 +46,9 @@ #define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up #define FPGA_H4_ENABLE_BIT_MASK 0x01 ///< Bit mask for enabling the blood pump. -#define FPGA_H4_DIR_FORWARD_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction. +#define FPGA_H4_DIRECTION_A_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction A setting. +#define FPGA_H4_DIRECTION_B_BIT_MASK 0x04 ///< Bit mask for setting the blood pump direction B setting. #define FPGA_H4_BRAKE_AND_HOLD_TORQUE 0x06 ///< Bit mask for braking the blood pump while holding the torque of the pump. -#define FPGA_H4_BIT_2_INDEX 2 ///< Blood pump bit 2 index. #define FPGA_H13_OPEN_BIT_MASK 0x01 ///< Bit mask for setting H13 valve position to open. #define FPGA_H20_OPEN_BIT_MASK 0x02 ///< Bit mask for setting H20 valve position to open. @@ -483,23 +483,28 @@ * The setH4Direction function sets the direction for the blood pump * motor to the given direction. * @details \b Inputs: none - * @details \b Outputs: Blood pump motor direction is set (bit 1 and 2 of BP control register). - * 0 - CW (forward) - * 1 - CCW (reverse) + * @details \b Outputs: Blood pump motor direction is set + * (bit 1 (A) and 2 (B) of BP control register). + * AB + * 00 - Power stage enabled + * 01 - CCW (reverse) + * 10 - CW (forward) + * 11 - Braking and holding torque * @param dir the desired direction for the blood pump motor (fwd or rev) * @return none *************************************************************************/ void setH4Direction( MOTOR_DIR_T dir ) { + // This clears bit 2 for both forward and reverse directions if ( MOTOR_DIR_FORWARD == dir ) { - // First clear bit 2 if it is on otherwise the pump can be kept on brake - fpgaActuatorSetPoints.h4Control &= ~( 1 << FPGA_H4_BIT_2_INDEX ); - fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIR_FORWARD_BIT_MASK; + fpgaActuatorSetPoints.h4Control &= ~FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_A_BIT_MASK; } else { - fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIR_FORWARD_BIT_MASK); + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIRECTION_A_BIT_MASK); } } @@ -515,6 +520,12 @@ void setH4SetSpeed( U16 rpm ) { fpgaActuatorSetPoints.h4SetSpeed = rpm; + // if commanded speed is zero, apply brake + if ( 0 == rpm ) + { + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_A_BIT_MASK; + } } /*********************************************************************//**