A Quadrature Encoder class to be used with the ME 405 test bench.
More...
|
|
| ch_A |
| | Channel A.
|
| |
|
| ch_B |
| | Channel B.
|
| |
|
| enc |
| | The timer channel to poll which collects encoder counts.
|
| |
|
| timer |
| | The Timer that tracks the encoder.
|
| |
|
| last_count |
| | The previous pulse count.
|
| |
|
| position |
| | The current absolute position as a count of pulses.
|
| |
|
| PPR |
| | The pulse rate (Pulses Per Revolution).
|
| |
A Quadrature Encoder class to be used with the ME 405 test bench.
Supports encoder polling at a frequency of up to 65536pps
◆ __init__()
| def drivers.Encoder.Encoder.__init__ |
( |
|
self, |
|
|
|
ch_A, |
|
|
|
ch_B, |
|
|
Timer |
timer, |
|
|
|
position = 0 |
|
) |
| |
Constructor for the Encoder object.
- Parameters
-
| ch_A | Pin on channel A |
| ch_B | Pin on channel B |
| timer | A Timer that will be used to track the encoder |
| position | An optional initial position |
◆ get_position()
| def drivers.Encoder.Encoder.get_position |
( |
|
self, |
|
|
|
units = "pulses" |
|
) |
| |
Get the current encoder position.
- Returns
- Return the current position in the specified units. If none are specified (or they are unrecognized) return the current position in pulses.
- Parameters
-
| units | The units to return. Supported units:
- pules - The number of edges (timer counts)
- cycles - The number of cycles for a quadrature encoder (cycles = pulses / 4)
- degrees - The total angle in degrees
- radians - The total angle in degrees
- revolutions - The total number of revolutions
|
◆ set_position()
| def drivers.Encoder.Encoder.set_position |
( |
|
self, |
|
|
|
position, |
|
|
|
units = "pulses" |
|
) |
| |
Set the current encoder position.
- Returns
- Return the current position in the specified units. If none are specified (or they are unrecognized) return the current position in pulses.
- Parameters
-
| position | The new value of the encoder position. |
| units | The units to return. Supported units:
- pules - The number of edges (timer counts)
- cycles - The number of cycles for a quadrature encoder (cycles = pulses / 4)
- degrees - The total angle in degrees
- radians - The total angle in degrees
- revolutions - The total number of revolutions
|
◆ update()
| def drivers.Encoder.Encoder.update |
( |
|
self | ) |
|
Update the current position and the last position.
Update the current position and the last position. Assumes that the encoder is updated at least once every half period of the timer and handles the overflow associated. Thus any counter value above half the period is assumed to be a backwards rotation.
The documentation for this class was generated from the following file: