Controller Values mapped incorrectly

Yesterday, when we were testing code for our robot, we found that the robot was not responding appropriately to the buttons we were pressing on our controller. To further investigate, we set up a simple program that would read the buttons that were pressed and print out to the LCD. We saw that the pressing certain buttons would be read as some other button. We tried changing laptops, changing controllers and changing batteries, but the problem persists. The misread values are constant across controllers and power cycles; for instance button 6D is always read as 8U. Only three buttons are read appropriately.

We are using the orange cable to connect the cortex with the controller so it isn’t a vex net issue.

When nothing is pressed, 5D and 6U are true.
When 6D is pressed, 8D is true.
When channels 1 and 2 are not zero, 7D is true.
When 5U is pressed, 5U is true.
When 7L is pressed, 7L is true.
When 7U is pressed, 7U is true.
The values returned from channels 1 and 2 are huge nonsensical four digit numbers. Channels 3 and 4 are copying these values but not reading anything on their own. No other buttons are working or being read.

Any suggestions? Completely stupefied here…!
Jesse
2442B

I have never seen that type of issue before and I would assume its a code problem.

Could you post your code?
RobotC or EasyC?

We are using RobotC. Since the problem occurs both when we try our supposed competition code and this testing code, we don’t think it’s a code problem…maybe. Not really sure of anything right now, so more eyes checking it is appreciated. This is our code:

#pragma config(Motor,  port2,           rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  port3,           leftMotor,     tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{

  while(true)
{

  if (vexRT[Btn5U] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B5U");
  }
  else if (vexRT[Btn5D])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B5D");
  }
  else if (vexRT[Btn6U] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B6U");
  }
  else if (vexRT[Btn6D])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B6D");
  }
  else if (vexRT[Btn7U] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B7U");
  }
  else if (vexRT[Btn7D])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B7D");
  }
  else if (vexRT[Btn7L] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B7L");
  }
  else if (vexRT[Btn7R])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B7R");
  }
  else if (vexRT[Btn8U] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B8U");
  }
  else if (vexRT[Btn8D])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B8D");
  }
  else if (vexRT[Btn8L] == 1)
	{
		clearLCDLine(0);
	  displayLCDString(0,0,"B8L");
  }
  else if (vexRT[Btn8R])
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"B8R");
  }
  else if (vexRT[Ch3])
  {
  	clearLCDLine(0);
  	displayLCDNumber(0,0,vexRT[Ch3]);
  }
  else if (vexRT[Ch4])
  {
  	clearLCDLine(0);
  	displayLCDNumber(0,0,vexRT[Ch4]);
  }
  else
  {
  	clearLCDLine(0);
  	displayLCDString(0,0,"None");
  }
}
}

Last week we had a problem where the buttons on the joystick got stuck so they would not retract after pressed. Could this be the cause of the readings?

You could try this code.
You will need to open your debug stream. (Click Robot>Debugger Windows>Debug Stream)
Adjust the wait time to your liking.

You will be able to see it 2 are pressed at once.

task main()
{
	while(true)
	{
		writeDebugStreamLine("==========");
		if (vexRT[Btn5U])	writeDebugStreamLine("B5U");
		if (vexRT[Btn5D])	writeDebugStreamLine("B5D");
		if (vexRT[Btn6U])	writeDebugStreamLine("B6U");
		if (vexRT[Btn6D])	writeDebugStreamLine("B6D");
		if (vexRT[Btn7U])	writeDebugStreamLine("B7U");
		if (vexRT[Btn7D])	writeDebugStreamLine("B7D");
		if (vexRT[Btn7L])	writeDebugStreamLine("B7L");
		if (vexRT[Btn7R])	writeDebugStreamLine("B7R");
		if (vexRT[Btn8U])	writeDebugStreamLine("B8U");
		if (vexRT[Btn8D])	writeDebugStreamLine("B8D");
		if (vexRT[Btn8L])	writeDebugStreamLine("B8L");
		if (vexRT[Btn8R])	writeDebugStreamLine("B8R");
		if (vexRT[Ch3])		writeDebugStreamLine("Ch3: %s", vexRT[Ch3]);
		if (vexRT[Ch4])		writeDebugStreamLine("Ch4: %s", vexRT[Ch4]);
		wait1Msec(10);
	}
}

Or use the “VEXnet joystick viewer” under the Robot->advanced tools menu.

What firmware are you running? Is the firmware matched in joystick and cortex? Have you loaded the correct ROBOTC firmware for the version of ROBOTC you are using, for example, V3.62 needs firmware 968.

Thanks for all of the suggestions! After comparing with some older code from previous competitions, we later found out that in the vexRT] command, apparently there was a typo where the Btn variable was typed with all lowercase letters. After we made the change, everything was okay again. Seems like a tiny thing, but it made a huge difference.

So basically,
vexRT[btn6U] = BAD
vexRT[Btn6U] = GOOD

Thanks everyone!
Jesse 2442B