Hi!
I was wondering if anyone had any code that would, in driver control, select an autonomous from our LCD or through software press the center button to kick us back into driver control in the case of a disconnect. If we don’t press the center button on the LCD after we disconnect, we will not have driver control of the robot. this is obviously bad if we disconnect in game after moving, as the game rules prevent you from touching the robot in game unless you have not moved. any help would be great!!
thanks!
Andrew Palumbo
VEX KY Team 1859S
Unfortunately, this a major design flaw with LCD autonomous selectors, and pretty much the only reason that people use potentiometers instead. What my team did to at least attempt to combat this issue is have a wait limit on a button press, let’s just use 3 seconds as an example. If a button (be it to select or to move between multiple routines) is not pressed within 3 seconds, it will automatically select whichever one is currently on-screen. This does make you have to wait an extra 3 seconds after reconnecting, but I like having the clarity and assurance of an LCD over a potentiometer, so I see this as a nice compromise between the two systems.
Usually after a disconnect (if your battery didn’t unplug) it’ll just go back to the current mode it was in. This function would be practically useless. And if your battery unplugs you might as well accept it and leave it sit because chances are it won’t come back. (Keep in mind this is all just from my 3 years of experience in Vex and the context of the question).
This isn’t really true. If the issue is purely wireless connection-based, then it may return to its former state. But if, for example, the battery becomes unplugged for a tiny bit of time, then the robot will turn off and on again, and you will have to start over once the robot reconnects. This is what we’re talking about.
That’s what I’m saying. Something to do is set up a timer with your auton select and after a certain amount of time (10 seconds or so) it defaults to an option. It’s very doable I just haven’t done it because I’ve never really encountered it. Only connection based problems.
If you would like I could whip something up quick. It probably wouldn’t work the first time considering I’m a bit rusty but I could eventually get there lol.
Alright so I did a little bit of programming because I’m very deprived. The code below should work. Try unplugging and plugging the battery back in but don’t touch the lcd when it reconnects.
#pragma config(UART_Usage, UART1, uartVEXLCD, baudRate19200, IOPins, None, None)
#pragma config(UART_Usage, UART2, uartNotUsed, baudRate4800, IOPins, None, None)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma competitionControl(Competition)
#pragma platform(VEX2)
#include "Vex_Competition_Includes.c"
const short buttonLeft=1;
const short buttonMid=2;
const short buttonRight=4;
int count = 0;
void waitForPress()
{
if(nLCDButtons==0)
{
wait1Msec(5);
}
}
void waitForRelease()
{
if(nLCDButtons!=0)
{
wait1Msec(5);
}
}
void pre_auton()
{
clearLCDLine(0);
clearLCDLine(1);
clearTimer(T1);
{
while(nLCDButtons!=buttonMid)
{
if((nLCDButtons==0) && (time1[T1]<10000))
{
count=0;
}
bLCDBacklight=true;
switch(count)
{
case 0:
displayLCDCenteredString(0, "First Thing");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
if(nLCDButtons==buttonLeft)
{
waitForRelease();
count=3;
}
else if(nLCDButtons==buttonRight)
{
waitForRelease();
count++;
}
break;
case 1:
displayLCDCenteredString(0, "Second Thing");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
if(nLCDButtons==buttonLeft)
{
waitForRelease();
count--;
}
else if(nLCDButtons==buttonRight)
{
waitForRelease();
count++;
}
break;
case 2:
displayLCDCenteredString(0, "Third Thing");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
if(nLCDButtons==buttonLeft)
{
waitForRelease();
count--;
}
else if(nLCDButtons==buttonRight)
{
waitForRelease();
count++;
}
break;
case 3:
displayLCDCenteredString(0, "Fourth Thing");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
if(nLCDButtons==buttonLeft)
{
waitForRelease();
count--;
}
if(nLCDButtons==buttonRight)
{
waitForRelease();
count=0;
}
break;
default:
count=0;
break;
}
}
}
}
task autonomous()
{
clearLCDLine(0);
clearLCDLine(1);
switch(count)
{
case 0:
displayLCDCenteredString(0, "First Thing");
displayLCDCenteredString(1, "Is Running");
{
//Code for auton here
}
break;
case 1:
displayLCDCenteredString(0, "Second Thing");
displayLCDCenteredString(1, "Is Running");
{
//Code for auton here
}
break;
case 2:
displayLCDCenteredString(0, "Third Thing");
displayLCDCenteredString(1, "Is Running");
{
//Code for auton here
}
break;
case 3:
displayLCDCenteredString(0, "Fourth Thing");
displayLCDCenteredString(1, "Is Running");
{
//Code for auton here
}
break;
default:
displayLCDCenteredString(0, "System Restart");
displayLCDCenteredString(1, "Driver Engaged");
break;
}
}
task usercontrol()
{
while(true)
{
/*PUT YOUR DRIVERCONTROL CODE HERE*/
}
}
If you have questions or it doesn’t work, tell me what’s up or somethin (keep in mind I didn’t physically test this out so it’s kind of a shot in the dark so bear with me if it doesn’t work).
Instead of having a ‘select’ button, on our LCD the selection is passive. We cycle through the options and every time we cycle, a global variable is updated to reflect the current selection. This means that we do not have to actually ‘select’ the auton, as whatever is on the screen is automatically run when switch to autonomous mode. We also don’t have any problems like yours, because again, the selection is changed when we update the LCD instead of selecting a program. If the robot were to (for some bizarre reason) turn off and turn back on again on its own, it would simply default to the first autonomous (this is blank for safely reasons) and it will jump right into driver control. If the robot is disabled, you can cycle through and choose one any time, even after a choice has already been made, and we can reserve the middle button for another function (go back to the previous setup step, display battery data, etc).