All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexencoder.h File Reference

Header for the encoder driver. More...

Go to the source code of this file.

Data Structures

struct  _vexQuadEncoder_t
 Holds information relating to an encoder. More...
 

Typedefs

typedef struct _vexQuadEncoder_t vexQuadEncoder_t
 Holds information relating to an encoder. More...
 

Enumerations

enum  tVexQuadEncoderChannel {
  kVexQuadEncoder_1 = 0, kVexQuadEncoder_2, kVexQuadEncoder_3, kVexQuadEncoder_4,
  kVexQuadEncoder_5, kVexQuadEncoder_Num
}
 Encoder channel number. More...
 

Functions

void vexEncoderInit (void)
 Initialize all the encoder data, counts to zero etc. More...
 
void vexEncoderAdd (tVexQuadEncoderChannel channel, tVexDigitalPin pa, tVexDigitalPin pb)
 Add an encoder to the system. More...
 
void vexEncoderStart (tVexQuadEncoderChannel channel)
 Start an encoder interrupt handler. More...
 
void vexEncoderStop (tVexQuadEncoderChannel channel)
 Stop an encoder interrupt handler. More...
 
void vexEncoderStartAll (void)
 Start all encoder interrupt handlers. More...
 
int32_t vexEncoderGet (int16_t channel)
 Get encoder count. More...
 
void vexEncoderSet (int16_t channel, int32_t value)
 Get encoder count. More...
 
int16_t vexEncoderGetId (int16_t channel)
 Get encoder id. More...
 
void vexEncoderDebug (vexStream *chp, int argc, char *argv[])
 Send all encoder raw values and offsets to the console. More...
 

Detailed Description

Header for the encoder driver.

Typedef Documentation

Holds information relating to an encoder.

Note
pin refers to the digital pin 1 through 12, port refers to the STM32 port, GPIOA, GPIOB etc. pad refers to the bit on the digital port 0 through 15

Enumeration Type Documentation

Encoder channel number.

Enumerator
kVexQuadEncoder_1 
kVexQuadEncoder_2 
kVexQuadEncoder_3 
kVexQuadEncoder_4 
kVexQuadEncoder_5 
kVexQuadEncoder_Num 

Function Documentation

void vexEncoderInit ( void  )

Initialize all the encoder data, counts to zero etc.

void vexEncoderAdd ( tVexQuadEncoderChannel  channel,
tVexDigitalPin  pa,
tVexDigitalPin  pb 
)

Add an encoder to the system.

Parameters
[in]channelThe encoder channel
[in]paThe first input pin used by the encoder
[in]pbThe second input pin used by the encoder

Setup the interrupt handlers for an encoder but do not enable them

void vexEncoderStart ( tVexQuadEncoderChannel  channel)

Start an encoder interrupt handler.

Parameters
[in]channelThe encoder channel to start the irq handler on
void vexEncoderStop ( tVexQuadEncoderChannel  channel)

Stop an encoder interrupt handler.

Parameters
[in]channelThe encoder channel to stop the irq handler on
void vexEncoderStartAll ( void  )

Start all encoder interrupt handlers.

int32_t vexEncoderGet ( int16_t  channel)

Get encoder count.

Parameters
[in]channelThe encoder channel

Get an encoder count for a channel, we don't use the enumerated channel type so this can be used without warnings from other code in a callback. Typically the motor control code may call this and not know what type of encoder is being used, a quad encoder or an IME

void vexEncoderSet ( int16_t  channel,
int32_t  value 
)

Get encoder count.

Parameters
[in]channelThe encoder channel
[in]valueThe value to set the encoder to

Set encoder count for a channel, this saves the value as an offset to the current count

int16_t vexEncoderGetId ( int16_t  channel)

Get encoder id.

Parameters
[in]channelThe encoder channel

Get an encoder id for a channel, we don't use the enumerated type so this can be used without warnings from other code in a callback. Typically the motor control code may call this and not know what type of encoder is being used, a quad encoder or an IME The encoder id is basically the pin number for inputA

void vexEncoderDebug ( vexStream chp,
int  argc,
char *  argv[] 
)

Send all encoder raw values and offsets to the console.

Parameters
[in]chpA pointer to a vexStream object
[in]argcThe number of command line arguments
[in]argvAn array of pointers to the command line args