|
2010 FRC Java API |
|||||||||
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 befor 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.
Field Summary |
---|
Fields inherited from class edu.wpi.first.wpilibj.SensorBase |
---|
kAnalogChannels, kAnalogModules, kChassisSlots, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond |
Constructor Summary | |
---|---|
AnalogChannel(int channel)
Construct an analog channel on the default module. |
|
AnalogChannel(int slot,
int channel)
Construct an analog channel on a specified module. |
Method Summary | |
---|---|
protected 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 |
getOffset()
Get the factory scaling offset constant. |
int |
getOversampleBits()
Get the number of oversample bits. |
int |
getSlot()
Get the slot that the analog module is plugged into. |
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. |
boolean |
isAccumulatorChannel()
Is the channel attached to an accumulator. |
double |
pidGet()
Get the average value for usee 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. |
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnalogChannel(int channel)
channel
- The channel number to represent.public AnalogChannel(int slot, int channel)
slot
- The slot that the analog module is plugged into.channel
- The channel number to represent.Method Detail |
---|
protected 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 getSlot()
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 double pidGet()
pidGet
in interface PIDSource
|
2010 FRC Java API |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |