View Single Post
  #3   Spotlight this post!  
Unread 22-01-2014, 23:31
shindigo shindigo is offline
Registered User
AKA: Mike Parker
FRC #0102
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2009
Location: Somerville, NJ
Posts: 33
shindigo is an unknown quantity at this point
Re: NEW PROGRAMMER - MOTOR PROGRAMMING

Here is an outline of what you need to do to accomplish the goals you have laid out in your post:
1. Create a subsystem to control access to the motor. This class will contain a member variable that is the speedcontroller for the motor, see Jaguar, Victor, or Talon.
2. Within this subsystem you will create a Java function that will set the motor to a particular speed. Pass the speed as a parameter to the function.
3. Create a Command that will turn the motor on. Inside the initialize or the execute this will call the function from step 2. In the end and interrupt functions you will want to set the motor speed to zero again by calling the function from step 2.
4 in the operator interface OI.java you will need to create the Joystick object and the button objects. Use the button's whenPressed function to assign the command from step 3 to the button.
5. At this point I'm a little confused about your requirements: you say you want the motor to run for 5 secs, but you also say you want to stop the motor with another button press. Which is it? If you want the Command to timeout after 5 secs use the set Timeout function of the command to set the timeout and check the isTimeout function in the isFinished function of the command.
6. If you want to stop the motor with a second button, create the button in OI and have it call a Command that sets the motor speed to zero.

Hope that gets you going...
Reply With Quote