Robot C not working without USB

Hey there, We have a working code with the robot C and limit switch. We download it and we have communication mode: usb or vex net. We have tried USB only and USB/VexNet and some robots are not running without the USB cord. Is there something else we need to click on the robot drop down?
We are using Natural language, Vex not IQ, and PLTW. We do not have VEX IQ marked.

The advice about our code has really helped out and thank you so much.

USB only means that you cant use the Joystick, the code will start running as soon as you turn the Cortex on. USB or VEXnet means it’ll try to connect to VEXnet Joystick first and if there is no connection after a certain amount of time (maybe ten seconds) it’ll then time out and run the code without VEXnet.

Can you post some code that isn’t working?

3 Likes

Its been a while since I have used Robot C, but have you established the connection between your two vexnet recievers? If you are using robot C, I am guessing you might be on the EDR platform.

You need two pair the two receivers if you haven’t already. This is a great resource for it: http://cmra.rec.ri.cmu.edu/products/teaching_robotc_cortex/reference/VEXnet_setup_guide.pdf

1 Like

#pragma config(Sensor, dgtl6, Switch, sensorTouch)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port9, leftMotor, tmotorServoContinuousRotation, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

task main()
{
while(1==1)

   if(SensorValue(Switch)==1)


      {
        motor[port2] = 127;           // if pressed runs the motor
        motor[port9] = 127;           // if pressed runs the motor




   wait1Msec(4000); // robot moves forward for 1 seconds before program ends



motor[port2] = 0; //Stop
  motor[port9] = 0; //Stop

}

}
It has worked on several robots. It may be our cortex?

It sounds like you want to run the robots without the controller on. You need to set

bIfiAutonomousMode = true;   // autonomous mode No controller needed.  

Put it just after the

 task main() {
2 Likes

Thanks @Foster - I had seen & tried this:

task main() {
bIfiAutonomousMode = true;   // autonomous mode No controller needed.  
----- while(true) {
------
}//end main

…and got a weird error about not being able to set the value of a protected variable - I can re-create if you like.

Although this was not in a competition template - would that make a difference?

The template would not make a difference. That’s weird, I’ve done that before and it forced it to run.

NP - Thanks -

FWIW I got excited for a minute - saw V4 of Robot-C (old PC was V3) - I installed it on a different PC and got the same error:
**Severe*:Can't assign to read only 'const' variable

Very obsolete.
edit: actually that’s a read only variable that indicates the auton mode, I was thinking of something else.

Did you update RobotC firmware on the cortex ? Definitely do no use V3, not sure if that was even compatible with later version of the cortex master firmware.

Selecting “USB only” was the right thing to do, but make sure you power cycle the cortex after changing modes.

2 Likes

Yea, most of my info is that way. Wonder when it became read only?

Thanks for jumping into the thread.