Encoder class to allow for several encoders to be used. More...
Public Member Functions | |
def | __init__ (self, debugFlag=True, pin1=Pin.cpu.B6, pin2=Pin.cpu.B7, encTimer=4) |
Create an encoder object to find position and speeds. More... | |
def | update (self) |
Update the position and velocity of the encoders. More... | |
def | getPosition (self) |
Get the position of the encoder. More... | |
def | setPosition (self, newPosition) |
Zero the encoder. More... | |
def | getSpeed (self) |
Get the speed of the encoder. More... | |
def | getDelta (self) |
Get the delta of the encoder. More... | |
Encoder class to allow for several encoders to be used.
This class will allow for the position, delta, and speed of the encoders to be tracked.
def encoder.encoder.__init__ | ( | self, | |
debugFlag = True , |
|||
pin1 = Pin.cpu.B6 , |
|||
pin2 = Pin.cpu.B7 , |
|||
encTimer = 4 |
|||
) |
Create an encoder object to find position and speeds.
This object will be called in order to find the current positions, deltas, speeds, or to reset the encoder back to zero.
pin1 | Input pin to use for the first channel. User must input the exact pin name, for example, Pin.cpu.B6 for encoder 1 or Pin.cpu.C6 for encoder 2. |
pin2 | Input pin to use for the second channel. User must input the exact pin name, for example, Pin.cpu.B7 for encoder 1 or Pin.cpu.C7 for encoder 2. |
encTimer | Timer number that will be used for the encoder. Possible options include timer 4 and 8. |
debugFlag | Enables or prevents certain print statements from appearing. |
def encoder.encoder.getDelta | ( | self | ) |
Get the delta of the encoder.
When called, this function will output the current delta of the encoder in ticks.
def encoder.encoder.getPosition | ( | self | ) |
Get the position of the encoder.
When called, this function will output the current angle of the encoder in degrees.
def encoder.encoder.getSpeed | ( | self | ) |
Get the speed of the encoder.
When called, this function will output the current speed of the encoder in rpm.
def encoder.encoder.setPosition | ( | self, | |
newPosition | |||
) |
Zero the encoder.
When called, this will set theta to 0, thus resetting the encoder.
def encoder.encoder.update | ( | self | ) |
Update the position and velocity of the encoders.
This method updates the position (in ticks and degrees) as well as the speed of the motor whenever called. It will be called by the controller task whenever the the p/P key is pressed, or data is being collected.