Simple PID example for LabVIEW

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

QEI Class Reference

QEI Class Reference

Quadrature Encoder Interface. More...

#include <QEI.h>

Public Member Functions

 QEI (PinName channelA, PinName channelB, PinName index, int pulsesPerRev)
 Constructor.
void reset (void)
 Reset the encoder.
int getCurrentState (void)
 Read the state of the encoder.
int getPulses (void)
 Read the number of pulses recorded by the encoder.

Detailed Description

Quadrature Encoder Interface.

Definition at line 127 of file QEI.h.


Constructor & Destructor Documentation

QEI ( PinName  channelA,
PinName  channelB,
PinName  index,
int  pulsesPerRev 
)

Constructor.

Reads the current values on channel A and channel B to determine the initial state.

Attaches the encode function to the rise/fall interrupt edges of channels A and B to perform X4 encoding.

Attaches the index function to the rise interrupt edge of channel index (if it is used) to count revolutions.

Parameters:
channelAmbed pin for channel A input.
channelBmbed pin for channel B input.
indexmbed pin for optional index channel input, (pass NC if not needed).
pulsesPerRevNumber of pulses in one revolution.

Definition at line 112 of file QEI.cpp.


Member Function Documentation

int getCurrentState ( void   )

Read the state of the encoder.

Returns:
The current state of the encoder as a 2-bit number, where: bit 1 = The reading from channel B bit 2 = The reading from channel A

Definition at line 148 of file QEI.cpp.

int getPulses ( void   )

Read the number of pulses recorded by the encoder.

Returns:
Number of pulses which have occured.

Definition at line 154 of file QEI.cpp.

void reset ( void   )

Reset the encoder.

Sets the pulses and revolutions count to zero.

Definition at line 141 of file QEI.cpp.