Encoder Class Reference

#include <Encoder.h>

Inheritance diagram for Encoder:

Inheritance graph
[legend]
Collaboration diagram for Encoder:

Collaboration graph
[legend]

List of all members.

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)


Detailed Description

Class to read quad encoders. Quadrature encoders are devices that count shaft rotation and can sense direction. The output of the QuadEncoder class is an integer that can count either up or down, and can go negative for reverse direction counting. When creating QuadEncoders, a direction is supplied that changes the sense of the output to make code more readable if the encoder is mounted such that forward movement generates negative values. Quadrature encoders have two digital outputs, an A Channel and a B Channel that are out of phase with each other to allow the FPGA to do direction sensing.

Constructor & Destructor Documentation

Encoder::Encoder ( unsigned  aChannel,
unsigned  bChannel,
bool  reverseDirection = false 
)

QuadEncoder constructor. Construct a QuadEncoder given a and b channels assuming the default module.

Parameters:
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.

Parameters:
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.

Parameters:
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.


Member Function Documentation

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.

Returns:
Current count from 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.

Returns:
Period in microseconds of the most recent pulse.

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.

Parameters:
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.

Returns:
True if the encoder is considered stopped.

Implements CounterBase.

bool Encoder::GetDirection ( void   )  [virtual]

The last direction the encoder value changed.

Returns:
The last direction the encoder value changed.

Implements CounterBase.


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

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