tetsuya Ogata / TA8428

Dependents:   Enpra_practice06

Files at this revision

API Documentation at this revision

Comitter:
ogata_lab
Date:
Wed May 29 13:02:47 2013 +0000
Commit message:
First Commit

Changed in this revision

TA8428.cpp Show annotated file Show diff for this revision Revisions of this file
TA8428.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TA8428.cpp	Wed May 29 13:02:47 2013 +0000
@@ -0,0 +1,37 @@
+/**
+ * @file TA8428.cpp
+ * @brief This library is for controlling TA8428 (full-bridge driver (mainly for motor drive.)
+ * @author Yuki Suga
+ * @mail ysuga@ysuga.net
+ * @affilication Ogata Laboratory, Waseda University
+ * @url http://ogata-lab.jp/
+ * @copyright 2013, Ogata Laboratory
+ * @license public domain
+ */
+ 
+#include "mbed.h"
+#include "TA8428.h"
+
+
+TA8428::TA8428(PinName pin0, PinName pin1, const float period) :
+p0(pin0), p1(pin1) 
+{
+  p0.period(period);
+  p1.period(period);
+}
+
+TA8428::~TA8428()
+{
+
+}
+
+void TA8428::drive(const float pwmPercent)
+{
+  if (pwmPercent < 0) {
+    p0.write(0.0);
+    p1.write(-pwmPercent);
+  } else {
+    p0.write(pwmPercent);
+    p1.write(0.0);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TA8428.h	Wed May 29 13:02:47 2013 +0000
@@ -0,0 +1,41 @@
+/**
+ * @file TA8428.h
+ * @brief This library is for controlling TA8428 (full-bridge driver (mainly for motor drive.)
+ * @author Yuki Suga
+ * @mail ysuga@ysuga.net
+ * @affilication Ogata Laboratory, Waseda University
+ * @url http://ogata-lab.jp/
+ * @copyright 2013, Ogata Laboratory
+ * @license public domain
+ */
+#ifndef TA8428_HEADER_INCLUDED
+#define TA8428_HEADER_INCLUDED
+
+class TA8428 {
+private:
+  PwmOut p0;
+  PwmOut p1;
+  
+  float period;
+
+
+public:
+public:
+  /**
+   * @brief Constructor
+   *
+   * @param pin0 PWM pin, in mbed p21 - 26
+   * @param pin1 PWM pin, in mbed p21 - 26
+   */
+  TA8428(PinName pin0, PinName pin1, const float period=0.020);
+  
+  ~TA8428();
+  
+  /**
+   * @param pwmPercent [-1.0, 1.0]
+   */
+  void drive(const float pwmPercent);
+
+};
+
+#endif
\ No newline at end of file