View Single Post
  #4   Spotlight this post!  
Unread 10-03-2013, 04:41
westin444's Avatar
westin444 westin444 is offline
C++ Programmer
AKA: Westin Miller
FRC #1983 (Skunkworks)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Seattle, WA
Posts: 7
westin444 is on a distinguished road
Send a message via MSN to westin444
Re: Best way to implement a timed action

Assuming that you want to implement this as a command you can do something where you use the FPGA timer to time the 'halfway point' of the command.
In the command initialize you set a start time variable for the command to the current time.
In the execute you do something along the lines of setting the solenoid to forward when the start time + delay time is less than the current time, and set in to reverse otherwise.
In the is finished you can then check to see if the delay has passed and the limit switch is active.

In C++ this would be something like this:
https://gist.github.com/Equinox-/5127682

Last edited by westin444 : 10-03-2013 at 04:53. Reason: Example