We have seen some teams online using a programmed timer through there cortex and LCD that stops the auton as soon as 15 seconds are up so that they know the program fits in the 15 second auton when practicing. We lost some autonomous bonuses at worlds this year because the program didnt finish in the time limit.
The programmer for our team was wondering how other teams went about programing this and incorporating the LCD into it. Any insight is greatly appreciated!
You could use one of the timers and a set of variables in global scope to manage this.
Control variables
bool use_auton_timer= false;
Then use the LCD pad or some other thing like a jumper or pot to set the use_auton_timer variable. At the beginning of the auton, start the timer.
Idea 1 - start a background task and hog the CPU never leaving the auton at that point.
Idea 2- control the setting of motors via functions or tasks. If you use jpearman’s smart motor library or his slew rate code, you already abstract the motor control. Use the global variable in that task to set the motors to 0 beyond the auton timer time. Here you would start the timer at the start of the auton task and have a cut off to shut the motors down automatically.
Lines 744-769 is one area you could add the auton cut off. Or you could do it near line 1865 in the slew rate task. There are choices you could make to say you want it in one or the other. I personally think in the slew rate task would work better since the setmotor call is only called when you want to change things and the slew is always running int he background. If you do change this for an auton timer, please contribute back the code in a branch in Git Hub.](GitHub - jpearman/smartMotorLib)
Lines 744-769 is one area you could add the auton cut off. Or you could do it near line 1865 in the slew rate task. There are choices you could make to say you want it in one or the other. I personally think in the slew rate task would work better since the setmotor call is only called when you want to change things and the slew is always running int he background. If you do change this for an auton timer, please contribute back the code in a branch in Git Hub.](GitHub - jpearman/smartMotorLib)
Lost the bonus? Didn’t finish in the time limit? Does that mean that you would have won the bonus but were disqualified because your autonomous program kept running after the 15 seconds was completed? I thought the field control system would stop the auton programs at the same time.
Seems an overly complicated way of doing this. Just use another task that stops the program (or the autonomous task) after 15 seconds. I will try and post an example later.
Edit:
Here is some old code we used during sack attack. Almost what you want.
In our main task we used our own version of competition control, as part of that we could run the autonomous code for testing like this.
// Button 7 Left runs the show
if( vexRT Btn7L ] == 1 )
{
// wait for release
while( vexRT Btn7L ] == 1 )
wait1Msec(10);
// test run autonomous
RunTimerStart();
TheAutonCode();
RunTimerShowElapsed("run finished");
}
This would show how long the autonomous code takes. At that time we used a function, TheAutonCode(), for the autonomous code, if this is changed to a task the code can be modified as follows.
task TheAutonCode()
{
// the code goes here
}
and in the driver control function somewhere
// Button 7 Left runs the show
if( vexRT Btn7L ] == 1 )
{
// wait for release
while( vexRT Btn7L ] == 1 )
wait1Msec(10);
// test run autonomous
RunTimerStart();
startTask( TheAutonCode() );
// wait 15 seconds
while( RunTimerGet() < 15.0 )
wait1Msec(10);
// stop the task and motors
stopTask( TheAutonCode() );
allMotorsOff(); // in the "normal" competition template
// stop any other tasks you may have started in auton
RunTimerShowElapsed("run finished");
}
no, it didn’t finish in the time and was cut short by the field before we dumped the last 2 cubes or before we let go of the last skyrise because we only timed it by hand during practice. how it ended also depended on battery voltage.
you can see exactly what i’m talking about in our reveal below.