public class Counter extends CounterBase implements SensorModule, PIDSource
| Modifier and Type | Class and Description |
|---|---|
static class |
Counter.CounterMode
Modes for the counter to count in?
|
static class |
Counter.SourceType
The two different source types.
|
CounterBase.EncodingTypePIDSource.PIDSourceType| Modifier and Type | Field and Description |
|---|---|
private boolean |
m_allocatedDownSource |
private boolean |
m_allocatedUpSource |
private java.nio.ByteBuffer |
m_counter |
private double |
m_distancePerPulse |
private DigitalIO |
m_downSource |
private int |
m_index |
private PIDSource.PIDSourceType |
m_pidSType |
private DigitalIO |
m_upSource |
| Constructor and Description |
|---|
Counter()
Create an instance of a counter where no sources are selected.
|
Counter(CounterBase.EncodingType eType,
DigitalIO.DigitalChannel upChannel,
DigitalIO.DigitalChannel downChannel,
boolean inverted) |
Counter(CounterBase.EncodingType eType,
DigitalIO upSource,
DigitalIO downSource,
boolean inverted)
Create an instance of a Counter object.
|
Counter(DigitalIO.DigitalChannel upChannel)
Create an instance of a Counter object.
|
Counter(DigitalIO upSource)
Create an instance of a counter from a Digital Input.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearSource(Counter.SourceType sType)
Disable the counting source to the counter.
|
void |
disableModule()
Disable the module
|
void |
enableModule()
Enable the module
|
void |
free() |
int |
getCount()
Read the current counter value.
|
boolean |
getDirection()
The last direction the counter value changed.
|
double |
getDistance()
Read the current scaled counter value.
|
boolean |
getModuleEnabled() |
double |
getPeriod()
Get the Period of the most recent count.
|
double |
getRate()
Get the current rate of the Counter.
|
int |
getSamplesPerAverage()
Get the Samples to Average which specifies the number of samples of the
timer to average when calculating the period.
|
boolean |
getStopped()
Determine if the clock is stopped.
|
double |
pidGet() |
void |
reset()
Reset the Counter to zero.
|
void |
setDistancePerPulse(double distance)
Set the distance per pulse for this counter.
|
void |
setExternalDirectionMode()
Set external direction mode on this counter.
|
void |
setMaxPeriod(double maxPeriod)
Set the maximum period where the device is still considered "moving".
|
private void |
setMode(Counter.CounterMode mode,
java.lang.Object... args) |
void |
setPIDSourceType(PIDSource.PIDSourceType sType)
Set which parameter of the encoder you are using as a process control
variable.
|
void |
setPulseLengthMode(double threshold)
Configure the counter to count in up or down based on the length of the
input pulse.
|
void |
setReverseDirection(boolean reverse)
Set the Counter to return reversed sensing on the direction.
|
void |
setSamplesPerAverage(int samples)
Set the Samples to Average which specifies the number of samples of the
timer to average when calculating the period.
|
void |
setSemiPeriodMode(boolean highSemiPeriod)
Set Semi-period mode on this counter.
|
void |
setSource(Counter.SourceType sType,
DigitalIO.DigitalChannel channel)
Set the Up or Down source for the counter as a digital input channel.
|
void |
setSource(Counter.SourceType sType,
DigitalIO source)
Set the source object that causes the counter to count up or down.
|
void |
setSourceEdge(Counter.SourceType sType,
boolean risingEdge,
boolean fallingEdge)
Set the edge sensitivity on a counting source.
|
void |
setUpdateWhenEmpty(boolean enabled)
Select whether you want to continue updating the event timer output when
there are no samples captured.
|
void |
setUpDownCounterMode()
Set standard up / down counting mode on this counter.
|
get, getFPGAIndexprivate DigitalIO m_upSource
private DigitalIO m_downSource
private boolean m_allocatedUpSource
private boolean m_allocatedDownSource
private java.nio.ByteBuffer m_counter
private int m_index
private PIDSource.PIDSourceType m_pidSType
private double m_distancePerPulse
public Counter()
public Counter(DigitalIO.DigitalChannel upChannel)
upChannel - the DIO channel to use as the up source.public Counter(DigitalIO upSource)
upSource - the digital source to countpublic Counter(CounterBase.EncodingType eType, DigitalIO.DigitalChannel upChannel, DigitalIO.DigitalChannel downChannel, boolean inverted)
public Counter(CounterBase.EncodingType eType, DigitalIO upSource, DigitalIO downSource, boolean inverted)
eType - which edges to countupSource - first source to countdownSource - second source for directioninverted - true to invert the countpublic void free()
public void setSource(Counter.SourceType sType, DigitalIO.DigitalChannel channel)
sType - the Source type Up or Down.channel - the DIO channel to countpublic void setSource(Counter.SourceType sType, DigitalIO source)
sType - the Source type Up or Down.source - the digital source to countpublic void setSourceEdge(Counter.SourceType sType, boolean risingEdge, boolean fallingEdge)
sType - the Source type Up or Down.risingEdge - true to count the rising edgefallingEdge - true to count the falling edgepublic void clearSource(Counter.SourceType sType)
sType - the Source type Up or Down.private void setMode(Counter.CounterMode mode, java.lang.Object... args)
public void setUpDownCounterMode()
public void setSemiPeriodMode(boolean highSemiPeriod)
highSemiPeriod - true to count up on both rising and fallingpublic void setPulseLengthMode(double threshold)
threshold - The pulse length beyond which the counter counts the
opposite direction. Units are seconds.public void setExternalDirectionMode()
public int getCount()
getCount in interface CounterSourcegetCount in class CounterBasepublic double getDistance()
public void reset()
reset in interface CounterSourcereset in class CounterBasepublic void setMaxPeriod(double maxPeriod)
setMaxPeriod in class CounterBasemaxPeriod - The maximum period where the counted device is considered
moving in seconds.public void setUpdateWhenEmpty(boolean enabled)
enabled - true to continue updatingpublic boolean getStopped()
getStopped in class CounterBasepublic boolean getDirection()
getDirection in class CounterBasepublic void setReverseDirection(boolean reverse)
reverse - true if the value counted should be negated.public double getPeriod()
getPeriod in class CounterBasepublic double getRate()
public void setSamplesPerAverage(int samples)
samples - The number of samples to average from 1 to 127.public int getSamplesPerAverage()
public void setDistancePerPulse(double distance)
distance - The scale factor that will be used to convert pulses to
useful units.public void setPIDSourceType(PIDSource.PIDSourceType sType)
sType - An enum to select the parameter.public void enableModule()
enableModule in interface Modulepublic void disableModule()
disableModule in interface Modulepublic boolean getModuleEnabled()
getModuleEnabled in interface Module