ジャパンオープン用のメインプログラム
Dependencies: mbed AQM1602 HMC6352 PID
setting/def.h
- Committer:
- lilac0112_1
- Date:
- 2016-03-04
- Revision:
- 5:5ff3a7d5d8c2
- Parent:
- 4:52da8da146d4
- Child:
- 6:f9167470d819
File content as of revision 5:5ff3a7d5d8c2:
#ifndef _DEF_H_ #define _DEF_H_ //BT(BlueTooth) #define DATA_NUM 8+2//2byte→KEYCODE(拝啓)とCHECKCODE(敬具) 8byte→やりとりするデータ #define TX_KEYCODE 0xAA//あちらのKEYCODE #define RX_KEYCODE 0xAA//こちらのKEYCODE #define KEY 0//KEYCODEは配列の最初 #define CHECK DATA_NUM-1//CHECKCODEは配列の最後 //Switch 入力値 #define NONE 0 #define UP 1 #define DOWN 2 #define RIGHT 3 #define LEFT 4 //Lcd 設定値 #define BUFSIZE 7 #define STATE_NUM_X 0x04 #define STATE_NUM_Y 0x10 #define JUMP_TAG_MAX 0xFFFF //tag #define ZERO_FUNCTION 0x0000 #define START 0x0001 #define GET_IR 0x0002 #define GET_LINE 0x0003 #define GET_PID_VALUE 0x0004 #define CALIBRATION_ENTER 0x0005 #define CALIBRATION_EXIT 0x0006 #define FRONT_RESET 0x0007 #define SET_POWER1 0x0008 #define SET_POWER2 0x0009 #define SOFT_RESET 0x000A #define SET_STRATEGY1 0x000B #define SET_STRATEGY2 0x000C #define SET_STRATEGY3 0x000D #define SET_STRATEGY4 0x000E #define START2 0x000F typedef struct {//for command char LcdStr[STATE_NUM_X][BUFSIZE]; uint8_t str_num; uint8_t (*CommandFunction)(uint8_t x); uint16_t tag_num; } CommandItem; //繰り返し割り込み #define DUTY_NUM 1 #define DUTY_SW 0 #define DUTY_GYRO 1 #define DUTY_PING 2 #define DUTY_COLOR 3 #define DUTY_MOUSE 4 /*PID処理*/ #define RATE 0.052//52 #define PID_BIAS 1.0 #define REFERENCE 180.0 #define MINIMUM 0.0 #define MAXIMUM 359.9 #define P_GAIN 1.3//1.25//0.8 //0.78 #define I_GAIN 0.0 //0.0 #define D_GAIN 0.01//0.01 //0.009 #define OUT_LIMIT 30.0 #define MAX_POW 100 #define MIN_POW -100 #define PID_CYCLE 0.05 //s //ir //ir_pow_old #define IR_X 0 #define IR_Y 1 //ir_pow #define IR_X_DIR 0 #define IR_Y_DIR 1 #define IR_X_TURN 2 #define IR_Y_TURN 3 #define IR_SHORT 0 #define IR_LONG 1 #define X_AXIS 0 #define Y_AXIS 1 #define DIS_0 0x0//low_value #define DIS_1 0x1 #define DIS_2 0x2 #define DIS_3 0x3 #define DIS_4 0x4 #define DIS_5 0x5 #define DIS_6 0x6 #define DIS_7 0x7//high_value //ping #define L_PING 0 #define R_PING 1 #define F_PING 2 #define B_PING 3 //0,1...main //2,3...debug board //line #define A_SPOT 0 #define B_SPOT 1 #define C_SPOT 2 #define AB_SPOT 3 #define LINE_RF 5 #define LINE_DELAY 0.5 //思考パターン #define STRATEGY_NUM 12 //計算 #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 {//ir,line,gyro,mouse,ping //ping uint8_t ping[4]; //ir uint8_t irKey; uint8_t irNotice; uint8_t irSpot[2]; uint8_t irPosition; uint8_t IrFlag; //line uint8_t lnFlag[3]; uint8_t ball; uint8_t KickOffFlag; //uint8_t LineBind[4];//宣言すると動かない⇒構造体の限界 uint8_t KickFlag; //motor int32_t motorlog[2]; uint8_t MotorFlag; double s_pow; double l_pow; //cmps&pid uint8_t PidFlag; double cmps, CmpsInitialValue, CmpsDiff, FrontDeg;//0<x<360 double InputPID;//<<gyrosensor int16_t OutputPID;//>>motor uint8_t strategy; uint8_t init_point_flag; uint8_t stopflag; } Record; */ //NewStruct typedef struct { //cmps&pid double cmps, CmpsInitialValue, CmpsDiff, FrontDeg;//0<x<360 double InputPID;//<<gyrosensor int16_t OutputPID;//>>motor } CompassVal; typedef struct { //ping uint8_t ping[4]; //line uint8_t lineSpot[3]; uint8_t lnFlag[3]; /*uint8_t LineFlag[3]; uint8_t LinePriority[3]; uint8_t LineBind[3];*/ //ir(spi) uint8_t irKey;//2bit uint8_t irValPhase[2];//3*2bit uint8_t irDif[2];//3bit uint8_t irPosition;//5bit uint8_t irSpot[2];//4*2bit//old //ir(playing) uint8_t irNotice; //ball uint8_t ball; } SensorVal; typedef struct { //system,flag uint8_t strategy; uint16_t jump_flag;//0<=x<=JUMP_TAG_NUM uint8_t stopflag; uint8_t KickOffFlag; uint8_t DribbleFlag; uint8_t KickFlag; uint8_t MotorFlag; uint8_t IrFlag; uint8_t UswFlag; uint8_t UswFlag_2; uint8_t PidFlag; //motor double s_pow; double m_pow; double l_pow; int8_t dri_pow; uint8_t ir_pow_table; } SystemVal; #endif