Motor2

Dependents:   OneCircleRobot

Fork of Motor by Kiko Ishimoto

Revision:
1:4ab6e9768847
Parent:
0:1252cd3b995f
Child:
2:ef4a9c047681
--- a/Motor.cpp	Fri Jun 19 06:35:46 2015 +0000
+++ b/Motor.cpp	Tue Jul 21 08:11:59 2015 +0000
@@ -7,22 +7,28 @@
 motor(_pin_h1,_pin_g2,_pin_g1,_pin_h2),PwmPin(_pwm)
 {
     max=Max;
-    PwmPin.period_ms(10);
+    PwmPin.period_ms(1);
     run(Stop,1);
 }
+void Motor::setup(int _state)
+{
+    
+}
 void Motor::run(int i,float duty)
 {
     static int state;
-    Duty = duty/max;
+    Duty = (float)duty;
+    //printf("Duty %f \n",(float)duty);
     //if(state==i)return;
     PwmPin = Duty;
     if(state==i)return;
     Timer t;
     motor=0;
     //wait_us(20);
-    t.start();
+    /*t.start();
     t.reset();
-    while(t.read_us()>=20);
+    while(t.read_us()>=20);*/
+    wait_us(20);
     if(i==Front) motor=0x01|0x04;
     else if(i==Back) motor=0x02|0x08;
     else if(i==Stop) motor=0x01|0x08;
@@ -31,3 +37,5 @@
     state=i;
 }
 
+
+