JMotor
Loading...
Searching...
No Matches
Public Member Functions | List of all members
JEncoderQuadratureAttachInterrupt Class Reference

uses attachInterrupt() platform: esp32, teensy (could be used with standard avr arduinos but only with pins that support attachInterrupt()) More...

#include <JEncoderQuadratureAttachInterrupt.h>

Inheritance diagram for JEncoderQuadratureAttachInterrupt:
Inheritance graph
[legend]
Collaboration diagram for JEncoderQuadratureAttachInterrupt:
Collaboration graph
[legend]

Public Member Functions

 JEncoderQuadratureAttachInterrupt (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
 
- Public Member Functions inherited from JEncoderQuadrature
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)
 
- Public Member Functions inherited from JEncoder
virtual void setRev (bool _rev)
 empty function for directionless encoders to override
 

Additional Inherited Members

- Protected Member Functions inherited from JEncoderQuadrature
 JEncoderQuadrature (byte _encoderAPin, byte _encoderBPin, float _distPerCountFactor=1.0, bool _reverse=false, unsigned long _slowestIntervalMicros=100000UL)
 constructor, sets pins and settings
 
- Protected Attributes inherited from JEncoderQuadrature
byte encoderAPin
 
byte encoderBPin
 

Detailed Description

uses attachInterrupt() platform: esp32, teensy (could be used with standard avr arduinos but only with pins that support attachInterrupt())

Note
make sure to call setUpInterrupts() when your code starts

Constructor & Destructor Documentation

◆ JEncoderQuadratureAttachInterrupt()

JEncoderQuadratureAttachInterrupt::JEncoderQuadratureAttachInterrupt ( byte  _encoderAPin,
byte  _encoderBPin,
float  _distPerCountFactor = 1.0,
bool  _reverse = false,
unsigned long  _slowestIntervalMicros = 100000UL 
)
inline

constructor, sets pins and settings

Parameters
_encoderAPinone channel of quadrature encoder
_encoderBPinother channel of quadrature encoder
_distPerCountFactorconversion factor for getting distance in an actual unit
_reversefalse(default)
_slowestIntervalMicrosafter this many microseconds without an encoder tick velocity is set to zero.

Member Function Documentation

◆ setUpInterrupts()

void JEncoderQuadratureAttachInterrupt::setUpInterrupts ( void(*)(void)  _isrAPointer,
void(*)(void)  _isrBPointer 
)
inlinevirtual

set up pins and interrupts

Parameters
_isrAPointerglobal function that calls internal ISRA, to use with enableInterrupt
_isrBPointerglobal function that calls internal ISRB, to use with enableInterrupt

Reimplemented from JEncoderQuadrature.

◆ turnOffInterrupts()

void JEncoderQuadratureAttachInterrupt::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: