Turning point code

I’m trying to run a code with a quad encoder but when i turn on the autonomous all it does is go forward till i turn off the autonomous . What am i doing wrong?
#pragma config(Motor, port1, , tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, , tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma usercontrolDuration(120)

#include “Vex_Competition_Includes.c” //Main competition background code…do not modify!

/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
wait1Msec(2000); //Two second Delay
SensorValue[dgtl1] = 0; //Clear the right encoder value
SensorValue[dgtl3] = 0;
SensorValue[dgtl5] = 0;//Clear the left encoder value

//While the encoders have spun less than 3 rotations...
//while(SensorValue[dgtl1] < 1080)
//{
//Move Forward
//motor[port8] = 63;
//}


//Stop for half a second
//motor[port8] = 0;
//wait1Msec(500);
// All activities that occur befo re the competition starts
// Example: clearing encoders, setting servo positions, ...

}

/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task autonomous()
{
// …
// Insert user code here.
// …

// port 1,5,6 is the right
// port 3,4,10 is the left

while(SensorValue[dgtl1] < 300 || SensorValue[dgtl3] > -300)
{
	motor(port10)= - 170;
	motor(port3)= - 170;
	motor(port4)= - 170;
	motor(port1)=  170;
	motor(port5)=  170;
	motor(port6)=  170; // still get the same distance.
}
wait1Msec(500);
motor(port10)= 0;
motor(port3)=  0;
motor(port4)=  0;
motor(port1)=  0;
motor(port5)=  0;
motor(port6)=  0;
wait1Msec(500);

SensorValue[dgtl1] = 0;
SensorValue[dgtl3] = 0;

motor(port8)=-127;//shoot at high right flag
wait1Msec(1300);
motor(port8)=0;

while(SensorValue[dgtl1] > 0 || SensorValue[dgtl3] < 0)
{
motor(port10)= - 170;
motor(port3)= - 170;
motor(port4)= - 170;
motor(port1)= 170;
motor(port5)= 170;
motor(port6)= 170; // still get the same distance.
}
wait1Msec(500);
motor(port10)= 0;
motor(port3)= 0;
motor(port4)= 0;
motor(port1)= 0;
motor(port5)= 0;
motor(port6)= 0;
wait1Msec(500);

SensorValue[dgtl1] = 0;
SensorValue[dgtl3] = 0;

while(SensorValue[dgtl1] > -1750 || SensorValue[dgtl3] < 1750)
{
	motor(port10)=  170;
	motor(port3)=  170;
	motor(port4)=  170;
	motor(port1)= - 170;
	motor(port5)=  -170;
	motor(port6)=  -170; // still get the same distance.
}
	wait1Msec(500);
motor(port10)= 0;
motor(port3)=  0;
motor(port4)=  0;
motor(port1)=  0;
motor(port5)=  0;
motor(port6)=  0;
wait1Msec(500);


while(SensorValue[dgtl1] > 350 || SensorValue[dgtl3] <-350)
{
	motor(port10)=  170;
	motor(port3)=  170;
	motor(port4)=  170;
	motor(port1)= 170;
	motor(port5)= 170;
	motor(port6)=  170; // still get the same distance.
}
	wait1Msec(500);
motor(port10)= 0;
motor(port3)=  0;
motor(port4)=  0;
motor(port1)=  0;
motor(port5)=  0;
motor(port6)=  0;
wait1Msec(500);

SensorValue[dgtl1] = 0;
SensorValue[dgtl3] = 0;

while(SensorValue[dgtl1] > 2500 || SensorValue[dgtl3] <2500)
{
	motor(port10)= - 170;
	motor(port3)= - 170;
	motor(port4)= - 170;
	motor(port1)=  170;
	motor(port5)=  170;
	motor(port6)=  170; // still get the same distance.
}
	wait1Msec(500);
motor(port10)= 0;
motor(port3)=  0;
motor(port4)=  0;
motor(port1)=  0;
motor(port5)=  0;
motor(port6)=  0;
wait1Msec(500);


/////////////////////////////////////////////////////////////////////////////////////////
//
// User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

}
task usercontrol()
{ while (1==1)
{
motor(port10)= -vexRT[Ch2]; // port 1 is the front right driver
motor(port3)= -vexRT[Ch2]; // port 2 is the back right driver
motor(port4)= -vexRT[Ch2]; // port 9 is the front left driver
motor(port5)= vexRT[Ch3];// port 10 is the back left driver
motor(port6)= vexRT[Ch3];// port 10 is the back left driver
motor(port1)= vexRT[Ch3];// port 10 is the back left driver
}
// …
// Insert user code here.
// …

	if(vexRT[Btn6D] == 1) // if button 6u is pressed lift goes up
	{
		motor(port8)= 0;

	}
	else if(vexRT[Btn6U] ==1) // if button 6d is pressed lift goes down
	{
		motor(port8)= -127;

	}
	else // if nothing is pushed...
	{
		motor(port8)= 0;

	}
	if (vexRT[Btn5D] ==1) //if button 8r is pressed elevator goes up
	{
		motor(port7) = -127;
	}
	else if (vexRT[Btn5U] ==1) // if button 8d is pressed elevator goes down
	{
		motor(port7) = 127;
	}
	else // if nothing is pushed...
	{
		motor(port7) = 0;
	}
	if(vexRT[Btn7U] == 1) // if button 5u is close claw
	{
		motor(port2)= -127;

	}
	else if(vexRT[Btn7D] ==1) // if button 5d is pressed open claw
	{
		motor(port2)= 127;

	}
	else // if nothing is pushed...
	{
		motor(port2)= 0; // nothn happens
	}
	if(vexRT[Btn8U] == 1) // if button 5u is close claw
	{
		motor(port9)= -127;

	}
	else if(vexRT[Btn8D] ==1) // if button 5d is pressed open claw
	{
		motor(port9)= 127;

	}
	else // if nothing is pushed...
	{
		motor(port9)= 0; // nothn happens
	}
}

It doesn’t look like you have your encoders setup, you need to set them up in the motor and sensor setup.

If it still just goes forward and doesn’t stop after you set them up, they might be plugged in wrong, just plug the wires into the other port, so if your encoder was in port 1 and 2 you just flip those so the wire in port 2 is plugged into port 1.

Also, watch out. It looks like your buttons are outside of your while(1==1) loop, as the closing } is right after the joystick stuff.

Our girls just made a change to our motor commands in our program in the way we sequence the motors on. Your code has the same issue.

They have a 4 motor base, and originally turned on the left side then the right side in all sections for driving. This was proving unreliable, as sometimes the robot would “skip” to one side. On a whim, they changed it so we turned on both the rear motors(left and right), then both the front motors. This seemed to clean up the side shift skip it was doing and made a big difference to their paths.

This isn’t your issue, obviously, but arranging the sequence to turn motors on may help your accuracy in the future

I am guessing you have the wireless programming set up? If so, leave your cable connected to the joystick after downloading the program. When this is connected you can use the debug features built into robot C so you can see the values of your inputs on the computer while your program is running. Having this viewable, you can then track where the problem is - ie you can see if the encoders are behaving the way you think and react based on what is actually happening.

Another thing. up in the top of your program just after the pragma and include statements, put in an
int sequence = 0;

In various places in your program, add the following line
sequence = some number that identifies where you are

in the first move, make sequence = 1, in the second move make sequence = 2 and so on. this way you can track where you are in your program while watching the debug windows. We have had things go awry in the path, and we thought we were fixing something, but the code that was running was actually somewhere else. Having a variable get set where the program is actually executing makes it easy to identify where your processor is making decisions and what code is executing.

Good luck!