Wireless operation of the robot

Hello,
We are unable to have the program run on the cortex module unless the USB is connected to the laptop and the cortex. I.E. it’s as if the cortex does not remember the program got downloaded to it once the USB is taken off.

Can someone help us through this?

Thanks!

Are you sure that the controller is linked to the cortex?

Please post your code so that we can look for issues. You may have a simple issue that is causing the code to not execute.

There was a great flowchart posted for cortex troubleshooting… here. .

Normally the sort of issue you describe is related to driver compatibility. There are 3 drivers to download, one to the cortex, one to the joystick, and one for robotC to interface to the cortex. If any of the 3 are old, then you can have a file download but not run.

Document is available here http://www.roboticseducation.org/documents/2013/06/vex-cortex-troubleshooting-flowcharts.pdf

Thank you so much people!
This is to test the autonomous code without the intereference of the controller. I want the robot to run on the autonomous code after the program is downloaded and the USB cable removed. The robot doesn’t seem to pick up the autonomous code automatically with the USB unplugged from the laptop and cortex.

I have 2 autonomous tasks and 1 driver challenge task( the robot is controlled by the controller) and it has to count the number of ping pong balls that it picks up.

Here is my code:
#pragma config(Sensor, in1, RightSensor, sensorNone)
#pragma config(Sensor, in2, CenterSensor, sensorReflection)
#pragma config(Sensor, in3, LeftSensor, sensorReflection)
#pragma config(Sensor, dgtl4, LimitSwitch, sensorTouch)
#pragma config(Sensor, dgtl5, LeftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl7, RightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl10, sonarSensor, sensorSONAR_inch)
#pragma config(Motor, port1, RightMotor, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, ArmMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, ClawMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, LeftMotor, tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

//const short LeftButton=1;
//const short CenterButton=2;
//const short RightButton=4;
int pressed=0;

void Not_Pressed_Yet()
{
while (nLCDButtons==0) {}
wait1Msec(5);

}

void Not_Released_Yet()
{
while (nLCDButtons!=0) {}
wait1Msec(5);

}

void pressed_button()
{
while (Sensorvalue[dgtl4]==1)
{
pressed=1
}
wait1Msec(5);
}

void released_button()
{
while (SensorValue[LimitSwitch]==0)
{
pressed=0;
}
wait1Msec(5);
}

void Straight()
{
// if (SensorValue[LeftEncoder] > SensorValue[RightEncoder])
//{
// motor[port1]=50;
// motor[port10]=63;
// }
// if (SensorValue[LeftEncoder] < SensorValue[RightEncoder])
// {
// motor[port1]=63;
// motor[port10]=50;
// }
// if (SensorValue[LeftEncoder]==SensorValue[RightEncoder])
// {
motor[port1]=30;
motor[port10]=30;
//}
}
void TurnLeft()
{ motor[port1] = 0;
motor[port10] = 40;
}

void TurnRight()
{
motor[port1] = 40;
motor[port10] = 0;
}

void PowerRight()
{
motor[port1]=-50;
motor[port10]=50;
}

void PowerLeft()
{
motor[port1]=50;
motor[port10]=-50;
}

task autonomous_1()
{
motor[port1]=0;
motor[port10]=0;
wait1Msec(10000);
//bMotorReflected[port2]=1;
displayLCDCenteredString(0,“Have a nice Day!”);
SensorValue[LeftEncoder]=0;
SensorValue[RightEncoder]=0;
wait1Msec(5000);
motor[ArmMotor]=63;
Straight();
repeatUntil(SensorValue[dgtl10]<=1);
motor[ClawMotor]=63;
//stopAllMotors();
//}
//while (SensorValue[sonarSensor]<=1)
//{
//motor[ClawMotor]=25;
//} //Ultrasonic Range Finder code
}

task autonomous_2()
{
displayLCDCenteredString(0,“God s Great”);
while(1==1) // Center sensor sees black
{
if (SensorValue[in2] <= 2300)
{
Straight(); // Goes forward
}
if(SensorValue[in1] < 2300) // Right sensor sees black
{
TurnLeft(); // Turns left
}
if(SensorValue[in3] < 2300) // Left sensor sees black
{
TurnRight(); // Turns right
}

}	                                                         // Sensor challenge code

}

