#include <Encoder.h>
Public Member Functions | |
Encoder (unsigned aChannel, unsigned bChannel, bool reverseDirection=false) | |
Encoder (unsigned aSlot, unsigned aChannel, unsigned bSlot, unsigned _bChannel, bool reverseDirection=false) | |
Encoder (DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection=false) | |
virtual | ~Encoder (void) |
void | Start (void) |
signed int | Get (void) |
void | Reset (void) |
void | Stop (void) |
unsigned long | GetPeriod (void) |
void | SetMaxPeriod (unsigned long maxPeriod) |
bool | GetStopped (void) |
bool | GetDirection (void) |
Encoder::Encoder | ( | unsigned | aChannel, | |
unsigned | bChannel, | |||
bool | reverseDirection = false | |||
) |
QuadEncoder constructor. Construct a QuadEncoder given a and b channels assuming the default module.
aChannel | The a channel digital input channel. | |
bChannel | The b channel digital input channel. | |
reverseDirection | represents the orientation of the encoder and inverts the output values if necessary so forward represents positive values. |
Encoder::Encoder | ( | unsigned | aSlot, | |
unsigned | aChannel, | |||
unsigned | bSlot, | |||
unsigned | bChannel, | |||
bool | reverseDirection = false | |||
) |
QuadEncoder constructor. Construct a QuadEncoder given a and b modules and channels fully specified.
aSlot | The a channel digital input module. | |
aChannel | The a channel digital input channel. | |
bSlot | The b channel digital input module. | |
bChannel | The b channel digital input channel. | |
reverseDirection | represents the orientation of the encoder and inverts the output values if necessary so forward represents positive values. |
Encoder::Encoder | ( | DigitalSource * | aSource, | |
DigitalSource * | bSource, | |||
bool | reverseDirection = false | |||
) |
QuadEncoder constructor. Construct a QuadEncoder given a and b channels as digital inputs. This is used in the case where the digital inputs are shared. The QuadEncoder class will not allocate the digital inputs and assume that they already are counted.
aSource | The source that should be used for the a channel. | |
bSource | the source that should be used for the b channel. | |
reverseDirection | represents the orientation of the encoder and inverts the output values if necessary so forward represents positive values. |
Encoder::~Encoder | ( | void | ) | [virtual] |
Free the resources for a QuadEncoder. Frees the FPGA resources associated with a Quad Encoder.
void Encoder::Start | ( | void | ) | [virtual] |
Start the QuadEncoder. Starts counting pulses on the QuadEncoder device.
Implements CounterBase.
signed int Encoder::Get | ( | void | ) | [virtual] |
Gets the current count. Returns the current count on the QuadEncoder.
Implements CounterBase.
void Encoder::Reset | ( | void | ) | [virtual] |
Reset the QuadEncoder to zero. Resets the current count to zero on the encoder.
Implements CounterBase.
void Encoder::Stop | ( | void | ) | [virtual] |
Stops counting pulses on the QuadEncoder device. The value is not changed.
Implements CounterBase.
unsigned long Encoder::GetPeriod | ( | void | ) | [virtual] |
Returns the period of the most recent pulse. Returns the period of the most recent Quad Encoder pulse in microseconds.
Implements CounterBase.
void Encoder::SetMaxPeriod | ( | unsigned long | maxPeriod | ) | [virtual] |
Sets the maximum period for stopped detection. Sets the value that represents the maximum period of the QuadEncoder before it will assume that the attached device is stopped. This timeout allows users to determine if the wheels or other shaft has stopped rotating.
maxPeriod | The maximum time between rising and falling edges before the FPGA will consider the device stopped. This is expressed in microseconds. |
Implements CounterBase.
bool Encoder::GetStopped | ( | void | ) | [virtual] |
Determine if the encoder is stopped. Using the MaxPeriod value, a boolean is returned that is true if the encoder is considered stopped and false if it is still moving. A stopped encoder is one where the most recent pulse width exceeds the MaxPeriod.
Implements CounterBase.
bool Encoder::GetDirection | ( | void | ) | [virtual] |
The last direction the encoder value changed.
Implements CounterBase.