blob: d06f091fc697a860dc7f5f1bacf71f9b8e84284d [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 "Victor.h"
9
10#include "HAL/HAL.h"
11#include "LiveWindow/LiveWindow.h"
12
13using namespace frc;
14
15/**
16 * Constructor for a Victor.
17 *
18 * @param channel The PWM channel number that the Victor is attached to. 0-9
19 * are on-board, 10-19 are on the MXP port
20 */
21Victor::Victor(int channel) : PWMSpeedController(channel) {
22 /* Note that the Victor uses the following bounds for PWM values. These
23 * values were determined empirically and optimized for the Victor 888. These
24 * values should work reasonably well for Victor 884 controllers as well but
25 * if users experience issues such as asymmetric behaviour around the deadband
26 * or inability to saturate the controller in either direction, calibration is
27 * recommended. The calibration procedure can be found in the Victor 884 User
28 * Manual available from IFI.
29 *
30 * 2.027ms = full "forward"
31 * 1.525ms = the "high end" of the deadband range
32 * 1.507ms = center of the deadband range (off)
33 * 1.49ms = the "low end" of the deadband range
34 * 1.026ms = full "reverse"
35 */
36 SetBounds(2.027, 1.525, 1.507, 1.49, 1.026);
37 SetPeriodMultiplier(kPeriodMultiplier_2X);
38 SetSpeed(0.0);
39 SetZeroLatch();
40
41 LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
42 HAL_Report(HALUsageReporting::kResourceType_Victor, GetChannel());
43}