A class to interact with two encoders. More...
Public Member Functions | |
def | __init__ (self, e1_1=pyb.Pin.board.PB6, e1_2=pyb.Pin.board.PB7, e2_1=pyb.Pin.board.PC6, e2_2=pyb.Pin.board.PC7, current_position_a=0, current_position_b=0) |
Initializes the Encoders and their respective timers. More... | |
def | update (self) |
Updates the current position of each encoder. More... | |
def | get_position (self) |
Returns the most recently updated positions of the encoders. More... | |
def | set_position (self, a, b) |
Sets the position of the encoders to a specific value. More... | |
def | get_delta (self) |
Calculates difference between the two most recent recorded positions. More... | |
Public Attributes | |
p11 | |
p12 | |
p21 | |
p22 | |
tim4 | |
ch1a | |
ch2a | |
tim8 | |
ch1b | |
ch2b | |
cnt_a | |
cnt_last_a | |
cnt_b | |
cnt_last_b | |
pos_a | |
pos_last_a | |
pos_b | |
pos_last_b | |
A class to interact with two encoders.
This class connects with two encoders and can be used to update their current angle periodically. It can also get changes in angle, and reset the current angle to a user defined value.
def encoder.EncoderDriver.__init__ | ( | self, | |
e1_1 = pyb.Pin.board.PB6 , |
|||
e1_2 = pyb.Pin.board.PB7 , |
|||
e2_1 = pyb.Pin.board.PC6 , |
|||
e2_2 = pyb.Pin.board.PC7 , |
|||
current_position_a = 0 , |
|||
current_position_b = 0 |
|||
) |
Initializes the Encoders and their respective timers.
e1_1 | pyb.Pin for Encoder 1, Channel 1 (default=pyb.Pin.board.PB6) |
e1_2 | pyb.Pin for Encoder 1, Channel 2 (default=pyb.Pin.board.PB7) |
e2_1 | pyb.Pin for Encoder 2, Channel 1 (default=pyb.Pin.board.PC6) |
e2_2 | pyb.Pin for Encoder 2, Channel 2 (default=pyb.Pin.board.PC7) |
current_position_a | Initial position of Encoder 1 (default=0) |
current_position_b | Initial position of Encoder 2 (default=0) |
def encoder.EncoderDriver.get_delta | ( | self | ) |
Calculates difference between the two most recent recorded positions.
def encoder.EncoderDriver.get_position | ( | self | ) |
Returns the most recently updated positions of the encoders.
def encoder.EncoderDriver.set_position | ( | self, | |
a, | |||
b | |||
) |
Sets the position of the encoders to a specific value.
a | The position for encoder 1 |
b | The position for encoder 2 |
def encoder.EncoderDriver.update | ( | self | ) |
Updates the current position of each encoder.