Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r06dc7b658ce158806edc2c907f9b4462275f7bb9 -rd8015ede9ee8620fa26318990ebfeed9c84a9344 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 06dc7b658ce158806edc2c907f9b4462275f7bb9) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision d8015ede9ee8620fa26318990ebfeed9c84a9344) @@ -145,7 +145,7 @@ static OVERRIDE_U32_T bloodLeakDataPublishInterval = { BLOOD_LEAK_PUB_INTERVAL, BLOOD_LEAK_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish blood leak data to CAN bus. -static U32 bloodLeakDataPublicationTimerCounter; ///< Timer counter used to schedule blood leak data publication to CAN bus. +static U32 bloodLeakDataPublicationCounter; ///< Timer counter used to schedule blood leak data publication to CAN bus. static U32 bloodLeakUARTCmdIndex; ///< Blood leak UART command index. static U32 bloodLeakSetPointSeqLength; ///< Blood leak set point sequence actual length. static U08 bloodLeakSetPointSequence[ BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ][ 2 ]; ///< Blood leak set point sequence array. @@ -212,29 +212,29 @@ // Initialize the embedded mode specifications initEmbModeSpecs(); - bloodLeakDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - bloodLeakState = BLOOD_LEAK_WAIT_FOR_POST_STATE; - bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.ovInitData = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; - bloodLeakStatus.override = OVERRIDE_RESET; - bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; - bloodLeakUARTCmdIndex = 0; - bloodLeakSetPointSeqLength = 0; - bloodLeakPersistenceCtr = 0; - bloodLeakSignalEmbModeReq = FALSE; - bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; - bloodLeakEmbModeSubstate = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; - bloodLeakEmbModeOpsStartTime = 0; - bloodLeakEmbModeRespIndex = 0; - bloodLeakExitNormalRequested = FALSE; - bloodLeakEmbModeCmdSeqLength = 0; - bloodLeakEmbModeHasRxRqstBeenSent = FALSE; - bloodLeakEmbModeCmdQFrontIndex = 0; - bloodLeakEmbModeCmdQRearIndex = 0; - bloodLeakEmbModeCmdQCount = 0; - bloodLeakEmbModeHasZeroBeenRqustd = FALSE; - bloodLeakEmbModeCmdEnqueueCount = 0; + bloodLeakDataPublicationCounter = DATA_PUBLISH_COUNTER_START_COUNT; + bloodLeakState = BLOOD_LEAK_WAIT_FOR_POST_STATE; + bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.ovInitData = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; + bloodLeakStatus.override = OVERRIDE_RESET; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; + bloodLeakUARTCmdIndex = 0; + bloodLeakSetPointSeqLength = 0; + bloodLeakPersistenceCtr = 0; + bloodLeakSignalEmbModeReq = FALSE; + bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; + bloodLeakEmbModeSubstate = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; + bloodLeakEmbModeOpsStartTime = 0; + bloodLeakEmbModeRespIndex = 0; + bloodLeakExitNormalRequested = FALSE; + bloodLeakEmbModeCmdSeqLength = 0; + bloodLeakEmbModeHasRxRqstBeenSent = FALSE; + bloodLeakEmbModeCmdQFrontIndex = 0; + bloodLeakEmbModeCmdQRearIndex = 0; + bloodLeakEmbModeCmdQCount = 0; + bloodLeakEmbModeHasZeroBeenRqustd = FALSE; + bloodLeakEmbModeCmdEnqueueCount = 0; // Set the blood leak embedded mode command queue to zero memset( bloodLeakEmbModeCmdQ, 0x0, BLOOD_LEAK_EMB_MODE_CMD_Q_MAX_SIZE ); @@ -303,8 +303,7 @@ checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_BLOOD_LEAK_SENSOR, getFPGABloodLeakRxErrorCount() ); // Publish blood leak data if due - // TODO uncomment the function - //publishBloodLeakData(); + publishBloodLeakData(); } /*********************************************************************//** @@ -1205,27 +1204,25 @@ static void publishBloodLeakData( void ) { // Publish blood leak data on interval - if ( ++bloodLeakDataPublicationTimerCounter >= getU32OverrideValue( &bloodLeakDataPublishInterval ) ) + if ( ++bloodLeakDataPublicationCounter >= getU32OverrideValue( &bloodLeakDataPublishInterval ) ) { BLOOD_LEAK_DATA_T data; - data.bloodLeakStatus = (U32)getBloodLeakStatus(); - data.bloodLeakState = (U32)bloodLeakState; - data.bloodLeakDetectSetPoint = bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandResp; - data.bloodLeakDetectLevel = bloodLeakEmbModeCmd[ V_EMB_MODE_CMD ].commandResp; - data.bloodLeakLEDIntesity = bloodLeakEmbModeCmd[ I_EMB_MODE_CMD ].commandResp; + data.bloodLeakStatus = (U32)getBloodLeakStatus(); + data.bloodLeakState = (U32)bloodLeakState; + bloodLeakDataPublicationCounter = 0; broadcastData( MSG_ID_HD_BLOOD_LEAK_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&data, sizeof( BLOOD_LEAK_DATA_T ) ); - bloodLeakDataPublicationTimerCounter = 0; - if ( ( bloodLeakState >= BLOOD_LEAK_INIT_STATE ) && ( FALSE == bloodLeakEmbModeHasZeroBeenRqustd ) ) + + /*if ( ( bloodLeakState >= BLOOD_LEAK_INIT_STATE ) && ( FALSE == bloodLeakEmbModeHasZeroBeenRqustd ) ) { // Once the previous data was broadcast, and the system is not in init and blood leak zero request has not been set, enqueue the data // to be queried and read again. The data is queried here to make sure there is a second of time in between the queries for I, V, and D enqueueEmbModeCmd( I_EMB_MODE_CMD ); enqueueEmbModeCmd( V_EMB_MODE_CMD ); enqueueEmbModeCmd( D_EMB_MODE_CMD ); - } + }*/ // TODO remove } } Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -ref6283257df7c1f993d58fb934da57ea3e0a7067 -rd8015ede9ee8620fa26318990ebfeed9c84a9344 --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision ef6283257df7c1f993d58fb934da57ea3e0a7067) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision d8015ede9ee8620fa26318990ebfeed9c84a9344) @@ -46,9 +46,6 @@ { U32 bloodLeakStatus; ///< Blood leak detector status U32 bloodLeakState; ///< Blood leak detector state - U32 bloodLeakDetectSetPoint; ///< Blood leak detect set point - U32 bloodLeakDetectLevel; ///< Blood leak detect level - U32 bloodLeakLEDIntesity; ///< Blood leak LED intensity } BLOOD_LEAK_DATA_T; // ********** public function prototypes ********** Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -ref6283257df7c1f993d58fb934da57ea3e0a7067 -rd8015ede9ee8620fa26318990ebfeed9c84a9344 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision ef6283257df7c1f993d58fb934da57ea3e0a7067) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision d8015ede9ee8620fa26318990ebfeed9c84a9344) @@ -79,8 +79,10 @@ #define INITIAL_EDGE_OFFSET_READ_COUNT 100U ///< Offset in counts from energized and de-energized edges -#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 13250U ///< Energized edge maximum count (originally 13000 count) +#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 13250U ///< Energized edge maximum count #define INITIAL_ENERGIZED_EDGE_LOWER_RANGE 10750U ///< Energized edge minimum count +#define INITIAL_V3_ENERGIZED_EDGE_UPPER_RANGE 14000U ///< Energized edge maximum count +#define INITIAL_V3_ENERGIZED_EDGE_LOWER_RANGE 10750U ///< Energized edge minimum count #define AIR_TRAP_VALVE_GPIO_PIN 0x12 ///< Air trap valve GPIO Pin 18 of HET Port 1 @@ -199,8 +201,8 @@ // ********** private data ********** -static VALVE_SELF_TEST_STATE_T valveSelfTestState = VALVE_SELF_TEST_ENABLE_VALVES; ///< Valves self test state -static SELF_TEST_STATUS_T valvesSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< Valves self test result +static VALVE_SELF_TEST_STATE_T valveSelfTestState; ///< Valves self test state +static SELF_TEST_STATUS_T valvesSelfTestResult; ///< Valves self test result static VALVE_STATUS_T valvesStatus[ NUM_OF_VALVES ]; ///< Array of type VALVE_STATUS_T structure that holds the status of each valve static OVERRIDE_U32_T valvesDataPublishInterval = { VALVES_DATA_PUB_INTERVAL, VALVES_DATA_PUB_INTERVAL, 0, 0 }; ///< Valves data publish interval @@ -702,11 +704,20 @@ *************************************************************************/ static VALVE_STATE_T handleValveStateHomingFindDeenergizedEdge( VALVE_T valve ) { - VALVE_STATE_T state = VALVE_STATE_HOMING_FIND_DEENERGIZED_EDGE; + VALVE_STATE_T state = VALVE_STATE_HOMING_FIND_DEENERGIZED_EDGE; + S16 currentPosition = getValvePositionCounts( valve ); + S16 targetPosition = valvesStatus[ valve ].targetPositionInCounts; + S16 deltaPosition = currentPosition - targetPosition; + U32 energizedUpperEdge = INITIAL_ENERGIZED_EDGE_UPPER_RANGE; + U32 deenergizedLowerEdge = INITIAL_ENERGIZED_EDGE_LOWER_RANGE; - S16 currentPosition = getValvePositionCounts( valve ); - S16 targetPosition = valvesStatus[ valve ].targetPositionInCounts; - S16 deltaPosition = currentPosition - targetPosition; +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) + { + energizedUpperEdge = INITIAL_V3_ENERGIZED_EDGE_UPPER_RANGE; + deenergizedLowerEdge = INITIAL_V3_ENERGIZED_EDGE_LOWER_RANGE; + } +#endif // Still too far from intermediate target position? Either still more travel to go or stuck at end of travel if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) @@ -717,8 +728,8 @@ S16 energizedEdge = valvesStatus[ valve ].positions[ VALVE_POSITION_B_OPEN ]; S16 deltaEdges = energizedEdge - currentPosition; - // The range from energized to de-energized should be in between 10750 to 13250 steps - if ( ( deltaEdges <= INITIAL_ENERGIZED_EDGE_UPPER_RANGE ) && ( deltaEdges >= INITIAL_ENERGIZED_EDGE_LOWER_RANGE ) ) + // The range from energized to de-energized should be in the specified range + if ( ( deltaEdges <= energizedUpperEdge ) && ( deltaEdges >= deenergizedLowerEdge ) ) { S16 positionC = currentPosition + INITIAL_EDGE_OFFSET_READ_COUNT; S16 positionB = valvesStatus[ valve ].positions[ VALVE_POSITION_B_OPEN ]; Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -r06dc7b658ce158806edc2c907f9b4462275f7bb9 -rd8015ede9ee8620fa26318990ebfeed9c84a9344 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 06dc7b658ce158806edc2c907f9b4462275f7bb9) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision d8015ede9ee8620fa26318990ebfeed9c84a9344) @@ -51,8 +51,8 @@ #define ARTERIAL_PRESSURE_SELF_TEST_LOW_LIMIT_MMHG -50.0F ///< Arterial pressure low limit after running blood pump. #define VENOUS_PRESSURE_SELF_TEST_HIGH_LIMIT_MMHG 400 ///< Venous pressure high limit after running blood pump. -#define DECAY_PRESSURE_DIFF_TOLERANCE_MMHG 5.0F ///< Difference in pressure readings after the pump stops (in mmHg). -#define STABILITY_PRESSURE_DIFF_TOLERANCE_MMHG 2.0F ///< Difference in pressure readings while in a stable pressured state (in mmHg). +#define DECAY_PRESSURE_DIFF_TOLERANCE_MMHG 5.0F ///< Difference in pressure readings after the pump stops (in mmHg). +#define STABILITY_PRESSURE_DIFF_TOLERANCE_MMHG 2.0F ///< Difference in pressure readings while in a stable pressured state (in mmHg). #define NORMAL_PRESSURE_DIFF_TOLERANCE_MMHG 10.0F ///< Difference in pressure readings after return to normal state tolerance (in mmHg). #define DIP_FLOW_RATE_SETUP_ML_MIN 150 ///< Dialysate inlet pump flow rate during the setup for wet self-test.