task driver_challenge ()
{
motor[port1]=0;
motor[port10]=0;
int ball_counter=0;
int pressed=0;
while (true) {
clearLCDLine(0);
clearLCDLine(1);

displayNextLCDString("Count:  ")
displayNextLCDNumber(ball_counter)  //check what the 4 is for

 pressed_button();

   if(sensorvalue[dgtl4]==1){

   released_button();
   ball_counter++;
 }

}
}

task main()
{
int count=0;
clearLCDLine(0);
clearLCDLine(1);
Not_Pressed_Yet();
while (1==1)
if (nLCDButtons==1)
{
Not_Released_Yet();
count=1;
starttask (autonomous_1); // check if you need to call the function here! (20 secs auto)
}
else if (nLCDButtons==4)
{
Not_Released_Yet();
count=2;
starttask (autonomous_2); // Sensor challenge round
}
else if (nLCDButtons==2)
{
Not_Released_Yet();
count=3;
starttask (driver_challenge); // Driver challenge round
}
}

Thanks again!

The first thing I did was try to compile your code. Which it didn’t.

Your code had errors which were you had no semicolons ending some lines.

I have fixed these, try downloading the below code to your robot.

#pragma config(Sensor, in1, RightSensor, sensorNone)
#pragma config(Sensor, in2, CenterSensor, sensorReflection)
#pragma config(Sensor, in3, LeftSensor, sensorReflection)
#pragma config(Sensor, dgtl4, LimitSwitch, sensorTouch)
#pragma config(Sensor, dgtl5, LeftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl7, RightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl10, sonarSensor, sensorSONAR_inch)
#pragma config(Motor, port1, RightMotor, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, ArmMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, ClawMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, LeftMotor, tmotorVex393_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

//const short LeftButton=1;
//const short CenterButton=2;
//const short RightButton=4;
int pressed=0;

void Not_Pressed_Yet()
{
	while (nLCDButtons==0) {}
	wait1Msec(5);

}

void Not_Released_Yet()
{
	while (nLCDButtons!=0) {}
	wait1Msec(5);

}

void pressed_button()
{
	while (Sensorvalue[dgtl4]==1)
	{
		pressed=1;
	}
	wait1Msec(5);
}

void released_button()
{
	while (SensorValue[LimitSwitch]==0)
	{
		pressed=0;
	}
	wait1Msec(5);
}

void Straight()
{
	// if (SensorValue[LeftEncoder] > SensorValue[RightEncoder])
	//{
	// motor[port1]=50;
	// motor[port10]=63;
	// }
	// if (SensorValue[LeftEncoder] < SensorValue[RightEncoder])
	// {
	// motor[port1]=63;
	// motor[port10]=50;
	// }
	// if (SensorValue[LeftEncoder]==SensorValue[RightEncoder])
	// {
	motor[port1]=30;
	motor[port10]=30;
	//}
}
void TurnLeft()
{ motor[port1] = 0;
	motor[port10] = 40;
}

void TurnRight()
{
	motor[port1] = 40;
	motor[port10] = 0;
}

void PowerRight()
{
	motor[port1]=-50;
	motor[port10]=50;
}

void PowerLeft()
{
	motor[port1]=50;
	motor[port10]=-50;
}

task autonomous_1()
{
	motor[port1]=0;
	motor[port10]=0;
	wait1Msec(10000);
	//bMotorReflected[port2]=1;
	displayLCDCenteredString(0,"Have a nice Day!");
	SensorValue[LeftEncoder]=0;
	SensorValue[RightEncoder]=0;
	wait1Msec(5000);
	motor[ArmMotor]=63;
	Straight();
	repeatUntil(SensorValue[dgtl10]<=1);
	motor[ClawMotor]=63;
	//stopAllMotors();
	//}
	//while (SensorValue[sonarSensor]<=1)
	//{
	//motor[ClawMotor]=25;
	//} //Ultrasonic Range Finder code
}

