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 * Mindsensors SD540 Motor Controller.
013 *
014 * <p>Note that the SD540 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 SD540 User Manual available from
018 * Mindsensors.
019 *
020 * <ul>
021 *   <li>2.05ms = full "forward"
022 *   <li>1.55ms = the "high end" of the deadband range
023 *   <li>1.50ms = center of the deadband range (off)
024 *   <li>1.44ms = the "low end" of the deadband range
025 *   <li>0.94ms = full "reverse"
026 * </ul>
027 */
028public class SD540 extends PWMMotorController {
029  /**
030   * Constructor.
031   *
032   * @param channel The PWM channel that the SD540 is attached to. 0-9 are on-board, 10-19 are on
033   *     the MXP port
034   */
035  public SD540(final int channel) {
036    super("SD540", channel);
037
038    m_pwm.setBounds(2.05, 1.55, 1.50, 1.44, 0.94);
039    m_pwm.setPeriodMultiplier(PWM.PeriodMultiplier.k1X);
040    m_pwm.setSpeed(0.0);
041    m_pwm.setZeroLatch();
042
043    HAL.report(tResourceType.kResourceType_MindsensorsSD540, getChannel() + 1);
044  }
045}