Luisa Chiu Portfolio
encoder.Encoder Class Reference

Class that reads encoder. More...

Public Member Functions

def __init__ (self, pinA, pinB, tim_num)
 Constructs an encoder object. More...
 
def update (self)
 Updates encoder position and delta. More...
 
def get_position (self)
 Returns encoder position. More...
 
def set_position (self, position)
 Sets encoder position. More...
 
def get_delta (self)
 Returns encoder delta. More...
 

Public Attributes

 period
 "Auto Reload" value More...
 
 tim
 Variable that specifies timer number. More...
 
 start
 Variable representing previous time stamp. More...
 
 enc_pos
 The encoder position that counts total movement. More...
 
 stop
 Variable representing current time stamp. More...
 
 delta
 Calculates delta. More...
 

Detailed Description

Class that reads encoder.

Uses the operation of a timer to read from an encoder connected to arbitrary pins

Constructor & Destructor Documentation

◆ __init__()

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

Constructs an encoder object.

The encoder object is created from three attributes: pinA, pinB, and timer number.

Parameters
pinAFirst pin associated with the designated encoder object.
pinBSecond pin associated with the designated encoder object.
tim_numTimer number associated with designated encoder object.

Member Function Documentation

◆ get_delta()

def encoder.Encoder.get_delta (   self)

Returns encoder delta.

A function that returns encoder delta

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

◆ get_position()

def encoder.Encoder.get_position (   self)

Returns encoder position.

A function that returns encoder position

Returns
The position of the encoder shaft

◆ set_position()

def encoder.Encoder.set_position (   self,
  position 
)

Sets encoder position.

A function that sets encoder position to a specified value

Returns
The new position of the encoder shaft

◆ update()

def encoder.Encoder.update (   self)

Updates encoder position and delta.

Detects delta overflow and corrects delta and calculates encoder position.

Member Data Documentation

◆ delta

encoder.Encoder.delta

Calculates delta.

Delta is the difference between two most recently updated encoder positions

◆ enc_pos

encoder.Encoder.enc_pos

The encoder position that counts total movement.

The total position moved is characterized by the total number of timer counts

◆ period

encoder.Encoder.period

"Auto Reload" value

Specifies the largest number that can be stored in the timer

◆ start

encoder.Encoder.start

Variable representing previous time stamp.

Counter that corresponds to number of ticks

◆ stop

encoder.Encoder.stop

Variable representing current time stamp.

Counter that corresponds to number of ticks

◆ tim

encoder.Encoder.tim

Variable that specifies timer number.

Uses attributes of prescaler and period to create timer object


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