uses a pin change interrupt library to support more pins than attachInterrupt().
More...
#include <JEncoderQuadraturePinChange.h>
|
| | JEncoderQuadraturePinChange (byte _encoderAPin, byte _encoderBPin, float _distPerCountFactor=1.0, bool _reverse=false, unsigned long _slowestIntervalMicros=100000UL) |
| | constructor, sets pins and settings
|
| |
| void | setUpInterrupts (void(*_isrAPointer)(void), void(*_isrBPointer)(void)) |
| | set up pins and interrupts
|
| |
| void | turnOffInterrupts () |
| | disable interrupts and stop monitoring encoder
|
| |
| long | zeroCounter () |
| | reset the counter of how far the encoder has turned
|
| |
| float | getVel () |
| | calculates velocity in distance per second where distance was set by setdistPerCountFactor()
|
| |
| long | getCounter () |
| | returns how far the encoder has turned from the zero position
|
| |
| float | getPos () |
| | returns how far the encoder has turned from the zero position converted to distance
|
| |
| float | getDistPerCountFactor () |
| | returns a conversion factor between encoder ticks and distance that can be set for the encoder
|
| |
| void | setDistPerCountFactor (float _factor) |
| | set the conversion factor between encoder ticks and distance
|
| |
| void | setReverse (bool _reverse) |
| | reverse readings of encoder
|
| |
| bool | hasDirection () |
| | can this encoder measure direction or just speed
|
| |
| bool | isVelNew () |
| | could be useful for only recalculating a control loop if there's new velocity data
|
| |
| void | run () |
| | if an encoder needs to have some code called each loop (like absolute encoder polling encoder and calculating amount turned)
|
| |
| void | ISRA (void) |
| |
| void | ISRB (void) |
| |
| virtual void | setRev (bool _rev) |
| | empty function for directionless encoders to override
|
| |
|
| | JEncoderQuadrature (byte _encoderAPin, byte _encoderBPin, float _distPerCountFactor=1.0, bool _reverse=false, unsigned long _slowestIntervalMicros=100000UL) |
| | constructor, sets pins and settings
|
| |
| byte | encoderAPin |
| |
| byte | encoderBPin |
| |
uses a pin change interrupt library to support more pins than attachInterrupt().
Interrupt library (tested with v1.1.0): https://github.com/GreyGnome/EnableInterrupt
platform: AVR (standard Arduinos)
- Note
- make sure to call setUpInterrupts() when your code starts
◆ JEncoderQuadraturePinChange()
| JEncoderQuadraturePinChange::JEncoderQuadraturePinChange |
( |
byte |
_encoderAPin, |
|
|
byte |
_encoderBPin, |
|
|
float |
_distPerCountFactor = 1.0, |
|
|
bool |
_reverse = false, |
|
|
unsigned long |
_slowestIntervalMicros = 100000UL |
|
) |
| |
|
inline |
constructor, sets pins and settings
- Parameters
-
| _encoderAPin | one channel of quadrature encoder |
| _encoderBPin | other channel of quadrature encoder |
| _distPerCountFactor | conversion factor for getting distance in an actual unit |
| _reverse | false(default) |
| _slowestIntervalMicros | after this many microseconds without an encoder tick velocity is set to zero. |
◆ setUpInterrupts()
| void JEncoderQuadraturePinChange::setUpInterrupts |
( |
void(*)(void) |
_isrAPointer, |
|
|
void(*)(void) |
_isrBPointer |
|
) |
| |
|
inlinevirtual |
set up pins and interrupts
- Parameters
-
| _isrAPointer | global function that calls internal ISRA, to use with enableInterrupt |
| _isrBPointer | global function that calls internal ISRB, to use with enableInterrupt |
Reimplemented from JEncoderQuadrature.
◆ turnOffInterrupts()
| void JEncoderQuadraturePinChange::turnOffInterrupts |
( |
| ) |
|
|
inlinevirtual |
disable interrupts and stop monitoring encoder
- Note
- use setUpInterrupts to start encoder again
Reimplemented from JEncoderQuadrature.
The documentation for this class was generated from the following file: