|
ME 405 Romi
|
The Encoder Diver Class. More...
Public Member Functions | |
| __init__ (self, tim, chA_pin, chB_pin) | |
| Encoder Initialization. | |
| update (self) | |
| Encoder Update. | |
| get_position (self) | |
| Encoder Position Get. | |
| get_velocity (self) | |
| Encoder Velocity Get. | |
| zero (self) | |
| Zero the Encoder. | |
| get_dt (self) | |
| Get dt. | |
| set_offset (self, offset) | |
| Set Offset. | |
Public Attributes | |
| int | position = 0 |
| int | prev_count = 0 |
| int | delta = 0 |
| int | dt = 0 |
| int | last_time = 0 |
| int | current_time = 0 |
| tim = tim | |
| int | offset = 0 |
| timCh_A = tim.channel(1, pin=chA_pin, mode=Timer.ENC_A) | |
| timCh_B = tim.channel(2, pin=chB_pin, mode=Timer.ENC_B) | |
The Encoder Diver Class.
A quadrature encoder decoding interface encapsulated in a Python class
Definition at line 6 of file encoder.py.
| encoder.Encoder.__init__ | ( | self, | |
| tim, | |||
| chA_pin, | |||
| chB_pin ) |
Encoder Initialization.
| P1 | Timer Used |
| P2 | Channel A pin |
| P3 | Channel B pin |
Definition at line 12 of file encoder.py.
| encoder.Encoder.get_dt | ( | self | ) |
| encoder.Encoder.get_position | ( | self | ) |
Encoder Position Get.
Returns the most recently updated value of position as determined within the update() method
Definition at line 49 of file encoder.py.
| encoder.Encoder.get_velocity | ( | self | ) |
Encoder Velocity Get.
Returns a measure of velocity using the most recently updated value of delta as determined within the update() method
Definition at line 55 of file encoder.py.
| encoder.Encoder.set_offset | ( | self, | |
| offset ) |
| encoder.Encoder.update | ( | self | ) |
Encoder Update.
Runs one update step on the encoder's timer counter to keep track of the change in count and check for counter reload
Definition at line 30 of file encoder.py.
| encoder.Encoder.zero | ( | self | ) |
Zero the Encoder.
Sets the present encoder position to zero and causes future updates to measure with respect to the new zero position
Definition at line 61 of file encoder.py.
| int encoder.Encoder.current_time = 0 |
Definition at line 19 of file encoder.py.
| int encoder.Encoder.delta = 0 |
Definition at line 16 of file encoder.py.
| encoder.Encoder.dt = 0 |
Definition at line 17 of file encoder.py.
| int encoder.Encoder.last_time = 0 |
Definition at line 18 of file encoder.py.
| int encoder.Encoder.offset = 0 |
Definition at line 21 of file encoder.py.
| int encoder.Encoder.position = 0 |
Definition at line 14 of file encoder.py.
| int encoder.Encoder.prev_count = 0 |
Definition at line 15 of file encoder.py.
| encoder.Encoder.tim = tim |
Definition at line 20 of file encoder.py.
| encoder.Encoder.timCh_A = tim.channel(1, pin=chA_pin, mode=Timer.ENC_A) |
Definition at line 23 of file encoder.py.
| encoder.Encoder.timCh_B = tim.channel(2, pin=chB_pin, mode=Timer.ENC_B) |
Definition at line 24 of file encoder.py.