QPIDfirmware  v0.1
Object oriented firmware for autonomous motor drivers with encoder based PID controller and flexible interface
QPID_Encoder_QuadratureStateMachine Class Reference

Implements a state machine quadrature encoder based on Matthias Hertel's rotary library More...

Inheritance diagram for QPID_Encoder_QuadratureStateMachine:

Public Member Functions

double getCount ()
 Returns current incremental position.
 
void setCount (double count)
 set count of current encoder position More...
 
void clearCount ()
 set count of current encoder position to 0
 
void pauseCount ()
 Ignore any pulses until resumeCount() is called.
 
void resumeCount ()
 Resume counting, after having it stopped by pauseCount()
 
double getTicksPerRevolution ()
 ...
 
void update () override
 Polls encoder.
 
void init (double ticks, uint8_t PinA, uint8_t pinB)
 Attach rotary encoder to pins, initialize and clear position to 0. More...
 
- Public Member Functions inherited from QPID_Encoder
void setFilter (double value)
 Set filter to smoothen faulty or jittery absolute readings. More...
 
double getFilteredCount ()
 Returns current position count with filter setting applied. More...
 
- Public Member Functions inherited from QPID_Object
void throwError (const char *invokedBy, const char *errorMessage)
 Writes error message and error invoking class to Serial. More...
 
void log (const char *logEntry)
 Puts timestamped string into the system log (atm: writes it out to Serial). More...
 

Protected Member Functions

bool processMessage (uint8_t *m) override
 (abstract) Interprets message handed down from QPID_Unit locally. Must be overridden in derived classes
 
- Protected Member Functions inherited from QPID_Object
 QPID_Object ()
 Constructor. Begins Serial with 115200 baud for logging and error reporting, if not done previously.
 

Additional Inherited Members

- Public Attributes inherited from QPID_Encoder
double ticksPerRevolution
 
- Protected Attributes inherited from QPID_Encoder
double filter = 0
 
double lastCount = 0
 

Detailed Description

Implements a state machine quadrature encoder based on Matthias Hertel's rotary library

QPID_Encoder)

Note
This is a demo implementation which relies on polling via QPID subsystem polling (cf. QPID_Object::update() ). I assume this could be unreliable for fast counting, as polling/update frequency depends on QPID_Unit main update speed. A better implememtation would do the polling via timed interrupt (not pin change interrupt, this is a state machine encoder!), however this would have to be implemented per architecture.
Todo:
check private, protected etc. for all derived classes

Member Function Documentation

◆ setCount()

void QPID_Encoder_QuadratureStateMachine::setCount ( double  count)
virtual

set count of current encoder position

Parameters
countposition to set

Reimplemented from QPID_Encoder.

◆ init()

void QPID_Encoder_QuadratureStateMachine::init ( double  ticks,
uint8_t  pinA,
uint8_t  pinB 
)

Attach rotary encoder to pins, initialize and clear position to 0.

Parameters
ticksticks per revolution
pinA,pinBencoder pins

The documentation for this class was generated from the following files: