PS3 version

Dependencies:   Motor_NIT_Nagaoka_College PID QEI SoftServo SoftPWM mbed DebounceIn

Fork of NHK2015 by mbedを用いた制御学生の制御

Revision:
20:e05fdab66e68
Parent:
19:f1c567cb5bb8
Child:
21:5ca943882097
--- a/main.cpp	Sat Oct 10 06:27:50 2015 +0000
+++ b/main.cpp	Sun Oct 18 01:06:45 2015 +0000
@@ -15,7 +15,7 @@
 PwmOut Rl(LED2);
 Servo L(p25);
 Servo R(p26);
-PID Tp(50,40000,0,0.001);
+PID Tp(50,4000000,0,0.001);
 //PID Tp(4.,40000,0,0.001);
 BusOut led(p8,p13,p14,p24);
 Motor ot(p23,p19,p20);
@@ -64,7 +64,7 @@
     air = 0;
     i = 0;
     out = 1;
-    supply();
+    //supply();
 }
 void rev()
 {
@@ -88,12 +88,34 @@
     led= 15;
     conn.baud(38400);
     while(1) {
+        //ps3コントローラーシリアル受信
         if(conn.getc() == 255) {
             read = conn.getc();
-            ttilt = conn.getc()-30;
+            ttilt = conn.getc()-60;
             ro = (conn.getc()-127)/127.0*0.9;
             lo = (conn.getc()-127)/127.0*0.9;
         }
+        //nara シリアル受信
+        if(slave.avaiable(){
+            narasup = slave.getc();
+        }
+        if(narasup == 1){
+            sup1_speed(0.9);
+            sup2_speed(0);
+        }else if (narasup == 2){
+            sup1_speed(-0.9);
+            sup2_speed(0);
+        }else if (narasup == 4){
+            sup2_speed(0.9);
+            sup1_speed(0);
+        }else if (narasup ==8){
+            sup2_speed(-0.9);
+            sup1_speed(0);
+        }else {
+            sup1_speed(0);
+            sup2_speed(0);
+        }
+            
         if(read>4){
             read = 0;
         }
@@ -104,7 +126,7 @@
             i = 1;
         }
         /*補給制御*/
-        if(limit1 == 0) {
+        /*if(limit1 == 0) {
             su1 = 1;
         }
         if(limit2 == 0){
@@ -117,9 +139,9 @@
         if(limit2 == 1 && su2 == 1) {
             su2 = 0;
             sup2_speed(0);
-        }
+        }*/
         /*射角制御*/
-        Tp.setSetPoint(ttilt);
+        Tp.setSetPoint(ttilt/2.0);
         tilt = double(sensort.getPulses());
         tilt = tilt*49.0/1745.0;
         Tp.setProcessValue(tilt);