ROBOTC.net forums
http://www.robotc.net/forums/

Robot only runs when plugged into comp. w/ USB to Serial
http://www.robotc.net/forums/viewtopic.php?f=11&t=4162
Page 1 of 1

Author:  teachsail [ Wed Jan 25, 2012 2:37 pm ]
Post subject:  Robot only runs when plugged into comp. w/ USB to Serial

My class is using RobotC 1.08 on computers running Windows XP. One of the students squarebot w/ PIC will only run while it is connected to the computer. This problem persists on more then one computer. We tried reloading the firmware, but no difference.

Author:  magicode [ Wed Jan 25, 2012 4:10 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

It would help to give more details. What exactly are you doing?

Author:  teachsail [ Wed Jan 25, 2012 5:39 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

The robot has a sonar sensor on the front. The goal is to drive forward to within 5 inches from a barrier, turn 180 degrees,and then return to the starting area until another barrier is detected and stop. Would you like to see the code? The students have left but I could rewrite it myself.

Author:  jbflot [ Thu Jan 26, 2012 12:41 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

Try going to Robot > VEX Cortex Download Method, and choosing "Download using USB Only". Then redownload your program, and turn the robot off and back on. Your program should then immediately run any time you turn the robot on.

Author:  teachsail [ Thu Jan 26, 2012 3:17 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

My students are not using a cortex, they are using a PIC. Two of our robots are having this problem.

Author:  jbflot [ Thu Jan 26, 2012 3:22 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

Sonar sensors return a value of -1 when they don't get a sound echo. Sound takes time to travel, so for the first fraction of a second of any program, the sensor value will be -1 until the sensor gets a sound echo.

If the first thing in your program happens to be something along the lines of...

while(SensorValue[sonar] > 5)
{
}

...this condition will never be met, since it will have a value of -1. If this is the problem, you can fix the condition or put a brief wait statement at the beginning. If you go here: http://www.robotc.net/vex_full/ to the Sensing > Ultrasonic section, you'll find some tutorials that might help.

Author:  teachsail [ Fri Jan 27, 2012 5:24 pm ]
Post subject:  Re: Robot only runs when plugged into comp. w/ USB to Serial

jbflot wrote:
Sonar sensors return a value of -1 when they don't get a sound echo. Sound takes time to travel, so for the first fraction of a second of any program, the sensor value will be -1 until the sensor gets a sound echo.


Yes we realized this last week, the sonar was not working till we made this change. Here is the code we are using.

const tSensors sonarSensor = (tSensors) in5; //sensorSONAR //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration. !!*//

task main ()
{
wait1Msec(2000);
bMotorReflected[port2] = 1;

while (SensorValue[sonarSensor] > 5 || SensorValue[sonarSensor] < 0 ) // drive to far wall
{
motor [port2] = 63;
motor [port3] = 63;
}

motor [port2] = 0; //pause
motor [port3] = 0;
wait1Msec(500);

motor [port2] = 63; //turn 180
motor [port3] = -63;
wait1Msec(1143);

while (SensorValue[sonarSensor] > 5 || SensorValue[sonarSensor] == -1) // drive to near wall
{
motor [port2] = 63;
motor [port3] = 63;
}

}

While hooked to the computer, the program runs well. First the time delay, then the first while loop until we trigger the sensor, then the turn, then the last while loop. When off the computer it just does the "wait1Msec(2000);" and the turn.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/