version 3 通信方式,マイコン等に変更あり

Dependencies:   AQM0802A PID Servo mbed

Committer:
ryuna
Date:
Fri Mar 06 01:16:05 2015 +0000
Revision:
0:65b9e62cc2b6
Child:
1:f91d53098d57
check????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryuna 0:65b9e62cc2b6 1
ryuna 0:65b9e62cc2b6 2 /*PID処理*/
ryuna 0:65b9e62cc2b6 3 #define RATE 0.052//52
ryuna 0:65b9e62cc2b6 4 #define PID_BIAS 0.3
ryuna 0:65b9e62cc2b6 5 #define REFERENCE 180.0
ryuna 0:65b9e62cc2b6 6 #define MINIMUM 0.1
ryuna 0:65b9e62cc2b6 7 #define MAXIMUM 360.0
ryuna 0:65b9e62cc2b6 8 #define P_GAIN 1.4//1.4 //0.78
ryuna 0:65b9e62cc2b6 9 #define I_GAIN 0.0 //0.0
ryuna 0:65b9e62cc2b6 10 #define D_GAIN 0.05 //0.009
ryuna 0:65b9e62cc2b6 11 #define OUT_LIMIT 40.0
ryuna 0:65b9e62cc2b6 12 #define MAX_POW 100
ryuna 0:65b9e62cc2b6 13 #define MIN_POW -100
ryuna 0:65b9e62cc2b6 14
ryuna 0:65b9e62cc2b6 15 /*Serial Mbed間*/
ryuna 0:65b9e62cc2b6 16 #define ADDRESS 0xAA
ryuna 0:65b9e62cc2b6 17
ryuna 0:65b9e62cc2b6 18
ryuna 0:65b9e62cc2b6 19 /*BusIn sw 入力値*/
ryuna 0:65b9e62cc2b6 20 #define StartS 0x01
ryuna 0:65b9e62cc2b6 21 #define Debug1 0x02
ryuna 0:65b9e62cc2b6 22 #define Debug2 0x04
ryuna 0:65b9e62cc2b6 23 #define Debug3 0x08
ryuna 0:65b9e62cc2b6 24 #define Kicker 0x10
ryuna 0:65b9e62cc2b6 25
ryuna 0:65b9e62cc2b6 26 #define CW 1
ryuna 0:65b9e62cc2b6 27 #define CCW -1
ryuna 0:65b9e62cc2b6 28 #define ENTER 0
ryuna 0:65b9e62cc2b6 29 #define EXIT 1
ryuna 0:65b9e62cc2b6 30
ryuna 0:65b9e62cc2b6 31
ryuna 0:65b9e62cc2b6 32
ryuna 0:65b9e62cc2b6 33 BusIn Sw(p22,p23,p24,p25,p26);
ryuna 0:65b9e62cc2b6 34 BusIn Line(p5,p6,p7,p8);//No reading line → 0b1111 ,not pull up
ryuna 0:65b9e62cc2b6 35 DigitalOut Led[4] = {LED1,LED2,LED3,LED4};
ryuna 0:65b9e62cc2b6 36 DigitalOut Kick(p29);
ryuna 0:65b9e62cc2b6 37 Servo S555(p21);
ryuna 0:65b9e62cc2b6 38 AQM0802A Lcd(p28,p27);//sda,scl
ryuna 0:65b9e62cc2b6 39 MultiSerial Mbed(p9,p10);//tx,rx
ryuna 0:65b9e62cc2b6 40 Serial Motor(p13,p14);//tx,rx
ryuna 0:65b9e62cc2b6 41 Serial pc(USBTX,USBRX);
ryuna 0:65b9e62cc2b6 42
ryuna 0:65b9e62cc2b6 43
ryuna 0:65b9e62cc2b6 44 /*Compass PID SetUp*/
ryuna 0:65b9e62cc2b6 45 PID pid(P_GAIN,I_GAIN,D_GAIN, RATE);
ryuna 0:65b9e62cc2b6 46
ryuna 0:65b9e62cc2b6 47 /* motor driver*/
ryuna 0:65b9e62cc2b6 48 extern string StringFIN;
ryuna 0:65b9e62cc2b6 49 extern void array(int,int,int,int);
ryuna 0:65b9e62cc2b6 50 int speed[4] = {0};
ryuna 0:65b9e62cc2b6 51
ryuna 0:65b9e62cc2b6 52
ryuna 0:65b9e62cc2b6 53 enum {FRONT = 1, RIGHT, BACK, LEFT, NA} Direction;
ryuna 0:65b9e62cc2b6 54
ryuna 0:65b9e62cc2b6 55 int SetRad = 0;
ryuna 0:65b9e62cc2b6 56
ryuna 0:65b9e62cc2b6 57 /*Mbed sensor data */
ryuna 0:65b9e62cc2b6 58 uint8_t IrData[3] = {0},IrNum = 0;
ryuna 0:65b9e62cc2b6 59 uint8_t PingData[0];
ryuna 0:65b9e62cc2b6 60 unsigned int Compass = 0;
ryuna 0:65b9e62cc2b6 61 uint8_t rx_data[9] = {0};
ryuna 0:65b9e62cc2b6 62 /*mbed sensor data */
ryuna 0:65b9e62cc2b6 63
ryuna 0:65b9e62cc2b6 64 volatile int Angle[180] = {
ryuna 0:65b9e62cc2b6 65 0 , 1 , 2 , 3 ,
ryuna 0:65b9e62cc2b6 66 4 , 5 , 6 , 7 ,
ryuna 0:65b9e62cc2b6 67 8 , 9 , 10 , 11 ,
ryuna 0:65b9e62cc2b6 68 12 , 13 , 14 , 15 ,
ryuna 0:65b9e62cc2b6 69 16 , 17 , 18 , 19 ,
ryuna 0:65b9e62cc2b6 70 20 , 21 , 22 , 23 ,
ryuna 0:65b9e62cc2b6 71 24 , 25 , 26 , 27 ,
ryuna 0:65b9e62cc2b6 72 28 , 29 , 30 , 31 ,
ryuna 0:65b9e62cc2b6 73 32 , 33 , 34 , 35 ,
ryuna 0:65b9e62cc2b6 74 36 , 37 , 38 , 39 ,
ryuna 0:65b9e62cc2b6 75 40 , 41 , 42 , 43 ,
ryuna 0:65b9e62cc2b6 76 44 , 45 , 46 , 47 ,
ryuna 0:65b9e62cc2b6 77 48 , 49 , 50 , 51 ,
ryuna 0:65b9e62cc2b6 78 52 , 53 , 54 , 55 ,
ryuna 0:65b9e62cc2b6 79 56 , 57 , 58 , 59 ,
ryuna 0:65b9e62cc2b6 80 60 , 61 , 62 , 63 ,
ryuna 0:65b9e62cc2b6 81 64 , 65 , 66 , 67 ,
ryuna 0:65b9e62cc2b6 82 68 , 69 , 70 , 71 ,
ryuna 0:65b9e62cc2b6 83 72 , 73 , 74 , 75 ,
ryuna 0:65b9e62cc2b6 84 76 , 77 , 78 , 79 ,
ryuna 0:65b9e62cc2b6 85 80 , 81 , 82 , 83 ,
ryuna 0:65b9e62cc2b6 86 84 , 85 , 86 , 87 ,
ryuna 0:65b9e62cc2b6 87 88 , 89 , 90 , -89 ,
ryuna 0:65b9e62cc2b6 88 -88 , -87 , -86 , -85 ,
ryuna 0:65b9e62cc2b6 89 -84 , -83 , -82 , -81 ,
ryuna 0:65b9e62cc2b6 90 -80 , -79 , -78 , -77 ,
ryuna 0:65b9e62cc2b6 91 -76 , -75 , -74 , -73 ,
ryuna 0:65b9e62cc2b6 92 -72 , -71 , -70 , -69 ,
ryuna 0:65b9e62cc2b6 93 -68 , -67 , -66 , -65 ,
ryuna 0:65b9e62cc2b6 94 -64 , -63 , -62 , -61 ,
ryuna 0:65b9e62cc2b6 95 -60 , -59 , -58 , -57 ,
ryuna 0:65b9e62cc2b6 96 -56 , -55 , -54 , -53 ,
ryuna 0:65b9e62cc2b6 97 -52 , -51 , -50 , -49 ,
ryuna 0:65b9e62cc2b6 98 -48 , -47 , -46 , -45 ,
ryuna 0:65b9e62cc2b6 99 -44 , -43 , -42 , -41 ,
ryuna 0:65b9e62cc2b6 100 -40 , -39 , -38 , -37 ,
ryuna 0:65b9e62cc2b6 101 -36 , -35 , -34 , -33 ,
ryuna 0:65b9e62cc2b6 102 -32 , -31 , -30 , -29 ,
ryuna 0:65b9e62cc2b6 103 -28 , -27 , -26 , -25 ,
ryuna 0:65b9e62cc2b6 104 -24 , -23 , -22 , -21 ,
ryuna 0:65b9e62cc2b6 105 -20 , -19 , -18 , -17 ,
ryuna 0:65b9e62cc2b6 106 -16 , -15 , -14 , -13 ,
ryuna 0:65b9e62cc2b6 107 -12 , -11 , -10 , -9 ,
ryuna 0:65b9e62cc2b6 108 -8 , -7 , -6 , -5 ,
ryuna 0:65b9e62cc2b6 109 -4 , -3 , -2 , -1 };
ryuna 0:65b9e62cc2b6 110
ryuna 0:65b9e62cc2b6 111 volatile int RadToVector[4] = {1,-1,-1,1};
ryuna 0:65b9e62cc2b6 112
ryuna 0:65b9e62cc2b6 113 int wrapRad[24] = { 0,//
ryuna 0:65b9e62cc2b6 114 15,//15
ryuna 0:65b9e62cc2b6 115 60,//30
ryuna 0:65b9e62cc2b6 116 80,//45
ryuna 0:65b9e62cc2b6 117 100,//60
ryuna 0:65b9e62cc2b6 118 110,//75
ryuna 0:65b9e62cc2b6 119 180,//90
ryuna 0:65b9e62cc2b6 120 180,//105
ryuna 0:65b9e62cc2b6 121 185,//120
ryuna 0:65b9e62cc2b6 122 230,//135
ryuna 0:65b9e62cc2b6 123 250,//150
ryuna 0:65b9e62cc2b6 124 260,//165
ryuna 0:65b9e62cc2b6 125 90, //180 or270
ryuna 0:65b9e62cc2b6 126 100,//195
ryuna 0:65b9e62cc2b6 127 110,//210
ryuna 0:65b9e62cc2b6 128 130,//225
ryuna 0:65b9e62cc2b6 129 175,//240
ryuna 0:65b9e62cc2b6 130 180,//255
ryuna 0:65b9e62cc2b6 131 180,//270
ryuna 0:65b9e62cc2b6 132 250,//285
ryuna 0:65b9e62cc2b6 133 260,//300
ryuna 0:65b9e62cc2b6 134 280,//315
ryuna 0:65b9e62cc2b6 135 300,//330
ryuna 0:65b9e62cc2b6 136 345//345
ryuna 0:65b9e62cc2b6 137 };
ryuna 0:65b9e62cc2b6 138
ryuna 0:65b9e62cc2b6 139
ryuna 0:65b9e62cc2b6 140
ryuna 0:65b9e62cc2b6 141
ryuna 0:65b9e62cc2b6 142
ryuna 0:65b9e62cc2b6 143 /*
ryuna 0:65b9e62cc2b6 144 | |
ryuna 0:65b9e62cc2b6 145 | |
ryuna 0:65b9e62cc2b6 146 | o |
ryuna 0:65b9e62cc2b6 147 | |
ryuna 0:65b9e62cc2b6 148 | |
ryuna 0:65b9e62cc2b6 149 |---------------p,q
ryuna 0:65b9e62cc2b6 150
ryuna 0:65b9e62cc2b6 151
ryuna 0:65b9e62cc2b6 152 */