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 * VEX Robotics Victor 888 Motor Controller The Vex Robotics Victor 884 Motor Controller can also be
013 * used with this class but may need to be calibrated per the Victor 884 user manual.
014 *
015 * <p>Note that the Victor uses the following bounds for PWM values. These values were determined
016 * empirically and optimized for the Victor 888. These values should work reasonably well for Victor
017 * 884 controllers also but if users experience issues such as asymmetric behavior around the
018 * deadband or inability to saturate the controller in either direction, calibration is recommended.
019 * The calibration procedure can be found in the Victor 884 User Manual available from VEX Robotics:
020 * <a
021 * href="http://content.vexrobotics.com/docs/ifi-v884-users-manual-9-25-06.pdf">http://content.vexrobotics.com/docs/ifi-v884-users-manual-9-25-06.pdf</a>
022 *
023 * <ul>
024 *   <li>2.027ms = full "forward"
025 *   <li>1.525ms = the "high end" of the deadband range
026 *   <li>1.507ms = center of the deadband range (off)
027 *   <li>1.490ms = the "low end" of the deadband range
028 *   <li>1.026ms = full "reverse"
029 * </ul>
030 */
031public class Victor extends PWMMotorController {
032  /**
033   * Constructor.
034   *
035   * @param channel The PWM channel that the Victor is attached to. 0-9 are on-board, 10-19 are on
036   *     the MXP port
037   */
038  @SuppressWarnings("this-escape")
039  public Victor(final int channel) {
040    super("Victor", channel);
041
042    m_pwm.setBoundsMicroseconds(2027, 1525, 1507, 1490, 1026);
043    m_pwm.setPeriodMultiplier(PWM.PeriodMultiplier.k2X);
044    m_pwm.setSpeed(0.0);
045    m_pwm.setZeroLatch();
046
047    HAL.report(tResourceType.kResourceType_Victor, getChannel() + 1);
048  }
049}