Encoders

Defines

#define LEFT   0
 Left wheel.
#define RIGHT   1
 Right wheel.
#define ENCODER_MAX   1024
 Max value of valid encoder reading.
#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   46
 Buffer size.
#define ERR_VEL   1024

Functions

void encoders_init (void)
 Initialize encoders.
int encoder_read (char encoder)
 Read instantaneous encoder value.
int encoder_get_x (char encoder)
 Get total distance traveled.
int encoder_get_v (char encoder)
 Get instantaneous velocity.
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.

Definition at line 114 of file encoders.c.

References LEFT, and RIGHT.

Referenced by encoder_get_x().

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.

Definition at line 165 of file encoders.c.

int encoder_get_v ( char  encoder  ) 

Get instantaneous velocity.

Get instantaneous velocity.

Parameters:
encoder RIGHT or LEFT - the wheel you want the velocity for.
Returns:
The instantaneous velocity for the given wheel or twice the ERR_VEL if an error occurs (1024 * 2 = 2048)
Bug:
This uses hard coded values and results are inconsistent. Use at your own risk.

Definition at line 133 of file encoders.c.

int encoder_get_x ( char  encoder  ) 

Get total distance traveled.

Note:
Simply calls encoder_get_dx.

Get total distance traveled.

Parameters:
encoder the encoder that you want to read, either LEFT or RIGHT
Returns:
The distance covered by the specified encoder.
Note:
Simply calls encoder_get_dx.

Definition at line 103 of file encoders.c.

References encoder_get_dx().

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. -1 usually means low battery. values above ENCODER_MAX usually means phyiscal problems with the encoder.

Definition at line 87 of file encoders.c.

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

Definition at line 154 of file encoders.c.

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 

Definition at line 182 of file encoders.c.


Generated on Thu May 17 00:00:09 2012 for libdragonfly by  doxygen 1.6.1