Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r3aed94a6a0af49bed46f25c900f74e98997ac2e7 -r7a194faf1ace9385d62bfc36fdf81ad91532c52a --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 3aed94a6a0af49bed46f25c900f74e98997ac2e7) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 7a194faf1ace9385d62bfc36fdf81ad91532c52a) @@ -88,7 +88,7 @@ #define TRANSITION_STEP_CHANGE_IN_COUNTS 15000 ///< Step change in counts during normal operations #define MAX_DEVIATION_FROM_TARGET_IN_COUNTS 2500 ///< Maximum deviation from target in counts -#define MAX_DEVIATION_FROM_TGT_IN_HOMING_CNTS 150 ///< Maximum deviation from target in counts +#define MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS 150 ///< Maximum deviation from target in counts #define MAX_DEVIATION_FROM_TRAGET_IN_POS_B 1000 ///< Maximum allowed deviation from position B in counts #define MAX_ALLOWED_FAILED_HOMINGS 3U ///< Maximum allowed failed homings /// The time that the valve must be at the edge to be considered for edge detection @@ -681,7 +681,7 @@ S16 deltaPosition = targetPosition - currentPosition; // If there has not been any major travel for a certain period of time - if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_HOMING_CNTS ) + if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { if ( valvesStatus[ valve ].homingEdgeDetectionCounter >= HOMING_EDGE_DETECTION_TIME_INTERVAL ) { @@ -727,7 +727,7 @@ S16 deltaPosition = currentPosition - targetPosition; // 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_HOMING_CNTS ) + if ( deltaPosition > MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { // Are we stuck at end of travel? if ( valvesStatus[ valve ].homingEdgeDetectionCounter >= HOMING_EDGE_DETECTION_TIME_INTERVAL ) @@ -875,7 +875,7 @@ if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { // Enable current relaxation - setFPGAValveSetPoint( valve, currentPosition, TRUE ); + setFPGAValveSetPoint( valve, targetPosition, TRUE ); } // Go back to Idle state @@ -895,7 +895,7 @@ } } // Check if the valve is close to the temporary target position and if it is, assign the next target position - else if ( abs( currentPosition - targetPosition ) < MAX_DEVIATION_FROM_TARGET_IN_COUNTS ) + else if ( abs( currentPosition - targetPosition ) < MAX_DEVIATION_FROM_TGT_IN_TRAVEL_CNTS ) { setValveNextStep( valve, TRANSITION_STEP_CHANGE_IN_COUNTS ); } @@ -1300,22 +1300,22 @@ // Subtract the defined number of steps for the next transition if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) + nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition + nextStep; } if ( commandedPositionEnum == VALVE_POSITION_C_CLOSE ) { - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) - nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition - nextStep; } break; case VALVE_POSITION_B_OPEN: // If the valve is currently in position B, subtract the defined number of steps for the next transition - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) - nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition - nextStep; break; case VALVE_POSITION_C_CLOSE: // If the valve is currently in position C, add the defined number of steps for the next transition - valvesStatus[ valve ].targetPositionInCounts = getValvePositionCounts( valve ) + nextStep; + valvesStatus[ valve ].targetPositionInCounts = currentPosition + nextStep; break; default: