blob: 0e9505dbf4a7085f41af5af5059e2aff0273aaf0 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6
7#include "Talon.h"
8
9//#include "NetworkCommunication/UsageReporting.h"
10#include "LiveWindow/LiveWindow.h"
11
12/**
13 * @param channel The PWM channel that the Talon is attached to.
14 */
15Talon::Talon(uint32_t channel) : SafePWM(channel)
16{
17 /* Note that the Talon uses the following bounds for PWM values. These values
18 * should work reasonably well for most controllers, but if users experience
19 * issues such as asymmetric behavior around the deadband or inability to
20 * saturate the controller in either direction, calibration is recommended.
21 * The calibration procedure can be found in the Talon User Manual available
22 * from CTRE.
23 *
24 * - 211 = full "forward"
25 * - 133 = the "high end" of the deadband range
26 * - 129 = center of the deadband range (off)
27 * - 125 = the "low end" of the deadband range
28 * - 49 = full "reverse"
29 */
30 SetBounds(2.037, 1.539, 1.513, 1.487, .989);
31 SetPeriodMultiplier(kPeriodMultiplier_2X);
32 SetRaw(m_centerPwm);
33
34 LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
35}
36
37/**
38 * Set the PWM value.
39 *
40 * The PWM value is set using a range of -1.0 to 1.0, appropriately
41 * scaling the value for the FPGA.
42 *
43 * @param speed The speed value between -1.0 and 1.0 to set.
44 * @param syncGroup Unused interface.
45 */
46void Talon::Set(float speed, uint8_t syncGroup)
47{
48 SetSpeed(speed);
49}
50
51/**
52 * Get the recently set value of the PWM.
53 *
54 * @return The most recently set value for the PWM between -1.0 and 1.0.
55 */
56float Talon::Get() const
57{
58 return GetSpeed();
59}
60
61/**
62 * Common interface for disabling a motor.
63 */
64void Talon::Disable()
65{
66 SetRaw(kPwmDisabled);
67}
68
69/**
70 * Write out the PID value as seen in the PIDOutput base object.
71 *
72 * @param output Write out the PWM value as was found in the PIDController
73 */
74void Talon::PIDWrite(float output)
75{
76 Set(output);
77}