Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r72da1ff230f142e1235ea07f9ae06f44e3b17d1a -r45627442c3b93ec57ed18cd0943eed2662fb2dbc --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 72da1ff230f142e1235ea07f9ae06f44e3b17d1a) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 45627442c3b93ec57ed18cd0943eed2662fb2dbc) @@ -709,10 +709,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 ]; @@ -728,8 +728,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 ) )