task autonomous_2()
{
	displayLCDCenteredString(0,"God s Great");
	while(1==1) // Center sensor sees black
	{
		if (SensorValue[in2] <= 2300)
		{
			Straight(); // Goes forward
		}
		if(SensorValue[in1] < 2300) // Right sensor sees black
		{
			TurnLeft(); // Turns left
		}
		if(SensorValue[in3] < 2300) // Left sensor sees black
		{
			TurnRight(); // Turns right
		}

	} // Sensor challenge code
}

task driver_challenge ()
{
	motor[port1]=0;
	motor[port10]=0;
	int ball_counter=0;
	int pressed=0;
	while (true) {
		clearLCDLine(0);
		clearLCDLine(1);

		displayNextLCDString("Count: ");
		displayNextLCDNumber(ball_counter); //check what the 4 is for

		pressed_button();

		if(sensorvalue[dgtl4]==1){

			released_button();
			ball_counter++;
		}

	}
}

task main()
{
	int count=0;
	clearLCDLine(0);
	clearLCDLine(1);
	Not_Pressed_Yet();
	while (1==1)
		if (nLCDButtons==1)
	{
		Not_Released_Yet();
		count=1;
		starttask (autonomous_1); // check if you need to call the function here! (20 secs auto)
	}
	else if (nLCDButtons==4)
	{
		Not_Released_Yet();
		count=2;
		starttask (autonomous_2); // Sensor challenge round
	}
	else if (nLCDButtons==2)
	{
		Not_Released_Yet();
		count=3;
		starttask (driver_challenge); // Driver challenge round
	}
}

Hello,
I ran the edited code that you gave me and it still doesn’t run without the USB cable from the laptop to the cortex. I get an error like this(attached) when I connect the VEXnet USBs to the laptop and cortex. I have the USB cable running from the laptop to the controller.
I am not sure if this configuration is correct! And all the Firmwares are up to date as far as I checked. An amateur to building robots :slight_smile:

Could you please take a look at the error message and guide me?
Screenshot.PNG

You need to upgrade firmware on cortex and joystick, this is (usually, if it doesn’t fail) done by plugging the orange USB A-A cable into the computer and cortex, performing the firmware upgrade through RobotC, and repeating that with the joystick. Then make sure that the joystick and cortex are paired and connect to each other (green LEDs) when the the VEXnet keys are inserted into them and everything is turned on.

Do you have one of these cables: http://www.vexrobotics.com/276-2186.html
If not, you will need to download the code by plugging the USB cable into the cortex and computer, download the code, and then plugging the VEXnet key back in to the cortex and joystick so they connect with each other. VEXnet keys won’t let you download code when plugged into the computer, if you want to download code wirelessly you need the cable linked above.

Let us know if you need help with any of those things or if it doesn’t solve it. Also, if in doubt, power cycle often.

Hello,
I do not have the programming module, neither the RJ12 cable. I have just the Vexnet 2.0 keys and the USB A-A cable. I did try downloading the code by plugging the USB cable into cortex and computer and then plugging the VEXnet key back in to the cortex and joystick but the joystick stopped working! The VEXnet LED was blinking on both the cortex and joystick (a single blink) and I dont know what went wrong!

Has it got something to do with the VEXnet firmware upgrade utility? I did power cycle both the joystick and the cortex often. The competition is on this Friday and I can only hope for the best!

Thank you so much!

The keys themselves will sometimes have updates and if the keys are incompatible to the version on the cortex or the remote it wont work. An easy way to see if the keys are out of date without having the software downloaded is to connect the cortex and remote with the orange cable and then if everything turns green you know those two are working and then after connecting them with the cable turn everything off and then put the keys in and try it with the keys. If it doesn’t turn green then it generally means there is a mismatch between the versions of the keys and cortex/remote. Hope this helps.

Thank you for the reply Tylennis.
I tried connecting the cortex and the remote controller after assembling the clawbot and the joystick worked fine.I was able to test the motors and stuff with the default joystick code. This was even before using ROBOTC software.And this was a long time ago, like 2 weeks back. I didnt use the joystick at all after that till today. So has it got anything to do with my code that I have posted above?

