Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 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 "Spark.h" |
| 9 | |
| 10 | #include "HAL/HAL.h" |
| 11 | #include "LiveWindow/LiveWindow.h" |
| 12 | |
| 13 | using namespace frc; |
| 14 | |
| 15 | /** |
| 16 | * Note that the Spark uses the following bounds for PWM values. These values |
| 17 | * should work reasonably well for most controllers, but if users experience |
| 18 | * issues such as asymmetric behavior around the deadband or inability to |
| 19 | * saturate the controller in either direction, calibration is recommended. |
| 20 | * The calibration procedure can be found in the Spark User Manual available |
| 21 | * from REV Robotics. |
| 22 | * |
| 23 | * 2.003ms = full "forward" |
| 24 | * 1.55ms = the "high end" of the deadband range |
| 25 | * 1.50ms = center of the deadband range (off) |
| 26 | * 1.46ms = the "low end" of the deadband range |
| 27 | * 0.999ms = full "reverse" |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * Constructor for a Spark. |
| 32 | * |
| 33 | * @param channel The PWM channel that the Spark is attached to. 0-9 are |
| 34 | * on-board, 10-19 are on the MXP port |
| 35 | */ |
| 36 | Spark::Spark(int channel) : PWMSpeedController(channel) { |
| 37 | SetBounds(2.003, 1.55, 1.50, 1.46, .999); |
| 38 | SetPeriodMultiplier(kPeriodMultiplier_1X); |
| 39 | SetSpeed(0.0); |
| 40 | SetZeroLatch(); |
| 41 | |
| 42 | HAL_Report(HALUsageReporting::kResourceType_RevSPARK, GetChannel()); |
| 43 | LiveWindow::GetInstance()->AddActuator("Spark", GetChannel(), this); |
| 44 | } |