Sample for TB6612FNG without library

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ppr2013G2
Date:
Fri Jul 01 05:00:12 2016 +0000
Commit message:
TB6612FNG sample without library;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 0c3d3031e710 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 01 05:00:12 2016 +0000
@@ -0,0 +1,63 @@
+#include "mbed.h"
+
+#define LOW 0
+#define HIGH 1
+
+PwmOut pwmA(PTC9);
+DigitalOut Ain1(PTB1);
+DigitalOut Ain2(PTB0);
+PwmOut pwmB(PTA1);
+DigitalOut Bin1(PTB3);
+DigitalOut Bin2(PTC2);
+DigitalOut Stby(PTB2);
+
+int main() {
+    float p_a = 0.00002f;//50KHz
+    float p_b = 0.00002f;
+    float pw_a = 1.0;//duty cycle 0.0~1.0 ->  0%~100%
+    float pw_b = 1.0;
+    
+    pwmA.period(p_a);
+    pwmB.period(p_b);
+    
+    pwmA = pw_a;
+    pwmB = pw_b;
+    
+    while(1) {
+        //CW
+        Stby = HIGH;
+        
+        Ain1 = HIGH;
+        Ain2 = LOW;
+        
+        Bin1 = HIGH;
+        Bin2 = LOW;
+        
+        wait(5);
+        
+        //STBY
+        Stby = LOW;
+        
+        wait(5);
+        
+        //CCW
+        Stby = HIGH;
+        Ain1 = LOW;
+        Ain2 = HIGH;
+        
+        Bin1 = LOW;
+        Bin2 = HIGH;
+        
+        wait(5);
+        
+        //STOP
+        Ain1 = LOW;
+        Ain2 = LOW;
+        
+        Bin1 = LOW;
+        Bin2 = LOW;
+        
+        wait(5);
+        
+    }
+}
diff -r 000000000000 -r 0c3d3031e710 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 01 05:00:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file