Main Program

Dependencies:   mbed AQM1602 HMC6352 PID

Committer:
lilac0112_1
Date:
Thu Feb 04 20:45:41 2016 +0000
Revision:
42:02aaa806d929
Parent:
34:69bdf29a4442
InterruptForce are added and so on.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lilac0112_1 1:f2633c150301 1 #ifndef _DEF_H_
lilac0112_1 1:f2633c150301 2 #define _DEF_H_
lilac0112_1 1:f2633c150301 3
lilac0112_1 1:f2633c150301 4 //BT(BlueTooth)
lilac0112_1 1:f2633c150301 5 #define DATA_NUM 8+2//2byte→KEYCODE(拝啓)とCHECKCODE(敬具) 8byte→やりとりするデータ
lilac0112_1 1:f2633c150301 6 #define TX_KEYCODE 0xAA//あちらのKEYCODE
lilac0112_1 1:f2633c150301 7 #define RX_KEYCODE 0xAA//こちらのKEYCODE
lilac0112_1 1:f2633c150301 8 #define KEY 0//KEYCODEは配列の最初
lilac0112_1 1:f2633c150301 9 #define CHECK DATA_NUM-1//CHECKCODEは配列の最後
lilac0112_1 1:f2633c150301 10
lilac0112_1 4:69fd47e1d296 11
lilac0112_1 10:3d0714c1ac75 12 //Switch 入力値
lilac0112_1 16:6900f47fa0b5 13 #define NONE 0
lilac0112_1 16:6900f47fa0b5 14 #define UP 1
lilac0112_1 16:6900f47fa0b5 15 #define DOWN 2
lilac0112_1 16:6900f47fa0b5 16 #define RIGHT 3
lilac0112_1 16:6900f47fa0b5 17 #define LEFT 4
lilac0112_1 15:88f2c525caca 18
lilac0112_1 10:3d0714c1ac75 19 //Lcd 設定値
lilac0112_1 4:69fd47e1d296 20 #define BUFSIZE 10
lilac0112_1 6:4e83c236ee57 21 #define STATE_NUM_X 0x04
lilac0112_1 6:4e83c236ee57 22 #define STATE_NUM_Y 0x10
lilac0112_1 10:3d0714c1ac75 23 //繰り返し割り込み
lilac0112_1 10:3d0714c1ac75 24 #define DUTY_NUM 1
lilac0112_1 6:4e83c236ee57 25
lilac0112_1 10:3d0714c1ac75 26 #define DUTY_SW 0
lilac0112_1 10:3d0714c1ac75 27 #define DUTY_GYRO 1
lilac0112_1 10:3d0714c1ac75 28 #define DUTY_PING 2
lilac0112_1 10:3d0714c1ac75 29 #define DUTY_COLOR 3
lilac0112_1 10:3d0714c1ac75 30 #define DUTY_MOUSE 4
lilac0112_1 1:f2633c150301 31
lilac0112_1 16:6900f47fa0b5 32 /*PID処理*/
lilac0112_1 16:6900f47fa0b5 33 #define RATE 0.052//52
lilac0112_1 24:9fb74ea3c25d 34 #define PID_BIAS 1.0
lilac0112_1 16:6900f47fa0b5 35 #define REFERENCE 180.0
lilac0112_1 16:6900f47fa0b5 36 #define MINIMUM 0.0
lilac0112_1 16:6900f47fa0b5 37 #define MAXIMUM 359.9
lilac0112_1 26:fbb03281fc7d 38 #define P_GAIN 1.3//1.25//0.8 //0.78
lilac0112_1 16:6900f47fa0b5 39 #define I_GAIN 0.0 //0.0
lilac0112_1 26:fbb03281fc7d 40 #define D_GAIN 0.01//0.01 //0.009
lilac0112_1 16:6900f47fa0b5 41 #define OUT_LIMIT 30.0
lilac0112_1 16:6900f47fa0b5 42 #define MAX_POW 100
lilac0112_1 16:6900f47fa0b5 43 #define MIN_POW -100
lilac0112_1 16:6900f47fa0b5 44 #define PID_CYCLE 0.05 //s
lilac0112_1 16:6900f47fa0b5 45
lilac0112_1 24:9fb74ea3c25d 46 //ir
lilac0112_1 24:9fb74ea3c25d 47 #define IR_X 0
lilac0112_1 24:9fb74ea3c25d 48 #define IR_Y 1
lilac0112_1 24:9fb74ea3c25d 49 #define IR_SHORT 0
lilac0112_1 24:9fb74ea3c25d 50 #define IR_LONG 1
lilac0112_1 24:9fb74ea3c25d 51
lilac0112_1 24:9fb74ea3c25d 52 #define X_AXIS 0
lilac0112_1 24:9fb74ea3c25d 53 #define Y_AXIS 1
lilac0112_1 24:9fb74ea3c25d 54
lilac0112_1 42:02aaa806d929 55 //ping
lilac0112_1 42:02aaa806d929 56 #define L_PING 0
lilac0112_1 42:02aaa806d929 57 #define R_PING 1
lilac0112_1 42:02aaa806d929 58
lilac0112_1 27:769cb5a7ea37 59 //line
lilac0112_1 27:769cb5a7ea37 60
lilac0112_1 27:769cb5a7ea37 61 #define A_SPOT 0
lilac0112_1 27:769cb5a7ea37 62 #define B_SPOT 1
lilac0112_1 27:769cb5a7ea37 63 #define C_SPOT 2
lilac0112_1 27:769cb5a7ea37 64 #define AB_SPOT 3
lilac0112_1 27:769cb5a7ea37 65
lilac0112_1 28:8ac6c3c1e643 66 #define LINE_RF 5
lilac0112_1 42:02aaa806d929 67 #define LINE_DELAY 0.5
lilac0112_1 27:769cb5a7ea37 68 #define RELEASE_VAL 150
lilac0112_1 27:769cb5a7ea37 69
lilac0112_1 19:342da3a5a474 70 //思考パターン
lilac0112_1 22:a95f7c63af3c 71 #define STRATEGY_NUM 12
lilac0112_1 19:342da3a5a474 72
lilac0112_1 16:6900f47fa0b5 73 //計算
lilac0112_1 16:6900f47fa0b5 74 #define ROUND(x) ((x > 0) ? (x + 0.5) : (x - 0.5))//x...整数
lilac0112_1 16:6900f47fa0b5 75 #define PI 3.14159265358979323846
lilac0112_1 16:6900f47fa0b5 76 #define DEG2RAD(deg) (PI*(deg)/180.0)
lilac0112_1 16:6900f47fa0b5 77 #define RAD2DEG(rad) (180.0(rad)/PI)
lilac0112_1 16:6900f47fa0b5 78
lilac0112_1 13:f8f5bd2f0525 79 //データ
lilac0112_1 18:97eba56f82e4 80 typedef struct {//ir,line,gyro,mouse,ping
lilac0112_1 22:a95f7c63af3c 81 //ping
lilac0112_1 18:97eba56f82e4 82 uint8_t ping[2];
lilac0112_1 22:a95f7c63af3c 83 //ir
lilac0112_1 22:a95f7c63af3c 84 uint8_t irKey;
lilac0112_1 22:a95f7c63af3c 85 uint8_t irNotice;
lilac0112_1 22:a95f7c63af3c 86 uint8_t irSpot[2];
lilac0112_1 24:9fb74ea3c25d 87 uint8_t irPosition;
lilac0112_1 24:9fb74ea3c25d 88 uint8_t IrFlag;
lilac0112_1 22:a95f7c63af3c 89 //line
lilac0112_1 22:a95f7c63af3c 90 uint8_t lnFlag[3];
lilac0112_1 18:97eba56f82e4 91 uint8_t ball;
lilac0112_1 34:69bdf29a4442 92 uint8_t KickOffFlag;
lilac0112_1 34:69bdf29a4442 93 //uint8_t LineBind[4];//宣言すると動かない⇒構造体の限界
lilac0112_1 24:9fb74ea3c25d 94 uint8_t KickFlag;
lilac0112_1 18:97eba56f82e4 95 int32_t mouse[2];//0...x,1...y//1cm nearlyeq 1000count
lilac0112_1 24:9fb74ea3c25d 96 //motor
lilac0112_1 24:9fb74ea3c25d 97 int32_t motorlog[2];
lilac0112_1 27:769cb5a7ea37 98 uint8_t MotorFlag;
lilac0112_1 28:8ac6c3c1e643 99 double s_pow;
lilac0112_1 28:8ac6c3c1e643 100 double l_pow;
lilac0112_1 22:a95f7c63af3c 101 //cmps&pid
lilac0112_1 27:769cb5a7ea37 102 uint8_t PidFlag;
lilac0112_1 23:d95d8d3e89f3 103 double cmps, CmpsInitialValue, CmpsDiff, FrontDeg;//0<x<360
lilac0112_1 21:d69a8f3c76e1 104 double InputPID;//<<gyrosensor
lilac0112_1 24:9fb74ea3c25d 105 int16_t OutputPID;//>>motor
lilac0112_1 18:97eba56f82e4 106 //uint8_t color[3];
lilac0112_1 18:97eba56f82e4 107 //uint8_t lcdpoint[2];//0...x,1...y
lilac0112_1 18:97eba56f82e4 108 uint8_t strategy;
lilac0112_1 18:97eba56f82e4 109 uint8_t init_point_flag;
lilac0112_1 10:3d0714c1ac75 110 uint8_t stopflag;
lilac0112_1 1:f2633c150301 111 } Record;
lilac0112_1 1:f2633c150301 112
lilac0112_1 1:f2633c150301 113 #endif