Smart Car Controller  1.0
LIbrary to manage a Smart Car Robot
MD_DCMotor Class Referenceabstract

#include <MD_DCMotor.h>

Inheritance diagram for MD_DCMotor:

Public Types

Enumerated values and Typedefs.
enum  runCmd_t { DIR_FWD , DIR_REV , DIR_STOP }
 

Public Member Functions

Methods for core object control.
virtual void begin (void)=0
 
virtual void run (runCmd_t cmd, uint8_t speed)=0
 
virtual void setSpeed (uint16_t s)=0
 
uint16_t getSpeed ()
 

Protected Attributes

runCmd_t _mode
 The current mode for the motor.
 
uint16_t _speed
 The current speed setting for the motor.
 

Detailed Description

Core object for the MD_DCMotor class

This class is a simple abstraction for PWM motor controllers that use 2 digital pins for direction control and PWM for speed control.

Member Enumeration Documentation

◆ runCmd_t

Define the different motor commands/states

These commands are used to direct the different modes of running the DC motors allowed by the controller.

Enumerator
DIR_FWD 

Rotate in forward direction.

DIR_REV 

Rotate in reverse direction (opposite of DIR_FWD).

DIR_STOP 

Stop the motor. This should brake if possible.

Member Function Documentation

◆ begin()

virtual void MD_DCMotor::begin ( void  )
pure virtual

Initialize the object.

Initialize the object data. This needs to be called during setup() to initialize new data for the class that cannot be done during the object creation.

Implemented in MD_DCMotor_M1508, and MD_DCMotor_L298.

◆ getSpeed()

uint16_t MD_DCMotor::getSpeed ( )

Get the currently set speed for the motor.

Returns the current speed setting

Returns
the speed setting.

◆ run()

virtual void MD_DCMotor::run ( runCmd_t  cmd,
uint8_t  speed 
)
pure virtual

Run/Stop the motor with speed.

This controls how the motor runs/stops. This is a convenience wrapper for the run() and setSpeed() methods. The command specified is one of the runCmd_t values and the speed must be suitable for the setSpeed() method.

See also
setSpeed(), run()
Parameters
cmdthe run/stop mode.
speedthe speed to run at.

Implemented in MD_DCMotor_M1508, and MD_DCMotor_L298.

◆ setSpeed()

virtual void MD_DCMotor::setSpeed ( uint16_t  s)
pure virtual

Set the speed for the motor.

This controls the speed setting for the motor. This is replaced with a method to implement the specifics for the derived class.

Parameters
sthe speed setting appropriate for the controller type.

Implemented in MD_DCMotor_M1508, and MD_DCMotor_L298.


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