An encoder driver object. More...
Public Member Functions | |
| def | __init__ (self, TimerNo, EncoderA_pin, EncoderB_pin, prescaler, period) |
| Constructor for encoder driver. More... | |
| def | update (self) |
| Updated Position. More... | |
| def | get_position (self) |
| Gets the encoder's position. More... | |
| def | set_position (self, new_position) |
| Sets the encoder's position. More... | |
| def | get_delta (self) |
| Finds the change between 2 update methods. More... | |
Public Attributes | |
| EncoderA_pin | |
| EncoderB_pin | |
| prescaler | |
| period | |
| timer | |
| position | |
| last_position | |
| current_position | |
| delta | |
| new_position | |
An encoder driver object.
This class implements the encoder for the ME 405 board.
| def Encoder.Encoder.__init__ | ( | self, | |
| TimerNo, | |||
| EncoderA_pin, | |||
| EncoderB_pin, | |||
| prescaler, | |||
| period | |||
| ) |
Constructor for encoder driver.
This constructor is set to initialize the timer that will be used to count the ticks that are output from the encoder into the motor driver.
| TimerNo | The timer that the encoder will use |
| EncoderA_pin | The pin designated for encoder channel A |
| EncoderB_pin | The pin designated for encoder channel B |
| prescaler | The initial value used to set the encoder |
| period | The limit where the counting in the encoder will stop |
| def Encoder.Encoder.get_delta | ( | self | ) |
Finds the change between 2 update methods.
When called upon, this method returns the difference in recorded position between the two most recent calls to update().
| def Encoder.Encoder.get_position | ( | self | ) |
Gets the encoder's position.
When called upon, this method gets the encoder's current position and displays that position.
| def Encoder.Encoder.set_position | ( | self, | |
| new_position | |||
| ) |
Sets the encoder's position.
When called upon, this method will reset the encoder to the specified position. The position will be an argument assigned inside of the set_position method.
| new_position | The position you want the encoder to read starting from when this command is activated |
| def Encoder.Encoder.update | ( | self | ) |
Updated Position.
When called, this will update the recorded position of the encoder to the current position.