├── 4082驱动II.eprj ├── CODE ├── GUI.C ├── UI.H ├── deal_electrical.c ├── deal_electrical.h ├── direction.c ├── direction.h ├── eeprom.c ├── eeprom.h ├── example.c ├── example.h ├── fuzzy_pid.c ├── fuzzy_pid.h ├── init.c ├── init.h ├── key.c ├── key.h ├── main.c ├── mycode.c ├── mycode.h ├── readme.txt ├── speed.c ├── speed.h └── speed_control.h ├── DRV8701电机驱动.eprj └── README.md /4082驱动II.eprj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/4082驱动II.eprj -------------------------------------------------------------------------------- /CODE/GUI.C: -------------------------------------------------------------------------------- 1 | #include "UI.h" 2 | extern uint8 TrackFlag,SancaFlag; 3 | extern int Right_count,Left_count; 4 | extern int16 ad_avr_val[8]; 5 | extern PID_CLASS MotorPID; 6 | extern PID_CLASS ServPID; 7 | extern float Angle_Y,Angle_Z; 8 | extern float err; 9 | extern float speed_avr; 10 | unsigned char ui_page0[10][17] = 11 | { 12 | " page ", 13 | " Sensor ", 14 | " Speed ", 15 | " encoder ", 16 | " ServPID ", 17 | " CircleData ", 18 | " Gyroscope ", 19 | " FLAG ", 20 | " ", 21 | " page1 " 22 | }; 23 | 24 | 25 | 26 | unsigned char ui_Sensor[10][17] = 27 | { 28 | " L1: ", 29 | " L2: ", 30 | " R2: ", 31 | " R1: ", 32 | " ICM: ", 33 | " Dis: ", 34 | " TOF: ", 35 | " sp_L: ", 36 | " sp_R: ", 37 | " ", 38 | 39 | 40 | }; 41 | 42 | unsigned char ui_Speed[10][17] = 43 | { 44 | " Sp_max:", 45 | " ", 46 | " Sp_min:", 47 | " ", 48 | " L_Speed: ", 49 | " ", 50 | " R_Speed: ", 51 | " ", 52 | " ", 53 | " Speed " 54 | }; 55 | 56 | unsigned char ui_encoder[10][17] = 57 | { 58 | " LeftCnt: ", 59 | " ", 60 | " RightCnt: ", 61 | " ", 62 | " L_Speed: ", 63 | " ", 64 | " R_Speed: ", 65 | " ", 66 | " ", 67 | " encoder " 68 | }; 69 | 70 | unsigned char ui_ServPD[10][17] = 71 | { 72 | " Str_P:", 73 | " Str_D:", 74 | " Str_KP:", 75 | " Cur_P :", 76 | " Cur_D :", 77 | " Cur_KP: ", 78 | " RD_KP : ", 79 | " ", 80 | " ", 81 | " ServPD " 82 | }; 83 | unsigned char ui_MotorPID[10][17] = 84 | { 85 | " IS_R_AD: ", 86 | " IS_L_AD: ", 87 | " IS_R_KP: ", 88 | " IS_L_KP: ", 89 | " IS_R_DIS:", 90 | " ", 91 | " RK_DIS: ", 92 | " RK_Yaw: ", 93 | " ", 94 | " MotorPID " 95 | }; 96 | unsigned char ui_Gyroscope[10][17] = 97 | { 98 | " BZ_Dis: ", 99 | " ", 100 | " ", 101 | " ", 102 | " ", 103 | " ", 104 | " ", 105 | " ", 106 | " ", 107 | " Gyroscope " 108 | }; 109 | unsigned char ui_FLAG[10][17] = 110 | { 111 | " StartFlag: ", 112 | " CK_left: ", 113 | " CK_right: ", 114 | " is_left: ", 115 | " is_right: ", 116 | " ", 117 | " ", 118 | " ", 119 | " ", 120 | " FLAG " 121 | }; 122 | UI_CLASS ui = 123 | { 124 | &UI_Disp, 125 | {0}, 0, -1 126 | }; 127 | 128 | 129 | static void UI_DispUIStrings(uint8 strings[10][17]) 130 | { 131 | uint8 i; 132 | for (i = 0; i < 10; i++) 133 | { 134 | if (i == ui.cursor[ui.page]) 135 | strings[i][0] = '>'; 136 | else 137 | strings[i][0] = ' '; 138 | ips114_showstr(0, i, strings[i]); 139 | } 140 | } 141 | 142 | 143 | void UI_Disp(void) 144 | { 145 | switch(ui.page) 146 | { 147 | case 0: 148 | if(ui.enter == -1) 149 | { 150 | UI_DispUIStrings(ui_page0); 151 | } 152 | else 153 | { 154 | if(ui.enter == 0) 155 | { 156 | UI_DispUIStrings(ui_page0); 157 | } 158 | if(ui.enter == 1) 159 | { 160 | UI_DispUIStrings(ui_Sensor); 161 | ips114_showuint16(80,0,g_adValue[1]); 162 | ips114_showuint16(80,1,g_adValue[2]); 163 | ips114_showuint16(80,2,g_adValue[3]); 164 | ips114_showuint16(80,3,g_adValue[4]); 165 | ips114_showint16(80,4,icmdata_Yaw); 166 | ips114_showint16(80,5,encoder_sum); 167 | ips114_showint16(80,6,dl1a_distance_mm); 168 | ips114_showint16(80,7,templ_pluse); 169 | ips114_showint16(80,8,tempr_pluse); 170 | } 171 | if(ui.enter == 2) 172 | { 173 | UI_DispUIStrings(ui_Speed); 174 | ips114_showfloat(88,0,speed_max,3,1); 175 | ips114_showfloat(88,2,speed_min,3,1); 176 | ips114_showfloat(96,4,L_CarSpeed,1,1); 177 | ips114_showfloat(96,6,R_CarSpeed,1,1); 178 | } 179 | else if(ui.enter == 3) 180 | { 181 | UI_DispUIStrings(ui_encoder); 182 | ips114_showuint16(80, 0, Left_count); 183 | ips114_showuint16(80, 2, Right_count); 184 | ips114_showfloat(96,4,L_CarSpeed,1,1); 185 | ips114_showfloat(96,6,R_CarSpeed,1,1); 186 | 187 | } 188 | else if(ui.enter == 4) 189 | { 190 | UI_DispUIStrings(ui_ServPD); 191 | ips114_showfloat(80, 0, Str_P ,3,1); 192 | ips114_showfloat(80, 1, Str_D ,3,1); 193 | ips114_showfloat(80, 2, Str_KP,3,1); 194 | ips114_showfloat(80, 3, Cur_P ,3,1); 195 | ips114_showfloat(80, 4, Cur_D ,3,1); 196 | ips114_showfloat(80, 5, Cur_KP,3,1); 197 | ips114_showfloat(80, 6, RD_KP ,3,1); 198 | } 199 | else if(ui.enter == 5) 200 | { 201 | UI_DispUIStrings(ui_MotorPID); 202 | ips114_showfloat(80, 0, island_right_data,3,1); 203 | ips114_showfloat(80, 1, island_left_data ,3,1); 204 | ips114_showfloat(80, 2, CirR_KP,3,1); 205 | ips114_showfloat(80, 3, CirL_KP,3,1); 206 | ips114_showfloat(80, 4, island_right_dis,3,1); 207 | 208 | ips114_showfloat(80, 6, RK_Dis,3,1); 209 | ips114_showfloat(80, 7, RK_Yaw,3,1); 210 | } 211 | else if(ui.enter ==6) 212 | { 213 | 214 | UI_DispUIStrings(ui_Gyroscope); 215 | ips114_showfloat(88,0,BZ_Dis,3,1); 216 | ips114_showfloat(88,1,BZ_DisS,4,1); 217 | // ips114_showint16(80, 2, 1); 218 | // ips114_showint16(80, 3, 1); 219 | // ips114_showint16(80, 4, 1); 220 | // ips114_showint16(80, 5, 1); 221 | // ips114_showint16(80, 6, 1); 222 | // ips114_showint16(80, 7, 1); 223 | 224 | } 225 | else if(ui.enter ==7) 226 | { 227 | 228 | UI_DispUIStrings(ui_FLAG); 229 | ips114_showuint8(96,0,start_flag); 230 | ips114_showuint8(96,1,CK_left); 231 | ips114_showuint8(96,2,CK_right); 232 | ips114_showuint8(96,3,circle_left); 233 | ips114_showuint8(96,4,circle_right); 234 | } 235 | } 236 | break; 237 | // case 1: 238 | // if(ui.enter == -1) 239 | // { 240 | // UI_DispUIStrings(ui_page1); 241 | // } 242 | // break; 243 | // 244 | // case 2: 245 | // if(ui.enter == -1) 246 | // { 247 | // UI_DispUIStrings(ui_page2); 248 | // } 249 | // break; 250 | 251 | // case 3: 252 | // if(ui.enter == -1) 253 | // { 254 | // UI_DispUIStrings(ui_page3); 255 | // } 256 | // break; 257 | 258 | } 259 | } -------------------------------------------------------------------------------- /CODE/UI.H: -------------------------------------------------------------------------------- 1 | #ifndef __UI_H 2 | #define __UI_H 3 | #include "common.h" 4 | #include "headfile.h" 5 | typedef struct 6 | { 7 | void (*Disp)(void); 8 | int cursor[1], page, enter; 9 | } UI_CLASS; 10 | 11 | void UI_Disp(void); 12 | void UI_DispUIStrings(uint8 strings[10][17]); 13 | #endif 14 | -------------------------------------------------------------------------------- /CODE/deal_electrical.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/deal_electrical.c -------------------------------------------------------------------------------- /CODE/deal_electrical.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/deal_electrical.h -------------------------------------------------------------------------------- /CODE/direction.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/direction.c -------------------------------------------------------------------------------- /CODE/direction.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/direction.h -------------------------------------------------------------------------------- /CODE/eeprom.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/eeprom.c -------------------------------------------------------------------------------- /CODE/eeprom.h: -------------------------------------------------------------------------------- 1 | void extern_iap_write_float(float dat,uint8 num,uint8 pointnum,uint16 addr); 2 | float StrToDouble(const char *s); 3 | float iap_read_float(uint8 len, uint16 addr); 4 | 5 | -------------------------------------------------------------------------------- /CODE/example.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/example.c -------------------------------------------------------------------------------- /CODE/example.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/example.h -------------------------------------------------------------------------------- /CODE/fuzzy_pid.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/fuzzy_pid.c -------------------------------------------------------------------------------- /CODE/fuzzy_pid.h: -------------------------------------------------------------------------------- 1 | #ifndef CODE_MY_FUZZY_H_ 2 | #define CODE_MY_FUZZY_H_ 3 | 4 | #define range 2 5 | 6 | extern float Range_PError[5]; 7 | extern float Range_DError[5]; 8 | 9 | extern float Output_tmp_P_left[5]; 10 | extern float Output_tmp_D_left[5]; 11 | extern float Output_tmp_P_right[5]; 12 | extern float Output_tmp_D_right[5]; 13 | extern float Output_tmp_D[5]; 14 | 15 | extern float fuzzy_P[range][5]; 16 | extern float fuzzy_D[range][5]; 17 | 18 | void GetFuzzyPD(float Error,float DError); 19 | 20 | #endif /* CODE_MY_FUZZY_H_ */ 21 | -------------------------------------------------------------------------------- /CODE/init.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/init.c -------------------------------------------------------------------------------- /CODE/init.h: -------------------------------------------------------------------------------- 1 | #ifndef _init_h 2 | #define _init_h 3 | 4 | #include "headfile.h" 5 | 6 | 7 | //#define boma_4 !gpio_get(D14) 8 | //#define boma_3 !gpio_get(D15) 9 | //#define boma_2 !gpio_get(D12) 10 | //#define boma_1 !gpio_get(D13) 11 | 12 | void init_all(void); 13 | void my_pwm_init(void); 14 | void my_pit_init(void); 15 | void my_adc_init(void); 16 | void my_gpio_init(void); 17 | void key_init(void); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /CODE/key.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/key.c -------------------------------------------------------------------------------- /CODE/key.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/key.h -------------------------------------------------------------------------------- /CODE/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/main.c -------------------------------------------------------------------------------- /CODE/mycode.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/mycode.c -------------------------------------------------------------------------------- /CODE/mycode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/mycode.h -------------------------------------------------------------------------------- /CODE/readme.txt: -------------------------------------------------------------------------------- 1 | 该目录可以存放用户代码。 -------------------------------------------------------------------------------- /CODE/speed.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/speed.c -------------------------------------------------------------------------------- /CODE/speed.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/speed.h -------------------------------------------------------------------------------- /CODE/speed_control.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/CODE/speed_control.h -------------------------------------------------------------------------------- /DRV8701电机驱动.eprj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miku399/The-18th-SmartCar-Electromagnetic-Tracking/a23dbfdd56cf86834ccdf69d477f3c0fedba7ad0/DRV8701电机驱动.eprj -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #第18届智能汽车电磁跟踪 2 | 第十八届智能车负压电磁组 3 | 4 | 基于STC32G12k128开发,MDK5环境编译运行,需要逐飞科技STC32G固件库支持运行 5 | 6 | 极速2.8m/s,带有基于tof激光模块测距的自动避障,左右环岛检测,速度自动决策,以及覆盖整车80%的参数可调整菜单 7 | 8 | 附带复刻的逐飞科技两种版本驱动板pcb文件 9 | 10 | 决赛中因为eeprom异常清零导致倒车入库程序失效,导致最后未完赛,最后从西部赛区前五滑落,憾别国赛 11 | --------------------------------------------------------------------------------