Lucas Murray ME 305 Portfolio
Public Member Functions | Public Attributes | List of all members
encoder.Encoder Class Reference

Interface with quadrature encoders. More...

Public Member Functions

def __init__ (self, pinA, pinB, timNum)
 Constructs an encoder object. More...
 
def update (self, updatePosition)
 Updates encoder position and delta. More...
 
def get_position (self)
 Returns the encoder position. More...
 
def zero (self)
 Resets the encoder position to zero.
 
def get_delta (self)
 Returns change in position from previous update. More...
 

Public Attributes

 tim4
 
 position
 
 delta
 
 currentPosition
 

Detailed Description

Interface with quadrature encoders.

Can read and print the position of a quadrature encoder as well as control the update speed for the position.

Constructor & Destructor Documentation

◆ __init__()

def encoder.Encoder.__init__ (   self,
  pinA,
  pinB,
  timNum 
)

Constructs an encoder object.

Parameters
pinAThe first pin associated with the encoder
pinBThe second pin associated with the encoder
timNumThe number of the timer that works for the given pins

Member Function Documentation

◆ get_delta()

def encoder.Encoder.get_delta (   self)

Returns change in position from previous update.

Returns
self.delta The change in position of the encoder shaft between the two most recent updates

◆ get_position()

def encoder.Encoder.get_position (   self)

Returns the encoder position.

Returns
self.position The position of the encoder shaft

◆ update()

def encoder.Encoder.update (   self,
  updatePosition 
)

Updates encoder position and delta.

Takes the position of the encoder and recalculates it, updating the change in position in the process

Parameters
updatePositionThe current position of the encoder
Returns
[updatePosition] The time and position of the encoder after the update is finished

The documentation for this class was generated from the following file: