Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   CIM programming question (http://www.chiefdelphi.com/forums/showthread.php?t=126031)

jls667 07-02-2014 23:25

CIM programming question
 
I plan on connecting a CIM motor on my pickup device. I will probably use a talon. What method is best to use in order to run the CIM? I will probably program one button to make the CIM go in one direction and another for the other direction.

Domenic Rodriguez 07-02-2014 23:50

Re: CIM programming question
 
The code for this task varies depending on what template you are using: SimpleRobot, IterativeRobot, or Command Based. If you're using SimpleRobot or IterativeRobot, just add a Talon to your robot class...
Code:

private Talon pickupMotor = new Talon(1);
...and then in your teleop code check the joystick buttons and set the Talon accordingly
Code:

// inside operatorControl() or teleopPeriodic()
// assuming there is already a Joystick object named 'joystick'
if (joystick.getRawButton(1))
    pickupMotor.set(1.0);
else if (joystick.getRawButton(2))
    pickupMotor.set(-1.0);
else
    pickupMotor.set(0.0);

With the Command Based pattern, you'll want to add the Talon to your pickup subsystem, create a command(s) to set the motor, and then bind your commands to buttons in the OI class.


All times are GMT -5. The time now is 22:37.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi