|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.wpi.first.wpilibj.SensorBase
edu.wpi.first.wpilibj.AnalogChannel
public class AnalogChannel
Analog channel class. Each analog channel is read from hardware as a 12-bit number representing -10V to 10V. Connected to each analog channel is an averaging and oversampling engine. This engine accumulates the specified ( by setAverageBits() and setOversampleBits() ) number of samples before returning a new value. This is not a sliding window average. The only difference between the oversampled samples and the averaged samples is that the oversampled samples are simply accumulated effectively increasing the resolution, while the averaged samples are divided by the number of samples to retain the resolution, but get more stable values.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface edu.wpi.first.wpilibj.PIDSource |
---|
PIDSource.PIDSourceParameter |
Field Summary |
---|
Fields inherited from class edu.wpi.first.wpilibj.SensorBase |
---|
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond |
Constructor Summary | |
---|---|
AnalogChannel(int channel)
Construct an analog channel on the default module. |
|
AnalogChannel(int moduleNumber,
int channel)
Construct an analog channel on a specified module. |
Method Summary | |
---|---|
void |
free()
Channel destructor. |
long |
getAccumulatorCount()
Read the number of accumulated values. |
void |
getAccumulatorOutput(AccumulatorResult result)
Read the accumulated value and the number of accumulated values atomically. |
long |
getAccumulatorValue()
Read the accumulated value. |
int |
getAverageBits()
Get the number of averaging bits. |
int |
getAverageValue()
Get a sample from the output of the oversample and average engine for this channel. |
double |
getAverageVoltage()
Get a scaled sample from the output of the oversample and average engine for this channel. |
int |
getChannel()
Get the channel number. |
long |
getLSBWeight()
Get the factory scaling least significant bit weight constant. |
AnalogModule |
getModule()
Get the analog module that this channel is on. |
int |
getModuleNumber()
Gets the number of the analog module this channel is on. |
int |
getOffset()
Get the factory scaling offset constant. |
int |
getOversampleBits()
Get the number of oversample bits. |
java.lang.String |
getSmartDashboardType()
|
ITable |
getTable()
|
int |
getValue()
Get a sample straight from this channel on the module. |
double |
getVoltage()
Get a scaled sample straight from this channel on the module. |
void |
initAccumulator()
Initialize the accumulator. |
void |
initTable(ITable subtable)
Initializes a table for this sendable object. |
boolean |
isAccumulatorChannel()
Is the channel attached to an accumulator. |
double |
pidGet()
Get the average value for use with PIDController. |
void |
resetAccumulator()
Resets the accumulator to the initial value. |
void |
setAccumulatorCenter(int center)
Set the center value of the accumulator. |
void |
setAccumulatorDeadband(int deadband)
Set the accumulator's deadband. |
void |
setAccumulatorInitialValue(long initialValue)
Set an inital value for the accumulator. |
void |
setAverageBits(int bits)
Set the number of averaging bits. |
void |
setOversampleBits(int bits)
Set the number of oversample bits. |
void |
setVoltageForPID(boolean shouldUseVoltageForPID)
Set whether to use voltage of value for PIDGet This method determines whether PIDGet uses average voltage or value for PID controllers for a particular channel. |
void |
startLiveWindowMode()
Analog Channels don't have to do anything special when entering the LiveWindow. |
void |
stopLiveWindowMode()
Analog Channels don't have to do anything special when exiting the LiveWindow. |
void |
updateTable()
Update the table for this sendable object with the latest values. |
Methods inherited from class edu.wpi.first.wpilibj.SensorBase |
---|
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnalogChannel(int channel)
channel
- The channel number to represent.public AnalogChannel(int moduleNumber, int channel)
moduleNumber
- The digital module to use (1 or 2).channel
- The channel number to represent.Method Detail |
---|
public void free()
free
in class SensorBase
public AnalogModule getModule()
public int getValue()
public int getAverageValue()
public double getVoltage()
public double getAverageVoltage()
public long getLSBWeight()
public int getOffset()
public int getChannel()
public int getModuleNumber()
public void setAverageBits(int bits)
bits
- The number of averaging bits.public int getAverageBits()
public void setOversampleBits(int bits)
bits
- The number of oversample bits.public int getOversampleBits()
public void initAccumulator()
public void setAccumulatorInitialValue(long initialValue)
initialValue
- The value that the accumulator should start from when reset.public void resetAccumulator()
public void setAccumulatorCenter(int center)
public void setAccumulatorDeadband(int deadband)
public long getAccumulatorValue()
public long getAccumulatorCount()
public void getAccumulatorOutput(AccumulatorResult result)
result
- AccumulatorResult object to store the results in.public boolean isAccumulatorChannel()
public void setVoltageForPID(boolean shouldUseVoltageForPID)
m_shouldUseVoltageForPID
- True if voltage should be used for PIDGet. The
default is to use the value as it has been since the creation of the library.public double pidGet()
pidGet
in interface PIDSource
public java.lang.String getSmartDashboardType()
getSmartDashboardType
in interface Sendable
public void initTable(ITable subtable)
initTable
in interface Sendable
subtable
- The table to put the values in.public void updateTable()
updateTable
in interface LiveWindowSendable
public ITable getTable()
getTable
in interface Sendable
public void startLiveWindowMode()
startLiveWindowMode
in interface LiveWindowSendable
public void stopLiveWindowMode()
stopLiveWindowMode
in interface LiveWindowSendable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |