001/*----------------------------------------------------------------------------*/
002/* Copyright (c) FIRST 2008-2017. All Rights Reserved.                        */
003/* Open Source Software - may be modified and shared by FRC teams. The code   */
004/* must be accompanied by the FIRST BSD license file in the root directory of */
005/* the project.                                                               */
006/*----------------------------------------------------------------------------*/
007
008package edu.wpi.first.wpilibj;
009
010import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
011import edu.wpi.first.wpilibj.hal.HAL;
012import edu.wpi.first.wpilibj.livewindow.LiveWindow;
013
014/**
015 * Mindsensors SD540 Speed Controller.
016 */
017public class SD540 extends PWMSpeedController {
018
019  /**
020   * Common initialization code called by all constructors.
021   *
022   * <p>Note that the SD540 uses the following bounds for PWM values. These values should work
023   * reasonably well for most controllers, but if users experience issues such as asymmetric
024   * behavior around the deadband or inability to saturate the controller in either direction,
025   * calibration is recommended. The calibration procedure can be found in the SD540 User Manual
026   * available from Mindsensors.
027   *
028   * <p>- 2.05ms = full "forward" - 1.55ms = the "high end" of the deadband range - 1.50ms = center
029   * of the deadband range (off) - 1.44ms = the "low end" of the deadband range - .94ms = full
030   * "reverse"
031   */
032  protected void initSD540() {
033    setBounds(2.05, 1.55, 1.50, 1.44, .94);
034    setPeriodMultiplier(PeriodMultiplier.k1X);
035    setSpeed(0.0);
036    setZeroLatch();
037
038    LiveWindow.addActuator("SD540", getChannel(), this);
039    HAL.report(tResourceType.kResourceType_MindsensorsSD540, getChannel());
040  }
041
042  /**
043   * Constructor.
044   *
045   * @param channel The PWM channel that the SD540 is attached to. 0-9 are on-board, 10-19 are on
046   *                the MXP port
047   */
048  public SD540(final int channel) {
049    super(channel);
050    initSD540();
051  }
052}