Our robotc code in competition is not working sometimes when we connect to the tower is there a reason why?
#pragma config(Sensor, in8, Gyro, sensorGyro)
#pragma config(Sensor, dgtl1, , sensorQuadEncoder)
#pragma config(Sensor, dgtl3, , sensorQuadEncoder)
#pragma config(Sensor, dgtl9, SolTM, sensorDigitalOut)
#pragma config(Sensor, dgtl10, SolLM, sensorDigitalOut)
#pragma config(Sensor, dgtl11, SolSR, sensorDigitalOut)
#pragma config(Sensor, dgtl12, SolCE, sensorDigitalOut)
#pragma config(Motor, port1, Motor1, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, Motor2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, MotorA, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, MotorB, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, MotorC, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, MotorD, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, Filper, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, Slider, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, Motor9, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, Motor10, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(145)
#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;
SensorValue[SolCE] = 1;
SensorType[in8] = sensorNone;
wait1Msec(100);
//Reconfigure Analog Port 8 as a Gyro sensor and allow time for ROBOTC to calibrate it
SensorType[in8] = sensorGyro;
wait1Msec(200);
// 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()
{
SensorValue[SolCE] = 1;
motor[port1] = -127;
motor[port2] = -127;
motor[port9] = -127;
motor[port10] = -127;
wait1Msec(500);
motor[port1] = 0;
motor[port2] = 0;
motor[port9] = 0;
motor[port10] = 0;
wait1Msec(200);
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// 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)
{
bLCDBacklight = true; // Turn on LCD Backlight
string mainBattery, backupBattery;
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
//Display the Primary Robot battery voltage
displayLCDString(0, 0, "Primary: ");
sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
displayNextLCDString(mainBattery);
//Display the Backup battery voltage
displayLCDString(1, 0, "Backup: ");
sprintf(backupBattery, "%1.2f%c", BackupBatteryLevel/1000.0, 'V'); //Build the value to be displayed
displayNextLCDString(backupBattery);
//Short delay for the LCD refresh rate
motor[port3] = vexRT[Ch1Xmtr2] - vexRT[Ch2];//lift
motor[port4] = vexRT[Ch2] + vexRT[Ch1Xmtr2];
motor[port5] = vexRT[Ch2] + vexRT[Ch1Xmtr2];
motor[port6] = vexRT[Ch1Xmtr2] - vexRT[Ch2];
bMotorFlippedMode[port1] = 1;
bMotorFlippedMode[port9] = 1;
motor[port1] = vexRT[Ch3] - vexRT[Ch4];//drive
motor[port2] = vexRT[Ch3] - vexRT[Ch4];
motor[port10] = vexRT[Ch3] + vexRT[Ch4];
motor[port9] = vexRT[Ch3] + vexRT[Ch4];
if(vexRT[Btn6D] == 1)
{
motor[port7] = -127;
}
else if(vexRT[Btn5D] == 1)// && eqaul AND
{
motor[port7] = 127;
}
else
{
motor[port7] = 0;
}
if(vexRT[Btn8U] == 1)
{
motor[port8] = 55;
}
else if(vexRT[Btn8D] == 1)// && eqaul AND
{
motor[port8] = -55;
}
else
{
motor[port8] = 0;
}
if(vexRT[Btn7D] == 1) // If button is pressed:
{
SensorValue[SolCE] = 0; // …activate the solenoid.
}
else // If button 6U is NOT pressed:
{
SensorValue[SolCE] = 1; // ..deactivate the solenoid.
}
if(vexRT[Btn6U] == 1) // If button is pressed:
{
SensorValue[SolSR] = 1; // …activate the solenoid.
}
if(vexRT[Btn5U] == 1) // If button is pressed:
{
SensorValue[SolSR] = 0; // …activate the solenoid.
}
if(vexRT[Btn7U] == 1) // If button is pressed:
{
SensorValue[SolLM] = 1; // …activate the solenoid.
}
else // If button 6U is NOT pressed:
{
SensorValue[SolLM] = 0; // ..deactivate the solenoid.
}
wait1Msec(30);
}
}