public class PWM extends SensorBase implements LiveWindowSendable
Modifier and Type | Class and Description |
---|---|
static class |
PWM.PeriodMultiplier
Represents the amount to multiply the minimum servo-pulse pwm period by.
|
Modifier and Type | Field and Description |
---|---|
protected static double |
kDefaultPwmCenter
kDefaultPwmCenter is the PWM range center in ms
|
protected static double |
kDefaultPwmPeriod
kDefaultPwmPeriod is in ms
- 20ms periods (50 Hz) are the "safest" setting in that this works for all devices
- 20ms periods seem to be desirable for Vex Motors
- 20ms periods are the specified period for HS-322HD servos, but work reliably down
to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot;
by 5.0ms the hum is nearly continuous
- 10ms periods work well for Victor 884
- 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers.
|
protected static int |
kDefaultPwmStepsDown
kDefaultPWMStepsDown is the number of PWM steps below the centerpoint
|
static int |
kPwmDisabled |
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPDPChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond
Constructor and Description |
---|
PWM(int channel)
Allocate a PWM given a channel.
|
Modifier and Type | Method and Description |
---|---|
void |
enableDeadbandElimination(boolean eliminateDeadband)
Optionally eliminate the deadband from a speed controller.
|
void |
free()
Free the PWM channel.
|
int |
getChannel()
Gets the channel number associated with the PWM Object.
|
double |
getPosition()
Get the PWM value in terms of a position.
|
int |
getRaw()
Get the PWM value directly from the hardware.
|
String |
getSmartDashboardType() |
double |
getSpeed()
Get the PWM value in terms of speed.
|
edu.wpi.first.wpilibj.tables.ITable |
getTable() |
void |
initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
Initializes a table for this sendable object.
|
protected void |
setBounds(double max,
double deadbandMax,
double center,
double deadbandMin,
double min)
Set the bounds on the PWM pulse widths.
|
void |
setBounds(int max,
int deadbandMax,
int center,
int deadbandMin,
int min)
Deprecated.
Recommended to set bounds in ms using
setBounds(double, double, double, double, double) |
void |
setPeriodMultiplier(PWM.PeriodMultiplier mult)
Slow down the PWM signal for old devices.
|
void |
setPosition(double pos)
Set the PWM value based on a position.
|
void |
setRaw(int value)
Set the PWM value directly to the hardware.
|
protected void |
setZeroLatch() |
void |
startLiveWindowMode()
Start having this sendable object automatically respond to
value changes reflect the value on the table.
|
void |
stopLiveWindowMode()
Stop having this sendable object automatically respond to value
changes.
|
void |
updateTable()
Update the table for this sendable object with the latest
values.
|
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule
protected static final double kDefaultPwmPeriod
protected static final double kDefaultPwmCenter
protected static final int kDefaultPwmStepsDown
public static final int kPwmDisabled
public PWM(int channel)
channel
- The PWM channel.public void free()
free
in class SensorBase
public void enableDeadbandElimination(boolean eliminateDeadband)
eliminateDeadband
- If true, set the motor curve on the Jaguar to eliminate
the deadband in the middle of the range. Otherwise, keep the full range without
modifying any values.public void setBounds(int max, int deadbandMax, int center, int deadbandMin, int min)
setBounds(double, double, double, double, double)
max
- The Minimum pwm valuedeadbandMax
- The high end of the deadband rangecenter
- The center speed (off)deadbandMin
- The low end of the deadband rangemin
- The minimum pwm valueprotected void setBounds(double max, double deadbandMax, double center, double deadbandMin, double min)
max
- The max PWM pulse width in msdeadbandMax
- The high end of the deadband range pulse width in mscenter
- The center (off) pulse width in msdeadbandMin
- The low end of the deadband pulse width in msmin
- The minimum pulse width in mspublic int getChannel()
public void setPosition(double pos)
pos
- The position to set the servo between 0.0 and 1.0.public double getPosition()
public double getSpeed()
public void setRaw(int value)
value
- Raw PWM value. Range 0 - 255.public int getRaw()
public void setPeriodMultiplier(PWM.PeriodMultiplier mult)
mult
- The period multiplier to apply to this channelprotected void setZeroLatch()
public String getSmartDashboardType()
getSmartDashboardType
in interface Sendable
public void initTable(edu.wpi.first.wpilibj.tables.ITable subtable)
public void updateTable()
updateTable
in interface LiveWindowSendable
public edu.wpi.first.wpilibj.tables.ITable getTable()
public void startLiveWindowMode()
startLiveWindowMode
in interface LiveWindowSendable
public void stopLiveWindowMode()
stopLiveWindowMode
in interface LiveWindowSendable
Copyright © 2015. All rights reserved.