blob: fe29089cf95da1b831a1e2946c6d8cd5d801cf3b [file] [log] [blame]
Alex Perryc0db44f2020-02-17 19:16:09 -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/TalonFX.h"
9
10#include "hal/HAL.h"
11
12using namespace frc;
13
14/**
15 * Constructor for a TalonFX.
16 *
17 * @param channel The PWM channel that the TalonFX is attached to. 0-9 are
18 * on-board, 10-19 are on the MXP port
19 */
20TalonFX::TalonFX(int channel) : PWM(channel) {
21 /**
22 * Note that the TalonFX uses the following bounds for PWM values. These
23 * values should work reasonably well for most controllers, but if users
24 * experience issues such as asymmetric behavior around the deadband or
25 * inability to saturate the controller in either direction, calibration is
26 * recommended. The calibration procedure can be found in the TalonFX User
27 * Manual available from Vex.
28 *
29 * 2.004ms = full "forward"
30 * 1.52ms = the "high end" of the deadband range
31 * 1.50ms = center of the deadband range (off)
32 * 1.48ms = the "low end" of the deadband range
33 * 0.997ms = full "reverse"
34 */
35 SetBounds(2.004, 1.52, 1.50, 1.48, .997);
Austin Schuh028d81d2022-03-26 15:11:42 -070036 SetPeriodMultiplier(kPeriodMultiplier_2X);
Alex Perryc0db44f2020-02-17 19:16:09 -080037 SetSpeed(0.0);
38 SetZeroLatch();
39
40 HAL_Report(HALUsageReporting::kResourceType_VictorSP, GetChannel());
41}
42