Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 2 | /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */ |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 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 "frc/SD540.h" |
| 9 | |
| 10 | #include <hal/HAL.h> |
| 11 | |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 12 | #include "frc/smartdashboard/SendableRegistry.h" |
| 13 | |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 14 | using namespace frc; |
| 15 | |
| 16 | SD540::SD540(int channel) : PWMSpeedController(channel) { |
| 17 | /* Note that the SD540 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 SD540 User Manual available |
| 22 | * from Mindsensors. |
| 23 | * |
| 24 | * 2.05ms = full "forward" |
| 25 | * 1.55ms = the "high end" of the deadband range |
| 26 | * 1.50ms = center of the deadband range (off) |
| 27 | * 1.44ms = the "low end" of the deadband range |
| 28 | * 0.94ms = full "reverse" |
| 29 | */ |
| 30 | SetBounds(2.05, 1.55, 1.50, 1.44, .94); |
| 31 | SetPeriodMultiplier(kPeriodMultiplier_1X); |
| 32 | SetSpeed(0.0); |
| 33 | SetZeroLatch(); |
| 34 | |
| 35 | HAL_Report(HALUsageReporting::kResourceType_MindsensorsSD540, GetChannel()); |
James Kuszmaul | 4f3ad3c | 2019-12-01 16:35:21 -0800 | [diff] [blame^] | 36 | SendableRegistry::GetInstance().SetName(this, "SD540", GetChannel()); |
Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 37 | } |