daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Nov 20th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.usfirst.frc.team469.robot;
  2.  
  3. import com.ctre.CANTalon;
  4. import edu.wpi.first.wpilibj.IterativeRobot;
  5. import com.ctre.CANTalon.FeedbackDevice;
  6. import com.ctre.CANTalon.TalonControlMode;
  7.  
  8. public class SampleTalonSRX extends IterativeRobot {
  9.  CANTalon _talon = new CANTalon(0);
  10.  
  11.  public void robotInit() {
  12.   /* first choose the sensor */
  13.   _talon.setFeedbackDevice(FeedbackDevice.CtreMagEncoder_Relative);
  14.   _talon.reverseSensor(false);
  15.  
  16.   /* set the peak and nominal outputs, 12V means full */
  17.   _talon.configNominalOutputVoltage(+0.0 f, -0.0 f);
  18.   _talon.configPeakOutputVoltage(+12.0 f, -12.0 f);
  19.  
  20.   /* set closed loop gains in slot0 */
  21.   _talon.setProfile(0);
  22.   _talon.setF(0.1097);
  23.   _talon.setP(0.22);
  24.   _talon.setI(0);
  25.   _talon.setD(0);
  26.  }
  27.  
  28.  public void teleopPeriodic() {
  29.   _talon.changeControlMode(TalonControlMode.Speed);
  30.   _talon.set(1500); /* 1500 RPM in either direction */
  31.  }
RAW Paste Data
Top