ME 405 Romi
Loading...
Searching...
No Matches
encoder.Encoder Class Reference

The Encoder Diver Class. More...

Public Member Functions

 __init__ (self, tim, chA_pin, chB_pin)
 Encoder Initialization.
 update (self)
 Encoder Update.
 get_position (self)
 Encoder Position Get.
 get_velocity (self)
 Encoder Velocity Get.
 zero (self)
 Zero the Encoder.
 get_dt (self)
 Get dt.
 set_offset (self, offset)
 Set Offset.

Public Attributes

int position = 0
int prev_count = 0
int delta = 0
int dt = 0
int last_time = 0
int current_time = 0
 tim = tim
int offset = 0
 timCh_A = tim.channel(1, pin=chA_pin, mode=Timer.ENC_A)
 timCh_B = tim.channel(2, pin=chB_pin, mode=Timer.ENC_B)

Detailed Description

The Encoder Diver Class.

A quadrature encoder decoding interface encapsulated in a Python class

Definition at line 6 of file encoder.py.

Constructor & Destructor Documentation

◆ __init__()

encoder.Encoder.__init__ ( self,
tim,
chA_pin,
chB_pin )

Encoder Initialization.

Parameters
P1Timer Used
P2Channel A pin
P3Channel B pin

Definition at line 12 of file encoder.py.

Member Function Documentation

◆ get_dt()

encoder.Encoder.get_dt ( self)

Get dt.

gets the elapsed time in between encoder updates

Definition at line 68 of file encoder.py.

◆ get_position()

encoder.Encoder.get_position ( self)

Encoder Position Get.

Returns the most recently updated value of position as determined within the update() method

Definition at line 49 of file encoder.py.

◆ get_velocity()

encoder.Encoder.get_velocity ( self)

Encoder Velocity Get.

Returns a measure of velocity using the most recently updated value of delta as determined within the update() method

Definition at line 55 of file encoder.py.

◆ set_offset()

encoder.Encoder.set_offset ( self,
offset )

Set Offset.

Parameters
P1Offset

Definition at line 73 of file encoder.py.

◆ update()

encoder.Encoder.update ( self)

Encoder Update.

Runs one update step on the encoder's timer counter to keep track of the change in count and check for counter reload

Definition at line 30 of file encoder.py.

◆ zero()

encoder.Encoder.zero ( self)

Zero the Encoder.

Sets the present encoder position to zero and causes future updates to measure with respect to the new zero position

Definition at line 61 of file encoder.py.

Member Data Documentation

◆ current_time

int encoder.Encoder.current_time = 0

Definition at line 19 of file encoder.py.

◆ delta

int encoder.Encoder.delta = 0

Definition at line 16 of file encoder.py.

◆ dt

encoder.Encoder.dt = 0

Definition at line 17 of file encoder.py.

◆ last_time

int encoder.Encoder.last_time = 0

Definition at line 18 of file encoder.py.

◆ offset

int encoder.Encoder.offset = 0

Definition at line 21 of file encoder.py.

◆ position

int encoder.Encoder.position = 0

Definition at line 14 of file encoder.py.

◆ prev_count

int encoder.Encoder.prev_count = 0

Definition at line 15 of file encoder.py.

◆ tim

encoder.Encoder.tim = tim

Definition at line 20 of file encoder.py.

◆ timCh_A

encoder.Encoder.timCh_A = tim.channel(1, pin=chA_pin, mode=Timer.ENC_A)

Definition at line 23 of file encoder.py.

◆ timCh_B

encoder.Encoder.timCh_B = tim.channel(2, pin=chB_pin, mode=Timer.ENC_B)

Definition at line 24 of file encoder.py.


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