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

Quad Encoder driver. More...

#include <stdlib.h>
#include "ch.h"
#include "hal.h"
#include "vex.h"

Functions

void vexEncoderInit ()
 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 ()
 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

Quad Encoder driver.

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