y ishida / Mbed 2 deprecated RESTServer_team4

Dependencies:   NySNICInterface mbed-rtos mbed

Fork of RESTServerSample by KDDI Fx0 hackathon

Files at this revision

API Documentation at this revision

Comitter:
oks486
Date:
Sun Feb 15 02:55:36 2015 +0000
Parent:
3:f9d5cdce80dd
Child:
5:70c9f6045f2d
Commit message:
add motor control with pwm

Changed in this revision

RESTServerSample.lib Show diff for this revision Revisions of this file
control_motors.cpp Show annotated file Show diff for this revision Revisions of this file
control_motors.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RESTServerSample.lib	Sun Feb 15 01:02:58 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/KDDI-Fx0-hackathon/code/RESTServerSample/#998e2e00df0c
--- a/control_motors.cpp	Sun Feb 15 01:02:58 2015 +0000
+++ b/control_motors.cpp	Sun Feb 15 02:55:36 2015 +0000
@@ -71,12 +71,39 @@
         
         // TODO
         // モーター制御の処理
-        
+            if(speed > 0){
+            mPwmMotorR = (float)speed/255;
+            mDoutMotorR1 = 1;
+            mDoutMotorR2 = 0;
+        }else if (speed < 0){
+            mPwmMotorR = -(float)speed/255;
+            mDoutMotorR1 = 0;
+            mDoutMotorR2 = 1;
+        }else{
+            mPwmMotorR = 0;
+            mDoutMotorR1 = 0;
+            mDoutMotorR2 = 0;
+        }
+
     }else if(motor_id == MOTOR_LEFT){
         printf("motor left speed = %d\n", speed);
         
         // TODO
         // モーター制御の処理
+       if(speed > 0){
+            mPwmMotorL = (float)speed/255;
+            mDoutMotorL1 = 1;
+            mDoutMotorL2 = 0;
+        }else if (speed < 0){
+            mPwmMotorL = -(float)speed/255;
+            mDoutMotorL1 = 0;
+            mDoutMotorL2 = 1;
+        }else{
+            mPwmMotorL = 0.0;
+            mDoutMotorL1 = 0;
+            mDoutMotorL2 = 0;
+        }
+
     }
 }
 
@@ -86,6 +113,10 @@
 
     // TODO
     // モーター制御の処理
+    mPwmMotorTail = 0.8;
+    mDoutMotorTail1 = 1;
+    mDoutMotorTail2 = 0;
+
 }
 
     
@@ -94,4 +125,8 @@
 
     // TODO
     // モーター制御の処理
+    mPwmMotorTail = 0.0;
+    mDoutMotorTail1 = 0;
+    mDoutMotorTail2 = 0;
+
 }
--- a/control_motors.h	Sun Feb 15 01:02:58 2015 +0000
+++ b/control_motors.h	Sun Feb 15 02:55:36 2015 +0000
@@ -10,3 +10,14 @@
 void start_shaking_tail();
 void stop_shaking_tail();
 
+extern PwmOut mPwmMotorL;
+extern DigitalOut mDoutMotorL1;
+extern DigitalOut mDoutMotorL2;
+
+extern PwmOut mPwmMotorR;
+extern DigitalOut mDoutMotorR1;
+extern DigitalOut mDoutMotorR2;
+
+extern PwmOut mPwmMotorTail;
+extern DigitalOut mDoutMotorTail1;
+extern DigitalOut mDoutMotorTail2;
--- a/main.cpp	Sun Feb 15 01:02:58 2015 +0000
+++ b/main.cpp	Sun Feb 15 02:55:36 2015 +0000
@@ -42,6 +42,20 @@
 //C_SNIC_WifiInterface     mSNICwifi( p13, p14, p12, p11, p20 );
 C_SNIC_WifiInterface     mSNICwifi( p9, p10, NC, NC, p30 );
 
+// Left motor
+PwmOut mPwmMotorL(p23);
+DigitalOut mDoutMotorL1(p15);
+DigitalOut mDoutMotorL2(p16);
+
+// Rigth motor
+PwmOut mPwmMotorR(p22);
+DigitalOut mDoutMotorR1(p18);
+DigitalOut mDoutMotorR2(p17);
+
+// Tail motor
+PwmOut mPwmMotorTail(p21);
+DigitalOut mDoutMotorTail1(p19);
+DigitalOut mDoutMotorTail2(p20);
 
 
 void wifi_connect()
@@ -80,6 +94,10 @@
 {
     // for debug
     pc.baud( 115200 );
+    
+    mPwmMotorL.period_ms(20);
+    mPwmMotorR.period_ms(20);
+    mPwmMotorTail.period_ms(20);
 
     wifi_connect();