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

Mostly abstract class that defines access methods and features for generic motors, to be used in a QPID unit. More...

#include <QPID_MotorDriver.h>

Inheritance diagram for QPID_MotorDriver:

Public Types

enum  decayModeType : uint8_t { decayModeFast = 0, decayModeSlow = 1 }
 Symbolic names for decay modes that should be used during inactive part of PWM phase, if the driver supports that functionality.
 

Public Member Functions

virtual void setPower (int16_t pow)
 (abstract) Set power to the motor, i.e. make the motor run, sign indicates direction (-maxPower to maxPower). Non PWM driven motors need to map their power range accordingly.
 
virtual void coast ()
 (abstract) cut power and let motor coast to a slow stop (fast decay stop), implies setSpeed(0) More...
 
virtual void brake ()
 (abstract) bring motor to abrupt stop (slow decay stop), implies setSpeed(0) More...
 
virtual void setDecay (decayModeType mode)
 (abstract) Set mode for PWM inactive phases, if available for driver used
 
virtual void setFrequency (uint8_t onoff)
 (abstract) Set PWM frequency
 
virtual void enable ()
 (abstract) enable by hardware (EN oder SLEEP Pin) More...
 
virtual void disable ()
 (abstract) sleep by hardware (EN oder SLEEP Pin) More...
 
virtual int8_t hasFault ()
 Reports on motor driver errors. Has a dummy implementation in the base class which always returns false/0 (no fault). Override in derived classes if the motor driver supports fault signaling. More...
 
- Public Member Functions inherited from QPID_Object
virtual void update ()
 (abstract) Can be overridden by QPID subsystems which need to do their own polling. Will be called by QPID_Unit::update() for subsystems, and by firmware/client for QPID_Unit itself.
 
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 Attributes

decayModeType decayMode = decayModeSlow
 
int16_t currentPWM = 0
 
int16_t maxPower
 
int16_t alwaysOnPWM
 

Additional Inherited Members

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

Detailed Description

Mostly abstract class that defines access methods and features for generic motors, to be used in a QPID unit.

Derived classes should look at this class's documantation and the example
QPID_MotorDriver_DRV8833 class.
Todo:

Initially developed with only DC motors in mind (PWM, frequency, decay etc.). I'd be better to have an even more generic class and derive QPID_DC_MotorDriver and QPID_Stepper_MotorDriver classes

(done) document abstract methods as implementation guide for derived classes. For now, look at sample DRV8833 class

(done) add fault signaling

Member Function Documentation

◆ coast()

virtual void QPID_MotorDriver::coast ( )
inlinevirtual

(abstract) cut power and let motor coast to a slow stop (fast decay stop), implies setSpeed(0)

See also
brake()

Reimplemented in QPID_MotorDriver_AdafruitMotorShieldV2, and QPID_MotorDriver_DRV8833.

◆ brake()

virtual void QPID_MotorDriver::brake ( )
inlinevirtual

(abstract) bring motor to abrupt stop (slow decay stop), implies setSpeed(0)

See also
coast()

Reimplemented in QPID_MotorDriver_AdafruitMotorShieldV2, and QPID_MotorDriver_DRV8833.

◆ enable()

virtual void QPID_MotorDriver::enable ( )
inlinevirtual

(abstract) enable by hardware (EN oder SLEEP Pin)

See also
disable()

Reimplemented in QPID_MotorDriver_AdafruitMotorShieldV2, and QPID_MotorDriver_DRV8833.

◆ disable()

virtual void QPID_MotorDriver::disable ( )
inlinevirtual

(abstract) sleep by hardware (EN oder SLEEP Pin)

See also
enable()

Reimplemented in QPID_MotorDriver_AdafruitMotorShieldV2, and QPID_MotorDriver_DRV8833.

◆ hasFault()

virtual int8_t QPID_MotorDriver::hasFault ( )
inlinevirtual

Reports on motor driver errors. Has a dummy implementation in the base class which always returns false/0 (no fault). Override in derived classes if the motor driver supports fault signaling.

Returns
False for no fault, true or specific fault number otherwise. Always false (0) in base class dummy implementation.

Reimplemented in QPID_MotorDriver_DRV8833, and QPID_MotorDriver_AdafruitMotorShieldV2.


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