Public Member Functions | |
def | __init__ (self, timerNum, pin1, pin2, Period, Prescaler) |
An encoder driver that reads timer outputs from connected pins. More... | |
def | update (self) |
updates the recorded position of the encoder More... | |
def | get_position (self) |
returns the most recently updated position of the encoder More... | |
def | set_position (self, newPosition) |
resets the position to a specified value More... | |
def | get_delta (self) |
returns difference between the last two recorded position More... | |
Public Attributes | |
timerNum | |
Timer for the set of encoder pins. | |
pin1 | |
first pin for Encoder | |
pin2 | |
second pin for Encoder | |
Period | |
period for running the timer object | |
Prescaler | |
prescaler for the timer object | |
TIM | |
Timer object for Encoder. | |
currPosition | |
Channel 1 for Timer object. More... | |
prevPosition | |
Previous position. | |
delta | |
difference between last two recorded positions | |
newPosition | |
new position | |
def encoder2.Encoder.__init__ | ( | self, | |
timerNum, | |||
pin1, | |||
pin2, | |||
Period, | |||
Prescaler | |||
) |
An encoder driver that reads timer outputs from connected pins.
The driver takes the timer channels, 2 pin numbers, period and prescaler that will be utilized to count an encoder channel. The driver accounts for timer overflow and is used to control a motor's position.
timerNum | the timer channel for the set of pins |
pin1 | the first pin the encoder is connected to |
pin2 | the second pin the encoder is connected to |
Period | the largest number that can stored in timer |
Prescaler | the frequency dividier or period multiplier |
def encoder2.Encoder.get_delta | ( | self | ) |
returns difference between the last two recorded position
def encoder2.Encoder.get_position | ( | self | ) |
returns the most recently updated position of the encoder
def encoder2.Encoder.set_position | ( | self, | |
newPosition | |||
) |
resets the position to a specified value
this function takes in a new position value and replaces it with the current value. The previous current value is stored in a previous position variable.
newPosition | a new position set by the user |
def encoder2.Encoder.update | ( | self | ) |
updates the recorded position of the encoder
This update counts the position of the motor, and fixes the delta readings by adjusting depending on what the defined period is. This function stores the previous counter value and creates a new counter value each time the function is ran.
encoder2.Encoder.currPosition |
Channel 1 for Timer object.
Channel 2 for Timer object
Current position