Tohshiba motor driver IC TA8429 class
Revision 0:a56d6efd9c85, committed 2014-07-07
- Comitter:
- macht
- Date:
- Mon Jul 07 09:55:53 2014 +0000
- Commit message:
- TA8429 motor driver IC class
Changed in this revision
TA8429.cpp | Show annotated file Show diff for this revision Revisions of this file |
TA8429.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TA8429.cpp Mon Jul 07 09:55:53 2014 +0000 @@ -0,0 +1,31 @@ +#include "TA8429.h" + +TA8429::TA8429(PinName in1,PinName in2,float frequency):in1_ (in1),in2_(in2){ + in1_.period(1/frequency); + in2_.period(1/frequency); +} + +void TA8429::set_CW(float duty){ + if(duty < 0.0){ + duty = 0.0; + } + if(duty >1.0){ + duty = 1.0; + } + in1_ = 1.0; + in2_ = 1.0-duty; +} +void TA8429::set_CCW(float duty){ + if(duty < 0.0){ + duty = 0.0; + } + if(duty >1.0){ + duty = 1.0; + } + in2_ = 1.0; + in1_ = 1.0-duty; +} +void TA8429::stop(){ + in1_ = 1.0; + in2_ = 1.0; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TA8429.h Mon Jul 07 09:55:53 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef TA8429_H +#define TA8429_H +#include "mbed.h" + +class TA8429{ + public: + TA8429(PinName in1,PinName in2,float frequency); + void set_CW(float duty); + void set_CCW(float duty); + void stop(); + float get_duty(void); + private: + PwmOut in1_; + PwmOut in2_; +}; +#endif \ No newline at end of file