001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.wpilibj.motorcontrol;
006
007import edu.wpi.first.hal.FRCNetComm.tResourceType;
008import edu.wpi.first.hal.HAL;
009import edu.wpi.first.wpilibj.PWM;
010
011/**
012 * Cross the Road Electronics (CTRE) Talon and Talon SR Motor Controller.
013 *
014 * <p>Note that the Talon uses the following bounds for PWM values. These values should work
015 * reasonably well for most controllers, but if users experience issues such as asymmetric behavior
016 * around the deadband or inability to saturate the controller in either direction, calibration is
017 * recommended. The calibration procedure can be found in the Talon User Manual available from CTRE.
018 *
019 * <ul>
020 *   <li>2.037ms = full "forward"
021 *   <li>1.539ms = the "high end" of the deadband range
022 *   <li>1.513ms = center of the deadband range (off)
023 *   <li>1.487ms = the "low end" of the deadband range
024 *   <li>0.989ms = full "reverse"
025 * </ul>
026 */
027public class Talon extends PWMMotorController {
028  /**
029   * Constructor for a Talon (original or Talon SR).
030   *
031   * @param channel The PWM channel that the Talon is attached to. 0-9 are on-board, 10-19 are on
032   *     the MXP port
033   */
034  public Talon(final int channel) {
035    super("Talon", channel);
036
037    m_pwm.setBounds(2.037, 1.539, 1.513, 1.487, 0.989);
038    m_pwm.setPeriodMultiplier(PWM.PeriodMultiplier.k1X);
039    m_pwm.setSpeed(0.0);
040    m_pwm.setZeroLatch();
041
042    HAL.report(tResourceType.kResourceType_Talon, getChannel() + 1);
043  }
044}