PWM/Direction Motor Driver compatible with VNH3SP30 Motor Driver Carrier MD01B

Dependents:   RoboCup_2015

Committer:
OPSHUD
Date:
Sat Sep 27 07:18:56 2014 +0000
Revision:
0:be45415ffe07
Child:
1:4b1582384e71
Created Motor Driver Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OPSHUD 0:be45415ffe07 1 #include "MotorDriver.h"
OPSHUD 0:be45415ffe07 2 #include "mbed.h"
OPSHUD 0:be45415ffe07 3 MotorDriver::MotorDriver(PinName PWMPin, PinName directionPin1, PinName directionPin2) : mPWM(PWMPin),mDir1(directionPin1),mDir2(directionPin2) {
OPSHUD 0:be45415ffe07 4 this->SetValue(0);
OPSHUD 0:be45415ffe07 5 }
OPSHUD 0:be45415ffe07 6 void MotorDriver::SetValue(float value) {
OPSHUD 0:be45415ffe07 7 this->mValue = value;
OPSHUD 0:be45415ffe07 8 this->mDir1 = (mValue>0);
OPSHUD 0:be45415ffe07 9 this->mDir2 = !this->mDir1;
OPSHUD 0:be45415ffe07 10 this->mPWM = value;
OPSHUD 0:be45415ffe07 11 }
OPSHUD 0:be45415ffe07 12 MotorDriver& MotorDriver::operator=(float value) {
OPSHUD 0:be45415ffe07 13 /*if(value > 1.0) value = 1.0;
OPSHUD 0:be45415ffe07 14 if(value < -1.0) value = -1.0;*/
OPSHUD 0:be45415ffe07 15 this->SetValue(value);
OPSHUD 0:be45415ffe07 16 return *this;
OPSHUD 0:be45415ffe07 17 }
OPSHUD 0:be45415ffe07 18 float MotorDriver::GetValue() const {
OPSHUD 0:be45415ffe07 19 return this->mValue;
OPSHUD 0:be45415ffe07 20 }