Problem With Competition Template

Hello,

I wrote a simple program that works fine when I download and compile it. However, when I paste the exact program code into a competition template and compile & download the template, the robot doesn’t do anything other than make a slight motor noise.

I’ll paste the code to both the program file and the template file. Any help would be greatly appreciated.

Thanks!

Program Code (Works fine when compiled and downloaded):

#pragma config(Sensor, dgtl1, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, rightEncoder, sensorQuadEncoder)
#pragma config(Motor, port3, rightMotor, tmotorVex393, openLoop)
#pragma config(Motor, port10, leftMotor, tmotorVex393, openLoop, reversed)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()

{
/Reset encoders to 0/
SensorValue [leftEncoder]=0;
SensorValue [rightEncoder]=0;

while (SensorValue [rightEncoder]<200)
{
motor[leftMotor]=127;
motor[rightMotor]=127;
wait1Msec(2000);
}
motor[leftMotor]=0;
motor[rightMotor]=0;
wait1Msec(1000);

/Reset encoders to 0/
SensorValue [leftEncoder]=0;
SensorValue [rightEncoder]=0;

while (SensorValue [leftEncoder]<200)
{
motor[leftMotor]=127;
motor[rightMotor]=-127;
wait1Msec(2000);
}

}

Template Code (Doesn’t work when compiled and downloaded):

#pragma config(Sensor, dgtl1, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, rightEncoder, sensorQuadEncoder)
#pragma config(Motor, port3, rightMotor, tmotorVex393, openLoop)
#pragma config(Motor, port10, leftMotor, tmotorVex393, openLoop, reversed)
#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#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;

// All activities that occur before 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.
// …

// …
// Insert user code here.
// …

/Reset encoders to 0/
SensorValue [leftEncoder]=0;
SensorValue [rightEncoder]=0;

while (SensorValue [rightEncoder]<200)
{
motor[leftMotor]=127;
motor[rightMotor]=127;
wait1Msec(2000);

}

motor[leftMotor]=0;
motor[rightMotor]=0;
wait1Msec(1000);

/Reset encoders to 0/
SensorValue [leftEncoder]=0;
SensorValue [rightEncoder]=0;

while (SensorValue [leftEncoder]<200)
{
motor[leftMotor]=127;
motor[rightMotor]=-127;
wait1Msec(2000);
}

}

/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
// User control code here, inside the loop

while (true)
{
  // This is the main execution loop for the user control program. Each time through the loop
  // your program should update motor + servo values based on feedback from the joysticks.

  // .....................................................................................
  // Insert user code here. This is where you use the joystick values to update your motors, etc.
  // .....................................................................................

motor[leftMotor] = vexRT[Ch3];
motor[rightMotor] = vexRT[Ch2];
wait1Msec(20);
}

}

By " Not work", do you mean the autonomous portion or the user portion. To test out your autonomous, you need a competition switch. The rest of this post is about if it’s user control that’s not working. Seeing as though your code compiled and downloaded without errors and your code looks fine to me, I would suggest that maybe your Cortex is messed up in some way. If not, then check the wiring. If all those fail, then there may be something on your robot restricting movement from the axle.

Side note: Why is your left motor plugged into port 10 and your right in port 3? It doesn’t mess anything up, but whyyyy.

For your autonomous code to work, you need to have a competition switch, which can be purchased here: VEXnet Competition Switch - VEX Robotics

Alternatively, if you have a wireless programming kit (available to purchase here: http://www.vexrobotics.com/vexedr/products/accessories/electronics/276-2186.html )

If you use the wireless programming kit, then you should connect it correctly then go to Robot >> Advanced Tools >> VEXNet Joystick Viewer on your RobotC software. This has a built-in competition switch

I was originally in motor ports 1 and 10 as per the stock Claw Bot setup. The motor stopped working in Port 1, so I moved to Port 3. I only brought home one adapter, so I had to leave the other motor in Port 10.

Thanks!

Thanks!

does this need to be included?

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!