jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/
|
| 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 |
|
| 8 | #include "Jaguar.h"
|
| 9 | #include "NetworkCommunication/UsageReporting.h"
|
| 10 | #include "DigitalModule.h"
|
| 11 | #include "LiveWindow/LiveWindow.h"
|
| 12 |
|
| 13 | /**
|
| 14 | * Common initialization code called by all constructors.
|
| 15 | */
|
| 16 | void Jaguar::InitJaguar()
|
| 17 | {
|
| 18 | /*
|
| 19 | * Input profile defined by Luminary Micro.
|
| 20 | *
|
| 21 | * Full reverse ranges from 0.671325ms to 0.6972211ms
|
| 22 | * Proportional reverse ranges from 0.6972211ms to 1.4482078ms
|
| 23 | * Neutral ranges from 1.4482078ms to 1.5517922ms
|
| 24 | * Proportional forward ranges from 1.5517922ms to 2.3027789ms
|
| 25 | * Full forward ranges from 2.3027789ms to 2.328675ms
|
| 26 | * TODO: compute the appropriate values based on digital loop timing
|
| 27 | */
|
| 28 | SetBounds(251, 135, 128, 120, 4);
|
| 29 | SetPeriodMultiplier(kPeriodMultiplier_1X);
|
| 30 | SetRaw(m_centerPwm);
|
| 31 |
|
| 32 | nUsageReporting::report(nUsageReporting::kResourceType_Jaguar, GetChannel(), GetModuleNumber() - 1);
|
| 33 | LiveWindow::GetInstance()->AddActuator("Jaguar", GetModuleNumber(), GetChannel(), this);
|
| 34 | }
|
| 35 |
|
| 36 | /**
|
| 37 | * Constructor that assumes the default digital module.
|
| 38 | *
|
| 39 | * @param channel The PWM channel on the digital module that the Jaguar is attached to.
|
| 40 | */
|
| 41 | Jaguar::Jaguar(UINT32 channel) : SafePWM(channel)
|
| 42 | {
|
| 43 | InitJaguar();
|
| 44 | }
|
| 45 |
|
| 46 | /**
|
| 47 | * Constructor that specifies the digital module.
|
| 48 | *
|
| 49 | * @param moduleNumber The digital module (1 or 2).
|
| 50 | * @param channel The PWM channel on the digital module that the Jaguar is attached to.
|
| 51 | */
|
| 52 | Jaguar::Jaguar(UINT8 moduleNumber, UINT32 channel) : SafePWM(moduleNumber, channel)
|
| 53 | {
|
| 54 | InitJaguar();
|
| 55 | }
|
| 56 |
|
| 57 | Jaguar::~Jaguar()
|
| 58 | {
|
| 59 | }
|
| 60 |
|
| 61 | /**
|
| 62 | * Set the PWM value.
|
| 63 | *
|
| 64 | * The PWM value is set using a range of -1.0 to 1.0, appropriately
|
| 65 | * scaling the value for the FPGA.
|
| 66 | *
|
| 67 | * @param speed The speed value between -1.0 and 1.0 to set.
|
| 68 | * @param syncGroup Unused interface.
|
| 69 | */
|
| 70 | void Jaguar::Set(float speed, UINT8 syncGroup)
|
| 71 | {
|
| 72 | SetSpeed(speed);
|
| 73 | }
|
| 74 |
|
| 75 | /**
|
| 76 | * Get the recently set value of the PWM.
|
| 77 | *
|
| 78 | * @return The most recently set value for the PWM between -1.0 and 1.0.
|
| 79 | */
|
| 80 | float Jaguar::Get()
|
| 81 | {
|
| 82 | return GetSpeed();
|
| 83 | }
|
| 84 |
|
| 85 | /**
|
| 86 | * Common interface for disabling a motor.
|
| 87 | */
|
| 88 | void Jaguar::Disable()
|
| 89 | {
|
| 90 | SetRaw(kPwmDisabled);
|
| 91 | }
|
| 92 |
|
| 93 | /**
|
| 94 | * Write out the PID value as seen in the PIDOutput base object.
|
| 95 | *
|
| 96 | * @param output Write out the PWM value as was found in the PIDController
|
| 97 | */
|
| 98 | void Jaguar::PIDWrite(float output)
|
| 99 | {
|
| 100 | Set(output);
|
| 101 | }
|
| 102 |
|