Encoders


Defines

#define LEFT   0
 Left wheel.
#define RIGHT   1
 Right wheel.
#define ENCODER_MAGNET_FAILURE   1025
 Magnet misaligned - likely distance from encoder problem.
#define ENCODER_MISALIGNED   1027
 Encoder misaligned - likely on XY plane.
#define ENCODER_DATA_NOT_READY   1026
 Not enough time has passed - encoders not initialized in hardware.
#define ENCODER_DELAY   20
 delay_ms argument after a full read is complete
#define OCF   _BV(4)
#define COF   _BV(3)
#define LIN   _BV(2)
#define MagINCn   _BV(1)
#define MagDECn   _BV(0)
#define BUFFER_SIZE   23
 Buffer size.

Functions

void encoders_init (void)
 Initialize encoders.
int encoder_read (char encoder)
 Read instantaneous encoder value.
int encoder_get_dx (char encoder)
 Get total distance traveled.
void encoder_rst_dx (char encoder)
 Reset distance counter.
int encoder_get_tc (void)
 Get time count: The number of encoder reads that have occurred.
void encoder_rst_tc (void)
 Reset the time count.
void encoder_wait (int nReadings)
 Waits for the next n encoder reading, then returns.

Function Documentation

int encoder_get_dx ( char  encoder  ) 

Get total distance traveled.

Gets the total distance covered by the specified encoder (in encoder clicks)

Parameters:
encoder the encoder that you want to read, use LEFT or RIGHT
Returns:
The distance covered by the specified encoder.

References LEFT, and RIGHT.

int encoder_get_tc ( void   ) 

Get time count: The number of encoder reads that have occurred.

Get time count: The number of encoder reads that have occurred.

Returns:
The time count.

int encoder_read ( char  encoder  ) 

Read instantaneous encoder value.

Read instantaneous encoder value.

Parameters:
encoder this is the encoder that you want to read. Valid arguments are LEFT and RIGHT
Returns:
the value of the specified encoder

References LEFT, and RIGHT.

Referenced by odometry_reset().

void encoder_rst_dx ( char  encoder  ) 

Reset distance counter.

Resets the distance accumulator for the specified encoder.

Parameters:
encoder the encoder that you want to reset distance for

References LEFT, and RIGHT.

void encoder_wait ( int  n  ) 

Waits for the next n encoder reading, then returns.

Waits for the next n encoder reading, then returns.

Parameters:
n 


Generated on Mon Sep 7 19:07:28 2009 for libdragonfly by  doxygen 1.5.9