blob: 502ff31574e2181f31585ae3da73af76413cf94a [file] [log] [blame]
Lee Mracekac5ab712019-02-06 04:56:30 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2008-2018 FIRST. 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/Spark.h"
9
Austin Schuhf6b94632019-02-02 22:11:27 -080010#include <hal/HAL.h>
Lee Mracekac5ab712019-02-06 04:56:30 -050011
12using namespace frc;
13
14Spark::Spark(int channel) : PWM(channel) {
15 /* Note that the Spark uses the following bounds for PWM values. These values
16 * should work reasonably well for most controllers, but if users experience
17 * issues such as asymmetric behavior around the deadband or inability to
18 * saturate the controller in either direction, calibration is recommended.
19 * The calibration procedure can be found in the Spark User Manual available
20 * from REV Robotics.
21 *
22 * 2.003ms = full "forward"
23 * 1.55ms = the "high end" of the deadband range
24 * 1.50ms = center of the deadband range (off)
25 * 1.46ms = the "low end" of the deadband range
26 * 0.999ms = full "reverse"
27 */
28 SetBounds(2.003, 1.55, 1.50, 1.46, .999);
Austin Schuh028d81d2022-03-26 15:11:42 -070029 SetPeriodMultiplier(kPeriodMultiplier_2X);
Lee Mracekac5ab712019-02-06 04:56:30 -050030 SetSpeed(0.0);
31 SetZeroLatch();
32
33 HAL_Report(HALUsageReporting::kResourceType_RevSPARK, GetChannel());
34}