public class PWM extends Interface implements Module, LiveWindowSendable, NumberSink
| Modifier and Type | Class and Description |
|---|---|
static class |
PWM.PeriodMultiplier
The PeriodMultiplier enumeration
|
static class |
PWM.PWMChannel
The PWM Channel enum.
|
Interface.InterfaceType| Modifier and Type | Field and Description |
|---|---|
private int |
m_boundsCenter
The center of the bounds between positive and negative.
|
private int |
m_boundsNegativeMax
The high end of the negative bounds.
|
private int |
m_boundsNegativeMaxDeadband
The negative high end value used to eliminate deadband.
|
private int |
m_boundsNegativeMin
The low end of the negative bounds.
|
private int |
m_boundsPositiveMax
The high end of the positive bounds.
|
private int |
m_boundsPositiveMin
The low end of the positive bounds.
|
private int |
m_boundsPositiveMinDeadband
The positive low end value used to eliminate deadband.
|
private PWM.PWMChannel |
m_channel
The PWM Channel this PWM is operating on.
|
protected java.lang.String |
m_description |
protected boolean |
m_disabled
The disabled status.
|
private boolean |
m_eliminateDeadband
Should we be destroying the deadband? Only used by setBounds()
|
private java.nio.ByteBuffer |
m_port
The The RoboRIO port identifier.
|
private int |
m_scaleFactorFull
The full range bounds scaling factor.
|
private int |
m_scaleFactorNegative
The negative bounds scaling factor.
|
private int |
m_scaleFactorPositive
The positive bounds scaling factor
|
protected ITable |
m_table |
protected ITableListener |
m_table_listener |
protected static double |
PWM_DEFAULT_CENTER
The default PWM center pulse width in ms.
|
protected static double |
PWM_DEFAULT_PERIOD
The default PWM Period.
|
protected static int |
PWM_DEFAULT_STEPS_DOWN
The default steps down for a PWM?
|
static int |
PWM_DISABLED_WIDTH
The default disable value for a PWM.
|
static int |
SYSTEM_CLOCK_TICKS_PER_MICROSEC |
private static boolean[] |
USED_CHANNELS
Keep track of already used channels.
|
m_ifaceType, MAX_ANALOG_IN_CHANNELS, MAX_ANALOG_OUT_CHANNELS, MAX_DIGITAL_CHANNELS, MAX_PWM_CHANNELS, MAX_RELAY_CHANNELS| Constructor and Description |
|---|
PWM(PWM.PWMChannel channel) |
PWM(PWM.PWMChannel channel,
java.lang.String desc)
Instantiates a new pwm.
|
PWM(PWM.PWMChannel channel,
java.lang.String desc,
double boundsPosMax,
double boundsPosMin,
double boundsCenter,
double boundsNegMax,
double boundsNegMin,
PWM.PeriodMultiplier multi) |
| Modifier and Type | Method and Description |
|---|---|
private void |
allocateChannel(PWM.PWMChannel channel)
Allocate a PWM channel.
|
void |
disableModule()
Disable the module
|
void |
eliminateDeadband(boolean eliminateDeadband)
Enable Deadband Elimination.
|
void |
enableModule()
Enable the module
|
void |
free()
Free the PWM channel.
|
private boolean |
freeChannel(PWM.PWMChannel channel)
Free a PWM channel.
|
double |
get()
Gets the speed.
|
int |
getCenterPWM()
Get the center PWM value.
|
PWM.PWMChannel |
getChannel()
The channel this PWM is operating on.
|
java.lang.String |
getChannelName()
The channel this PWM is operating on, in string form.
|
int |
getChannelNumber()
The channel this PWM is operating on, in integer form.
|
boolean |
getModuleEnabled() |
double |
getPosition()
Gets the position.
|
int |
getRaw()
Get the PWM value directly from the hardware.
|
java.lang.String |
getSmartDashboardType() |
double |
getSpeed()
Gets the speed.
|
ITable |
getTable() |
void |
initTable(ITable subtable) |
void |
set(double value)
Sets the speed.
|
void |
setBounds(double max,
double deadMax,
double center,
double deadMin,
double min)
Set the bounds on pulse widths for this PWM.
|
void |
setPeriodMultiplier(PWM.PeriodMultiplier multi)
Set the period multiplier for older/newer devices.
|
void |
setPosition(double angle)
Set the position of the servo.
|
protected void |
setRaw(int value)
Set the PWM value directly to the hardware.
|
void |
setSpeed(double speed)
Sets the speed.
|
protected void |
setZeroLatch()
Sets the zero latch.
|
void |
startLiveWindowMode() |
void |
stopLiveWindowMode() |
void |
updateTable() |
allocateMXPPin, checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPWMChannel, checkRelayChannel, freeMXPPin, getInterfaceTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbindValue, bindValueprotected static final double PWM_DEFAULT_PERIOD
protected static final double PWM_DEFAULT_CENTER
protected static final int PWM_DEFAULT_STEPS_DOWN
public static final int PWM_DISABLED_WIDTH
public static final int SYSTEM_CLOCK_TICKS_PER_MICROSEC
private static final boolean[] USED_CHANNELS
private boolean m_eliminateDeadband
private int m_scaleFactorPositive
private int m_boundsPositiveMax
private int m_boundsPositiveMinDeadband
private int m_boundsPositiveMin
private int m_boundsCenter
private int m_boundsNegativeMax
private int m_boundsNegativeMaxDeadband
private int m_boundsNegativeMin
private int m_scaleFactorNegative
private int m_scaleFactorFull
protected boolean m_disabled
protected final java.lang.String m_description
private final java.nio.ByteBuffer m_port
private PWM.PWMChannel m_channel
protected ITable m_table
protected ITableListener m_table_listener
public PWM(PWM.PWMChannel channel)
channel - the channel for this pwmpublic PWM(PWM.PWMChannel channel, java.lang.String desc)
channel - the channel for this pwmdesc - public PWM(PWM.PWMChannel channel, java.lang.String desc, double boundsPosMax, double boundsPosMin, double boundsCenter, double boundsNegMax, double boundsNegMin, PWM.PeriodMultiplier multi)
public void free()
private final void allocateChannel(PWM.PWMChannel channel)
channel - the PWM channel to allocateprivate final boolean freeChannel(PWM.PWMChannel channel)
channel - the PWM channel to freepublic final PWM.PWMChannel getChannel()
PWM.PWMChannel representation of the PWM channelpublic final int getChannelNumber()
public final java.lang.String getChannelName()
public final void setBounds(double max,
double deadMax,
double center,
double deadMin,
double min)
max - The maximum PWM pulse in msdeadMax - The maximum of the pulse deadband in mscenter - The center/zero/off pulse width in msdeadMin - the mimium of the pulse deadband in msmin - The minimum PWM pulse in mspublic final void eliminateDeadband(boolean eliminateDeadband)
eliminateDeadband - Yes or Nopublic void setPosition(double angle)
angle - the servo positionpublic double getPosition()
public void setSpeed(double speed)
speed - the new speedpublic double getSpeed()
protected final void setRaw(int value)
value - Raw PWM value. Range 0 - 255.public final int getRaw()
public void set(double value)
set in interface NumberSinkspeed - the new speedpublic double get()
public final int getCenterPWM()
public final void setPeriodMultiplier(PWM.PeriodMultiplier multi)
multi - The PeriodMultiplier enumprotected final void setZeroLatch()
public final void initTable(ITable subtable)
public final java.lang.String getSmartDashboardType()
getSmartDashboardType in interface Sendablepublic final void updateTable()
updateTable in interface UpdatingSendablepublic final void startLiveWindowMode()
startLiveWindowMode in interface LiveWindowSendablepublic final void stopLiveWindowMode()
stopLiveWindowMode in interface LiveWindowSendablepublic void enableModule()
enableModule in interface Modulepublic void disableModule()
disableModule in interface Modulepublic boolean getModuleEnabled()
getModuleEnabled in interface Module