Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -red5ca124f43111316fce2a5fb18cf54c72629d6a -r6433fff760cca163a6855430d2282378627a4fc9 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision ed5ca124f43111316fce2a5fb18cf54c72629d6a) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 6433fff760cca163a6855430d2282378627a4fc9) @@ -56,7 +56,6 @@ { VALVE_POSITION_T commandedPosition; ///< Valve commanded position enum. VALVE_POSITION_T currentPosition; ///< Valve current position enum. - VALVE_POSITION_T pendingCommandedPosition; ///< Valve pending position enum. S16 priorEncPosition; ///< Valve prior position in encoder counts. BOOL hasTransitionBeenRequested; ///< Valve transition request flag. VALVE_STATE_T controlState; ///< Valve control state. @@ -125,15 +124,14 @@ { currentValveStates[ valve ].commandedPosition = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; - currentValveStates[ valve ].pendingCommandedPosition = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].hasTransitionBeenRequested = FALSE; currentValveStates[ valve ].hasHomingBeenRequested = FALSE; currentValveStates[ valve ].hasValveBeenHomed = FALSE; currentValveStates[ valve ].homingOperationActive = FALSE; currentValveStates[ valve ].controlState = VALVE_STATE_WAIT_FOR_POST; currentValveStates[ valve ].valveOpsStartTime = 0; - pendingValvePositionChange[ valve ] = VALVE_POSITION_NOT_IN_POSITION; + pendingValvePositionChange[ valve ] = VALVE_POSITION_NOT_IN_POSITION; } @@ -206,7 +204,8 @@ if ( ( valve < NUM_OF_VALVES ) && ( position > VALVE_POSITION_NOT_IN_POSITION ) && ( position < NUM_OF_VALVE_POSITIONS ) ) { if ( ( TRUE == currentValveStates[ valve ].hasValveBeenHomed ) && - ( FALSE == currentValveStates[ valve ].homingOperationActive ) ) + ( FALSE == currentValveStates[ valve ].homingOperationActive ) && + ( currentValveStates[ valve ].commandedPosition != position ) ) { pendingValvePositionChange[ valve ] = position; currentValveStates[ valve ].hasTransitionBeenRequested = TRUE; @@ -438,14 +437,13 @@ } else if ( TRUE == currentValveStates[ valve ].hasTransitionBeenRequested ) { - currentValveStates[ valve ].pendingCommandedPosition = pendingValvePositionChange[ valve ]; - if ( TRUE == movePinchValveToStoredPosition( valve, currentValveStates[ valve ].pendingCommandedPosition ) ) + if ( TRUE == movePinchValveToStoredPosition( valve, pendingValvePositionChange[ valve ] ) ) { - pendingValvePositionChange[ valve ] = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].hasTransitionBeenRequested = FALSE; - currentValveStates[ valve ].commandedPosition = currentValveStates[ valve ].pendingCommandedPosition; + currentValveStates[ valve ].commandedPosition = pendingValvePositionChange[ valve ]; currentValveStates[ valve ].currentPosition = VALVE_POSITION_NOT_IN_POSITION; currentValveStates[ valve ].valveOpsStartTime = getMSTimerCount(); + pendingValvePositionChange[ valve ] = VALVE_POSITION_NOT_IN_POSITION; nextState = VALVE_STATE_IN_TRANSITION; } } @@ -541,12 +539,12 @@ static VALVE_POSITION_T getCurrentValveABCPosition( VALVE_T valve ) { VALVE_POSITION_T result = VALVE_POSITION_NOT_IN_POSITION; + S32 pos = getPinchValvePosition( valve ); VALVE_POSITION_T p; for ( p = VALVE_POSITION_A_INSERT_EJECT; p < NUM_OF_VALVE_POSITIONS; p++ ) { - S32 pos = getPinchValveStoredPosition( valve, p ); - S32 targetPosition = getPinchValveStoredPosition( valve, currentValveStates[ valve ].commandedPosition ); + S32 targetPosition = getPinchValveStoredPosition( valve, p ); S32 positionDelta = abs( pos - targetPosition ); if ( positionDelta <= VALVE_TRANSITION_MIN_TGT_DELTA ) @@ -582,7 +580,7 @@ data.state = (U32)currentValveStates[ valve ].controlState; data.currentPosID = (U32)currentValveStates[ valve ].currentPosition; data.currentPos = (S16)getPinchValvePosition( valve ); - data.cmdPos = currentValveStates[ valve ].commandedPosition; + data.cmdPos = (S16)currentValveStates[ valve ].commandedPosition; data.posA = (S16)getPinchValveStoredPosition( valve, VALVE_POSITION_A_INSERT_EJECT ); data.posB = (S16)getPinchValveStoredPosition( valve, VALVE_POSITION_B_OPEN ); data.posC = (S16)getPinchValveStoredPosition( valve, VALVE_POSITION_C_CLOSE );