encoder¶
- class encoder.Encoder(enc_A_pin, enc_B_pin, enc_timer)¶
Bases:
object
A class to interface with a quadrature encoder using timers.
- enc_A_pin¶
Pin object for channel A of the encoder.
- Type:
Pin
- enc_B_pin¶
Pin object for channel B of the encoder.
- Type:
Pin
- timer¶
Timer object configured for encoder mode.
- Type:
Timer
- encoder_pos¶
Accumulated encoder position.
- Type:
int
- encoder_pos_last¶
Previous encoder position.
- Type:
int
- encoder_angle¶
Encoder angle in degrees or radians.
- Type:
float
- encoder_velocity¶
Encoder velocity in counts per second.
- Type:
float
- start_time¶
Timestamp of the last update.
- Type:
int
- last_time¶
Timestamp of the previous update.
- Type:
int
- del_time¶
Time difference between updates.
- Type:
int
- current_count¶
Current raw timer count.
- Type:
int
- delta¶
Difference in encoder counts since last update.
- Type:
int
- offset¶
Offset to correct encoder count.
- Type:
int
- get_angle()¶
Returns the current encoder angle.
- get_position()¶
Returns the current encoder position.
- get_velocity()¶
Returns the current encoder velocity.
- print_enc()¶
Prints the current encoder position.
- update(cb_src=None)¶
Updates the encoder position and velocity based on timer counts.
- Parameters:
cb_src (optional) – Callback source, not used in this implementation.
- zero()¶
Resets the encoder position to zero.