I have been having consistent problems where VEXnet would disconnect and the joystick would lose control of the robot. Usually this is not a big problem and we can figure it ourselves via different vexnet keys or whatnot. The issue we are having now is that our arm motors would continue to run in the direction that it was previously moving in BEFORE the disconnect. We’ve ended up with only a couple of broken axles thankfully, as we have to dive to turn the robot off…
I am using the newest revision of robotC and any help is appreciated. Is it a problem with robotC or could it be my code? I’ve already removed my arm state codes and the includes file is a fresh copy.
Many thanks,
Timothy Leung
#pragma config(Sensor, dgtl1, PistonLeft, sensorDigitalOut)
#pragma config(Sensor, dgtl2, PistonRight, sensorDigitalOut)
#pragma config(Sensor, dgtl3, EncoderLeft, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, EncoderRight, sensorQuadEncoder)
#pragma config(Sensor, dgtl7, ArmEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl12, ArmButton, sensorTouch)
#pragma config(Motor, port1, BackDriveLTwo, tmotorVex393, openLoop)
#pragma config(Motor, port2, FrontDriveL, tmotorVex393, openLoop)
#pragma config(Motor, port3, ArmL2, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port4, ArmR1, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port5, BackDriveROne, tmotorVex393, openLoop)
#pragma config(Motor, port6, BackDriveLOne, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port7, ArmL1, tmotorVex393, openLoop)
#pragma config(Motor, port8, FrontDriveR, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port9, ArmR2, tmotorVex393, openLoop)
#pragma config(Motor, port10, BackDriveRTwo, tmotorVex393, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c"
// Variables
int joy_1_x = 0;
int joy_1_y = 0;
int joy_2_x = 0;
int FrontRight = 0;
int FrontLeft = 0;
int BackRight = 0;
int BackLeft = 0;
int armpower = 0;
void pre_auton()
{
bStopTasksBetweenModes = true;
}
task autonomous()
{
}
task usercontrol()
{
while (true)
{
// Getting Values
joy_1_x = vexRT[Ch4];
joy_1_y = vexRT[Ch3];
joy_2_x = vexRT[Ch1];
// Setting Deadzones
if(joy_1_x <= 50 && joy_1_x >= -50){joy_1_x = 0;}
if(joy_1_y <= 30 && joy_1_y >= -30){joy_1_y = 0;}
if(joy_2_x <= 30 && joy_2_x >= -30){joy_2_x = 0;}
// Holonomic math
FrontLeft = (1*joy_1_y) + (joy_1_x) + (joy_2_x);
FrontRight = (1*joy_1_y) + (-1*joy_1_x) + (-1*joy_2_x);
BackRight = (1*joy_1_y) + (joy_1_x) + (-1*joy_2_x);
BackLeft = (1*joy_1_y) + (-1*joy_1_x) + (joy_2_x);
// Checking
if (FrontLeft >= 127)
{
FrontLeft = 127;
}
else if (FrontLeft <= -127)
{
FrontLeft = -127;
}
if (BackRight >= 127)
{
BackRight = 127;
}
else if(BackRight <= -127)
{
BackRight = -127;
}
if ( FrontRight >= 127)
{
FrontRight = 127;
}
else if( FrontRight <= -127)
{
FrontRight = -127;
}
if (BackLeft >= 127)
{
BackLeft = 127;
}
else if(BackLeft <= -127)
{
BackLeft = -127;
}
//// Motor
motor[BackDriveLOne] = motor[BackDriveLTwo] = BackLeft;
motor[FrontDriveL] = FrontLeft;
motor[BackDriveROne] = motor[BackDriveRTwo] = BackRight;
motor[FrontDriveR] = FrontRight;
if(vexRT[Btn5U] == 1)
{
SensorValue[PistonLeft] =0;
SensorValue[PistonRight] =0;
}
else if (vexRT[Btn5U] ==0)
{
SensorValue[PistonLeft] =1;
SensorValue[PistonRight] =1;
}
if(vexRT[Btn6U] == 1)
{
armpower = 127;
}
else if (vexRT[Btn6D] ==1)
{
armpower = -127;
}
else
{
armpower = 0;
}
motor[ArmL1] = motor[ArmL2] = motor[ArmR1] = motor[ArmR2] = armpower;
}