Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r72da1ff230f142e1235ea07f9ae06f44e3b17d1a -r575f9b78ced835f11c015d652be1bd8b83fc9578 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 72da1ff230f142e1235ea07f9ae06f44e3b17d1a) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 575f9b78ced835f11c015d652be1bd8b83fc9578) @@ -79,7 +79,7 @@ #define INITIAL_EDGE_OFFSET_READ_COUNT 100U ///< Offset in counts from energized and de-energized edges -#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 13000U ///< Energized edge maximum count +#define INITIAL_ENERGIZED_EDGE_UPPER_RANGE 14000U // TODO it was originally 13000 ///< Energized edge maximum count #define INITIAL_ENERGIZED_EDGE_LOWER_RANGE 9000U ///< Energized edge minimum count #define AIR_TRAP_VALVE_GPIO_PIN 0x12 ///< Air trap valve GPIO Pin 18 of HET Port 1 @@ -227,6 +227,11 @@ static OPN_CLS_STATE_T valveAirTrapStatus; ///< Air trap valve status (open/close) static HD_VALVES_CAL_RECORD_T valvesCalibrationRecord; ///< Valves calibration record. +// TODO remove for testing only +static S32 testPos[ NUM_OF_VALVES ][300]; +static U32 idx[ NUM_OF_VALVES ] = {0,0,0,0}; +// TODO remove for testing only + // Self test function prototypes static VALVE_SELF_TEST_STATE_T handleValveSelfTestEnableValves( void ); static VALVE_SELF_TEST_STATE_T handleValveSelfTestConfirmEnable( void ); @@ -266,6 +271,17 @@ *************************************************************************/ void initValves( void ) { + // TODO remove + memset(testPos[0], 0x0, 300 * sizeof(S32)); + idx[ 0 ] = 0; + memset(testPos[1], 0x0, 300 * sizeof(S32)); + idx[ 1 ] = 0; + memset(testPos[20], 0x0, 300 * sizeof(S32)); + idx[ 2 ] = 0; + memset(testPos[30], 0x0, 300 * sizeof(S32)); + idx[ 3 ] = 0; + // TODO remove + VALVE_T valve; valveSelfTestState = VALVE_SELF_TEST_ENABLE_VALVES; @@ -1158,6 +1174,18 @@ valvesStatus[ VBA ].currentPositionInCounts.data = (S32)getFPGAValveBloodArterialPosition(); valvesStatus[ VBV ].currentPositionInCounts.data = (S32)getFPGAValveBloodVenousPosition(); + testPos[VDI][ idx[VDI] ] = valvesStatus[ VDI ].currentPositionInCounts.data; + idx[VDI] = INC_WRAP(idx[VDI], 0, 300); + + testPos[VDO][ idx[VDO] ] = valvesStatus[ VDO ].currentPositionInCounts.data; + idx[VDO] = INC_WRAP(idx[VDO], 0, 300); + + testPos[VBA][ idx[VBA] ] = valvesStatus[ VBA ].currentPositionInCounts.data; + idx[VBA] = INC_WRAP(idx[VBA], 0, 300); + + testPos[VBV][ idx[VBV] ] = valvesStatus[ VBV ].currentPositionInCounts.data; + idx[VBV] = INC_WRAP(idx[VBV], 0, 300); + // Check the position of each valve for ( valve = VDI; valve < NUM_OF_VALVES; valve++ ) { @@ -1166,7 +1194,7 @@ { U32 maxDeviation = MAX_DEVIATION_FROM_TARGET_IN_COUNTS; - currentPosition = getValvePositionCounts( valve ); + currentPosition = getValvePositionCounts( valve ); commandedPositionEnum = valvesStatus[ valve ].commandedPosition; commandedPosition = valvesStatus[ valve ].positions[ commandedPositionEnum ];