blob: 58bc10960d021dde3b3578a785db138ac1ccfa7c [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-2017. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "Talon.h"
9
10#include "HAL/HAL.h"
11#include "LiveWindow/LiveWindow.h"
12
13using namespace frc;
14
15/**
16 * Constructor for a Talon (original or Talon SR).
17 *
18 * @param channel The PWM channel number that the Talon is attached to. 0-9 are
19 * on-board, 10-19 are on the MXP port
20 */
21Talon::Talon(int channel) : PWMSpeedController(channel) {
22 /* Note that the Talon uses the following bounds for PWM values. These values
23 * should work reasonably well for most controllers, but if users experience
24 * issues such as asymmetric behavior around the deadband or inability to
25 * saturate the controller in either direction, calibration is recommended.
26 * The calibration procedure can be found in the Talon User Manual available
27 * from CTRE.
28 *
29 * 2.037ms = full "forward"
30 * 1.539ms = the "high end" of the deadband range
31 * 1.513ms = center of the deadband range (off)
32 * 1.487ms = the "low end" of the deadband range
33 * 0.989ms = full "reverse"
34 */
35 SetBounds(2.037, 1.539, 1.513, 1.487, .989);
36 SetPeriodMultiplier(kPeriodMultiplier_1X);
37 SetSpeed(0.0);
38 SetZeroLatch();
39
40 HAL_Report(HALUsageReporting::kResourceType_Talon, GetChannel());
41 LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
42}