|
ME 405 Term Project
|
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 |
A quadrature encoder decoding interface encapsulated in a Python class. Provides position and velocity.
| encoder.Encoder.__init__ | ( | self, | |
| Pin | chA_pin, | ||
| Pin | chB_pin, | ||
| int | tim_num ) |
Initializes an Encoder object
| encoder.Encoder.get_position | ( | self, | |
| str | unit = "counts" ) |
Return position in specified units: "counts", "rad", or "mm".
| encoder.Encoder.get_velocity | ( | self, | |
| str | unit = "counts/s" ) |
Return velocity in specified units: "counts/s", "rad/s", or "mm/s".
| encoder.Encoder.update | ( | self | ) |
Update encoder count and compute velocity.
| encoder.Encoder.zero | ( | self | ) |
Zero the encoder position.
| int encoder.Encoder.AR = 65535 |
| encoder.Encoder.chA_pin = Pin(chA_pin) |
| encoder.Encoder.chB_pin = Pin(chB_pin) |
|
static |
|
static |
| int encoder.Encoder.delta = 0 |
| int encoder.Encoder.dt = 0 |
|
static |
| int encoder.Encoder.position_counts = 0 |
| encoder.Encoder.prev_count = self.tim_obj.counter() |
| encoder.Encoder.prev_time = ticks_us() |
|
static |
| encoder.Encoder.tim_obj = Timer(tim_num, prescaler=0, period=self.AR) |
| int encoder.Encoder.velocity_counts_per_s = 0 |
|
static |