Exploring BeagleBone  V1.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions
exploringBB::DCMotor Class Reference

A generic DC motor class that controls a motor driver board using a PWM signal,and a GPIO state to control the motor direction. More...

#include <DCMotor.h>

Public Types

enum  DIRECTION { CLOCKWISE, ANTICLOCKWISE }
 

Public Member Functions

 DCMotor (PWM *pwm, GPIO *gpio)
 
 DCMotor (PWM *pwm, int gpioNumber)
 
 DCMotor (PWM *pwm, GPIO *gpio, DCMotor::DIRECTION direction)
 
 DCMotor (PWM *pwm, int gpioNumber, DCMotor::DIRECTION direction)
 
 DCMotor (PWM *pwm, GPIO *gpio, DCMotor::DIRECTION direction, float speedPercent)
 
 DCMotor (PWM *pwm, int gpioNumber, DCMotor::DIRECTION direction, float speedPercent)
 
virtual void go ()
 
virtual void setSpeedPercent (float speedPercent)
 
virtual float getSpeedPercent ()
 
virtual void setDirection (DIRECTION direction)
 
virtual DIRECTION getDirection ()
 
virtual void reverseDirection ()
 
virtual void stop ()
 
virtual void setDutyCyclePeriod (unsigned int period_ns)
 
virtual ~DCMotor ()
 

Detailed Description

A generic DC motor class that controls a motor driver board using a PWM signal,and a GPIO state to control the motor direction.

Member Enumeration Documentation

Enumerator
CLOCKWISE 
ANTICLOCKWISE 
Definition: DCMotor.h:42
Definition: DCMotor.h:42

Constructor & Destructor Documentation

exploringBB::DCMotor::DCMotor ( PWM pwm,
GPIO gpio 
)
29  {
30  init(pwm, gpio, CLOCKWISE, DEFAULT_DCMOTOR_SPEED);
31 }
#define DEFAULT_DCMOTOR_SPEED
Definition: DCMotor.h:31
Definition: DCMotor.h:42
exploringBB::DCMotor::DCMotor ( PWM pwm,
int  gpioNumber 
)
33  {
34  this->gpio = new GPIO(gpioNumber);
35  this->gpio->setDirection(GPIO::OUTPUT);
36  init(pwm, this->gpio, CLOCKWISE, DEFAULT_DCMOTOR_SPEED);
37 }
#define DEFAULT_DCMOTOR_SPEED
Definition: DCMotor.h:31
Definition: GPIO.h:48
Definition: DCMotor.h:42
virtual int setDirection(GPIO::DIRECTION)
Definition: GPIO.cpp:120
exploringBB::DCMotor::DCMotor ( PWM pwm,
GPIO gpio,
DCMotor::DIRECTION  direction 
)
39  {
40  init(pwm, gpio, direction, DEFAULT_DCMOTOR_SPEED);
41 }
#define DEFAULT_DCMOTOR_SPEED
Definition: DCMotor.h:31
exploringBB::DCMotor::DCMotor ( PWM pwm,
int  gpioNumber,
DCMotor::DIRECTION  direction 
)
43  {
44  this->gpio = new GPIO(gpioNumber);
45  this->gpio->setDirection(GPIO::OUTPUT);
46  init(pwm, this->gpio, direction, DEFAULT_DCMOTOR_SPEED);
47 }
#define DEFAULT_DCMOTOR_SPEED
Definition: DCMotor.h:31
Definition: GPIO.h:48
virtual int setDirection(GPIO::DIRECTION)
Definition: GPIO.cpp:120
exploringBB::DCMotor::DCMotor ( PWM pwm,
GPIO gpio,
DCMotor::DIRECTION  direction,
float  speedPercent 
)
49  {
50  init(pwm, gpio, direction, speedPercent);
51 }
exploringBB::DCMotor::DCMotor ( PWM pwm,
int  gpioNumber,
DCMotor::DIRECTION  direction,
float  speedPercent 
)
53  {
54  this->gpio = new GPIO(gpioNumber);
55  this->gpio->setDirection(GPIO::OUTPUT);
56  init(pwm, this->gpio, direction, speedPercent);
57 }
Definition: GPIO.h:48
virtual int setDirection(GPIO::DIRECTION)
Definition: GPIO.cpp:120
exploringBB::DCMotor::~DCMotor ( )
virtual
108  {
109  delete gpio;
110 }

Member Function Documentation

virtual DIRECTION exploringBB::DCMotor::getDirection ( )
inlinevirtual
60 { return this->direction; }
virtual float exploringBB::DCMotor::getSpeedPercent ( )
inlinevirtual
58 { return this->speedPercent; }
void exploringBB::DCMotor::go ( )
virtual
100  {
101  this->pwm->run();
102 }
virtual int run()
Definition: PWM.cpp:114
void exploringBB::DCMotor::reverseDirection ( )
virtual
87  {
88  if(this->direction == CLOCKWISE){
90  }
91  else{
92  this->setDirection(CLOCKWISE);
93  }
94 }
virtual void setDirection(DIRECTION direction)
Definition: DCMotor.cpp:77
Definition: DCMotor.h:42
Definition: DCMotor.h:42
void exploringBB::DCMotor::setDirection ( DIRECTION  direction)
virtual
77  {
78  if(direction == CLOCKWISE){
79  this->gpio->setValue(GPIO::HIGH);
80  }
81  else{
82  this->gpio->setValue(GPIO::LOW);
83  }
84  this->direction = direction;
85 }
Definition: GPIO.h:49
Definition: GPIO.h:49
Definition: DCMotor.h:42
virtual int setValue(GPIO::VALUE)
Definition: GPIO.cpp:130
void exploringBB::DCMotor::setDutyCyclePeriod ( unsigned int  period_ns)
virtual
104  {
105  this->pwm->setPeriod(period_ns);
106 }
virtual int setPeriod(unsigned int period_ns)
Definition: PWM.cpp:38
void exploringBB::DCMotor::setSpeedPercent ( float  speedPercent)
virtual
72  {
73  this->pwm->setDutyCycle(speedPercentage);
74  this->speedPercent = speedPercentage;
75 }
virtual int setDutyCycle(unsigned int duration_ns)
Definition: PWM.cpp:64
void exploringBB::DCMotor::stop ( )
virtual
96  {
97  this->pwm->stop();
98 }
virtual int stop()
Definition: PWM.cpp:123

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