This class defines the three functions of the encoder driver. More...
Public Member Functions | |
| def | __init__ (self, timer_number, ch1_pin, ch2_pin) |
| Defines parameters needed for an encoder object. More... | |
| def | update (self) |
| Function which consistently updates motor position. More... | |
| def | get_position (self) |
| This function returns the current position of the motor. More... | |
| def | set_position (self) |
| This function sets the position of the motor to zero. More... | |
| def | get_delta (self) |
| This function returns the most recent delta. More... | |
Public Attributes | |
| ch1_pin | |
| ch2_pin | |
| tim1 | |
| delt1 | |
| zero1 | |
| pos1 | |
| position1 | |
| delta1 | |
| position | |
This class defines the three functions of the encoder driver.
The three functions defined by this class are the initialization function, the get position function, the set position function, and the zero function. All three are intended to be called by another file.
| def Encoder_Driver.EncoderDriver.__init__ | ( | self, | |
| timer_number, | |||
| ch1_pin, | |||
| ch2_pin | |||
| ) |
Defines parameters needed for an encoder object.
This function accepts 5 inputs to define the appropriate pins and channels needed to use any encoder. Also defines variables needed when updating encoder outputs.
| timer_number | Variable for desired timer number |
| ch1_pin | Variable for desired chanel 1 pin |
| ch2_pin | Variable for desired chanel 2 pin |
| ch1_num | Variable for desired chanel 1 number |
| ch2_num | Variable for desired chanel 2 number |
| def Encoder_Driver.EncoderDriver.get_delta | ( | self | ) |
This function returns the most recent delta.
Returns the difference between the motor position at the last two position updates.
| def Encoder_Driver.EncoderDriver.get_position | ( | self | ) |
This function returns the current position of the motor.
This function converts the position value into units of degrees and then returns the most recent position.
| def Encoder_Driver.EncoderDriver.set_position | ( | self | ) |
This function sets the position of the motor to zero.
Sets the zero value to the current position of the motor so that during the next update the position will reflect the zero.
| def Encoder_Driver.EncoderDriver.update | ( | self | ) |
Function which consistently updates motor position.
Creates an array of two variables which upon every update is changed to reflect the most recent position and the last position. This array makes it easy to access the most recent position as well as the delta between the last update.