The Encoder class reads ticks from a quadrature encoder and converts them to the shaft position in rotations.
More...
|
|
| timer |
| | the pyb.Timer object to read from the input pins
|
| |
| | ticksPerRev |
| | The total number of timer ticks in a revolution. More...
|
| |
|
| CH1 |
| | The first channel of the encoder.
|
| |
|
| CH2 |
| | The seccond channel of the encoder.
|
| |
|
| position |
| | The current recorded position of the encoder, in rotations from initialization.
|
| |
|
| prevPosition |
| | The previous position of the encoder, in rotations from initialization.
|
| |
|
| prevTick1 |
| | The previous tick count of encoder channel 1, self.CH1.
|
| |
|
| prevTick2 |
| | The previous tick count of encoder channel 2, self.CH2.
|
| |
|
| lastPrintedPostion |
| | The last position printed to the console for debugging.
|
| |
The Encoder class reads ticks from a quadrature encoder and converts them to the shaft position in rotations.
◆ __init__()
| def encoderDriver.Encoder.__init__ |
( |
|
self, |
|
|
|
IN1_pin, |
|
|
|
IN2_pin, |
|
|
|
timer, |
|
|
|
ticksPerRev = 4000 |
|
) |
| |
Method to initialise an Encoder object.
- Parameters
-
| IN1_pin | The pyb.Pin object connected to channel one of the encoder. |
| IN2_pin | The pyb.Pin object connected to channel two of the encoder. |
| timer | The pyb.Timer object to read from the input pins. |
| ticksPerRev | The total number of timer ticks in a revolution. Include both channels' rising and falling edges. |
◆ get_degrees()
| def encoderDriver.Encoder.get_degrees |
( |
|
self | ) |
|
Method to get the last read position of the encoder.
- Returns
- The last read position of the encoder, in degrees.
◆ get_delta()
| def encoderDriver.Encoder.get_delta |
( |
|
self | ) |
|
Method to get the difference between the last two position readings.
- Returns
- The difference of the last two position readings, in rotations.
◆ get_position()
| def encoderDriver.Encoder.get_position |
( |
|
self | ) |
|
Method to get the last read position of the encoder.
- Returns
- The last read position of the encoder, in rotations.
◆ get_radians()
| def encoderDriver.Encoder.get_radians |
( |
|
self | ) |
|
Method to get the last read position of the encoder.
- Returns
- The last read position of the encoder, in radians.
◆ set_position()
| def encoderDriver.Encoder.set_position |
( |
|
self, |
|
|
|
pos = 0 |
|
) |
| |
Method to reset the position of the encoder to a given value.
- Parameters
-
| pos | The position to set the encoder position to, in rotations. |
◆ ticksPerRev
| encoderDriver.Encoder.ticksPerRev |
The total number of timer ticks in a revolution.
Include both channels' rising and falling edges.
The documentation for this class was generated from the following file: