Quote:
Originally Posted by F22Rapture
We need to have our frisbee injector (which is an arm attached to a window motor) actuate forward for exactly X milliseconds, and then retract backwards until it triggers a limit switch. I know there are a couple different ways to do this but I was wondering how it would be best to do so.
1. Spawn off a second thread, set to actuate forward, Timer.delay() for X milliseconds, actuate backward, and then return isFinished() as true when the microswitch is triggered. I could have sworn I'd seen a team do it this way, but then I came across some comments saying that creating a Thread inside a command is a bad idea, etc.
2. Create 2 commands (which I would prefer not to do), the first of which is timed using isTimedOut(), the second of which triggers via the microswitch, and call them sequentially in a command group
3. Ways I haven't thought of
Thoughts?
|
Why don't you use the FPGA timer?
In java you could do something like
int amountOfTimeToRun = 0;//insert amount of time here to run in milliseconds
//button press or something here
int timeStamp = Timer.getFPGATimestamp();//records time
while(Timer.getFPGATimestamp() - timeStamp <= amountOfTimeToRun)
{actuate forward}