ME 405 Term Project
Loading...
Searching...
No Matches
encoder.Encoder Class Reference

Public Member Functions

 __init__ (self, Pin chA_pin, Pin chB_pin, int tim_num)
 update (self)
 zero (self)
 get_position (self, str unit="counts")
 get_velocity (self, str unit="counts/s")

Public Attributes

 chA_pin = Pin(chA_pin)
 chB_pin = Pin(chB_pin)
int AR = 65535
 tim_obj = Timer(tim_num, prescaler=0, period=self.AR)
int position_counts = 0
 prev_count = self.tim_obj.counter()
int delta = 0
 prev_time = ticks_us()
int dt = 0
int velocity_counts_per_s = 0

Static Public Attributes

int GEAR_RATIO = 3952/33
int CPR_MOTOR = 12
int CPR_WHEEL = GEAR_RATIO*CPR_MOTOR
int RAD_PER_COUNT = 2 * math.pi / CPR_WHEEL
int WHEEL_RADIUS_MM = 35

Detailed Description

A quadrature encoder decoding interface encapsulated in a Python class. Provides position and velocity.

Constructor & Destructor Documentation

◆ __init__()

encoder.Encoder.__init__ ( self,
Pin chA_pin,
Pin chB_pin,
int tim_num )
Initializes an Encoder object

Member Function Documentation

◆ get_position()

encoder.Encoder.get_position ( self,
str unit = "counts" )
Return position in specified units: "counts", "rad", or "mm".

◆ get_velocity()

encoder.Encoder.get_velocity ( self,
str unit = "counts/s" )
Return velocity in specified units: "counts/s", "rad/s", or "mm/s".

◆ update()

encoder.Encoder.update ( self)
Update encoder count and compute velocity.

◆ zero()

encoder.Encoder.zero ( self)
Zero the encoder position.

Member Data Documentation

◆ AR

int encoder.Encoder.AR = 65535

◆ chA_pin

encoder.Encoder.chA_pin = Pin(chA_pin)

◆ chB_pin

encoder.Encoder.chB_pin = Pin(chB_pin)

◆ CPR_MOTOR

int encoder.Encoder.CPR_MOTOR = 12
static

◆ CPR_WHEEL

int encoder.Encoder.CPR_WHEEL = GEAR_RATIO*CPR_MOTOR
static

◆ delta

int encoder.Encoder.delta = 0

◆ dt

int encoder.Encoder.dt = 0

◆ GEAR_RATIO

int encoder.Encoder.GEAR_RATIO = 3952/33
static

◆ position_counts

int encoder.Encoder.position_counts = 0

◆ prev_count

encoder.Encoder.prev_count = self.tim_obj.counter()

◆ prev_time

encoder.Encoder.prev_time = ticks_us()

◆ RAD_PER_COUNT

int encoder.Encoder.RAD_PER_COUNT = 2 * math.pi / CPR_WHEEL
static

◆ tim_obj

encoder.Encoder.tim_obj = Timer(tim_num, prescaler=0, period=self.AR)

◆ velocity_counts_per_s

int encoder.Encoder.velocity_counts_per_s = 0

◆ WHEEL_RADIUS_MM

int encoder.Encoder.WHEEL_RADIUS_MM = 35
static

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