Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r575f9b78ced835f11c015d652be1bd8b83fc9578 -rc5b653fce3854c9c80a94d72aa5a0a04ab21a476 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 575f9b78ced835f11c015d652be1bd8b83fc9578) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision c5b653fce3854c9c80a94d72aa5a0a04ab21a476) @@ -276,9 +276,9 @@ idx[ 0 ] = 0; memset(testPos[1], 0x0, 300 * sizeof(S32)); idx[ 1 ] = 0; - memset(testPos[20], 0x0, 300 * sizeof(S32)); + memset(testPos[2], 0x0, 300 * sizeof(S32)); idx[ 2 ] = 0; - memset(testPos[30], 0x0, 300 * sizeof(S32)); + memset(testPos[3], 0x0, 300 * sizeof(S32)); idx[ 3 ] = 0; // TODO remove @@ -725,10 +725,10 @@ S16 targetPosition = valvesStatus[ valve ].targetPositionInCounts; S16 deltaPosition = currentPosition - targetPosition; - // If there has not been any major travel + // Still too far from intermediate target position? Either still more travel to go or stuck at end of travel if ( deltaPosition > MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) { - // Check if the specified time has elapsed + // Are we stuck at end of travel? if ( valvesStatus[ valve ].homingEdgeDetectionCounter >= HOMING_EDGE_DETECTION_TIME_INTERVAL ) { S16 energizedEdge = valvesStatus[ valve ].positions[ VALVE_POSITION_B_OPEN ]; @@ -744,8 +744,7 @@ valvesStatus[ valve ].positions[ VALVE_POSITION_C_CLOSE ] = currentPosition + INITIAL_EDGE_OFFSET_READ_COUNT; // Position A is the average of the Position B that was read last time and position C that was the target of this state - valvesStatus[ valve ].positions[ VALVE_POSITION_A_INSERT_EJECT ] = ( valvesStatus[ valve ].positions[ VALVE_POSITION_B_OPEN ] - - valvesStatus[ valve ].positions[ VALVE_POSITION_C_CLOSE ] ) / 2; + valvesStatus[ valve ].positions[ VALVE_POSITION_A_INSERT_EJECT ] = currentPosition + ( ( valvesStatus[ valve ].positions[ VALVE_POSITION_B_OPEN ] - valvesStatus[ valve ].positions[ VALVE_POSITION_C_CLOSE ] ) / 2 ); #ifndef _RELEASE_ if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_VBA_SPECIAL_POSITION_C ) == SW_CONFIG_ENABLE_VALUE ) && ( VBA == valve ) )