Skip to content
rseetham edited this page Jul 11, 2014 · 1 revision

RotaryEncoderis a library for PyBBIO to interface with Rotary Encoders.

The example program using this library is here.

API

RotaryEncoder(RotaryEncoder.eqep_num)

Creates an instance of the class RotaryEncoder. eqep_num determines which eQEP pins are set up. eqep_num can be: EQEP0, EQEP1, EQEP2 or EQEP2b based on which pins the rotary encoder is connected to.

RotaryEncoder.enable()

Turns the eQEP hardware ON

RotaryEncoder.disable()

Turns the eQEP hardware OFF

RotaryEncoder.setAbsolute()

Set mode as Absolute. The position starts at zero and is incremented or decremented by the encoder's movement.

RotaryEncoder.setRelative()

Set mode as Relative. The position is reset when the unit timer overflows.

RotaryEncoder.getMode()

Returns the mode the eQEP hardware is in.

RotaryEncoder.getPosition()

Get the current position of the encoder. In absolute mode, this attribute represents the current position of the encoder. In relative mode, this attribute represents the position of the encoder at the last unit timer overflow.

RotaryEncoder.setFrequency(self,freq):

setFrequency(freq) Set the frequency in Hz at which the driver reports new positions.

RotaryEncoder.setPosition(value)

Give a new value to the current position

RotaryEncoder. zero()

Set the current position to 0