Counter Class Reference

#include <Counter.h>

Inheritance diagram for Counter:

Inheritance graph
[legend]
Collaboration diagram for Counter:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Counter (void)
 Counter (unsigned channel)
 Counter (unsigned slot, unsigned channel)
 Counter (DigitalSource *source)
 Counter (AnalogTrigger *trigger)
virtual ~Counter (void)
void SetUpSource (unsigned channel)
void SetUpSource (unsigned slot, unsigned channel)
void SetUpSource (AnalogTrigger *analogTrigger, AnalogTriggerOutput::Type triggerType)
void SetUpSource (DigitalSource *source)
void SetUpSourceEdge (bool risingEdge, bool fallingEdge)
void ClearUpSource (void)
void SetDownSource (unsigned channel)
void SetDownSource (unsigned slot, unsigned channel)
void SetDownSource (AnalogTrigger *analogTrigger, AnalogTriggerOutput::Type triggerType)
void SetDownSource (DigitalSource *source)
void SetDownSourceEdge (bool risingEdge, bool fallingEdge)
void ClearDownSource (void)
void SetUpDownCounterMode (void)
void SetExternalDirectionMode (void)
void SetSemiPeriodMode (bool highRisingPeriod)
void SetPulseLengthMode (unsigned threshold)
void Start (void)
signed int Get (void)
void Reset (void)
void Stop (void)
void SetMaxPeriod (unsigned long maxPeriod)
bool GetStopped (void)
bool GetDirection (void)


Detailed Description

Class for counting the number of ticks on a digital input channel. This is a general purpose class for counting repetitive events. It can return the number of counts, the period of the most recent cycle, and detect when the signal being counted has stopped by supplying a maximum cycle time.

Constructor & Destructor Documentation

Counter::Counter ( void   ) 

Create an instance of a counter where no sources are selected. Then they all must be selected by calling functions to specify the upsource and the downsource independently.

Counter::Counter ( unsigned  channel  ) 

Create an instance of a Counter object. Create an up-Counter instance given a channel. The default digital module is assumed.

Counter::Counter ( unsigned  slot,
unsigned  channel 
)

Create an instance of a Counter object. Create an instance of an up-Counter given a digital module and a channel.

Parameters:
slot The cRIO chassis slot for the digital module used
channel The channel in the digital module

Counter::Counter ( DigitalSource source  ) 

Create an instance of a counter from a Digital Input. This is used if an existing digital input is to be shared by multiple other objects such as encoders.

Counter::Counter ( AnalogTrigger *  trigger  ) 

Create an instance of a Counter object. Create an instance of a simple up-Counter given an analog trigger. Use the trigger state output from the analog trigger.

Counter::~Counter ( void   )  [virtual]

Delete the Counter object.


Member Function Documentation

void Counter::SetUpSource ( unsigned  channel  ) 

Set the upsource for the counter as a digital input channel. The slot will be the default digital module slot.

void Counter::SetUpSource ( unsigned  slot,
unsigned  channel 
)

Set the up source for the counter as digital input channel and slot.

void Counter::SetUpSource ( AnalogTrigger *  analogTrigger,
AnalogTriggerOutput::Type  triggerType 
)

Set the up counting source to be an analog trigger.

Parameters:
analogTrigger The analog trigger object that is used for the Up Source
triggerType The analog trigger output that will trigger the counter.

void Counter::SetUpSource ( DigitalSource source  ) 

Set the source object that causes the counter to count up. Set the up counting DigitalSource.

void Counter::SetUpSourceEdge ( bool  risingEdge,
bool  fallingEdge 
)

Set the edge sensitivity on an up counting source. Set the up source to either detect rising edges or falling edges.

void Counter::ClearUpSource ( void   ) 

Disable the up counting source to the counter.

void Counter::SetDownSource ( unsigned  channel  ) 

Set the down counting source to be a digital input channel. The slot will be set to the default digital module slot.

void Counter::SetDownSource ( unsigned  slot,
unsigned  channel 
)

Set the down counting source to be a digital input slot and channel.

void Counter::SetDownSource ( AnalogTrigger *  analogTrigger,
AnalogTriggerOutput::Type  triggerType 
)

Set the down counting source to be an analog trigger.

Parameters:
analogTrigger The analog trigger object that is used for the Down Source
triggerType The analog trigger output that will trigger the counter.

void Counter::SetDownSource ( DigitalSource source  ) 

Set the source object that causes the counter to count down. Set the down counting DigitalSource.

void Counter::SetDownSourceEdge ( bool  risingEdge,
bool  fallingEdge 
)

Set the edge sensitivity on a down counting source. Set the down source to either detect rising edges or falling edges.

void Counter::ClearDownSource ( void   ) 

Disable the down counting source to the counter.

void Counter::SetUpDownCounterMode ( void   ) 

Set standard up / down counting mode on this counter. Up and down counts are sourced independently from two inputs.

void Counter::SetExternalDirectionMode ( void   ) 

Set external direction mode on this counter. Counts are sourced on the Up counter input. The Down counter input represents the direction to count.

void Counter::SetSemiPeriodMode ( bool  highSemiPeriod  ) 

Set Semi-period mode on this counter. Counts up on both rising and falling edges.

void Counter::SetPulseLengthMode ( unsigned  threshold  ) 

Configure the counter to count in up or down based on the length of the input pulse. This mode is most useful for direction sensitive gear tooth sensors.

Parameters:
threshold The pulse length beyond which the counter counts the opposite direction. Units are microseconds.

void Counter::Start ( void   )  [virtual]

Start the Counter counting. This enables the counter and it starts accumulating counts from the associated input channel. The counter value is not reset on starting, and still has the previous value.

Implements CounterBase.

signed int Counter::Get ( void   )  [virtual]

Read the current counter value. Read the value at this instant. It may still be running, so it reflects the current value. Next time it is read, it might have a different value.

Implements CounterBase.

void Counter::Reset ( void   )  [virtual]

Reset the Counter to zero. Set the counter value to zero. This doesn't effect the running state of the counter, just sets the current value to zero.

Implements CounterBase.

void Counter::Stop ( void   )  [virtual]

Stop the Counter. Stops the counting but doesn't effect the current value.

Implements CounterBase.

void Counter::SetMaxPeriod ( unsigned long  maxPeriod  )  [virtual]

Set the maximum period where the device is still considered "moving" Sets the maximum period where the device is considered moving. This value is used to determine the "stopped" state of the counter using the GetStopped method.

Parameters:
maxPeriod The maximum period where the counted device is considered moving in microseconds.

Implements CounterBase.

bool Counter::GetStopped ( void   )  [virtual]

Determine if the clock is stopped. Determine if the clocked input is stopped based on the MaxPeriod value set using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the device (and counter) are assumed to be stopped and it returns true.

Returns:
Returns true if the most recent counter period exceeds the MaxPeriod value set by SetMaxPeriod.

Implements CounterBase.

bool Counter::GetDirection ( void   )  [virtual]

The last direction the counter value changed.

Returns:
The last direction the counter value changed.

Implements CounterBase.


The documentation for this class was generated from the following files:

Generated on Thu Oct 2 14:01:23 2008 for WPI Robotics Library by  doxygen 1.5.5