After trying to download the code using the USB A-A cable and after connecting the VEXnet keys to the cortex and joystick, the VEXnet LEDS were just blinking green.:frowning:

Well after downloading the code connect the remote and cortex using the orange cable and try driving it around with the new code if that works then it means there is an issue with the keys be it what version they are on or something else. If when plugged together with the orange cable the lights don’t turn green then my first step would be to go through the firmware update utility and update both the remote and cortex to the latest versions, that generally fixes most problems I encounter with stuff not connecting.

Connect your joystick to your computer.

In ROBOTC go to the “Robot” menu, then “Download Firmware”, then Click on "Automatically Update VEXnet Joystick"

After the process has finished, disconnect your joystick from the computer and connect the Cortex.
Perform the same steps as above but select “Automatically Update VEX Cortex”.

After this has happened, power cycle both the controller and the cortex and re-pair the VEXnet connection by connecting them together with the USB A-A cable for a few seconds till the lights turn green on both.

NOTE: You must re-download the code from ROBOTC to the Cortex after you have updated the firmware.

If you are still having issues you may need to update the firmware on the VEXnet keys.

To do this, download and install the VEXnet Key 2.0 Firmware Utility) from here http://link.vex.com/downloads/VEXnet-Key-2p0-Update

This will only work if you are using the 2.0 keys

You must complete the process for each key, instructions are available here http://link.vex.com/docs/VEXnet-Key-2p0-Firmware-Instructions

If you are still having issues you may need to contact VEX technical support via email at support@vexrobotics.com

So the issue is you need to go to robot communication type, usb only. If your running standalone code without a controller.

At our school one of our teams had connection issues due to a defective Vexnet key. On the inside of the usb insert a part was chipped. Because of this they had connection issues. Have you swapped out Vexnet keys?

Thank you people! I am going to try going through the whole process of pairing them up again and I will keep you updated!
But if I need to download the code wirelessly using VEXnet keys, the communication mode has to be VEXnet or USB and the communication port has to be set to “Automatic Selection”?

My code has both autonomous and user controlled tasks. Task 3 (Driver challenge round) is started when LCD button 4 is pressed. It has to be then operated by the controller and it should execute Task 3 of the code where the LCD has to show he number of balls picked up.

Is my code correctly structured or I need to add some functions like user_control() and change the template? Also do I need to code the joystick buttons or maybe just assume that it will run on its default code?

Could you please take a look at my code and let me know? Task 1 and 2 are autonomous tasks and task 3 is executed when LCD button 4 is pressed. But the robot has to be controlled by the controller to pick up balls.

task autonomous_1()
{
motor[port1]=0;
motor[port10]=0;
wait1Msec(10000);
//bMotorReflected[port2]=1;
displayLCDCenteredString(0,“Have a nice Day!”);
SensorValue[LeftEncoder]=0;
SensorValue[RightEncoder]=0;
//motor[ArmMotor]=63;
Straight();
repeatUntil(SensorValue[dgtl10]<=2);

stopAllMotors();
}

task autonomous_2()
{
displayLCDCenteredString(0,“God s Great”);
while(SensorValue[in2] > 2250) // Center sensor sees black
{

Straight(); // Goes forward
if(SensorValue[in1] > 2300) // Right sensor sees black
{
TurnLeft(); // Turns left
}
if(SensorValue[in3] > 2300) // Left sensor sees black
{
TurnRight(); // Turns right
}

}
}

task driver_challenge ()
{
motor[port1]=0;
motor[port10]=0;
int ball_counter=0;
int pressed=0;
while (true) {
clearLCDLine(0);
clearLCDLine(1);

displayNextLCDString("Count:  ")
displayNextLCDNumber(ball_counter)  //check what the 4 is for

 pressed_button();

   if(sensorvalue[dgtl4]==1){

   released_button();
   ball_counter++;
 }

}
}

@GeroldaffeTheGiraffe , We didnt swap them yet! But our VEXnet keys were working fine when we tested the basic functionality of the motors using the controller, after the clawbot was assembled. This was before downloading any ROBOTC code.

Thank you so much!