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... | |
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 encoderDriver.encoderDriver.__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 encoderDriver.encoderDriver.getPosition | ( | self | ) |
Get the position of the encoder.
When called, this function will output the current angle of the encoder in radians.
def encoderDriver.encoderDriver.getSpeed | ( | self | ) |
Get the speed of the encoder.
When called, this function will output the current speed of the encoder in rpm.
def encoderDriver.encoderDriver.setPosition | ( | self, | |
newPosition | |||
) |
Zero the encoder.
When called, this will set theta to 0, thus resetting the encoder.
newPosition | The specified position to zero the encoder to. |
def encoderDriver.encoderDriver.update | ( | self | ) |
Update the position and velocity of the encoders.
This method updates the position (in ticks and radians) as well as the speed of the motor whenever called. It will return the angle in radians and speed in rad/s.