reads a quadrature (incremental) encoder that is connected to a Byte Sized Encoder Decoder board connected over I2C to the main controller
More...
#include <JEncoderBSED.h>
|
| | JEncoderBSED (ByteSizedEncoderDecoder &_bsed, byte _encoderChannel, bool _reverse=false, float _distPerCountFactor=1.0, int16_t _slowestIntervalMicros=0, int16_t _encoderEnoughCounts=0) |
| | constructor, sets pins and settings
|
| |
| 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)
|
| |
| virtual void | setRev (bool _rev) |
| | empty function for directionless encoders to override
|
| |
reads a quadrature (incremental) encoder that is connected to a Byte Sized Encoder Decoder board connected over I2C to the main controller
◆ JEncoderBSED()
| JEncoderBSED::JEncoderBSED |
( |
ByteSizedEncoderDecoder & |
_bsed, |
|
|
byte |
_encoderChannel, |
|
|
bool |
_reverse = false, |
|
|
float |
_distPerCountFactor = 1.0, |
|
|
int16_t |
_slowestIntervalMicros = 0, |
|
|
int16_t |
_encoderEnoughCounts = 0 |
|
) |
| |
|
inline |
constructor, sets pins and settings
- Note
- Parameters
-
| _bsed | instance of BSED class |
| _encoderChannel | channel of encoder on BSED (1-8) |
| _reverse | false(default) |
| _distPerCountFactor | conversion factor for getting distance in an actual unit |
| _slowestIntervalMicros | after this many microseconds without an encoder tick velocity is set to zero. |
| _encoderEnoughCounts | enough counts to calculate velocity from |
◆ getCounter()
| long JEncoderBSED::getCounter |
( |
| ) |
|
|
inlinevirtual |
returns how far the encoder has turned from the zero position
- Note
- remember that variables overflow
- Return values
-
Reimplemented from JEncoder.
◆ getDistPerCountFactor()
| float JEncoderBSED::getDistPerCountFactor |
( |
| ) |
|
|
inlinevirtual |
returns a conversion factor between encoder ticks and distance that can be set for the encoder
- Note
- default is 1.0
- Return values
-
| (float) | distPerCountFactor |
Reimplemented from JEncoder.
◆ getPos()
| float JEncoderBSED::getPos |
( |
| ) |
|
|
inlinevirtual |
returns how far the encoder has turned from the zero position converted to distance
- Note
- remember that variables overflow (counter) and that floats have limited precision
- Return values
-
| (float) | encoder ticks converted to distance |
Reimplemented from JEncoder.
◆ getVel()
| float JEncoderBSED::getVel |
( |
| ) |
|
|
inlinevirtual |
calculates velocity in distance per second where distance was set by setdistPerCountFactor()
- Return values
-
Reimplemented from JEncoder.
◆ hasDirection()
| bool JEncoderBSED::hasDirection |
( |
| ) |
|
|
inlinevirtual |
can this encoder measure direction or just speed
- Return values
-
| (bool) | true = can measure direction |
Reimplemented from JEncoder.
◆ isVelNew()
| bool JEncoderBSED::isVelNew |
( |
| ) |
|
|
inlinevirtual |
could be useful for only recalculating a control loop if there's new velocity data
- Return values
-
| (bool) | true if velocity has changed since this function was last called |
Reimplemented from JEncoder.
◆ run()
| void JEncoderBSED::run |
( |
| ) |
|
|
inlinevirtual |
if an encoder needs to have some code called each loop (like absolute encoder polling encoder and calculating amount turned)
- Note
- interrupt based encoders don't need this to do anything and can define an empty function
Reimplemented from JEncoder.
◆ setDistPerCountFactor()
| void JEncoderBSED::setDistPerCountFactor |
( |
float |
_factor | ) |
|
|
inlinevirtual |
set the conversion factor between encoder ticks and distance
- Parameters
-
Reimplemented from JEncoder.
◆ setReverse()
| void JEncoderBSED::setReverse |
( |
bool |
_reverse | ) |
|
|
inline |
reverse readings of encoder
- Parameters
-
| _reverse | whether to invert sign of readings |
- Return values
-
◆ zeroCounter()
| long JEncoderBSED::zeroCounter |
( |
| ) |
|
|
inlinevirtual |
reset the counter of how far the encoder has turned
- Return values
-
| (long) | returns value of counter before it is reset |
Reimplemented from JEncoder.
◆ bsed
| ByteSizedEncoderDecoder& JEncoderBSED::bsed |
|
protected |
◆ distPerCountFactor
| float JEncoderBSED::distPerCountFactor |
|
protected |
◆ encoderChannel
| byte JEncoderBSED::encoderChannel |
|
protected |
◆ reverse
| int8_t JEncoderBSED::reverse |
|
protected |
◆ zeroVal
| int32_t JEncoderBSED::zeroVal |
|
protected |
The documentation for this class was generated from the following file: