Main Program

Dependencies:   mbed AQM1602 HMC6352 PID

Revision:
16:6900f47fa0b5
Parent:
15:88f2c525caca
Child:
18:97eba56f82e4
diff -r 88f2c525caca -r 6900f47fa0b5 setting/def.h
--- a/setting/def.h	Sat Jan 09 02:15:46 2016 +0000
+++ b/setting/def.h	Mon Jan 11 17:45:56 2016 +0000
@@ -10,14 +10,11 @@
 
 
 //Switch 入力値
-#define NONE    0x00
-#define FRONT   0x01
-#define BACK    0x02
-#define RIGHT   0x04
-#define LEFT    0x08
-
-#define F_L     0x09
-#define B_R     0x06
+#define NONE    0
+#define UP      1
+#define DOWN    2
+#define RIGHT   3
+#define LEFT    4
 
 //Lcd 設定値
 #define BUFSIZE 10
@@ -35,14 +32,36 @@
 //MPU6050関連
 //config.h
 
+/*PID処理*/
+#define RATE    0.052//52
+#define PID_BIAS    0.2
+#define REFERENCE   180.0
+#define MINIMUM     0.0
+#define MAXIMUM     359.9
+#define P_GAIN  1.4//1.4    //0.78   
+#define I_GAIN  0.0     //0.0
+#define D_GAIN  0.05  //0.009
+#define OUT_LIMIT   30.0
+#define MAX_POW     100
+#define MIN_POW     -100
+#define PID_CYCLE   0.05   //s
+
+//計算
+#define ROUND(x) ((x > 0) ? (x + 0.5) : (x - 0.5))//x...整数
+#define PI  3.14159265358979323846
+#define DEG2RAD(deg)  (PI*(deg)/180.0)
+#define RAD2DEG(rad)  (180.0(rad)/PI)
+
 //データ
 typedef struct {
     uint8_t ping[4];
     uint8_t ir[12];
     uint8_t irLong[6];
     uint8_t line[3];
-    uint8_t mouse[2];
-    uint16_t compass;
+    int mouse[2];//0...x,1...y//1cm nearlyeq 1000count
+    uint16_t gyro, GyroInitialValue, FrontDeg;//0<x<3599
+    double InputPID;//<<gyrosensor
+    double OutputPID;//>>motor
     uint8_t color[3];
     uint8_t lcdpoint[2];
     uint8_t stopflag;