Meyenberg_Project
EncoderDriver.EncoderDriver Class Reference

Allows the user to read angle measurements from the encoder. More...

Public Member Functions

def __init__ (self, encoderA_pin, encoderB_pin, timerNumber, prescaler, period)
 Creates a EncoderDriver object to read an encoder. More...
 
def update (self)
 Updates the position of the encoder and calculates the amount of change in position to store in delta. More...
 
def get_position (self)
 Returns the most recently updated position of the encoder.
 
def set_position (self, position)
 Sets the position of the encoder.
 
def get_delta (self)
 Returns the amount of change in position since the last update.
 
def zero (self)
 Sets the position of the encoder to 0.
 

Public Attributes

 EncoderA_pin
 Encoder A pin.
 
 EncoderB_pin
 Encoder B pin.
 
 TimerNumber
 Encoder timer number.
 
 Prescaler
 Encoder timer prescaler.
 
 Period
 Encoder timer period.
 
 Timer
 Encoder timer object.
 
 CurCount
 Encoder timer current value.
 
 PrevCount
 Encoder timer previous value.
 
 Position
 Encoder position.
 
 Delta
 Encoder change in position.
 

Detailed Description

Allows the user to read angle measurements from the encoder.

Constructor & Destructor Documentation

◆ __init__()

def EncoderDriver.EncoderDriver.__init__ (   self,
  encoderA_pin,
  encoderB_pin,
  timerNumber,
  prescaler,
  period 
)

Creates a EncoderDriver object to read an encoder.

Parameters
encoderA_pinA pyb.Pin object used as the encoder's A pin.
encoderB_pinA pyb.Pin object used as the encoder's B pin.
timerNumberA value used to create a pyb.Timer object to count for the encoder.
prescalerA value used for the timer.
periodA value used for the timer.

Member Function Documentation

◆ update()

def EncoderDriver.EncoderDriver.update (   self)

Updates the position of the encoder and calculates the amount of change in position to store in delta.

If theres is overflow or underflow, the delta is adjusted. The delta value is added to the current position.


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