Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

encoder.h File Reference

Detailed Description

Definition in file encoder.h.

#include "global.h"
#include "encoderconf.h"

Go to the source code of this file.


#define IMSK   GIMSK


typedef struct_EncoderState EncoderStateType
 Encoder state structure.


void encoderInit (void)
 encoderInit() initializes hardware and encoder position readings
void encoderOff (void)
 encoderOff() disables hardware and stops encoder position updates
s32 encoderGetPosition (u08 encoderNum)
 encoderGetPosition() reads the current position of the encoder
void encoderSetPosition (u08 encoderNum, s32 position)
 encoderSetPosition() sets the current position of the encoder

Define Documentation

#define IMSK   GIMSK

To keep track of the encoder position in software, we connect PhaseA to an external processor interrupt line, and PhaseB to any I/O pin. We set up the external interrupt to trigger whenever PhaseA produces a rising edge. When a rising edge is detected, our interrupt handler function is executed. Inside the handler function, we quickly check the PhaseB line to see if it is high or low. If it is high, we increment the encoder's position counter, otherwise we decrement it. The encoder position counter can be read at any time to find out the current position.

Definition at line 110 of file encoder.h.

Generated on Sun Oct 29 03:41:08 2006 for Procyon AVRlib by  doxygen 1.4.2