blob: e3af5673f4964b3cd53f2572ed5605561d887eb8 [file] [log] [blame]
Parker Schuhd3b7a8872018-02-19 16:42:27 -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 "frc971/wpilib/ahal/Talon.h"
9
Austin Schuhf6b94632019-02-02 22:11:27 -080010#include "hal/HAL.h"
Parker Schuhd3b7a8872018-02-19 16:42:27 -080011
12using namespace frc;
13
14/**
15 * Constructor for a Talon (original or Talon SR).
16 *
17 * @param channel The PWM channel number that the Talon is attached to. 0-9 are
18 * on-board, 10-19 are on the MXP port
19 */
20Talon::Talon(int channel) : PWM(channel) {
21 /* Note that the Talon uses the following bounds for PWM values. These values
22 * should work reasonably well for most controllers, but if users experience
23 * issues such as asymmetric behavior around the deadband or inability to
24 * saturate the controller in either direction, calibration is recommended.
25 * The calibration procedure can be found in the Talon User Manual available
26 * from CTRE.
27 *
28 * 2.037ms = full "forward"
29 * 1.539ms = the "high end" of the deadband range
30 * 1.513ms = center of the deadband range (off)
31 * 1.487ms = the "low end" of the deadband range
32 * 0.989ms = full "reverse"
33 */
34 SetBounds(2.037, 1.539, 1.513, 1.487, .989);
35 SetPeriodMultiplier(kPeriodMultiplier_1X);
36 SetSpeed(0.0);
37 SetZeroLatch();
38
39 HAL_Report(HALUsageReporting::kResourceType_Talon, GetChannel());
40}