Matthew Tagupa's ME 405 Labs and Term Project
Encoder.Encoder Class Reference

An encoder driver object. More...

Public Member Functions

def __init__ (self, TimerNo, EncoderA_pin, EncoderB_pin, prescaler, period)
 Constructor for encoder driver. More...
 
def update (self)
 Updated Position. More...
 
def get_position (self)
 Gets the encoder's position. More...
 
def set_position (self, new_position)
 Sets the encoder's position. More...
 
def get_delta (self)
 Finds the change between 2 update methods. More...
 

Public Attributes

 EncoderA_pin
 
 EncoderB_pin
 
 prescaler
 
 period
 
 timer
 
 position
 
 last_position
 
 current_position
 
 delta
 
 new_position
 

Detailed Description

An encoder driver object.

This class implements the encoder for the ME 405 board.

Author
Matthew Tagupa
Date
May 21, 2020

Constructor & Destructor Documentation

◆ __init__()

def Encoder.Encoder.__init__ (   self,
  TimerNo,
  EncoderA_pin,
  EncoderB_pin,
  prescaler,
  period 
)

Constructor for encoder driver.

This constructor is set to initialize the timer that will be used to count the ticks that are output from the encoder into the motor driver.

Parameters
TimerNoThe timer that the encoder will use
EncoderA_pinThe pin designated for encoder channel A
EncoderB_pinThe pin designated for encoder channel B
prescalerThe initial value used to set the encoder
periodThe limit where the counting in the encoder will stop

Member Function Documentation

◆ get_delta()

def Encoder.Encoder.get_delta (   self)

Finds the change between 2 update methods.

When called upon, this method returns the difference in recorded position between the two most recent calls to update().

◆ get_position()

def Encoder.Encoder.get_position (   self)

Gets the encoder's position.

When called upon, this method gets the encoder's current position and displays that position.

◆ set_position()

def Encoder.Encoder.set_position (   self,
  new_position 
)

Sets the encoder's position.

When called upon, this method will reset the encoder to the specified position. The position will be an argument assigned inside of the set_position method.

Parameters
new_positionThe position you want the encoder to read starting from when this command is activated

◆ update()

def Encoder.Encoder.update (   self)

Updated Position.

When called, this will update the recorded position of the encoder to the current position.


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