RobotC Encoder Issue

While attempting to code the autonomous for our X-Holonomic, we ran into an issue with resetting the values of the quadrature encoders attached to the four drive motors. I have attached the problematic code below. Any help is much appreciated.


task autonomous()
{
	//==========================================FORWARD======================================
	while((SensorValue[RightEncoder]+SensorValue[RightEncoderF]) < (2*200)) //Forward for defined rotations
	{
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) < (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the left side has reversed more than the right...
			motor[port3] = 115; //slow down the left...
			motor[port2] = 127; //and speed up the right
			motor[port4] = 115; //slow down the left...
			motor[port5] = 127; //and speed up the right
		}
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) > (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the right side has reversed more than the left...
			motor[port3] = 127; //speed up the left...
			motor[port2] = 115; //and slow down the right...
			motor[port4] = 127; //speed up the left...
			motor[port5] = 115; //and slow down the right...
		}
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) == (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the left and right have reversed the same amount...
			motor[port3] = 127; //run the motors at the same speed
			motor[port2] = 127;
			motor[port4] = 127; //run the motors at the same speed
			motor[port5] = 127;
		}
	}
	motor[port2] = 0;
	motor[port3] = 0;
	motor[port4] = 0;
	motor[port5] = 0;
	
	Sensorvalue[RightEncoder] = 0;
	Sensorvalue[RightEncoderF] = 0;
	Sensorvalue[LeftEncoder] = 0;
	Sensorvalue[LeftEncoderF] = 0;
	//===========================================END==============================================
	wait1Msec(2000);

	//==========================================FORWARD======================================
	while((SensorValue[RightEncoder]+SensorValue[RightEncoderF]) < (2*200)) //Forward for defined rotations
	{
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) < (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the left side has reversed more than the right...
			motor[port3] = 115; //slow down the left...
			motor[port2] = 127; //and speed up the right
			motor[port4] = 115; //slow down the left...
			motor[port5] = 127; //and speed up the right
		}
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) > (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the right side has reversed more than the left...
			motor[port3] = 127; //speed up the left...
			motor[port2] = 115; //and slow down the right...
			motor[port4] = 127; //speed up the left...
			motor[port5] = 115; //and slow down the right...
		}
		if(((SensorValue[LeftEncoder]* -1)+(SensorValue[LeftEncoderF]* -1)) == (SensorValue[RightEncoder]+SensorValue[RightEncoderF]))
		{ //If the left and right have reversed the same amount...
			motor[port3] = 127; //run the motors at the same speed
			motor[port2] = 127;
			motor[port4] = 127; //run the motors at the same speed
			motor[port5] = 127;
		}
	}
	motor[port2] = 0;
	motor[port3] = 0;
	motor[port4] = 0;
	motor[port5] = 0;

Thanks.

So what was the issue?

Post the #pragma statements as well so we know which ports everything in connected to.

Sorry for my lack of clarity. Referring to the code in the original post, we expected the robot to move forward until the encoders read a certain amount, stop, reset the encoders to the value of zero, finally wait two seconds and do the process over again. Instead it goes through the fist section of code and moves forward then stops, when it gets to the code that resets the encoders to zero it does not do the movement again as it should. This leads us to believe that the encoders may not be resetting correctly, but we have no way to confirm. We posted to see if anybody could see a flaw in our logic, or help us diagnose what might be the problem. Thanks for the help.

Have you tried using the RobotC debugger window? You could write the sensor values into variables and read them in real time from the debugger window.

http://help.robotc.net/WebHelpVEX/index.htm#Topics/ROBOTC%20Debugger/Debug%20Windows/Program%20Debug.htm%3FTocPath%3DROBOTC%2520Debugger%7CUsing%2520the%2520Debugger%7C_____1

Thanks you two for the help you have provided. After using the advice that fullmetal provided we were able to diagnose the problem and found our solution. Thanks.