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