aa

Dependencies:   mbed TrapezoidControl QEI

Committer:
yabahiro
Date:
Sat Oct 05 08:11:29 2019 +0000
Revision:
46:4a8bca4cc1fd
Parent:
45:878f8f385635
Child:
47:b6e5a6bfe7ab
aa;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishibekairohan 13:b6e02d6261d7 1
t_yamamoto 0:669ef71cba68 2 #include "mbed.h"
t_yamamoto 0:669ef71cba68 3 #include "Process.h"
7ka884 4:ba9df71868df 4 #include "QEI.h"
t_yamamoto 0:669ef71cba68 5
7ka884 4:ba9df71868df 6 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 7 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
yabahiro 21:1f1e9c585da8 8 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 9 #include "../../Communication/Controller/Controller.h"
t_yamamoto 0:669ef71cba68 10 #include "../../Input/ExternalInt/ExternalInt.h"
t_yamamoto 0:669ef71cba68 11 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:669ef71cba68 12 #include "../../Input/Potentiometer/Potentiometer.h"
kishibekairohan 16:3f2c2d89372b 13 #include "../../Input/Encoder/Encoder.h"
t_yamamoto 0:669ef71cba68 14 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 15 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 16 #include "../Using.h"
t_yamamoto 0:669ef71cba68 17
t_yamamoto 0:669ef71cba68 18 using namespace SWITCH;
7ka884 4:ba9df71868df 19 using namespace PID_SPACE;
kishibekairohan 16:3f2c2d89372b 20 using namespace ENCODER;
yabahiro 21:1f1e9c585da8 21 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 22
t_yamamoto 0:669ef71cba68 23 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 24 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 25 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 26
t_yamamoto 0:669ef71cba68 27 static bool lock;
t_yamamoto 0:669ef71cba68 28 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 29 static int current;
t_yamamoto 0:669ef71cba68 30
t_yamamoto 0:669ef71cba68 31 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 32
t_yamamoto 0:669ef71cba68 33 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 34 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 35 #endif
t_yamamoto 0:669ef71cba68 36
t_yamamoto 0:669ef71cba68 37 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 38
t_yamamoto 0:669ef71cba68 39 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 40
kishibekairohan 2:c015739085d3 41 Serial pc(USBTX, USBRX);
kishibekairohan 2:c015739085d3 42
kishibekairohan 16:3f2c2d89372b 43 //**************Encoder***************
kishibekairohan 16:3f2c2d89372b 44 const int PerRev = 256;
kishibekairohan 16:3f2c2d89372b 45 QEI ECD_0(ECD_A_0,ECD_B_0,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 46 QEI ECD_1(ECD_A_1,ECD_B_1,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 47 QEI ECD_2(ECD_A_2,ECD_B_2,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 48 QEI ECD_3(ECD_A_3,ECD_B_3,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 49 //**************Encoder***************
kishibekairohan 7:e88c5d47a3be 50
kishibekairohan 16:3f2c2d89372b 51 //**************Buzzer****************
kishibekairohan 11:028a150943b5 52 //DigitalOut buzzer(BUZZER_PIN);
kishibekairohan 9:f93fc79a49ea 53 void BuzzerTimer_func();
kishibekairohan 9:f93fc79a49ea 54 Ticker BuzzerTimer;
kishibekairohan 16:3f2c2d89372b 55 bool EMGflag = false;
yabahiro 21:1f1e9c585da8 56 //PWMOut buzzer(BUZZER_PIN);
kishibekairohan 16:3f2c2d89372b 57 //**************Buzzer****************
kishibekairohan 11:028a150943b5 58
kishibekairohan 11:028a150943b5 59 //************TapeLed*****************
kishibekairohan 11:028a150943b5 60 void TapeLedEms_func();
kishibekairohan 11:028a150943b5 61 TapeLedData tapeLED;
kishibekairohan 11:028a150943b5 62 TapeLedData sendLedData;
kishibekairohan 11:028a150943b5 63 TapeLED_Mode ledMode = Normal;
kishibekairohan 11:028a150943b5 64 Ticker tapeLedTimer;
kishibekairohan 11:028a150943b5 65 //************TapaLed*****************
kishibekairohan 16:3f2c2d89372b 66
M_souta 18:c694bae76e51 67 float tireProRPM[4];
M_souta 18:c694bae76e51 68 float tireTarRPM[4];
yabahiro 21:1f1e9c585da8 69 float tirepwm[4];
yabahiro 21:1f1e9c585da8 70
yabahiro 21:1f1e9c585da8 71 const int omni[15][15] = {
yabahiro 21:1f1e9c585da8 72 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 73 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 74 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 75 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
yabahiro 21:1f1e9c585da8 76 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
yabahiro 21:1f1e9c585da8 77 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
yabahiro 21:1f1e9c585da8 78 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
yabahiro 21:1f1e9c585da8 79 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
yabahiro 21:1f1e9c585da8 80 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
yabahiro 21:1f1e9c585da8 81 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
yabahiro 21:1f1e9c585da8 82 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
yabahiro 21:1f1e9c585da8 83 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
yabahiro 21:1f1e9c585da8 84 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
yabahiro 21:1f1e9c585da8 85 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
yabahiro 21:1f1e9c585da8 86 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
yabahiro 21:1f1e9c585da8 87 };
yabahiro 21:1f1e9c585da8 88
yabahiro 21:1f1e9c585da8 89 const int curve[15] = { -152, -98, -54, -18, 0, 0, 0, 0, 0, 0, 0, 18, 54, 98, 152 };
yabahiro 21:1f1e9c585da8 90 //{-200,-146,-102,-66,-36,-16,0,0,0,16,36,66,102,146,200}
yabahiro 21:1f1e9c585da8 91
yabahiro 21:1f1e9c585da8 92 uint8_t SetStatus(int);
yabahiro 21:1f1e9c585da8 93 uint8_t SetStatus(int pwmVal)
yabahiro 21:1f1e9c585da8 94 {
yabahiro 21:1f1e9c585da8 95 if (pwmVal < 0) return BACK;
yabahiro 21:1f1e9c585da8 96 else if (pwmVal > 0) return FOR;
yabahiro 21:1f1e9c585da8 97 else if (pwmVal == 0) return BRAKE;
yabahiro 21:1f1e9c585da8 98 else return BRAKE;
yabahiro 21:1f1e9c585da8 99 }
yabahiro 21:1f1e9c585da8 100 uint8_t Setpwm(int);
yabahiro 21:1f1e9c585da8 101 uint8_t Setpwm(int pwmVal)
yabahiro 21:1f1e9c585da8 102 {
yabahiro 21:1f1e9c585da8 103 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
yabahiro 21:1f1e9c585da8 104 else return abs(pwmVal);
yabahiro 21:1f1e9c585da8 105 }
M_souta 18:c694bae76e51 106
yabahiro 42:4f9689c0a349 107 int selectnum[16][4]= {
yabahiro 42:4f9689c0a349 108 //1,2,4,8
yabahiro 42:4f9689c0a349 109 {0,0,0,0},
yabahiro 42:4f9689c0a349 110 {1,0,0,0},
yabahiro 42:4f9689c0a349 111 {0,1,0,0},
yabahiro 42:4f9689c0a349 112 {1,1,0,0},
yabahiro 42:4f9689c0a349 113 {0,0,1,0},
yabahiro 42:4f9689c0a349 114 {1,0,1,0},
yabahiro 42:4f9689c0a349 115 {0,1,1,0},
yabahiro 42:4f9689c0a349 116 {1,1,1,0},
yabahiro 42:4f9689c0a349 117 {0,0,0,1},
yabahiro 42:4f9689c0a349 118 {1,0,0,1},
yabahiro 42:4f9689c0a349 119 {0,1,0,1},
yabahiro 42:4f9689c0a349 120 {1,1,0,1},
yabahiro 42:4f9689c0a349 121 {0,0,1,1},
yabahiro 42:4f9689c0a349 122 {1,0,1,1},
yabahiro 42:4f9689c0a349 123 {0,1,1,1},
yabahiro 42:4f9689c0a349 124 {1,1,1,1}
yabahiro 42:4f9689c0a349 125 };
yabahiro 42:4f9689c0a349 126
yabahiro 43:677f7446612e 127 DigitalIn EMC(PB_0);
yabahiro 43:677f7446612e 128
yabahiro 42:4f9689c0a349 129 void LedMode(int num)
yabahiro 35:94f026ab4d30 130 {
yabahiro 42:4f9689c0a349 131 POTENTIOMETER::dio[0]= selectnum[num][0];
yabahiro 42:4f9689c0a349 132 POTENTIOMETER::dio[1]= selectnum[num][1];;
yabahiro 42:4f9689c0a349 133 POTENTIOMETER::dio[2]= selectnum[num][2];;
yabahiro 42:4f9689c0a349 134 POTENTIOMETER::dio[3]= selectnum[num][3];;
yabahiro 35:94f026ab4d30 135
yabahiro 35:94f026ab4d30 136 }
yabahiro 31:45f97698857b 137 int Twsh;
yabahiro 31:45f97698857b 138 bool UP_flag = false;
yabahiro 35:94f026ab4d30 139 bool SW_flag = false;
yabahiro 31:45f97698857b 140 bool Air_flag = false;
yabahiro 35:94f026ab4d30 141 bool zyouge;
yabahiro 39:f89166d7411c 142 bool zyougedo;
yabahiro 31:45f97698857b 143 bool dz1=true;
yabahiro 31:45f97698857b 144 bool dz1i=false;
yabahiro 31:45f97698857b 145 bool dz2=true;
yabahiro 31:45f97698857b 146 bool dz2i=false;
yabahiro 31:45f97698857b 147 bool dz3=true;
yabahiro 31:45f97698857b 148 bool dz3i=false;
yabahiro 31:45f97698857b 149 bool dz4=true;
yabahiro 31:45f97698857b 150 bool dz4i=false;
yabahiro 31:45f97698857b 151 bool zone;
yabahiro 31:45f97698857b 152 bool through=false;
yabahiro 35:94f026ab4d30 153 bool counts=false;
yabahiro 36:788274604650 154 bool mtc=false;
yabahiro 36:788274604650 155 bool mtc2 = false;
yabahiro 43:677f7446612e 156 bool emcs=false;
yabahiro 45:878f8f385635 157 bool kiri;
yabahiro 31:45f97698857b 158
yabahiro 41:e1dd6d97f17d 159 bool start_flag = true;
yabahiro 41:e1dd6d97f17d 160
yabahiro 42:4f9689c0a349 161 int mode =0;
yabahiro 31:45f97698857b 162 int cross=0;//十字数える用
yabahiro 35:94f026ab4d30 163 int cros=0;
yabahiro 31:45f97698857b 164 int count=100000;//wait代替え
kishibekairohan 33:656aa14904a5 165
kishibekairohan 33:656aa14904a5 166 ///*********PWM調整用*********///
yabahiro 40:7f93984e8ba1 167 int fast =60;
yabahiro 40:7f93984e8ba1 168 int normal = 40;
yabahiro 40:7f93984e8ba1 169 int slow = 20;
yabahiro 31:45f97698857b 170
t_yamamoto 0:669ef71cba68 171 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 172
t_yamamoto 0:669ef71cba68 173 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 174 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 175 static void Process0(void);
t_yamamoto 0:669ef71cba68 176 #endif
t_yamamoto 0:669ef71cba68 177 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 178 static void Process1(void);
t_yamamoto 0:669ef71cba68 179 #endif
t_yamamoto 0:669ef71cba68 180 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 181 static void Process2(void);
t_yamamoto 0:669ef71cba68 182 #endif
t_yamamoto 0:669ef71cba68 183 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 184 static void Process3(void);
t_yamamoto 0:669ef71cba68 185 #endif
t_yamamoto 0:669ef71cba68 186 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 187 static void Process4(void);
t_yamamoto 0:669ef71cba68 188 #endif
t_yamamoto 0:669ef71cba68 189 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 190 static void Process5(void);
t_yamamoto 0:669ef71cba68 191 #endif
t_yamamoto 0:669ef71cba68 192 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 193 static void Process6(void);
t_yamamoto 0:669ef71cba68 194 #endif
t_yamamoto 0:669ef71cba68 195 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 196 static void Process7(void);
t_yamamoto 0:669ef71cba68 197 #endif
t_yamamoto 0:669ef71cba68 198 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 199 static void Process8(void);
t_yamamoto 0:669ef71cba68 200 #endif
t_yamamoto 0:669ef71cba68 201 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 202 static void Process9(void);
t_yamamoto 0:669ef71cba68 203 #endif
t_yamamoto 0:669ef71cba68 204 #endif
t_yamamoto 0:669ef71cba68 205
t_yamamoto 0:669ef71cba68 206 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 207 {
yabahiro 21:1f1e9c585da8 208 #pragma region USER-DEFINED_VARIABLE_INIT
yabahiro 21:1f1e9c585da8 209 /*Replace here with the initialization code of your variables.*/
yabahiro 21:1f1e9c585da8 210 #pragma endregion USER-DEFINED_VARIABLE_INIT
t_yamamoto 0:669ef71cba68 211
yabahiro 21:1f1e9c585da8 212 lock = true;
yabahiro 21:1f1e9c585da8 213 processChangeComp = true;
yabahiro 21:1f1e9c585da8 214 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 215
yabahiro 21:1f1e9c585da8 216 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 217 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 218 Process[0] = Process0;
yabahiro 21:1f1e9c585da8 219 #endif
yabahiro 21:1f1e9c585da8 220 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 221 Process[1] = Process1;
yabahiro 21:1f1e9c585da8 222 #endif
yabahiro 21:1f1e9c585da8 223 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 224 Process[2] = Process2;
yabahiro 21:1f1e9c585da8 225 #endif
yabahiro 21:1f1e9c585da8 226 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 227 Process[3] = Process3;
yabahiro 21:1f1e9c585da8 228 #endif
yabahiro 21:1f1e9c585da8 229 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 230 Process[4] = Process4;
yabahiro 21:1f1e9c585da8 231 #endif
yabahiro 21:1f1e9c585da8 232 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 233 Process[5] = Process5;
yabahiro 21:1f1e9c585da8 234 #endif
yabahiro 21:1f1e9c585da8 235 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 236 Process[6] = Process6;
yabahiro 21:1f1e9c585da8 237 #endif
yabahiro 21:1f1e9c585da8 238 #if USE_PROCESS_NUM>7
yabahiro 21:1f1e9c585da8 239 Process[7] = Process7;
yabahiro 21:1f1e9c585da8 240 #endif
yabahiro 21:1f1e9c585da8 241 #if USE_PROCESS_NUM>8
yabahiro 21:1f1e9c585da8 242 Process[8] = Process8;
yabahiro 21:1f1e9c585da8 243 #endif
yabahiro 21:1f1e9c585da8 244 #if USE_PROCESS_NUM>9
yabahiro 21:1f1e9c585da8 245 Process[9] = Process9;
yabahiro 21:1f1e9c585da8 246 #endif
yabahiro 21:1f1e9c585da8 247 #endif
t_yamamoto 0:669ef71cba68 248 }
t_yamamoto 0:669ef71cba68 249
t_yamamoto 0:669ef71cba68 250 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 251 {
yabahiro 21:1f1e9c585da8 252 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 253 if(controller->Button.HOME) lock = false;
yabahiro 21:1f1e9c585da8 254
yabahiro 21:1f1e9c585da8 255 if(controller->Button.START && processChangeComp) {
yabahiro 21:1f1e9c585da8 256 current++;
yabahiro 21:1f1e9c585da8 257 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
yabahiro 21:1f1e9c585da8 258 processChangeComp = false;
yabahiro 21:1f1e9c585da8 259 } else if(controller->Button.SELECT && processChangeComp) {
yabahiro 21:1f1e9c585da8 260 current--;
yabahiro 21:1f1e9c585da8 261 if (current < 0) current = 0;
yabahiro 21:1f1e9c585da8 262 processChangeComp = false;
yabahiro 21:1f1e9c585da8 263 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
yabahiro 21:1f1e9c585da8 264 #endif
yabahiro 21:1f1e9c585da8 265
yabahiro 21:1f1e9c585da8 266 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 267 ACTUATORHUB::MOTOR::Motor::Update(motor);
yabahiro 21:1f1e9c585da8 268 #endif
yabahiro 21:1f1e9c585da8 269
yabahiro 21:1f1e9c585da8 270 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 271 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
yabahiro 21:1f1e9c585da8 272 #endif
yabahiro 21:1f1e9c585da8 273
yabahiro 21:1f1e9c585da8 274 #ifdef USE_RS485
yabahiro 21:1f1e9c585da8 275 ACTUATORHUB::ActuatorHub::Update();
yabahiro 21:1f1e9c585da8 276 #endif
yabahiro 21:1f1e9c585da8 277
yabahiro 21:1f1e9c585da8 278 }
yabahiro 21:1f1e9c585da8 279
yabahiro 21:1f1e9c585da8 280 int g[8];
yabahiro 21:1f1e9c585da8 281
yabahiro 21:1f1e9c585da8 282 void SystemProcess()
yabahiro 21:1f1e9c585da8 283 {
yabahiro 21:1f1e9c585da8 284 SystemProcessInitialize();
yabahiro 21:1f1e9c585da8 285
yabahiro 21:1f1e9c585da8 286 while(1) {
yabahiro 43:677f7446612e 287 if(EMC==0) {
yabahiro 43:677f7446612e 288 fast=40;
yabahiro 43:677f7446612e 289 normal=30;
yabahiro 43:677f7446612e 290 slow=20;
yabahiro 43:677f7446612e 291 cross=0;//十字数える用
yabahiro 43:677f7446612e 292 cros=0;
yabahiro 46:4a8bca4cc1fd 293 count=0;//wait代替え
yabahiro 43:677f7446612e 294 UP_flag = false;
yabahiro 43:677f7446612e 295 SW_flag = false;
yabahiro 43:677f7446612e 296 Air_flag = false;
yabahiro 43:677f7446612e 297 zyouge=false;
yabahiro 43:677f7446612e 298 zyougedo=false;
yabahiro 43:677f7446612e 299 dz1=true;
yabahiro 43:677f7446612e 300 dz1i=false;
yabahiro 43:677f7446612e 301 dz2=true;
yabahiro 43:677f7446612e 302 dz2i=false;
yabahiro 43:677f7446612e 303 dz3=true;
yabahiro 43:677f7446612e 304 dz3i=false;
yabahiro 43:677f7446612e 305 dz4=true;
yabahiro 43:677f7446612e 306 dz4i=false;
yabahiro 43:677f7446612e 307 through=false;
yabahiro 43:677f7446612e 308 counts=false;
yabahiro 43:677f7446612e 309 mtc=false;
yabahiro 43:677f7446612e 310 mtc2 = false;
yabahiro 43:677f7446612e 311 current = 0;
yabahiro 43:677f7446612e 312 SystemProcessInitialize();
yabahiro 43:677f7446612e 313 if(emcs==false) {
yabahiro 43:677f7446612e 314 AllActuatorReset();
yabahiro 43:677f7446612e 315 emcs=true;
yabahiro 43:677f7446612e 316 }
yabahiro 43:677f7446612e 317 } else {
yabahiro 43:677f7446612e 318 emcs=false;
yabahiro 43:677f7446612e 319 }
yabahiro 43:677f7446612e 320
yabahiro 42:4f9689c0a349 321 if(mode==0) {
yabahiro 42:4f9689c0a349 322 if(ZoneSW) {
yabahiro 42:4f9689c0a349 323 LedMode(1);
yabahiro 42:4f9689c0a349 324 } else {
yabahiro 42:4f9689c0a349 325 LedMode(2);
yabahiro 42:4f9689c0a349 326 }
yabahiro 42:4f9689c0a349 327 }
yabahiro 21:1f1e9c585da8 328 for(int i = 0; i < 8; i++) {
yabahiro 21:1f1e9c585da8 329 g[i] = LineHub::GetPara(i);
yabahiro 21:1f1e9c585da8 330 }
yabahiro 41:e1dd6d97f17d 331 if(ThSW) {
yabahiro 41:e1dd6d97f17d 332 Twsh=1;
yabahiro 41:e1dd6d97f17d 333 } else {
yabahiro 41:e1dd6d97f17d 334 Twsh=2;
yabahiro 41:e1dd6d97f17d 335 }
yabahiro 42:4f9689c0a349 336
yabahiro 45:878f8f385635 337 if(StertSW && start_flag == true) {
yabahiro 42:4f9689c0a349 338 start_flag = false;
yabahiro 42:4f9689c0a349 339 lock = false;
yabahiro 42:4f9689c0a349 340 if(ZoneSW) {
yabahiro 46:4a8bca4cc1fd 341 count=0;
yabahiro 42:4f9689c0a349 342 mode=1;
yabahiro 44:c208a908583c 343 current = 6;
yabahiro 46:4a8bca4cc1fd 344
yabahiro 42:4f9689c0a349 345 } else {
yabahiro 46:4a8bca4cc1fd 346 count=0;
yabahiro 42:4f9689c0a349 347 mode=1;
yabahiro 43:677f7446612e 348 current = 4;
yabahiro 41:e1dd6d97f17d 349 }
yabahiro 42:4f9689c0a349 350 }
yabahiro 41:e1dd6d97f17d 351 if(DWSW||DOSW) {
yabahiro 41:e1dd6d97f17d 352 if(DWSW) {
yabahiro 41:e1dd6d97f17d 353 zyouge=true;
yabahiro 41:e1dd6d97f17d 354 }
yabahiro 41:e1dd6d97f17d 355 if(DOSW) {
yabahiro 41:e1dd6d97f17d 356 if(DOLS) {
yabahiro 41:e1dd6d97f17d 357 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 358 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 359 } else {
yabahiro 41:e1dd6d97f17d 360 motor[MOTOR_0].pwm = 50;
yabahiro 41:e1dd6d97f17d 361 motor[MOTOR_0].dir = BACK;
yabahiro 41:e1dd6d97f17d 362 }
yabahiro 41:e1dd6d97f17d 363 }
yabahiro 42:4f9689c0a349 364 } else if(zyouge==false) {
yabahiro 41:e1dd6d97f17d 365 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 366 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 367 }
yabahiro 41:e1dd6d97f17d 368 if(zyouge) {
yabahiro 41:e1dd6d97f17d 369 if(Twsh==1) {
yabahiro 46:4a8bca4cc1fd 370 motor[MOTOR_0].pwm = 215;
yabahiro 41:e1dd6d97f17d 371 motor[MOTOR_0].dir = FOR;
yabahiro 41:e1dd6d97f17d 372 if(UPLS) {
yabahiro 41:e1dd6d97f17d 373 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 374 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 375 zyouge=false;
yabahiro 41:e1dd6d97f17d 376 }
yabahiro 41:e1dd6d97f17d 377 }
yabahiro 41:e1dd6d97f17d 378 if(Twsh==2) {
yabahiro 46:4a8bca4cc1fd 379 motor[MOTOR_0].pwm = 245;
yabahiro 41:e1dd6d97f17d 380 motor[MOTOR_0].dir = FOR;
yabahiro 41:e1dd6d97f17d 381 if(UPLS2) {
yabahiro 41:e1dd6d97f17d 382 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 383 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 384 zyouge=false;
yabahiro 41:e1dd6d97f17d 385 }
yabahiro 41:e1dd6d97f17d 386 }
yabahiro 41:e1dd6d97f17d 387 }
yabahiro 41:e1dd6d97f17d 388 if(AIRSW) {
yabahiro 41:e1dd6d97f17d 389 if(SW_flag==false) {
yabahiro 41:e1dd6d97f17d 390 if(Air_flag==false) {
yabahiro 41:e1dd6d97f17d 391 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 41:e1dd6d97f17d 392 Air_flag=true;
yabahiro 41:e1dd6d97f17d 393 SW_flag=true;
yabahiro 41:e1dd6d97f17d 394 } else {
yabahiro 41:e1dd6d97f17d 395 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 41:e1dd6d97f17d 396 Air_flag=false;
yabahiro 41:e1dd6d97f17d 397 SW_flag=true;
yabahiro 41:e1dd6d97f17d 398 }
yabahiro 41:e1dd6d97f17d 399 }
yabahiro 41:e1dd6d97f17d 400 } else {
yabahiro 42:4f9689c0a349 401 if( SW_flag==true) {
yabahiro 42:4f9689c0a349 402 count++;
yabahiro 43:677f7446612e 403 if(count>=2000) {
yabahiro 42:4f9689c0a349 404 SW_flag=false;
yabahiro 42:4f9689c0a349 405 count=0;
yabahiro 42:4f9689c0a349 406 }
yabahiro 42:4f9689c0a349 407 }
yabahiro 41:e1dd6d97f17d 408 }
yabahiro 35:94f026ab4d30 409
yabahiro 36:788274604650 410 //printf("0:%d 1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 9:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 35:94f026ab4d30 411
yabahiro 21:1f1e9c585da8 412 #ifdef USE_MU
yabahiro 21:1f1e9c585da8 413 controller = CONTROLLER::Controller::GetData();
yabahiro 21:1f1e9c585da8 414 #endif
yabahiro 21:1f1e9c585da8 415
yabahiro 21:1f1e9c585da8 416 #ifdef USE_ERRORCHECK
yabahiro 41:e1dd6d97f17d 417 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost & start_flag) { //& start_flag
yabahiro 21:1f1e9c585da8 418 CONTROLLER::Controller::DataReset();
yabahiro 21:1f1e9c585da8 419 AllActuatorReset();
yabahiro 21:1f1e9c585da8 420 lock = true;
yabahiro 21:1f1e9c585da8 421 } else
yabahiro 21:1f1e9c585da8 422 #endif
yabahiro 21:1f1e9c585da8 423 {
yabahiro 21:1f1e9c585da8 424
yabahiro 21:1f1e9c585da8 425 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 426 if(!lock) {
yabahiro 21:1f1e9c585da8 427 Process[current]();
yabahiro 21:1f1e9c585da8 428 } else
yabahiro 21:1f1e9c585da8 429 #endif
yabahiro 21:1f1e9c585da8 430 {
yabahiro 21:1f1e9c585da8 431 //ロック時の処理
yabahiro 21:1f1e9c585da8 432 }
yabahiro 21:1f1e9c585da8 433 }
yabahiro 43:677f7446612e 434
yabahiro 21:1f1e9c585da8 435 SystemProcessUpdate();
yabahiro 21:1f1e9c585da8 436 }
t_yamamoto 0:669ef71cba68 437 }
t_yamamoto 0:669ef71cba68 438
t_yamamoto 0:669ef71cba68 439 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 440 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 441 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 442 static void Process0()
yabahiro 21:1f1e9c585da8 443 {
yabahiro 42:4f9689c0a349 444 /*
yabahiro 36:788274604650 445 mode=1;
yabahiro 36:788274604650 446 LedMode(1);
yabahiro 35:94f026ab4d30 447 if(ThSW) {
yabahiro 35:94f026ab4d30 448 Twsh=1;
yabahiro 35:94f026ab4d30 449 } else {
yabahiro 35:94f026ab4d30 450 Twsh=2;
yabahiro 31:45f97698857b 451 }
yabahiro 36:788274604650 452
yabahiro 25:38d4964e8aad 453 if(StertSW) {
yabahiro 41:e1dd6d97f17d 454 //start_flag == false;
yabahiro 41:e1dd6d97f17d 455 //lock = false;
yabahiro 36:788274604650 456 if(ZoneSW) {
yabahiro 31:45f97698857b 457 mode=1;
yabahiro 31:45f97698857b 458 current = 2;
yabahiro 31:45f97698857b 459 } else {
yabahiro 31:45f97698857b 460 mode=1;
yabahiro 40:7f93984e8ba1 461 current = 5;
yabahiro 31:45f97698857b 462 }
yabahiro 25:38d4964e8aad 463 }
yabahiro 35:94f026ab4d30 464 if(DWSW) {
yabahiro 35:94f026ab4d30 465 zyouge=true;
yabahiro 35:94f026ab4d30 466 }
yabahiro 39:f89166d7411c 467 if(DOSW) {
yabahiro 39:f89166d7411c 468 zyougedo=true;
yabahiro 39:f89166d7411c 469 }
yabahiro 35:94f026ab4d30 470 if(AIRSW) {
yabahiro 35:94f026ab4d30 471 if(SW_flag==false) {
yabahiro 35:94f026ab4d30 472 if(Air_flag==false) {
yabahiro 35:94f026ab4d30 473 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 35:94f026ab4d30 474 Air_flag=true;
yabahiro 35:94f026ab4d30 475 SW_flag=true;
yabahiro 35:94f026ab4d30 476 } else {
yabahiro 35:94f026ab4d30 477 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 35:94f026ab4d30 478 Air_flag=false;
yabahiro 35:94f026ab4d30 479 SW_flag=true;
yabahiro 35:94f026ab4d30 480 }
yabahiro 35:94f026ab4d30 481 }
yabahiro 35:94f026ab4d30 482 } else {
yabahiro 35:94f026ab4d30 483 SW_flag=false;
yabahiro 31:45f97698857b 484 }
yabahiro 31:45f97698857b 485
yabahiro 35:94f026ab4d30 486 if(zyouge) {
yabahiro 35:94f026ab4d30 487 if(Twsh==1) {
yabahiro 35:94f026ab4d30 488 motor[MOTOR_0].pwm = 220;
yabahiro 35:94f026ab4d30 489 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 490 if(UPLS) {
yabahiro 35:94f026ab4d30 491 motor[MOTOR_0].pwm = 100;
yabahiro 35:94f026ab4d30 492 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 493 zyouge=false;
yabahiro 35:94f026ab4d30 494 }
yabahiro 35:94f026ab4d30 495 }
yabahiro 35:94f026ab4d30 496 if(Twsh==2) {
yabahiro 37:7cfa39c41245 497 motor[MOTOR_0].pwm = 230;
yabahiro 35:94f026ab4d30 498 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 499 if(UPLS2) {
yabahiro 35:94f026ab4d30 500 motor[MOTOR_0].pwm = 100;
yabahiro 35:94f026ab4d30 501 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 502 zyouge=false;
yabahiro 35:94f026ab4d30 503 }
yabahiro 31:45f97698857b 504 }
yabahiro 39:f89166d7411c 505 }
yabahiro 39:f89166d7411c 506 if(zyougedo) {
yabahiro 39:f89166d7411c 507 motor[MOTOR_0].pwm = 50;
yabahiro 39:f89166d7411c 508 motor[MOTOR_0].dir = BACK;
yabahiro 39:f89166d7411c 509 if(DOLS) {
yabahiro 39:f89166d7411c 510 motor[MOTOR_0].pwm = 100;
yabahiro 39:f89166d7411c 511 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:f89166d7411c 512 zyougedo=false;
yabahiro 39:f89166d7411c 513 }
yabahiro 31:45f97698857b 514 }
yabahiro 42:4f9689c0a349 515 */
yabahiro 35:94f026ab4d30 516 }
t_yamamoto 0:669ef71cba68 517 #endif
t_yamamoto 0:669ef71cba68 518
t_yamamoto 0:669ef71cba68 519 #if USE_PROCESS_NUM>1
kishibekairohan 16:3f2c2d89372b 520 static void Process1()
t_yamamoto 0:669ef71cba68 521 {
yabahiro 42:4f9689c0a349 522 LedMode(6);
yabahiro 41:e1dd6d97f17d 523 start_flag = true;
yabahiro 36:788274604650 524 mtc=false;
yabahiro 36:788274604650 525 mtc2 = false;
yabahiro 31:45f97698857b 526 mode=1;
yabahiro 27:545148741493 527 cross=0;
yabahiro 35:94f026ab4d30 528 Twsh=1;
yabahiro 21:1f1e9c585da8 529 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 530 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 531 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 532 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 533
yabahiro 21:1f1e9c585da8 534 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 535 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 536 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 537 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 538
yabahiro 21:1f1e9c585da8 539 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 540
yabahiro 21:1f1e9c585da8 541 if(controller->Button.UP) {
yabahiro 35:94f026ab4d30 542 motor[MOTOR_0].pwm =200;
yabahiro 21:1f1e9c585da8 543 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 544 if(UPLS) {
yabahiro 35:94f026ab4d30 545 motor[MOTOR_0].pwm = 0;
yabahiro 35:94f026ab4d30 546 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 547 }
yabahiro 21:1f1e9c585da8 548 }
yabahiro 21:1f1e9c585da8 549 if(controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 550 motor[MOTOR_0].pwm = 50;
yabahiro 21:1f1e9c585da8 551 motor[MOTOR_0].dir = BACK;
yabahiro 21:1f1e9c585da8 552 }
yabahiro 21:1f1e9c585da8 553 } else {
yabahiro 21:1f1e9c585da8 554 motor[MOTOR_0].pwm = 0;
yabahiro 21:1f1e9c585da8 555 motor[MOTOR_0].dir = BRAKE;
yabahiro 21:1f1e9c585da8 556 }
yabahiro 21:1f1e9c585da8 557
yabahiro 21:1f1e9c585da8 558 if(controller->Button.Y) {
yabahiro 21:1f1e9c585da8 559 if(dz2==true) {
yabahiro 21:1f1e9c585da8 560 if(dz2i==false) {
yabahiro 21:1f1e9c585da8 561 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 562 dz2i=true;
yabahiro 21:1f1e9c585da8 563 } else {
yabahiro 21:1f1e9c585da8 564 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 565 dz2i=false;
yabahiro 21:1f1e9c585da8 566 }
yabahiro 21:1f1e9c585da8 567 dz2=false;
yabahiro 21:1f1e9c585da8 568 }
yabahiro 21:1f1e9c585da8 569 } else {
yabahiro 21:1f1e9c585da8 570 dz2=true;
yabahiro 21:1f1e9c585da8 571 }
yabahiro 21:1f1e9c585da8 572
yabahiro 21:1f1e9c585da8 573 if(controller->Button.A) {
yabahiro 21:1f1e9c585da8 574 if(dz3==true) {
yabahiro 21:1f1e9c585da8 575 if(dz3i==false) {
yabahiro 30:9450dc1d53cc 576
yabahiro 21:1f1e9c585da8 577 dz3i=true;
yabahiro 21:1f1e9c585da8 578 } else {
yabahiro 21:1f1e9c585da8 579 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 580 dz3i=false;
yabahiro 21:1f1e9c585da8 581 }
yabahiro 21:1f1e9c585da8 582 dz3=false;
yabahiro 21:1f1e9c585da8 583 }
yabahiro 21:1f1e9c585da8 584 } else {
yabahiro 21:1f1e9c585da8 585 dz3=true;
yabahiro 21:1f1e9c585da8 586 }
yabahiro 21:1f1e9c585da8 587
yabahiro 21:1f1e9c585da8 588 if(controller->Button.B) {
yabahiro 21:1f1e9c585da8 589 if(dz4==true) {
yabahiro 21:1f1e9c585da8 590 if(dz4i==false) {
yabahiro 21:1f1e9c585da8 591 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 592 dz4i=true;
yabahiro 21:1f1e9c585da8 593 } else {
yabahiro 21:1f1e9c585da8 594 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 595 dz4i=false;
yabahiro 21:1f1e9c585da8 596 }
yabahiro 21:1f1e9c585da8 597 dz4=false;
yabahiro 21:1f1e9c585da8 598 }
yabahiro 21:1f1e9c585da8 599 } else {
yabahiro 21:1f1e9c585da8 600 dz4=true;
yabahiro 21:1f1e9c585da8 601 }
yabahiro 21:1f1e9c585da8 602 /*
yabahiro 21:1f1e9c585da8 603 if(controller->Button.RIGHT){
yabahiro 21:1f1e9c585da8 604 motor[MOTOR_1].dir = FOR;
yabahiro 21:1f1e9c585da8 605 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 606 if (ARM_1){
yabahiro 21:1f1e9c585da8 607 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 608 }
yabahiro 21:1f1e9c585da8 609 }
yabahiro 21:1f1e9c585da8 610 else if(controller->Button.LEFT){
yabahiro 21:1f1e9c585da8 611 motor[MOTOR_1].dir = BACK;
yabahiro 21:1f1e9c585da8 612 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 613 if (ARM_0){
yabahiro 21:1f1e9c585da8 614 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 615 }
yabahiro 21:1f1e9c585da8 616 }
yabahiro 21:1f1e9c585da8 617 */
t_yamamoto 0:669ef71cba68 618 }
t_yamamoto 0:669ef71cba68 619 #endif
t_yamamoto 0:669ef71cba68 620
t_yamamoto 0:669ef71cba68 621 #if USE_PROCESS_NUM>2
kishibekairohan 16:3f2c2d89372b 622 static void Process2()
yabahiro 21:1f1e9c585da8 623 {
yabahiro 42:4f9689c0a349 624 // printf("1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 36:788274604650 625 LedMode(3);
yabahiro 31:45f97698857b 626 count++;
yabahiro 44:c208a908583c 627 if(mode==0||mode==1) {
yabahiro 35:94f026ab4d30 628
yabahiro 38:391a0c8e4c16 629 if(Twsh==2) {
yabahiro 38:391a0c8e4c16 630 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 38:391a0c8e4c16 631 }
yabahiro 35:94f026ab4d30 632 if(counts==false&&g[0]==0) {
yabahiro 35:94f026ab4d30 633 cros++;
yabahiro 35:94f026ab4d30 634 counts=true;
yabahiro 35:94f026ab4d30 635 }
yabahiro 35:94f026ab4d30 636 if(counts==true&&g[0]==99) {
yabahiro 35:94f026ab4d30 637 counts=false;
yabahiro 35:94f026ab4d30 638 }
yabahiro 35:94f026ab4d30 639
yabahiro 35:94f026ab4d30 640 if(cros==2) {
yabahiro 37:7cfa39c41245 641
yabahiro 37:7cfa39c41245 642 // mode=21;
yabahiro 37:7cfa39c41245 643 // count=0;
yabahiro 37:7cfa39c41245 644 // cros=0;
yabahiro 35:94f026ab4d30 645 }//ゆっくりモードに入れなかった時の保険
yabahiro 44:c208a908583c 646 if(g[0]==0) {
yabahiro 44:c208a908583c 647 fast=35;
yabahiro 44:c208a908583c 648 normal=20;
yabahiro 44:c208a908583c 649 slow=15;
yabahiro 44:c208a908583c 650 }
yabahiro 45:878f8f385635 651
yabahiro 31:45f97698857b 652 switch(g[2]) {
yabahiro 31:45f97698857b 653 case 98:
kishibekairohan 33:656aa14904a5 654 motor[TIRE_FR].pwm = normal;
kishibekairohan 22:c47f29caded6 655 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 656 motor[TIRE_FL].pwm = normal;
kishibekairohan 22:c47f29caded6 657 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 658 motor[TIRE_BR].pwm = normal;
kishibekairohan 22:c47f29caded6 659 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 660 motor[TIRE_BL].pwm = normal;
kishibekairohan 22:c47f29caded6 661 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 662 if(count>30000) {
yabahiro 31:45f97698857b 663 cross++;
yabahiro 31:45f97698857b 664 count=0;
yabahiro 31:45f97698857b 665 }
yabahiro 31:45f97698857b 666 mtc2=true;
yabahiro 43:677f7446612e 667 if(cross==2) {
yabahiro 43:677f7446612e 668 mode=22;
yabahiro 31:45f97698857b 669 count=0;
yabahiro 31:45f97698857b 670 cross=0;
yabahiro 44:c208a908583c 671 fast=40;
yabahiro 44:c208a908583c 672 normal=30;
yabahiro 44:c208a908583c 673 slow=20;
yabahiro 31:45f97698857b 674 }
yabahiro 31:45f97698857b 675 break;
yabahiro 31:45f97698857b 676 case 0:
kishibekairohan 33:656aa14904a5 677 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 678 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 679 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 680 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 681 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 682 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 683 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 684 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 685 mtc2=true;
yabahiro 31:45f97698857b 686 break;
yabahiro 31:45f97698857b 687 case 255:
kishibekairohan 33:656aa14904a5 688 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 689 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 690 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 691 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 692 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 693 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 694 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 695 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 696 mtc2=true;
yabahiro 31:45f97698857b 697 break;
yabahiro 31:45f97698857b 698 case 253:
yabahiro 31:45f97698857b 699 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 700 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 701 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 702 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 703 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 704 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 705 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 706 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 707 mtc2=true;
yabahiro 31:45f97698857b 708 break;
yabahiro 31:45f97698857b 709 case 254:
yabahiro 31:45f97698857b 710 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 711 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 712 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 713 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 714 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 715 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 716 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 717 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 718 mtc2=true;
yabahiro 31:45f97698857b 719 break;
yabahiro 31:45f97698857b 720 case 1:
kishibekairohan 33:656aa14904a5 721 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 722 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 723 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 724 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 725 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 726 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 727 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 728 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 729 mtc2=true;
yabahiro 31:45f97698857b 730 break;
yabahiro 31:45f97698857b 731 case 3:
kishibekairohan 33:656aa14904a5 732 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 733 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 734 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 735 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 736 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 737 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 738 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 739 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 740 mtc2=true;
yabahiro 31:45f97698857b 741 break;
yabahiro 31:45f97698857b 742 case 2:
kishibekairohan 33:656aa14904a5 743 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 744 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 745 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 746 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 747 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 748 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 749 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 750 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 751 mtc2=true;
yabahiro 31:45f97698857b 752 break;
yabahiro 31:45f97698857b 753 }
yabahiro 31:45f97698857b 754 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 755 switch(g[3]) {
yabahiro 29:c78a46f51209 756 case 0:
yabahiro 31:45f97698857b 757 mtc2=false;
yabahiro 29:c78a46f51209 758 break;
yabahiro 29:c78a46f51209 759 case 255:
yabahiro 31:45f97698857b 760 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 761 mtc2=false;
yabahiro 29:c78a46f51209 762 break;
yabahiro 29:c78a46f51209 763 case 253:
yabahiro 31:45f97698857b 764 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 765 mtc2=false;
yabahiro 29:c78a46f51209 766 break;
yabahiro 29:c78a46f51209 767 case 254:
yabahiro 31:45f97698857b 768 motor[TIRE_BL].pwm += 20;
yabahiro 29:c78a46f51209 769 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 770 mtc2=false;
yabahiro 29:c78a46f51209 771 break;
yabahiro 29:c78a46f51209 772 case 1:
yabahiro 31:45f97698857b 773 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 774 mtc2=false;
yabahiro 29:c78a46f51209 775 break;
yabahiro 29:c78a46f51209 776 case 3:
yabahiro 31:45f97698857b 777 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 778 mtc2=false;
yabahiro 29:c78a46f51209 779 break;
yabahiro 29:c78a46f51209 780 case 2:
yabahiro 31:45f97698857b 781 motor[TIRE_FL].pwm += 20;
yabahiro 31:45f97698857b 782 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 783 mtc2=false;
yabahiro 29:c78a46f51209 784 break;
yabahiro 29:c78a46f51209 785 }
yabahiro 31:45f97698857b 786 }
yabahiro 31:45f97698857b 787 } else if(mode==21) {
yabahiro 43:677f7446612e 788 motor[TIRE_FR].pwm = 30;
yabahiro 42:4f9689c0a349 789 motor[TIRE_FR].dir = FOR;
yabahiro 42:4f9689c0a349 790 motor[TIRE_FL].pwm = 30;
yabahiro 42:4f9689c0a349 791 motor[TIRE_FL].dir = FOR;
yabahiro 43:677f7446612e 792 motor[TIRE_BR].pwm = 30;
yabahiro 42:4f9689c0a349 793 motor[TIRE_BR].dir = BACK;
yabahiro 42:4f9689c0a349 794 motor[TIRE_BL].pwm = 30;
yabahiro 42:4f9689c0a349 795 motor[TIRE_BL].dir = BACK;
yabahiro 42:4f9689c0a349 796 if(g[2]==98&&count>=10000) {
yabahiro 42:4f9689c0a349 797 mode=22;
yabahiro 42:4f9689c0a349 798 count=0;
yabahiro 42:4f9689c0a349 799 }
yabahiro 43:677f7446612e 800 }
yabahiro 44:c208a908583c 801 if(YELLOW==true) {
yabahiro 43:677f7446612e 802 if(mode==22) {
yabahiro 44:c208a908583c 803 motor[TIRE_FR].pwm = 100;
yabahiro 43:677f7446612e 804 motor[TIRE_FR].dir = BRAKE;
yabahiro 44:c208a908583c 805 motor[TIRE_FL].pwm = 100;
yabahiro 43:677f7446612e 806 motor[TIRE_FL].dir = BRAKE;
yabahiro 44:c208a908583c 807 motor[TIRE_BR].pwm = 100;
yabahiro 43:677f7446612e 808 motor[TIRE_BR].dir = BRAKE;
yabahiro 44:c208a908583c 809 motor[TIRE_BL].pwm = 100;
yabahiro 43:677f7446612e 810 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 811 if(count>=10000) {
yabahiro 43:677f7446612e 812 mode=23;
yabahiro 43:677f7446612e 813 }
yabahiro 43:677f7446612e 814 } else if(mode==23) {
yabahiro 43:677f7446612e 815 motor[TIRE_FR].pwm = 20;
yabahiro 43:677f7446612e 816 motor[TIRE_FR].dir = BACK;
yabahiro 43:677f7446612e 817 motor[TIRE_FL].pwm = 20;
yabahiro 43:677f7446612e 818 motor[TIRE_FL].dir = BACK;
yabahiro 43:677f7446612e 819 motor[TIRE_BR].pwm = 20;
yabahiro 43:677f7446612e 820 motor[TIRE_BR].dir = FOR;
yabahiro 43:677f7446612e 821 motor[TIRE_BL].pwm = 20;
yabahiro 43:677f7446612e 822 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 823 if(g[2]==98) {
yabahiro 44:c208a908583c 824 mode=24;
yabahiro 44:c208a908583c 825 count=0;
yabahiro 44:c208a908583c 826 }
yabahiro 44:c208a908583c 827 } else if(mode==24) {
yabahiro 44:c208a908583c 828 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 829 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 830 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 831 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 832 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 833 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 834 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 835 motor[TIRE_BL].dir = FOR;
yabahiro 43:677f7446612e 836 if(g[2]!=98) {
yabahiro 43:677f7446612e 837 count=0;
yabahiro 44:c208a908583c 838 mode=25;
yabahiro 43:677f7446612e 839 }
yabahiro 44:c208a908583c 840 } else if(mode==25) {
yabahiro 43:677f7446612e 841 motor[TIRE_FR].pwm = 10;
yabahiro 43:677f7446612e 842 motor[TIRE_FR].dir = BRAKE;
yabahiro 43:677f7446612e 843 motor[TIRE_FL].pwm = 10;
yabahiro 43:677f7446612e 844 motor[TIRE_FL].dir = BRAKE;
yabahiro 43:677f7446612e 845 motor[TIRE_BR].pwm = 10;
yabahiro 43:677f7446612e 846 motor[TIRE_BR].dir = BRAKE;
yabahiro 43:677f7446612e 847 motor[TIRE_BL].pwm = 10;
yabahiro 43:677f7446612e 848 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 849 if(count>=10000) {
yabahiro 44:c208a908583c 850 mode=26;
yabahiro 44:c208a908583c 851 count=0;
yabahiro 43:677f7446612e 852 }
yabahiro 44:c208a908583c 853 } else if(mode==26) {
yabahiro 44:c208a908583c 854 motor[TIRE_FR].pwm = 20;
yabahiro 43:677f7446612e 855 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 856 motor[TIRE_FL].pwm = 20;
yabahiro 43:677f7446612e 857 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 858 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 859 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 860 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 861 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 862 if(count>=5000) {
yabahiro 44:c208a908583c 863 mode=27;
yabahiro 44:c208a908583c 864 count=0;
yabahiro 44:c208a908583c 865 }
yabahiro 44:c208a908583c 866 } else if(mode==27) {
yabahiro 44:c208a908583c 867 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 868 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 869 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 870 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 871 motor[TIRE_BR].pwm = 20;
yabahiro 43:677f7446612e 872 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 873 motor[TIRE_BL].pwm = 20;
yabahiro 43:677f7446612e 874 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 875 //どれくらい回転するかって値
yabahiro 44:c208a908583c 876 if(count>=2500) {
yabahiro 44:c208a908583c 877 count=0;
yabahiro 43:677f7446612e 878 mode=30;
yabahiro 43:677f7446612e 879 }
yabahiro 43:677f7446612e 880 } else if(mode==24) {
yabahiro 43:677f7446612e 881 motor[TIRE_FR].pwm = 10;
yabahiro 43:677f7446612e 882 motor[TIRE_FR].dir = BRAKE;
yabahiro 43:677f7446612e 883 motor[TIRE_FL].pwm = 10;
yabahiro 43:677f7446612e 884 motor[TIRE_FL].dir = BRAKE;
yabahiro 43:677f7446612e 885 motor[TIRE_BR].pwm = 10;
yabahiro 43:677f7446612e 886 motor[TIRE_BR].dir = BRAKE;
yabahiro 43:677f7446612e 887 motor[TIRE_BL].pwm = 10;
yabahiro 43:677f7446612e 888 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 889 if(count>=10000) {
yabahiro 43:677f7446612e 890 mode=30;
yabahiro 44:c208a908583c 891 count=0;
yabahiro 43:677f7446612e 892 }
yabahiro 42:4f9689c0a349 893 }
yabahiro 43:677f7446612e 894 } else {
yabahiro 43:677f7446612e 895 if(mode==22) {
yabahiro 43:677f7446612e 896 motor[TIRE_FR].pwm = 0;
yabahiro 43:677f7446612e 897 motor[TIRE_FR].dir = FREE;
yabahiro 43:677f7446612e 898 motor[TIRE_FL].pwm = 25;
yabahiro 43:677f7446612e 899 motor[TIRE_FL].dir = FOR;
yabahiro 43:677f7446612e 900 motor[TIRE_BR].pwm = 25;
yabahiro 43:677f7446612e 901 motor[TIRE_BR].dir = BACK;
yabahiro 43:677f7446612e 902 motor[TIRE_BL].pwm = 0;
yabahiro 43:677f7446612e 903 motor[TIRE_BL].dir = FREE;
yabahiro 43:677f7446612e 904 if(g[0]==0) {
yabahiro 43:677f7446612e 905 mode=30;
yabahiro 43:677f7446612e 906 cros=0;
yabahiro 43:677f7446612e 907 }
yabahiro 42:4f9689c0a349 908 }
yabahiro 43:677f7446612e 909 }
yabahiro 43:677f7446612e 910 if(mode==30) {
yabahiro 44:c208a908583c 911 motor[TIRE_FR].pwm = 59;
yabahiro 38:391a0c8e4c16 912 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 913 motor[TIRE_FL].pwm = 62;
yabahiro 38:391a0c8e4c16 914 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 915 motor[TIRE_BR].pwm = 59;
yabahiro 38:391a0c8e4c16 916 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 917 motor[TIRE_BL].pwm = 62;
yabahiro 38:391a0c8e4c16 918 motor[TIRE_BL].dir = FOR;
yabahiro 38:391a0c8e4c16 919 if(g[0]==98) {
yabahiro 35:94f026ab4d30 920 mode=31;
yabahiro 38:391a0c8e4c16 921 count=0;
yabahiro 38:391a0c8e4c16 922 }
yabahiro 38:391a0c8e4c16 923 } else if(mode==31) {
yabahiro 42:4f9689c0a349 924 motor[TIRE_FR].pwm = 0;
yabahiro 42:4f9689c0a349 925 motor[TIRE_FR].dir = FREE;
yabahiro 42:4f9689c0a349 926 motor[TIRE_FL].pwm = 0;
yabahiro 42:4f9689c0a349 927 motor[TIRE_FL].dir = FREE;
yabahiro 42:4f9689c0a349 928 motor[TIRE_BR].pwm = 0;
yabahiro 42:4f9689c0a349 929 motor[TIRE_BR].dir = FREE;
yabahiro 42:4f9689c0a349 930 motor[TIRE_BL].pwm = 0;
yabahiro 42:4f9689c0a349 931 motor[TIRE_BL].dir = FREE;
yabahiro 42:4f9689c0a349 932 if(count>=5000) {
yabahiro 38:391a0c8e4c16 933 count=0;
yabahiro 38:391a0c8e4c16 934 mode=32;
yabahiro 38:391a0c8e4c16 935 }
yabahiro 38:391a0c8e4c16 936 } else if(mode==32) {
yabahiro 42:4f9689c0a349 937 motor[TIRE_FR].pwm = 10;
yabahiro 42:4f9689c0a349 938 motor[TIRE_FR].dir = BRAKE;
yabahiro 42:4f9689c0a349 939 motor[TIRE_FL].pwm = 10;
yabahiro 42:4f9689c0a349 940 motor[TIRE_FL].dir = BRAKE;
yabahiro 42:4f9689c0a349 941 motor[TIRE_BR].pwm = 10;
yabahiro 42:4f9689c0a349 942 motor[TIRE_BR].dir = BRAKE;
yabahiro 42:4f9689c0a349 943 motor[TIRE_BL].pwm = 10;
yabahiro 42:4f9689c0a349 944 motor[TIRE_BL].dir = BRAKE;
yabahiro 42:4f9689c0a349 945 if(count>=40000) {
yabahiro 42:4f9689c0a349 946 mode=33;
yabahiro 42:4f9689c0a349 947 count=0;
yabahiro 42:4f9689c0a349 948 }
yabahiro 42:4f9689c0a349 949 } else if(mode==33) {
yabahiro 44:c208a908583c 950 motor[TIRE_FR].pwm = 0;
yabahiro 42:4f9689c0a349 951 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 952 motor[TIRE_FL].pwm = 30;
yabahiro 44:c208a908583c 953 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 954 motor[TIRE_BR].pwm = 30;
yabahiro 44:c208a908583c 955 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 956 motor[TIRE_BL].pwm = 0;
yabahiro 42:4f9689c0a349 957 motor[TIRE_BL].dir = FOR;
yabahiro 38:391a0c8e4c16 958 if(g[3]==0) {
yabahiro 38:391a0c8e4c16 959 count=0;
yabahiro 39:f89166d7411c 960 if(Twsh==2) {
yabahiro 39:f89166d7411c 961 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 39:f89166d7411c 962 }
yabahiro 38:391a0c8e4c16 963 mode=40;
yabahiro 38:391a0c8e4c16 964 }
yabahiro 31:45f97698857b 965 } else if(mode==40) {
yabahiro 38:391a0c8e4c16 966 if(LIB) {
yabahiro 38:391a0c8e4c16 967 mode=42;
yabahiro 38:391a0c8e4c16 968 }
yabahiro 35:94f026ab4d30 969 if(counts==false&&g[0]==0) {
yabahiro 35:94f026ab4d30 970 cros++;
yabahiro 35:94f026ab4d30 971 counts=true;
yabahiro 35:94f026ab4d30 972 }
yabahiro 35:94f026ab4d30 973 if(counts==true&&g[0]==99) {
yabahiro 35:94f026ab4d30 974 counts=false;
yabahiro 35:94f026ab4d30 975 }
yabahiro 35:94f026ab4d30 976
yabahiro 38:391a0c8e4c16 977 if(cros==1) {
yabahiro 36:788274604650 978 // mode=41;
yabahiro 35:94f026ab4d30 979 //count=0;
yabahiro 35:94f026ab4d30 980 //cros=0;
yabahiro 35:94f026ab4d30 981 }//ゆっくりモードに入れなかった時の保険
yabahiro 35:94f026ab4d30 982
yabahiro 31:45f97698857b 983 switch(g[3]) {
yabahiro 31:45f97698857b 984 case 98:
kishibekairohan 33:656aa14904a5 985 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 986 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 987 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 988 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 989 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 990 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 991 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 992 motor[TIRE_BL].dir = FOR;
yabahiro 35:94f026ab4d30 993 if(count>20000) {
yabahiro 31:45f97698857b 994 cross++;
yabahiro 31:45f97698857b 995 count=0;
yabahiro 31:45f97698857b 996 }
yabahiro 31:45f97698857b 997 mtc2=true;
yabahiro 44:c208a908583c 998 if(cross==2) {
yabahiro 31:45f97698857b 999 mode=41;
yabahiro 31:45f97698857b 1000 count=0;
yabahiro 31:45f97698857b 1001 cross=0;
kishibekairohan 22:c47f29caded6 1002 }
yabahiro 31:45f97698857b 1003 break;
yabahiro 31:45f97698857b 1004 case 0:
kishibekairohan 33:656aa14904a5 1005 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1006 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1007 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1008 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1009 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1010 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1011 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1012 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1013 mtc2=true;
yabahiro 31:45f97698857b 1014 break;
yabahiro 31:45f97698857b 1015 case 255:
kishibekairohan 33:656aa14904a5 1016 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1017 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1018 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1019 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1020 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1021 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1022 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1023 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1024 mtc2=true;
yabahiro 31:45f97698857b 1025 break;
yabahiro 31:45f97698857b 1026 case 253:
yabahiro 31:45f97698857b 1027 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1028 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1029 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1030 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1031 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1032 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1033 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1034 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1035 mtc2=true;
yabahiro 31:45f97698857b 1036 break;
yabahiro 31:45f97698857b 1037 case 254:
yabahiro 31:45f97698857b 1038 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1039 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1040 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1041 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1042 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1043 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1044 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1045 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1046 mtc2=true;
yabahiro 31:45f97698857b 1047 break;
yabahiro 31:45f97698857b 1048 case 1:
kishibekairohan 33:656aa14904a5 1049 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1050 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1051 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1052 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1053 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1054 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1055 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1056 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1057 mtc2=true;
yabahiro 31:45f97698857b 1058 break;
yabahiro 31:45f97698857b 1059 case 3:
kishibekairohan 33:656aa14904a5 1060 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1061 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1062 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1063 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1064 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1065 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1066 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1067 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1068 mtc2=true;
yabahiro 31:45f97698857b 1069 break;
yabahiro 31:45f97698857b 1070 case 2:
kishibekairohan 33:656aa14904a5 1071 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1072 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1073 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1074 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1075 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1076 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1077 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1078 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1079 mtc2=true;
yabahiro 31:45f97698857b 1080 break;
yabahiro 31:45f97698857b 1081 }
yabahiro 31:45f97698857b 1082 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 1083 switch(g[2]) {
yabahiro 29:c78a46f51209 1084 case 0:
yabahiro 31:45f97698857b 1085 mtc2=false;
yabahiro 29:c78a46f51209 1086 break;
yabahiro 29:c78a46f51209 1087 case 255:
yabahiro 31:45f97698857b 1088 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1089 mtc2=false;
yabahiro 29:c78a46f51209 1090 break;
yabahiro 29:c78a46f51209 1091 case 253:
yabahiro 31:45f97698857b 1092 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1093 mtc2=false;
yabahiro 29:c78a46f51209 1094 break;
yabahiro 29:c78a46f51209 1095 case 254:
yabahiro 31:45f97698857b 1096 motor[TIRE_FL].pwm += 20;
yabahiro 29:c78a46f51209 1097 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1098 mtc2=false;
yabahiro 29:c78a46f51209 1099 break;
yabahiro 29:c78a46f51209 1100 case 1:
yabahiro 31:45f97698857b 1101 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 1102 mtc2=false;
yabahiro 29:c78a46f51209 1103 break;
yabahiro 29:c78a46f51209 1104 case 3:
yabahiro 31:45f97698857b 1105 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 1106 mtc2=false;
yabahiro 29:c78a46f51209 1107 break;
yabahiro 29:c78a46f51209 1108 case 2:
yabahiro 31:45f97698857b 1109 motor[TIRE_BL].pwm += 20;
yabahiro 29:c78a46f51209 1110 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1111 mtc2=false;
yabahiro 29:c78a46f51209 1112 break;
yabahiro 29:c78a46f51209 1113 }
yabahiro 31:45f97698857b 1114 }
yabahiro 31:45f97698857b 1115 } else if(mode==41) {
yabahiro 42:4f9689c0a349 1116 if(LIF||LIB) {
yabahiro 42:4f9689c0a349 1117 mode=42;
yabahiro 42:4f9689c0a349 1118 }
yabahiro 31:45f97698857b 1119 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1120 motor[TIRE_FR].dir = FREE;
yabahiro 35:94f026ab4d30 1121 motor[TIRE_FL].pwm = 30;
yabahiro 31:45f97698857b 1122 motor[TIRE_FL].dir = BACK;
yabahiro 35:94f026ab4d30 1123 motor[TIRE_BR].pwm = 30;
yabahiro 31:45f97698857b 1124 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1125 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1126 motor[TIRE_BL].dir = FREE;
yabahiro 35:94f026ab4d30 1127 if(g[1]==0) {
yabahiro 31:45f97698857b 1128 count=0;
yabahiro 31:45f97698857b 1129 mode=70;
yabahiro 31:45f97698857b 1130 }
yabahiro 38:391a0c8e4c16 1131 } else if(mode==42) {
yabahiro 38:391a0c8e4c16 1132 motor[TIRE_FR].pwm = 20;
yabahiro 38:391a0c8e4c16 1133 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1134 motor[TIRE_FL].pwm = 0;
yabahiro 38:391a0c8e4c16 1135 motor[TIRE_FL].dir = FREE;
yabahiro 38:391a0c8e4c16 1136 motor[TIRE_BR].pwm = 0;
yabahiro 38:391a0c8e4c16 1137 motor[TIRE_BR].dir = FREE;
yabahiro 38:391a0c8e4c16 1138 motor[TIRE_BL].pwm = 20;
yabahiro 38:391a0c8e4c16 1139 motor[TIRE_BL].dir = BACK;
yabahiro 38:391a0c8e4c16 1140 if(g[1]==0) {
yabahiro 38:391a0c8e4c16 1141 count=0;
yabahiro 38:391a0c8e4c16 1142 mode=70;
yabahiro 38:391a0c8e4c16 1143 }
yabahiro 31:45f97698857b 1144 } else if(mode==70) {
yabahiro 31:45f97698857b 1145 switch(g[1]) {
yabahiro 31:45f97698857b 1146 case 99:
yabahiro 31:45f97698857b 1147 if(count>=100000) {
yabahiro 31:45f97698857b 1148 mode=100;
yabahiro 29:c78a46f51209 1149 }
yabahiro 31:45f97698857b 1150 break;
yabahiro 31:45f97698857b 1151 case 98:
kishibekairohan 33:656aa14904a5 1152 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1153 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1154 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1155 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1156 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1157 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1158 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1159 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1160 break;
yabahiro 31:45f97698857b 1161 case 0:
yabahiro 38:391a0c8e4c16 1162 motor[TIRE_FR].pwm = 80;
yabahiro 31:45f97698857b 1163 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1164 motor[TIRE_FL].pwm = 80;
yabahiro 31:45f97698857b 1165 motor[TIRE_FL].dir = BACK;
yabahiro 38:391a0c8e4c16 1166 motor[TIRE_BR].pwm = 80;
yabahiro 31:45f97698857b 1167 motor[TIRE_BR].dir = FOR;
yabahiro 38:391a0c8e4c16 1168 motor[TIRE_BL].pwm = 80;
yabahiro 31:45f97698857b 1169 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1170 mtc=true;
yabahiro 31:45f97698857b 1171 break;
yabahiro 31:45f97698857b 1172 case 255:
kishibekairohan 33:656aa14904a5 1173 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1174 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1175 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1176 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1177 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1178 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1179 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1180 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1181 mtc=true;
yabahiro 31:45f97698857b 1182 break;
yabahiro 31:45f97698857b 1183 case 253:
kishibekairohan 33:656aa14904a5 1184 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1185 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1186 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1187 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1188 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1189 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1190 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1191 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1192 mtc=true;
yabahiro 31:45f97698857b 1193 break;
yabahiro 31:45f97698857b 1194 case 254:
kishibekairohan 33:656aa14904a5 1195 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1196 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1197 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1198 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1199 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1200 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1201 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1202 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1203 mtc=true;
yabahiro 31:45f97698857b 1204 break;
yabahiro 31:45f97698857b 1205 case 1:
kishibekairohan 33:656aa14904a5 1206 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1207 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1208 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1209 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1210 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1211 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1212 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1213 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1214 mtc=true;
yabahiro 31:45f97698857b 1215 break;
yabahiro 31:45f97698857b 1216 case 3:
yabahiro 31:45f97698857b 1217 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1218 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1219 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1220 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1221 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1222 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1223 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1224 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1225 mtc=true;
yabahiro 31:45f97698857b 1226 break;
yabahiro 31:45f97698857b 1227 case 2:
yabahiro 31:45f97698857b 1228 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1229 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1230 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1231 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1232 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1233 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1234 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1235 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1236 mtc=true;
yabahiro 31:45f97698857b 1237 break;
yabahiro 31:45f97698857b 1238 }
yabahiro 31:45f97698857b 1239 if(g[1]!=98&&mtc==true) {
yabahiro 31:45f97698857b 1240 switch(g[0]) {
yabahiro 29:c78a46f51209 1241 case 0:
yabahiro 31:45f97698857b 1242 mtc=false;
yabahiro 29:c78a46f51209 1243 break;
yabahiro 29:c78a46f51209 1244 case 255:
yabahiro 31:45f97698857b 1245 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1246 mtc=false;
yabahiro 29:c78a46f51209 1247 break;
yabahiro 29:c78a46f51209 1248 case 253:
yabahiro 31:45f97698857b 1249 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1250 mtc=false;
yabahiro 29:c78a46f51209 1251 break;
yabahiro 29:c78a46f51209 1252 case 254:
yabahiro 31:45f97698857b 1253 motor[TIRE_FL].pwm += 20;
yabahiro 31:45f97698857b 1254 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1255 mtc=false;
yabahiro 29:c78a46f51209 1256 break;
yabahiro 29:c78a46f51209 1257 case 1:
yabahiro 31:45f97698857b 1258 motor[TIRE_FR].pwm += 5;
yabahiro 31:45f97698857b 1259 mtc=false;
yabahiro 29:c78a46f51209 1260 break;
yabahiro 29:c78a46f51209 1261 case 3:
yabahiro 31:45f97698857b 1262 motor[TIRE_FR].pwm += 10;
yabahiro 31:45f97698857b 1263 mtc=false;
yabahiro 29:c78a46f51209 1264 break;
yabahiro 29:c78a46f51209 1265 case 2:
yabahiro 31:45f97698857b 1266 motor[TIRE_FR].pwm += 20;
yabahiro 31:45f97698857b 1267 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1268 mtc=false;
yabahiro 29:c78a46f51209 1269 break;
yabahiro 29:c78a46f51209 1270 }
yabahiro 31:45f97698857b 1271 }
yabahiro 31:45f97698857b 1272 } else if(mode==100) {
yabahiro 35:94f026ab4d30 1273 motor[TIRE_FR].pwm = 20;
yabahiro 31:45f97698857b 1274 motor[TIRE_FR].dir = FOR;
yabahiro 35:94f026ab4d30 1275 motor[TIRE_FL].pwm = 20;
yabahiro 31:45f97698857b 1276 motor[TIRE_FL].dir = BACK;
yabahiro 31:45f97698857b 1277 motor[TIRE_BR].pwm = 23;
yabahiro 31:45f97698857b 1278 motor[TIRE_BR].dir = FOR;
yabahiro 35:94f026ab4d30 1279 motor[TIRE_BL].pwm = 20;
yabahiro 31:45f97698857b 1280 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1281 } else {
yabahiro 31:45f97698857b 1282 }
yabahiro 31:45f97698857b 1283 }
yabahiro 31:45f97698857b 1284 #endif
yabahiro 31:45f97698857b 1285
yabahiro 31:45f97698857b 1286 #if USE_PROCESS_NUM>3
yabahiro 31:45f97698857b 1287 static void Process3()
yabahiro 31:45f97698857b 1288 {
yabahiro 36:788274604650 1289 }
yabahiro 36:788274604650 1290 #endif
yabahiro 36:788274604650 1291
yabahiro 36:788274604650 1292 #if USE_PROCESS_NUM>4
yabahiro 36:788274604650 1293 static void Process4()
yabahiro 36:788274604650 1294 {
yabahiro 36:788274604650 1295 LedMode(4);
yabahiro 36:788274604650 1296 count++;
yabahiro 31:45f97698857b 1297 if(mode==1) {//スタートゾーンから白線検知
yabahiro 45:878f8f385635 1298 fast=40;
yabahiro 40:7f93984e8ba1 1299 normal=30;
yabahiro 40:7f93984e8ba1 1300 slow=20;
yabahiro 45:878f8f385635 1301 motor[TIRE_FR].pwm = 27;
yabahiro 40:7f93984e8ba1 1302 motor[TIRE_FR].dir = FOR;
yabahiro 45:878f8f385635 1303 motor[TIRE_FL].pwm = 33;
yabahiro 40:7f93984e8ba1 1304 motor[TIRE_FL].dir = BACK;
yabahiro 45:878f8f385635 1305 motor[TIRE_BR].pwm = 33;
yabahiro 40:7f93984e8ba1 1306 motor[TIRE_BR].dir = FOR;
yabahiro 45:878f8f385635 1307 motor[TIRE_BL].pwm = 27;
yabahiro 40:7f93984e8ba1 1308 motor[TIRE_BL].dir = BACK;
yabahiro 46:4a8bca4cc1fd 1309 if(g[2]==0&&count>=100000) {
yabahiro 40:7f93984e8ba1 1310 count=100000;
yabahiro 40:7f93984e8ba1 1311 cross=0;
yabahiro 40:7f93984e8ba1 1312 mode=3;
yabahiro 40:7f93984e8ba1 1313 }
yabahiro 40:7f93984e8ba1 1314 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 43:677f7446612e 1315 motor[TIRE_FR].pwm = 30;
yabahiro 40:7f93984e8ba1 1316 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1317 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1318 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1319 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1320 motor[TIRE_BR].dir = FREE;
yabahiro 43:677f7446612e 1321 motor[TIRE_BL].pwm = 30;
yabahiro 40:7f93984e8ba1 1322 motor[TIRE_BL].dir = BACK;
yabahiro 45:878f8f385635 1323 if(g[1]==0) {
yabahiro 40:7f93984e8ba1 1324 mode=10;
yabahiro 40:7f93984e8ba1 1325 count=100000;
yabahiro 40:7f93984e8ba1 1326 }
yabahiro 40:7f93984e8ba1 1327 } else if(mode==10) { //縦ライントレース
yabahiro 40:7f93984e8ba1 1328
yabahiro 40:7f93984e8ba1 1329 if(counts==false&&g[2]==0) {
yabahiro 40:7f93984e8ba1 1330 cros++;
yabahiro 40:7f93984e8ba1 1331 counts=true;
yabahiro 40:7f93984e8ba1 1332 }
yabahiro 40:7f93984e8ba1 1333 if(counts==true&&g[2]==99) {
yabahiro 40:7f93984e8ba1 1334 counts=false;
yabahiro 40:7f93984e8ba1 1335 }
yabahiro 40:7f93984e8ba1 1336
yabahiro 40:7f93984e8ba1 1337 if(cros==Twsh) {
yabahiro 40:7f93984e8ba1 1338 mode=11;
yabahiro 40:7f93984e8ba1 1339 count=0;
yabahiro 40:7f93984e8ba1 1340 cros=0;
yabahiro 40:7f93984e8ba1 1341 }//ゆっくりモードに入れなかった時の保険
yabahiro 40:7f93984e8ba1 1342 switch(g[1]) {
yabahiro 40:7f93984e8ba1 1343 case 98:
yabahiro 40:7f93984e8ba1 1344 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1345 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1346 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1347 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1348 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1349 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1350 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1351 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1352 mtc=true;
yabahiro 40:7f93984e8ba1 1353 if(count>80000) {
yabahiro 40:7f93984e8ba1 1354 cross++;
yabahiro 40:7f93984e8ba1 1355 count=0;
yabahiro 40:7f93984e8ba1 1356 }
yabahiro 40:7f93984e8ba1 1357 if(cross==Twsh) {
yabahiro 40:7f93984e8ba1 1358 mode=11;
yabahiro 40:7f93984e8ba1 1359 count=0;
yabahiro 40:7f93984e8ba1 1360 cross=0;
yabahiro 40:7f93984e8ba1 1361 }
yabahiro 40:7f93984e8ba1 1362 break;
yabahiro 40:7f93984e8ba1 1363 case 0:
yabahiro 40:7f93984e8ba1 1364 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1365 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1366 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1367 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1368 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1369 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1370 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1371 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1372 mtc=true;
yabahiro 40:7f93984e8ba1 1373 break;
yabahiro 40:7f93984e8ba1 1374 case 255:
yabahiro 40:7f93984e8ba1 1375 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1376 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1377 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1378 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1379 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1380 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1381 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1382 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1383 mtc=true;
yabahiro 40:7f93984e8ba1 1384 break;
yabahiro 40:7f93984e8ba1 1385 case 253:
yabahiro 40:7f93984e8ba1 1386 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 1387 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1388 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1389 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1390 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1391 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1392 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 1393 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1394 mtc=true;
yabahiro 40:7f93984e8ba1 1395 break;
yabahiro 40:7f93984e8ba1 1396 case 254:
yabahiro 40:7f93984e8ba1 1397 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1398 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1399 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1400 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1401 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1402 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1403 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1404 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1405 mtc=true;
yabahiro 40:7f93984e8ba1 1406 break;
yabahiro 40:7f93984e8ba1 1407 case 1:
yabahiro 40:7f93984e8ba1 1408 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 1409 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1410 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1411 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1412 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1413 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1414 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 1415 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1416 mtc=true;
yabahiro 40:7f93984e8ba1 1417 break;
yabahiro 40:7f93984e8ba1 1418 case 3:
yabahiro 40:7f93984e8ba1 1419 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1420 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1421 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1422 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1423 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1424 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1425 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1426 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1427 mtc=true;
yabahiro 40:7f93984e8ba1 1428 break;
yabahiro 40:7f93984e8ba1 1429 case 2:
yabahiro 40:7f93984e8ba1 1430 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1431 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1432 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1433 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1434 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1435 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1436 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1437 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1438 mtc=true;
yabahiro 40:7f93984e8ba1 1439 break;
yabahiro 40:7f93984e8ba1 1440 }
yabahiro 40:7f93984e8ba1 1441 if(g[0]!=98&&mtc==true) {
yabahiro 40:7f93984e8ba1 1442 switch(g[0]) {
yabahiro 40:7f93984e8ba1 1443 case 0:
yabahiro 40:7f93984e8ba1 1444 mtc=false;
yabahiro 40:7f93984e8ba1 1445 break;
yabahiro 40:7f93984e8ba1 1446 case 255:
yabahiro 40:7f93984e8ba1 1447 motor[TIRE_FL].pwm += 5;
yabahiro 40:7f93984e8ba1 1448 mtc=false;
yabahiro 40:7f93984e8ba1 1449 break;
yabahiro 40:7f93984e8ba1 1450 case 253:
yabahiro 40:7f93984e8ba1 1451 motor[TIRE_FL].pwm += 10;
yabahiro 40:7f93984e8ba1 1452 mtc=false;
yabahiro 40:7f93984e8ba1 1453 break;
yabahiro 40:7f93984e8ba1 1454 case 254:
yabahiro 40:7f93984e8ba1 1455 motor[TIRE_FL].pwm += 20;
yabahiro 40:7f93984e8ba1 1456 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1457 mtc=false;
yabahiro 40:7f93984e8ba1 1458 break;
yabahiro 40:7f93984e8ba1 1459 case 1:
yabahiro 40:7f93984e8ba1 1460 motor[TIRE_FR].pwm += 5;
yabahiro 40:7f93984e8ba1 1461 mtc=false;
yabahiro 40:7f93984e8ba1 1462 break;
yabahiro 40:7f93984e8ba1 1463 case 3:
yabahiro 40:7f93984e8ba1 1464 motor[TIRE_FR].pwm += 10;
yabahiro 40:7f93984e8ba1 1465 mtc=false;
yabahiro 40:7f93984e8ba1 1466 break;
yabahiro 40:7f93984e8ba1 1467 case 2:
yabahiro 40:7f93984e8ba1 1468 motor[TIRE_FR].pwm += 20;
yabahiro 40:7f93984e8ba1 1469 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1470 mtc=false;
yabahiro 40:7f93984e8ba1 1471 break;
yabahiro 40:7f93984e8ba1 1472 }
yabahiro 40:7f93984e8ba1 1473 }
yabahiro 40:7f93984e8ba1 1474 } else if(mode==11) {
yabahiro 40:7f93984e8ba1 1475 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1476 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1477 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1478 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1479 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1480 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1481 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1482 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1483 if(g[2]==0) {
yabahiro 40:7f93984e8ba1 1484 count=0;
yabahiro 40:7f93984e8ba1 1485 cross=0;
yabahiro 40:7f93984e8ba1 1486 mode=20;
yabahiro 40:7f93984e8ba1 1487 }
yabahiro 40:7f93984e8ba1 1488 } else if(mode==20) {
yabahiro 40:7f93984e8ba1 1489
yabahiro 40:7f93984e8ba1 1490 if(Twsh==2) {
yabahiro 40:7f93984e8ba1 1491 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 40:7f93984e8ba1 1492 }
yabahiro 40:7f93984e8ba1 1493
yabahiro 40:7f93984e8ba1 1494 if(counts==false&&g[1]==0) {
yabahiro 40:7f93984e8ba1 1495 cros++;
yabahiro 40:7f93984e8ba1 1496 counts=true;
yabahiro 40:7f93984e8ba1 1497 }
yabahiro 40:7f93984e8ba1 1498 if(counts==true&&g[1]==99) {
yabahiro 40:7f93984e8ba1 1499 counts=false;
yabahiro 40:7f93984e8ba1 1500 }
yabahiro 40:7f93984e8ba1 1501
yabahiro 40:7f93984e8ba1 1502 if(cros==2) {
yabahiro 40:7f93984e8ba1 1503 //mode=21;
yabahiro 40:7f93984e8ba1 1504 //count=0;
yabahiro 40:7f93984e8ba1 1505 //cros=0;
yabahiro 40:7f93984e8ba1 1506 }//ゆっくりモードに入れなかった時の保険
yabahiro 45:878f8f385635 1507 if(g[1]==0) {
yabahiro 45:878f8f385635 1508 fast=35;
yabahiro 45:878f8f385635 1509 normal=20;
yabahiro 45:878f8f385635 1510 slow=15;
yabahiro 45:878f8f385635 1511 }
yabahiro 40:7f93984e8ba1 1512 switch(g[2]) {
yabahiro 40:7f93984e8ba1 1513 case 98:
yabahiro 40:7f93984e8ba1 1514 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1515 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1516 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1517 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1518 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1519 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1520 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1521 motor[TIRE_BL].dir = BACK;
yabahiro 41:e1dd6d97f17d 1522 if(count>50000) {
yabahiro 40:7f93984e8ba1 1523 cross++;
yabahiro 40:7f93984e8ba1 1524 count=0;
yabahiro 40:7f93984e8ba1 1525 }
yabahiro 40:7f93984e8ba1 1526 mtc2=true;
yabahiro 40:7f93984e8ba1 1527 if(cross==2) {
yabahiro 45:878f8f385635 1528 mode=22;
yabahiro 40:7f93984e8ba1 1529 cross=0;
yabahiro 41:e1dd6d97f17d 1530 count=0;
yabahiro 45:878f8f385635 1531 fast=40;
yabahiro 45:878f8f385635 1532 normal=30;
yabahiro 45:878f8f385635 1533 slow=20;
yabahiro 40:7f93984e8ba1 1534 }
yabahiro 40:7f93984e8ba1 1535 break;
yabahiro 40:7f93984e8ba1 1536 case 0:
yabahiro 40:7f93984e8ba1 1537 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1538 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1539 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1540 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1541 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1542 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1543 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1544 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1545 mtc2=true;
yabahiro 40:7f93984e8ba1 1546 break;
yabahiro 40:7f93984e8ba1 1547 case 255:
yabahiro 40:7f93984e8ba1 1548 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1549 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1550 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1551 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1552 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1553 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1554 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1555 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1556 mtc2=true;
yabahiro 40:7f93984e8ba1 1557 break;
yabahiro 40:7f93984e8ba1 1558 case 253:
yabahiro 40:7f93984e8ba1 1559 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1560 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1561 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1562 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1563 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1564 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1565 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1566 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1567 mtc2=true;
yabahiro 40:7f93984e8ba1 1568 break;
yabahiro 40:7f93984e8ba1 1569 case 254:
yabahiro 40:7f93984e8ba1 1570 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1571 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1572 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1573 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1574 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1575 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1576 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1577 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1578 mtc2=true;
yabahiro 40:7f93984e8ba1 1579 break;
yabahiro 40:7f93984e8ba1 1580 case 1:
yabahiro 40:7f93984e8ba1 1581 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1582 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1583 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1584 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 1585 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1586 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 1587 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1588 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1589 mtc2=true;
yabahiro 40:7f93984e8ba1 1590 break;
yabahiro 40:7f93984e8ba1 1591 case 3:
yabahiro 40:7f93984e8ba1 1592 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 1593 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1594 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1595 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1596 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1597 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1598 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 1599 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1600 mtc2=true;
yabahiro 40:7f93984e8ba1 1601 break;
yabahiro 40:7f93984e8ba1 1602 case 2:
yabahiro 40:7f93984e8ba1 1603 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1604 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1605 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1606 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1607 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1608 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1609 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1610 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1611 mtc2=true;
yabahiro 40:7f93984e8ba1 1612 break;
yabahiro 40:7f93984e8ba1 1613 }
yabahiro 40:7f93984e8ba1 1614 if(g[2]!=98&&mtc2==true) {
yabahiro 40:7f93984e8ba1 1615 switch(g[3]) {
yabahiro 40:7f93984e8ba1 1616 case 0:
yabahiro 40:7f93984e8ba1 1617 mtc2=false;
yabahiro 40:7f93984e8ba1 1618 break;
yabahiro 40:7f93984e8ba1 1619 case 255:
yabahiro 40:7f93984e8ba1 1620 motor[TIRE_BL].pwm += 5;
yabahiro 40:7f93984e8ba1 1621 mtc2=false;
yabahiro 40:7f93984e8ba1 1622 break;
yabahiro 40:7f93984e8ba1 1623 case 253:
yabahiro 40:7f93984e8ba1 1624 motor[TIRE_BL].pwm += 10;
yabahiro 40:7f93984e8ba1 1625 mtc2=false;
yabahiro 40:7f93984e8ba1 1626 break;
yabahiro 40:7f93984e8ba1 1627 case 254:
yabahiro 40:7f93984e8ba1 1628 motor[TIRE_BL].pwm += 20;
yabahiro 40:7f93984e8ba1 1629 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1630 mtc2=false;
yabahiro 40:7f93984e8ba1 1631 break;
yabahiro 40:7f93984e8ba1 1632 case 1:
yabahiro 40:7f93984e8ba1 1633 motor[TIRE_FL].pwm += 5;
yabahiro 40:7f93984e8ba1 1634 mtc2=false;
yabahiro 40:7f93984e8ba1 1635 break;
yabahiro 40:7f93984e8ba1 1636 case 3:
yabahiro 40:7f93984e8ba1 1637 motor[TIRE_FL].pwm += 10;
yabahiro 40:7f93984e8ba1 1638 mtc2=false;
yabahiro 40:7f93984e8ba1 1639 break;
yabahiro 40:7f93984e8ba1 1640 case 2:
yabahiro 40:7f93984e8ba1 1641 motor[TIRE_FL].pwm += 20;
yabahiro 40:7f93984e8ba1 1642 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1643 mtc2=false;
yabahiro 40:7f93984e8ba1 1644 break;
yabahiro 40:7f93984e8ba1 1645 }
yabahiro 40:7f93984e8ba1 1646 }
yabahiro 42:4f9689c0a349 1647
yabahiro 40:7f93984e8ba1 1648 } else if(mode==21) {
yabahiro 45:878f8f385635 1649 motor[TIRE_FR].pwm = 30;
yabahiro 41:e1dd6d97f17d 1650 motor[TIRE_FR].dir = BRAKE;
yabahiro 45:878f8f385635 1651 motor[TIRE_FL].pwm = 30;
yabahiro 41:e1dd6d97f17d 1652 motor[TIRE_FL].dir = BRAKE;
yabahiro 45:878f8f385635 1653 motor[TIRE_BR].pwm = 30;
yabahiro 41:e1dd6d97f17d 1654 motor[TIRE_BR].dir = BRAKE;
yabahiro 45:878f8f385635 1655 motor[TIRE_BL].pwm = 30;
yabahiro 41:e1dd6d97f17d 1656 motor[TIRE_BL].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 1657 if(count<=100000) {
yabahiro 41:e1dd6d97f17d 1658 mode=22;
yabahiro 41:e1dd6d97f17d 1659 }
yabahiro 42:4f9689c0a349 1660 }
yabahiro 45:878f8f385635 1661 kiri=true;
yabahiro 45:878f8f385635 1662 if(kiri) {
yabahiro 42:4f9689c0a349 1663 if(mode==22) {
yabahiro 45:878f8f385635 1664 motor[TIRE_FR].pwm = 100;
yabahiro 45:878f8f385635 1665 motor[TIRE_FR].dir = BRAKE;
yabahiro 45:878f8f385635 1666 motor[TIRE_FL].pwm = 100;
yabahiro 45:878f8f385635 1667 motor[TIRE_FL].dir = BRAKE;
yabahiro 45:878f8f385635 1668 motor[TIRE_BR].pwm = 100;
yabahiro 45:878f8f385635 1669 motor[TIRE_BR].dir = BRAKE;
yabahiro 45:878f8f385635 1670 motor[TIRE_BL].pwm = 100;
yabahiro 45:878f8f385635 1671 motor[TIRE_BL].dir = BRAKE;
yabahiro 45:878f8f385635 1672 if(count>=10000) {
yabahiro 45:878f8f385635 1673 mode=23;
yabahiro 45:878f8f385635 1674 }
yabahiro 45:878f8f385635 1675 } else if(mode==23) {
yabahiro 45:878f8f385635 1676 motor[TIRE_FR].pwm = 20;
yabahiro 45:878f8f385635 1677 motor[TIRE_FR].dir = BACK;
yabahiro 45:878f8f385635 1678 motor[TIRE_FL].pwm = 20;
yabahiro 45:878f8f385635 1679 motor[TIRE_FL].dir = BACK;
yabahiro 45:878f8f385635 1680 motor[TIRE_BR].pwm = 20;
yabahiro 45:878f8f385635 1681 motor[TIRE_BR].dir = FOR;
yabahiro 45:878f8f385635 1682 motor[TIRE_BL].pwm = 20;
yabahiro 45:878f8f385635 1683 motor[TIRE_BL].dir = FOR;
yabahiro 45:878f8f385635 1684 if(g[2]==98) {
yabahiro 45:878f8f385635 1685 mode=24;
yabahiro 45:878f8f385635 1686 count=0;
yabahiro 45:878f8f385635 1687 }
yabahiro 45:878f8f385635 1688 } else if(mode==24) {
yabahiro 42:4f9689c0a349 1689 motor[TIRE_FR].pwm = 20;
yabahiro 42:4f9689c0a349 1690 motor[TIRE_FR].dir = BACK;
yabahiro 42:4f9689c0a349 1691 motor[TIRE_FL].pwm = 20;
yabahiro 42:4f9689c0a349 1692 motor[TIRE_FL].dir = BACK;
yabahiro 42:4f9689c0a349 1693 motor[TIRE_BR].pwm = 20;
yabahiro 42:4f9689c0a349 1694 motor[TIRE_BR].dir = FOR;
yabahiro 42:4f9689c0a349 1695 motor[TIRE_BL].pwm = 20;
yabahiro 42:4f9689c0a349 1696 motor[TIRE_BL].dir = FOR;
yabahiro 42:4f9689c0a349 1697 if(g[2]!=98) {
yabahiro 45:878f8f385635 1698 count=0;
yabahiro 45:878f8f385635 1699 mode=25;
yabahiro 45:878f8f385635 1700 }
yabahiro 45:878f8f385635 1701 } else if(mode==25) {
yabahiro 45:878f8f385635 1702 motor[TIRE_FR].pwm = 10;
yabahiro 45:878f8f385635 1703 motor[TIRE_FR].dir = BRAKE;
yabahiro 45:878f8f385635 1704 motor[TIRE_FL].pwm = 10;
yabahiro 45:878f8f385635 1705 motor[TIRE_FL].dir = BRAKE;
yabahiro 45:878f8f385635 1706 motor[TIRE_BR].pwm = 10;
yabahiro 45:878f8f385635 1707 motor[TIRE_BR].dir = BRAKE;
yabahiro 45:878f8f385635 1708 motor[TIRE_BL].pwm = 10;
yabahiro 45:878f8f385635 1709 motor[TIRE_BL].dir = BRAKE;
yabahiro 45:878f8f385635 1710 if(count>=10000) {
yabahiro 45:878f8f385635 1711 mode=26;
yabahiro 45:878f8f385635 1712 count=0;
yabahiro 42:4f9689c0a349 1713 }
yabahiro 45:878f8f385635 1714 } else if(mode==26) {
yabahiro 45:878f8f385635 1715 motor[TIRE_FR].pwm = 20;
yabahiro 45:878f8f385635 1716 motor[TIRE_FR].dir = FOR;
yabahiro 45:878f8f385635 1717 motor[TIRE_FL].pwm = 20;
yabahiro 45:878f8f385635 1718 motor[TIRE_FL].dir = FOR;
yabahiro 45:878f8f385635 1719 motor[TIRE_BR].pwm = 20;
yabahiro 45:878f8f385635 1720 motor[TIRE_BR].dir = BACK;
yabahiro 45:878f8f385635 1721 motor[TIRE_BL].pwm = 20;
yabahiro 45:878f8f385635 1722 motor[TIRE_BL].dir = BACK;
yabahiro 45:878f8f385635 1723 if(count>=5000) {
yabahiro 45:878f8f385635 1724 mode=27;
yabahiro 45:878f8f385635 1725 count=0;
yabahiro 45:878f8f385635 1726 }
yabahiro 45:878f8f385635 1727 } else if(mode==27) {
yabahiro 45:878f8f385635 1728 motor[TIRE_FR].pwm = 20;
yabahiro 45:878f8f385635 1729 motor[TIRE_FR].dir = FOR;
yabahiro 45:878f8f385635 1730 motor[TIRE_FL].pwm = 20;
yabahiro 45:878f8f385635 1731 motor[TIRE_FL].dir = FOR;
yabahiro 45:878f8f385635 1732 motor[TIRE_BR].pwm = 20;
yabahiro 45:878f8f385635 1733 motor[TIRE_BR].dir = FOR;
yabahiro 45:878f8f385635 1734 motor[TIRE_BL].pwm = 20;
yabahiro 45:878f8f385635 1735 motor[TIRE_BL].dir = FOR;
yabahiro 45:878f8f385635 1736 //どれくらい回転するかって値
yabahiro 45:878f8f385635 1737 if(count>=4000) {
yabahiro 45:878f8f385635 1738 count=0;
yabahiro 45:878f8f385635 1739 mode=28;
yabahiro 45:878f8f385635 1740 }
yabahiro 45:878f8f385635 1741 } else if(mode==28) {
yabahiro 45:878f8f385635 1742 motor[TIRE_FR].pwm = 10;
yabahiro 45:878f8f385635 1743 motor[TIRE_FR].dir = BRAKE;
yabahiro 45:878f8f385635 1744 motor[TIRE_FL].pwm = 10;
yabahiro 45:878f8f385635 1745 motor[TIRE_FL].dir = BRAKE;
yabahiro 45:878f8f385635 1746 motor[TIRE_BR].pwm = 10;
yabahiro 45:878f8f385635 1747 motor[TIRE_BR].dir = BRAKE;
yabahiro 45:878f8f385635 1748 motor[TIRE_BL].pwm = 10;
yabahiro 45:878f8f385635 1749 motor[TIRE_BL].dir = BRAKE;
yabahiro 45:878f8f385635 1750 if(count>=10000) {
yabahiro 45:878f8f385635 1751 mode=30;
yabahiro 45:878f8f385635 1752 count=0;
yabahiro 45:878f8f385635 1753 }
yabahiro 43:677f7446612e 1754 }
yabahiro 42:4f9689c0a349 1755 } else {
yabahiro 42:4f9689c0a349 1756 if(mode==22) {
yabahiro 45:878f8f385635 1757 motor[TIRE_FR].pwm = 0;
yabahiro 45:878f8f385635 1758 motor[TIRE_FR].dir = FREE;
yabahiro 45:878f8f385635 1759 motor[TIRE_FL].pwm = 25;
yabahiro 45:878f8f385635 1760 motor[TIRE_FL].dir = FOR;
yabahiro 45:878f8f385635 1761 motor[TIRE_BR].pwm = 25;
yabahiro 45:878f8f385635 1762 motor[TIRE_BR].dir = BACK;
yabahiro 45:878f8f385635 1763 motor[TIRE_BL].pwm = 0;
yabahiro 45:878f8f385635 1764 motor[TIRE_BL].dir = FREE;
yabahiro 45:878f8f385635 1765 if(g[0]==0&&count>=10000) {
yabahiro 45:878f8f385635 1766 mode=30;
yabahiro 42:4f9689c0a349 1767 count=0;
yabahiro 45:878f8f385635 1768 cros=0;
yabahiro 42:4f9689c0a349 1769 }
yabahiro 42:4f9689c0a349 1770 }
yabahiro 42:4f9689c0a349 1771 }
yabahiro 42:4f9689c0a349 1772 if(mode==30) {
yabahiro 43:677f7446612e 1773 motor[TIRE_FR].pwm = 60;
yabahiro 40:7f93984e8ba1 1774 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 1775 motor[TIRE_FL].pwm = 60;
yabahiro 40:7f93984e8ba1 1776 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1777 motor[TIRE_BR].pwm = 60;
yabahiro 40:7f93984e8ba1 1778 motor[TIRE_BR].dir = FOR;
yabahiro 45:878f8f385635 1779 motor[TIRE_BL].pwm = 57;
yabahiro 40:7f93984e8ba1 1780 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 1781 if(g[1]==98) {
yabahiro 40:7f93984e8ba1 1782 mode=31;
yabahiro 41:e1dd6d97f17d 1783 count=0;
yabahiro 40:7f93984e8ba1 1784 }
yabahiro 40:7f93984e8ba1 1785 } else if(mode==31) {
yabahiro 42:4f9689c0a349 1786 motor[TIRE_FR].pwm = 0;
yabahiro 41:e1dd6d97f17d 1787 motor[TIRE_FR].dir = FREE;
yabahiro 42:4f9689c0a349 1788 motor[TIRE_FL].pwm = 0;
yabahiro 41:e1dd6d97f17d 1789 motor[TIRE_FL].dir = FREE;
yabahiro 42:4f9689c0a349 1790 motor[TIRE_BR].pwm = 0;
yabahiro 41:e1dd6d97f17d 1791 motor[TIRE_BR].dir = FREE;
yabahiro 42:4f9689c0a349 1792 motor[TIRE_BL].pwm = 0;
yabahiro 41:e1dd6d97f17d 1793 motor[TIRE_BL].dir = FREE;
yabahiro 42:4f9689c0a349 1794 if(count>=5000) {
yabahiro 41:e1dd6d97f17d 1795 mode=32;
yabahiro 40:7f93984e8ba1 1796 count=0;
yabahiro 40:7f93984e8ba1 1797 }
yabahiro 40:7f93984e8ba1 1798 } else if(mode==32) {
yabahiro 42:4f9689c0a349 1799 motor[TIRE_FR].pwm = 10;
yabahiro 41:e1dd6d97f17d 1800 motor[TIRE_FR].dir = BRAKE;
yabahiro 42:4f9689c0a349 1801 motor[TIRE_FL].pwm = 10;
yabahiro 41:e1dd6d97f17d 1802 motor[TIRE_FL].dir = BRAKE;
yabahiro 42:4f9689c0a349 1803 motor[TIRE_BR].pwm = 10;
yabahiro 41:e1dd6d97f17d 1804 motor[TIRE_BR].dir = BRAKE;
yabahiro 42:4f9689c0a349 1805 motor[TIRE_BL].pwm = 10;
yabahiro 41:e1dd6d97f17d 1806 motor[TIRE_BL].dir = BRAKE;
yabahiro 42:4f9689c0a349 1807 if(count>=30000) {
yabahiro 41:e1dd6d97f17d 1808 mode=33;
yabahiro 41:e1dd6d97f17d 1809 count=0;
yabahiro 41:e1dd6d97f17d 1810 }
yabahiro 41:e1dd6d97f17d 1811 } else if(mode==33) {
yabahiro 45:878f8f385635 1812 motor[TIRE_FR].pwm = 30;
yabahiro 45:878f8f385635 1813 motor[TIRE_FR].dir = FOR;
yabahiro 45:878f8f385635 1814 motor[TIRE_FL].pwm = 0;
yabahiro 45:878f8f385635 1815 motor[TIRE_FL].dir = FREE;
yabahiro 45:878f8f385635 1816 motor[TIRE_BR].pwm = 0;
yabahiro 45:878f8f385635 1817 motor[TIRE_BR].dir = FREE;
yabahiro 45:878f8f385635 1818 motor[TIRE_BL].pwm = 30;
yabahiro 45:878f8f385635 1819 motor[TIRE_BL].dir = BACK;
yabahiro 45:878f8f385635 1820 if(g[3]==0&&count>=20000) {
yabahiro 40:7f93984e8ba1 1821 count=0;
yabahiro 40:7f93984e8ba1 1822 if(Twsh==2) {
yabahiro 40:7f93984e8ba1 1823 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 40:7f93984e8ba1 1824 }
yabahiro 40:7f93984e8ba1 1825 mode=40;
yabahiro 40:7f93984e8ba1 1826 }
yabahiro 40:7f93984e8ba1 1827 } else if(mode==40) {
yabahiro 45:878f8f385635 1828 if(LIB) {
yabahiro 40:7f93984e8ba1 1829 mode=42;
yabahiro 40:7f93984e8ba1 1830 }
yabahiro 40:7f93984e8ba1 1831 switch(g[3]) {
yabahiro 40:7f93984e8ba1 1832 case 98:
yabahiro 40:7f93984e8ba1 1833 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1834 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1835 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1836 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1837 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1838 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1839 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1840 motor[TIRE_BL].dir = FOR;
yabahiro 45:878f8f385635 1841 if(count>=10000) {
yabahiro 40:7f93984e8ba1 1842 cross++;
yabahiro 40:7f93984e8ba1 1843 count=0;
yabahiro 40:7f93984e8ba1 1844 }
yabahiro 40:7f93984e8ba1 1845 mtc2=true;
yabahiro 45:878f8f385635 1846 if(cross==2) {
yabahiro 40:7f93984e8ba1 1847 mode=41;
yabahiro 40:7f93984e8ba1 1848 count=0;
yabahiro 40:7f93984e8ba1 1849 cross=0;
yabahiro 40:7f93984e8ba1 1850 }
yabahiro 40:7f93984e8ba1 1851 break;
yabahiro 40:7f93984e8ba1 1852 case 0:
yabahiro 40:7f93984e8ba1 1853 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1854 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1855 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1856 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1857 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1858 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1859 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1860 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1861 mtc2=true;
yabahiro 40:7f93984e8ba1 1862 break;
yabahiro 40:7f93984e8ba1 1863 case 255:
yabahiro 40:7f93984e8ba1 1864 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 1865 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1866 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 1867 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1868 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 1869 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1870 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 1871 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1872 mtc2=true;
yabahiro 40:7f93984e8ba1 1873 break;
yabahiro 40:7f93984e8ba1 1874 case 253:
yabahiro 40:7f93984e8ba1 1875 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1876 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1877 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1878 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1879 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1880 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1881 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1882 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1883 mtc2=true;
yabahiro 40:7f93984e8ba1 1884 break;
yabahiro 40:7f93984e8ba1 1885 case 254:
yabahiro 40:7f93984e8ba1 1886 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1887 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 1888 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 1889 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1890 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 1891 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1892 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 1893 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 1894 mtc2=true;
yabahiro 40:7f93984e8ba1 1895 break;
yabahiro 40:7f93984e8ba1 1896 case 1:
yabahiro 40:7f93984e8ba1 1897 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 1898 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1899 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 1900 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 1901 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 1902 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1903 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 1904 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1905 mtc2=true;
yabahiro 40:7f93984e8ba1 1906 break;
yabahiro 40:7f93984e8ba1 1907 case 3:
yabahiro 40:7f93984e8ba1 1908 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 1909 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1910 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1911 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1912 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1913 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1914 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 1915 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1916 mtc2=true;
yabahiro 40:7f93984e8ba1 1917 break;
yabahiro 40:7f93984e8ba1 1918 case 2:
yabahiro 40:7f93984e8ba1 1919 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 1920 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1921 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1922 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1923 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1924 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1925 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 1926 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1927 mtc2=true;
yabahiro 40:7f93984e8ba1 1928 break;
yabahiro 40:7f93984e8ba1 1929 }
yabahiro 40:7f93984e8ba1 1930 if(g[2]!=98&&mtc2==true) {
yabahiro 40:7f93984e8ba1 1931 switch(g[2]) {
yabahiro 40:7f93984e8ba1 1932 case 0:
yabahiro 40:7f93984e8ba1 1933 mtc2=false;
yabahiro 40:7f93984e8ba1 1934 break;
yabahiro 40:7f93984e8ba1 1935 case 255:
yabahiro 40:7f93984e8ba1 1936 motor[TIRE_FR].pwm += 5;
yabahiro 40:7f93984e8ba1 1937 mtc2=false;
yabahiro 40:7f93984e8ba1 1938 break;
yabahiro 40:7f93984e8ba1 1939 case 253:
yabahiro 40:7f93984e8ba1 1940 motor[TIRE_FR].pwm += 10;
yabahiro 40:7f93984e8ba1 1941 mtc2=false;
yabahiro 40:7f93984e8ba1 1942 break;
yabahiro 40:7f93984e8ba1 1943 case 254:
yabahiro 40:7f93984e8ba1 1944 motor[TIRE_FR].pwm += 20;
yabahiro 40:7f93984e8ba1 1945 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1946 mtc2=false;
yabahiro 40:7f93984e8ba1 1947 break;
yabahiro 40:7f93984e8ba1 1948 case 1:
yabahiro 40:7f93984e8ba1 1949 motor[TIRE_BR].pwm += 5;
yabahiro 40:7f93984e8ba1 1950 mtc2=false;
yabahiro 40:7f93984e8ba1 1951 break;
yabahiro 40:7f93984e8ba1 1952 case 3:
yabahiro 40:7f93984e8ba1 1953 motor[TIRE_BR].pwm += 10;
yabahiro 40:7f93984e8ba1 1954 mtc2=false;
yabahiro 40:7f93984e8ba1 1955 break;
yabahiro 40:7f93984e8ba1 1956 case 2:
yabahiro 40:7f93984e8ba1 1957 motor[TIRE_BR].pwm += 20;
yabahiro 40:7f93984e8ba1 1958 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 1959 mtc2=false;
yabahiro 40:7f93984e8ba1 1960 break;
yabahiro 40:7f93984e8ba1 1961 }
yabahiro 40:7f93984e8ba1 1962 }
yabahiro 40:7f93984e8ba1 1963 } else if(mode==41) {
yabahiro 41:e1dd6d97f17d 1964 if(LIF||LIB) {
yabahiro 41:e1dd6d97f17d 1965 mode=42;
yabahiro 41:e1dd6d97f17d 1966 }
yabahiro 40:7f93984e8ba1 1967 motor[TIRE_FR].pwm = 30;
yabahiro 40:7f93984e8ba1 1968 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 1969 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 1970 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 1971 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 1972 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 1973 motor[TIRE_BL].pwm = 30;
yabahiro 40:7f93984e8ba1 1974 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 1975 if(g[1]==0) {
yabahiro 40:7f93984e8ba1 1976 count=0;
yabahiro 40:7f93984e8ba1 1977 mode=70;
yabahiro 40:7f93984e8ba1 1978 normal=60;
yabahiro 45:878f8f385635 1979 fast=70;
yabahiro 40:7f93984e8ba1 1980 slow=40;
yabahiro 40:7f93984e8ba1 1981 }
yabahiro 40:7f93984e8ba1 1982 } else if(mode==42) {
yabahiro 41:e1dd6d97f17d 1983 motor[TIRE_FR].pwm = 0;
yabahiro 41:e1dd6d97f17d 1984 motor[TIRE_FR].dir = FREE;
yabahiro 45:878f8f385635 1985 motor[TIRE_FL].pwm = 20;
yabahiro 40:7f93984e8ba1 1986 motor[TIRE_FL].dir = FOR;
yabahiro 45:878f8f385635 1987 motor[TIRE_BR].pwm = 20;
yabahiro 40:7f93984e8ba1 1988 motor[TIRE_BR].dir = BACK;
yabahiro 41:e1dd6d97f17d 1989 motor[TIRE_BL].pwm = 0;
yabahiro 41:e1dd6d97f17d 1990 motor[TIRE_BL].dir = FREE;
yabahiro 41:e1dd6d97f17d 1991 if(g[0]==0) {
yabahiro 40:7f93984e8ba1 1992 count=0;
yabahiro 40:7f93984e8ba1 1993 slow=40;
yabahiro 40:7f93984e8ba1 1994 }
yabahiro 40:7f93984e8ba1 1995
yabahiro 40:7f93984e8ba1 1996 } else if(mode==70)
yabahiro 40:7f93984e8ba1 1997 switch(g[0]) {
yabahiro 40:7f93984e8ba1 1998 case 99:
yabahiro 40:7f93984e8ba1 1999 if(count>=100000) {
yabahiro 40:7f93984e8ba1 2000 cross++;
yabahiro 40:7f93984e8ba1 2001 mode=100;
yabahiro 40:7f93984e8ba1 2002 count=0;
yabahiro 40:7f93984e8ba1 2003 }
yabahiro 41:e1dd6d97f17d 2004 if(cross==2) {
yabahiro 40:7f93984e8ba1 2005 cross=0;
yabahiro 40:7f93984e8ba1 2006 mode=100;
yabahiro 40:7f93984e8ba1 2007 }
yabahiro 40:7f93984e8ba1 2008 break;
yabahiro 40:7f93984e8ba1 2009 case 98:
yabahiro 40:7f93984e8ba1 2010 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2011 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2012 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2013 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2014 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2015 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2016 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2017 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2018 break;
yabahiro 40:7f93984e8ba1 2019 case 0:
yabahiro 40:7f93984e8ba1 2020 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2021 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2022 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2023 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2024 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2025 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2026 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2027 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2028 mtc=true;
yabahiro 40:7f93984e8ba1 2029 break;
yabahiro 40:7f93984e8ba1 2030 case 255:
yabahiro 40:7f93984e8ba1 2031 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2032 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2033 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2034 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2035 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2036 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2037 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2038 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2039 mtc=true;
yabahiro 40:7f93984e8ba1 2040 break;
yabahiro 40:7f93984e8ba1 2041 case 253:
yabahiro 40:7f93984e8ba1 2042 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2043 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2044 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2045 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2046 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2047 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2048 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2049 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2050 mtc=true;
yabahiro 40:7f93984e8ba1 2051 break;
yabahiro 40:7f93984e8ba1 2052 case 254:
yabahiro 40:7f93984e8ba1 2053 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2054 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2055 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2056 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2057 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2058 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2059 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2060 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2061 mtc=true;
yabahiro 40:7f93984e8ba1 2062 break;
yabahiro 40:7f93984e8ba1 2063 case 1:
yabahiro 40:7f93984e8ba1 2064 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2065 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2066 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2067 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2068 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2069 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2070 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2071 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2072 mtc=true;
yabahiro 40:7f93984e8ba1 2073 break;
yabahiro 40:7f93984e8ba1 2074 case 3:
yabahiro 40:7f93984e8ba1 2075 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2076 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2077 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2078 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2079 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2080 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2081 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2082 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2083 mtc=true;
yabahiro 40:7f93984e8ba1 2084 break;
yabahiro 40:7f93984e8ba1 2085 case 2:
yabahiro 40:7f93984e8ba1 2086 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2087 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2088 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2089 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2090 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2091 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2092 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2093 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2094 mtc=true;
yabahiro 40:7f93984e8ba1 2095 break;
yabahiro 40:7f93984e8ba1 2096 }
yabahiro 40:7f93984e8ba1 2097 if(g[1]!=98&&mtc==true) {
yabahiro 40:7f93984e8ba1 2098 switch(g[1]) {
yabahiro 40:7f93984e8ba1 2099 case 0:
yabahiro 40:7f93984e8ba1 2100 mtc=false;
yabahiro 40:7f93984e8ba1 2101 break;
yabahiro 40:7f93984e8ba1 2102 case 255:
yabahiro 40:7f93984e8ba1 2103 motor[TIRE_BR].pwm += 5;
yabahiro 40:7f93984e8ba1 2104 mtc=false;
yabahiro 40:7f93984e8ba1 2105 break;
yabahiro 40:7f93984e8ba1 2106 case 253:
yabahiro 40:7f93984e8ba1 2107 motor[TIRE_BR].pwm += 10;
yabahiro 40:7f93984e8ba1 2108 mtc=false;
yabahiro 40:7f93984e8ba1 2109 break;
yabahiro 40:7f93984e8ba1 2110 case 254:
yabahiro 40:7f93984e8ba1 2111 motor[TIRE_BR].pwm += 20;
yabahiro 40:7f93984e8ba1 2112 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2113 mtc=false;
yabahiro 40:7f93984e8ba1 2114 break;
yabahiro 40:7f93984e8ba1 2115 case 1:
yabahiro 40:7f93984e8ba1 2116 motor[TIRE_BL].pwm += 5;
yabahiro 40:7f93984e8ba1 2117 mtc=false;
yabahiro 40:7f93984e8ba1 2118 break;
yabahiro 40:7f93984e8ba1 2119 case 3:
yabahiro 40:7f93984e8ba1 2120 motor[TIRE_BL].pwm += 10;
yabahiro 40:7f93984e8ba1 2121 mtc=false;
yabahiro 40:7f93984e8ba1 2122 break;
yabahiro 40:7f93984e8ba1 2123 case 2:
yabahiro 40:7f93984e8ba1 2124 motor[TIRE_BL].pwm += 20;
yabahiro 40:7f93984e8ba1 2125 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2126 mtc=false;
yabahiro 40:7f93984e8ba1 2127 break;
yabahiro 40:7f93984e8ba1 2128 }
yabahiro 40:7f93984e8ba1 2129 } else if(mode==100) {
yabahiro 40:7f93984e8ba1 2130 motor[TIRE_FR].pwm = 20;
yabahiro 40:7f93984e8ba1 2131 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2132 motor[TIRE_FL].pwm = 20;
yabahiro 40:7f93984e8ba1 2133 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2134 motor[TIRE_BR].pwm = 23;
yabahiro 40:7f93984e8ba1 2135 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2136 motor[TIRE_BL].pwm = 20;
yabahiro 40:7f93984e8ba1 2137 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2138 }
yabahiro 43:677f7446612e 2139 }
yabahiro 43:677f7446612e 2140 #endif
yabahiro 40:7f93984e8ba1 2141
yabahiro 43:677f7446612e 2142 #if USE_PROCESS_NUM>5
yabahiro 43:677f7446612e 2143 static void Process5()
yabahiro 43:677f7446612e 2144 {
kishibekairohan 13:b6e02d6261d7 2145 }
kishibekairohan 13:b6e02d6261d7 2146 #endif
kishibekairohan 13:b6e02d6261d7 2147
kishibekairohan 13:b6e02d6261d7 2148 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 2149 static void Process6()
kishibekairohan 13:b6e02d6261d7 2150 {
yabahiro 44:c208a908583c 2151 // printf("1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 44:c208a908583c 2152 LedMode(3);
yabahiro 44:c208a908583c 2153 count++;
yabahiro 44:c208a908583c 2154 if(mode==1) {//スタートゾーンから白線検知
yabahiro 44:c208a908583c 2155 fast=40;
yabahiro 44:c208a908583c 2156 normal=30;
yabahiro 44:c208a908583c 2157 slow=20;
yabahiro 44:c208a908583c 2158 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2159 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2160 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2161 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2162 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2163 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2164 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2165 motor[TIRE_BL].dir = FOR;
yabahiro 46:4a8bca4cc1fd 2166 if(g[2]==0&&count>=100000) {
yabahiro 44:c208a908583c 2167 count=100000;
yabahiro 44:c208a908583c 2168 cross=0;
yabahiro 44:c208a908583c 2169 mode=3;
yabahiro 44:c208a908583c 2170 }
yabahiro 44:c208a908583c 2171 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 44:c208a908583c 2172 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2173 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2174 motor[TIRE_FL].pwm = 25;
yabahiro 44:c208a908583c 2175 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2176 motor[TIRE_BR].pwm = 25;
yabahiro 44:c208a908583c 2177 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2178 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2179 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2180 if(g[0]==0) {
yabahiro 44:c208a908583c 2181 mode=10;
yabahiro 44:c208a908583c 2182 count=100000;
yabahiro 44:c208a908583c 2183 }
yabahiro 44:c208a908583c 2184 } else if(mode==10) { //縦ライントレース
yabahiro 44:c208a908583c 2185 if(counts==false&&g[2]==0) {
yabahiro 44:c208a908583c 2186 cros++;
yabahiro 44:c208a908583c 2187 counts=true;
yabahiro 44:c208a908583c 2188 }
yabahiro 44:c208a908583c 2189 if(counts==true&&g[2]==99) {
yabahiro 44:c208a908583c 2190 counts=false;
yabahiro 44:c208a908583c 2191 }
yabahiro 21:1f1e9c585da8 2192
yabahiro 44:c208a908583c 2193 if(cros==Twsh) {
yabahiro 44:c208a908583c 2194 mode=11;
yabahiro 44:c208a908583c 2195 count=0;
yabahiro 44:c208a908583c 2196 cros=0;
yabahiro 44:c208a908583c 2197 }//ゆっくりモードに入れなかった時の保険
yabahiro 44:c208a908583c 2198 switch(g[0]) {
yabahiro 44:c208a908583c 2199 case 98:
yabahiro 44:c208a908583c 2200 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2201 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2202 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2203 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2204 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2205 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2206 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2207 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2208 mtc=true;
yabahiro 44:c208a908583c 2209 if(count>80000) {
yabahiro 44:c208a908583c 2210 cross++;
yabahiro 44:c208a908583c 2211 count=0;
yabahiro 44:c208a908583c 2212 }
yabahiro 44:c208a908583c 2213 if(cross==Twsh) {
yabahiro 44:c208a908583c 2214 mode=11;
yabahiro 44:c208a908583c 2215 count=0;
yabahiro 44:c208a908583c 2216 cross=0;
yabahiro 44:c208a908583c 2217 }
yabahiro 44:c208a908583c 2218 break;
yabahiro 44:c208a908583c 2219 case 0:
yabahiro 44:c208a908583c 2220 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2221 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2222 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2223 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2224 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2225 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2226 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2227 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2228 mtc=true;
yabahiro 44:c208a908583c 2229 break;
yabahiro 44:c208a908583c 2230 case 255:
yabahiro 44:c208a908583c 2231 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2232 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2233 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2234 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2235 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2236 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2237 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2238 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2239 mtc=true;
yabahiro 44:c208a908583c 2240 break;
yabahiro 44:c208a908583c 2241 case 253:
yabahiro 44:c208a908583c 2242 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2243 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2244 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2245 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2246 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2247 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2248 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2249 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2250 mtc=true;
yabahiro 44:c208a908583c 2251 break;
yabahiro 44:c208a908583c 2252 case 254:
yabahiro 44:c208a908583c 2253 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2254 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2255 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2256 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2257 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2258 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2259 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2260 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2261 mtc=true;
yabahiro 44:c208a908583c 2262 break;
yabahiro 44:c208a908583c 2263 case 1:
yabahiro 44:c208a908583c 2264 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2265 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2266 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2267 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2268 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2269 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2270 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2271 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2272 mtc=true;
yabahiro 44:c208a908583c 2273 break;
yabahiro 44:c208a908583c 2274 case 3:
yabahiro 44:c208a908583c 2275 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2276 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2277 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2278 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2279 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2280 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2281 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2282 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2283 mtc=true;
yabahiro 44:c208a908583c 2284 break;
yabahiro 44:c208a908583c 2285 case 2:
yabahiro 44:c208a908583c 2286 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2287 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2288 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2289 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2290 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2291 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2292 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2293 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2294 mtc=true;
yabahiro 44:c208a908583c 2295 break;
yabahiro 44:c208a908583c 2296 }
yabahiro 44:c208a908583c 2297 if(g[0]!=98&&mtc==true) {
yabahiro 44:c208a908583c 2298 switch(g[1]) {
yabahiro 44:c208a908583c 2299 case 0:
yabahiro 44:c208a908583c 2300 mtc=false;
yabahiro 44:c208a908583c 2301 break;
yabahiro 44:c208a908583c 2302 case 255:
yabahiro 44:c208a908583c 2303 motor[TIRE_BR].pwm += 5;
yabahiro 44:c208a908583c 2304 mtc=false;
yabahiro 44:c208a908583c 2305 break;
yabahiro 44:c208a908583c 2306 case 253:
yabahiro 44:c208a908583c 2307 motor[TIRE_BR].pwm += 10;
yabahiro 44:c208a908583c 2308 mtc=false;
yabahiro 44:c208a908583c 2309 break;
yabahiro 44:c208a908583c 2310 case 254:
yabahiro 44:c208a908583c 2311 motor[TIRE_BR].pwm += 20;
yabahiro 44:c208a908583c 2312 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2313 mtc=false;
yabahiro 44:c208a908583c 2314 break;
yabahiro 44:c208a908583c 2315 case 1:
yabahiro 44:c208a908583c 2316 motor[TIRE_BL].pwm += 5;
yabahiro 44:c208a908583c 2317 mtc=false;
yabahiro 44:c208a908583c 2318 break;
yabahiro 44:c208a908583c 2319 case 3:
yabahiro 44:c208a908583c 2320 motor[TIRE_BL].pwm += 10;
yabahiro 44:c208a908583c 2321 mtc=false;
yabahiro 44:c208a908583c 2322 break;
yabahiro 44:c208a908583c 2323 case 2:
yabahiro 44:c208a908583c 2324 motor[TIRE_BL].pwm += 20;
yabahiro 44:c208a908583c 2325 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2326 mtc=false;
yabahiro 44:c208a908583c 2327 break;
yabahiro 44:c208a908583c 2328 }
yabahiro 44:c208a908583c 2329 }
yabahiro 44:c208a908583c 2330 } else if(mode==11) {
yabahiro 44:c208a908583c 2331 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2332 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2333 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2334 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2335 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2336 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2337 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2338 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2339 if(g[2]==0) {
yabahiro 44:c208a908583c 2340 count=0;
yabahiro 44:c208a908583c 2341 cross=0;
yabahiro 44:c208a908583c 2342 mode=20;
yabahiro 44:c208a908583c 2343 }
yabahiro 44:c208a908583c 2344 } else if(mode==20) {
yabahiro 44:c208a908583c 2345
yabahiro 44:c208a908583c 2346 if(Twsh==2) {
yabahiro 44:c208a908583c 2347 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 44:c208a908583c 2348 }
yabahiro 44:c208a908583c 2349 if(counts==false&&g[0]==0) {
yabahiro 44:c208a908583c 2350 cros++;
yabahiro 44:c208a908583c 2351 counts=true;
yabahiro 44:c208a908583c 2352 }
yabahiro 44:c208a908583c 2353 if(counts==true&&g[0]==99) {
yabahiro 44:c208a908583c 2354 counts=false;
yabahiro 44:c208a908583c 2355 }
yabahiro 44:c208a908583c 2356
yabahiro 44:c208a908583c 2357 if(cros==2) {
yabahiro 44:c208a908583c 2358
yabahiro 44:c208a908583c 2359 // mode=21;
yabahiro 44:c208a908583c 2360 // count=0;
yabahiro 44:c208a908583c 2361 // cros=0;
yabahiro 44:c208a908583c 2362 }//ゆっくりモードに入れなかった時の保険
yabahiro 44:c208a908583c 2363 if(g[0]==0) {
yabahiro 44:c208a908583c 2364 fast=35;
yabahiro 44:c208a908583c 2365 normal=20;
yabahiro 44:c208a908583c 2366 slow=15;
yabahiro 44:c208a908583c 2367 }
yabahiro 44:c208a908583c 2368 switch(g[2]) {
yabahiro 44:c208a908583c 2369 case 98:
yabahiro 44:c208a908583c 2370 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2371 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2372 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2373 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2374 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2375 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2376 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2377 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2378 if(count>30000) {
yabahiro 44:c208a908583c 2379 cross++;
yabahiro 44:c208a908583c 2380 count=0;
yabahiro 44:c208a908583c 2381 }
yabahiro 44:c208a908583c 2382 mtc2=true;
yabahiro 44:c208a908583c 2383 if(cross==2) {
yabahiro 44:c208a908583c 2384 mode=22;
yabahiro 44:c208a908583c 2385 count=0;
yabahiro 44:c208a908583c 2386 cross=0;
yabahiro 44:c208a908583c 2387 fast=40;
yabahiro 44:c208a908583c 2388 normal=30;
yabahiro 44:c208a908583c 2389 slow=20;
yabahiro 44:c208a908583c 2390 }
yabahiro 44:c208a908583c 2391 break;
yabahiro 44:c208a908583c 2392 case 0:
yabahiro 44:c208a908583c 2393 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2394 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2395 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2396 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2397 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2398 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2399 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2400 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2401 mtc2=true;
yabahiro 44:c208a908583c 2402 break;
yabahiro 44:c208a908583c 2403 case 255:
yabahiro 44:c208a908583c 2404 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2405 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2406 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2407 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2408 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2409 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2410 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2411 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2412 mtc2=true;
yabahiro 44:c208a908583c 2413 break;
yabahiro 44:c208a908583c 2414 case 253:
yabahiro 44:c208a908583c 2415 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2416 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2417 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2418 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2419 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2420 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2421 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2422 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2423 mtc2=true;
yabahiro 44:c208a908583c 2424 break;
yabahiro 44:c208a908583c 2425 case 254:
yabahiro 44:c208a908583c 2426 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2427 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2428 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2429 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2430 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2431 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2432 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2433 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2434 mtc2=true;
yabahiro 44:c208a908583c 2435 break;
yabahiro 44:c208a908583c 2436 case 1:
yabahiro 44:c208a908583c 2437 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2438 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2439 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2440 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2441 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2442 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2443 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2444 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2445 mtc2=true;
yabahiro 44:c208a908583c 2446 break;
yabahiro 44:c208a908583c 2447 case 3:
yabahiro 44:c208a908583c 2448 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2449 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2450 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2451 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2452 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2453 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2454 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2455 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2456 mtc2=true;
yabahiro 44:c208a908583c 2457 break;
yabahiro 44:c208a908583c 2458 case 2:
yabahiro 44:c208a908583c 2459 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2460 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2461 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2462 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2463 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2464 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2465 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2466 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2467 mtc2=true;
yabahiro 44:c208a908583c 2468 break;
yabahiro 44:c208a908583c 2469 }
yabahiro 44:c208a908583c 2470 if(g[2]!=98&&mtc2==true) {
yabahiro 44:c208a908583c 2471 switch(g[3]) {
yabahiro 44:c208a908583c 2472 case 0:
yabahiro 44:c208a908583c 2473 mtc2=false;
yabahiro 44:c208a908583c 2474 break;
yabahiro 44:c208a908583c 2475 case 255:
yabahiro 44:c208a908583c 2476 motor[TIRE_BL].pwm += 5;
yabahiro 44:c208a908583c 2477 mtc2=false;
yabahiro 44:c208a908583c 2478 break;
yabahiro 44:c208a908583c 2479 case 253:
yabahiro 44:c208a908583c 2480 motor[TIRE_BL].pwm += 10;
yabahiro 44:c208a908583c 2481 mtc2=false;
yabahiro 44:c208a908583c 2482 break;
yabahiro 44:c208a908583c 2483 case 254:
yabahiro 44:c208a908583c 2484 motor[TIRE_BL].pwm += 20;
yabahiro 44:c208a908583c 2485 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2486 mtc2=false;
yabahiro 44:c208a908583c 2487 break;
yabahiro 44:c208a908583c 2488 case 1:
yabahiro 44:c208a908583c 2489 motor[TIRE_FL].pwm += 5;
yabahiro 44:c208a908583c 2490 mtc2=false;
yabahiro 44:c208a908583c 2491 break;
yabahiro 44:c208a908583c 2492 case 3:
yabahiro 44:c208a908583c 2493 motor[TIRE_FL].pwm += 10;
yabahiro 44:c208a908583c 2494 mtc2=false;
yabahiro 44:c208a908583c 2495 break;
yabahiro 44:c208a908583c 2496 case 2:
yabahiro 44:c208a908583c 2497 motor[TIRE_FL].pwm += 20;
yabahiro 44:c208a908583c 2498 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2499 mtc2=false;
yabahiro 44:c208a908583c 2500 break;
yabahiro 44:c208a908583c 2501 }
yabahiro 44:c208a908583c 2502 }
yabahiro 44:c208a908583c 2503 } else if(mode==21) {
yabahiro 44:c208a908583c 2504 motor[TIRE_FR].pwm = 30;
yabahiro 44:c208a908583c 2505 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2506 motor[TIRE_FL].pwm = 30;
yabahiro 44:c208a908583c 2507 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2508 motor[TIRE_BR].pwm = 30;
yabahiro 44:c208a908583c 2509 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2510 motor[TIRE_BL].pwm = 30;
yabahiro 44:c208a908583c 2511 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2512 if(g[2]==98&&count>=10000) {
yabahiro 44:c208a908583c 2513 mode=22;
yabahiro 44:c208a908583c 2514 count=0;
yabahiro 44:c208a908583c 2515 }
yabahiro 44:c208a908583c 2516 }
yabahiro 44:c208a908583c 2517 kiri=true;
yabahiro 44:c208a908583c 2518 if(kiri) {
yabahiro 44:c208a908583c 2519 if(mode==22) {
yabahiro 44:c208a908583c 2520 motor[TIRE_FR].pwm = 100;
yabahiro 44:c208a908583c 2521 motor[TIRE_FR].dir = BRAKE;
yabahiro 44:c208a908583c 2522 motor[TIRE_FL].pwm = 100;
yabahiro 44:c208a908583c 2523 motor[TIRE_FL].dir = BRAKE;
yabahiro 44:c208a908583c 2524 motor[TIRE_BR].pwm = 100;
yabahiro 44:c208a908583c 2525 motor[TIRE_BR].dir = BRAKE;
yabahiro 44:c208a908583c 2526 motor[TIRE_BL].pwm = 100;
yabahiro 44:c208a908583c 2527 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 2528 if(count>=10000) {
yabahiro 44:c208a908583c 2529 mode=23;
yabahiro 44:c208a908583c 2530 }
yabahiro 44:c208a908583c 2531 } else if(mode==23) {
yabahiro 44:c208a908583c 2532 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2533 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2534 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 2535 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2536 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 2537 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2538 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 2539 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2540 if(g[2]==98) {
yabahiro 44:c208a908583c 2541 mode=24;
yabahiro 44:c208a908583c 2542 count=0;
yabahiro 44:c208a908583c 2543 }
yabahiro 44:c208a908583c 2544 } else if(mode==24) {
yabahiro 44:c208a908583c 2545 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2546 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2547 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 2548 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2549 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 2550 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2551 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 2552 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2553 if(g[2]!=98) {
yabahiro 44:c208a908583c 2554 count=0;
yabahiro 44:c208a908583c 2555 mode=25;
yabahiro 44:c208a908583c 2556 }
yabahiro 44:c208a908583c 2557 } else if(mode==25) {
yabahiro 44:c208a908583c 2558 motor[TIRE_FR].pwm = 10;
yabahiro 44:c208a908583c 2559 motor[TIRE_FR].dir = BRAKE;
yabahiro 44:c208a908583c 2560 motor[TIRE_FL].pwm = 10;
yabahiro 44:c208a908583c 2561 motor[TIRE_FL].dir = BRAKE;
yabahiro 44:c208a908583c 2562 motor[TIRE_BR].pwm = 10;
yabahiro 44:c208a908583c 2563 motor[TIRE_BR].dir = BRAKE;
yabahiro 44:c208a908583c 2564 motor[TIRE_BL].pwm = 10;
yabahiro 44:c208a908583c 2565 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 2566 if(count>=10000) {
yabahiro 44:c208a908583c 2567 mode=26;
yabahiro 44:c208a908583c 2568 count=0;
yabahiro 44:c208a908583c 2569 }
yabahiro 44:c208a908583c 2570 } else if(mode==26) {
yabahiro 44:c208a908583c 2571 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2572 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2573 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 2574 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2575 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 2576 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2577 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 2578 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2579 if(count>=5000) {
yabahiro 44:c208a908583c 2580 mode=27;
yabahiro 44:c208a908583c 2581 count=0;
yabahiro 44:c208a908583c 2582 }
yabahiro 44:c208a908583c 2583 } else if(mode==27) {
yabahiro 44:c208a908583c 2584 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2585 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2586 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 2587 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2588 motor[TIRE_BR].pwm = 20;
yabahiro 44:c208a908583c 2589 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2590 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 2591 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2592 //どれくらい回転するかって値
yabahiro 45:878f8f385635 2593 if(count>=100) {
yabahiro 44:c208a908583c 2594 count=0;
yabahiro 44:c208a908583c 2595 mode=30;
yabahiro 44:c208a908583c 2596 }
yabahiro 44:c208a908583c 2597 } else if(mode==24) {
yabahiro 44:c208a908583c 2598 motor[TIRE_FR].pwm = 10;
yabahiro 44:c208a908583c 2599 motor[TIRE_FR].dir = BRAKE;
yabahiro 44:c208a908583c 2600 motor[TIRE_FL].pwm = 10;
yabahiro 44:c208a908583c 2601 motor[TIRE_FL].dir = BRAKE;
yabahiro 44:c208a908583c 2602 motor[TIRE_BR].pwm = 10;
yabahiro 44:c208a908583c 2603 motor[TIRE_BR].dir = BRAKE;
yabahiro 44:c208a908583c 2604 motor[TIRE_BL].pwm = 10;
yabahiro 44:c208a908583c 2605 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 2606 if(count>=10000) {
yabahiro 44:c208a908583c 2607 mode=30;
yabahiro 44:c208a908583c 2608 count=0;
yabahiro 44:c208a908583c 2609 }
yabahiro 44:c208a908583c 2610 }
yabahiro 44:c208a908583c 2611 } else {
yabahiro 44:c208a908583c 2612 if(mode==22) {
yabahiro 44:c208a908583c 2613 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2614 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2615 motor[TIRE_FL].pwm = 25;
yabahiro 44:c208a908583c 2616 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2617 motor[TIRE_BR].pwm = 25;
yabahiro 44:c208a908583c 2618 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2619 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2620 motor[TIRE_BL].dir = FREE;
yabahiro 45:878f8f385635 2621 if(g[0]==0&&count>=10000) {
yabahiro 44:c208a908583c 2622 mode=30;
yabahiro 45:878f8f385635 2623 count=0;
yabahiro 44:c208a908583c 2624 cros=0;
yabahiro 44:c208a908583c 2625 }
yabahiro 44:c208a908583c 2626 }
yabahiro 44:c208a908583c 2627 }
yabahiro 44:c208a908583c 2628 if(mode==30) {
yabahiro 44:c208a908583c 2629 motor[TIRE_FR].pwm = 59;
yabahiro 44:c208a908583c 2630 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2631 motor[TIRE_FL].pwm = 62;
yabahiro 44:c208a908583c 2632 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2633 motor[TIRE_BR].pwm = 59;
yabahiro 44:c208a908583c 2634 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2635 motor[TIRE_BL].pwm = 62;
yabahiro 44:c208a908583c 2636 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2637 if(g[0]==98) {
yabahiro 44:c208a908583c 2638 mode=31;
yabahiro 44:c208a908583c 2639 count=0;
yabahiro 44:c208a908583c 2640 }
yabahiro 44:c208a908583c 2641 } else if(mode==31) {
yabahiro 44:c208a908583c 2642 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2643 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2644 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2645 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2646 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2647 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2648 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2649 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2650 if(count>=5000) {
yabahiro 44:c208a908583c 2651 count=0;
yabahiro 44:c208a908583c 2652 mode=32;
yabahiro 44:c208a908583c 2653 }
yabahiro 44:c208a908583c 2654 } else if(mode==32) {
yabahiro 44:c208a908583c 2655 motor[TIRE_FR].pwm = 10;
yabahiro 44:c208a908583c 2656 motor[TIRE_FR].dir = BRAKE;
yabahiro 44:c208a908583c 2657 motor[TIRE_FL].pwm = 10;
yabahiro 44:c208a908583c 2658 motor[TIRE_FL].dir = BRAKE;
yabahiro 44:c208a908583c 2659 motor[TIRE_BR].pwm = 10;
yabahiro 44:c208a908583c 2660 motor[TIRE_BR].dir = BRAKE;
yabahiro 44:c208a908583c 2661 motor[TIRE_BL].pwm = 10;
yabahiro 44:c208a908583c 2662 motor[TIRE_BL].dir = BRAKE;
yabahiro 44:c208a908583c 2663 if(count>=40000) {
yabahiro 44:c208a908583c 2664 mode=33;
yabahiro 44:c208a908583c 2665 count=0;
yabahiro 44:c208a908583c 2666 }
yabahiro 44:c208a908583c 2667 } else if(mode==33) {
yabahiro 44:c208a908583c 2668 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2669 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2670 motor[TIRE_FL].pwm = 30;
yabahiro 44:c208a908583c 2671 motor[TIRE_FL].dir = FOR;
yabahiro 44:c208a908583c 2672 motor[TIRE_BR].pwm = 30;
yabahiro 44:c208a908583c 2673 motor[TIRE_BR].dir = BACK;
yabahiro 44:c208a908583c 2674 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2675 motor[TIRE_BL].dir = FOR;
yabahiro 45:878f8f385635 2676 if(g[3]==0&&count>=20000) {
yabahiro 44:c208a908583c 2677 count=0;
yabahiro 44:c208a908583c 2678 if(Twsh==2) {
yabahiro 44:c208a908583c 2679 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 44:c208a908583c 2680 }
yabahiro 44:c208a908583c 2681 mode=40;
yabahiro 44:c208a908583c 2682 }
yabahiro 44:c208a908583c 2683 } else if(mode==40) {
yabahiro 44:c208a908583c 2684 if(LIB) {
yabahiro 44:c208a908583c 2685 mode=42;
yabahiro 44:c208a908583c 2686 }
yabahiro 44:c208a908583c 2687 if(counts==false&&g[0]==0) {
yabahiro 44:c208a908583c 2688 cros++;
yabahiro 44:c208a908583c 2689 counts=true;
yabahiro 44:c208a908583c 2690 }
yabahiro 44:c208a908583c 2691 if(counts==true&&g[0]==99) {
yabahiro 44:c208a908583c 2692 counts=false;
yabahiro 44:c208a908583c 2693 }
yabahiro 44:c208a908583c 2694
yabahiro 44:c208a908583c 2695 if(cros==1) {
yabahiro 44:c208a908583c 2696 // mode=41;
yabahiro 44:c208a908583c 2697 //count=0;
yabahiro 44:c208a908583c 2698 //cros=0;
yabahiro 44:c208a908583c 2699 }//ゆっくりモードに入れなかった時の保険
yabahiro 44:c208a908583c 2700
yabahiro 44:c208a908583c 2701 switch(g[3]) {
yabahiro 44:c208a908583c 2702 case 98:
yabahiro 44:c208a908583c 2703 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2704 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2705 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2706 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2707 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2708 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2709 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2710 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2711 if(count>20000) {
yabahiro 44:c208a908583c 2712 cross++;
yabahiro 44:c208a908583c 2713 count=0;
yabahiro 44:c208a908583c 2714 }
yabahiro 44:c208a908583c 2715 mtc2=true;
yabahiro 44:c208a908583c 2716 if(cross==2) {
yabahiro 44:c208a908583c 2717 mode=41;
yabahiro 44:c208a908583c 2718 count=0;
yabahiro 44:c208a908583c 2719 cross=0;
yabahiro 44:c208a908583c 2720 }
yabahiro 44:c208a908583c 2721 break;
yabahiro 44:c208a908583c 2722 case 0:
yabahiro 44:c208a908583c 2723 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2724 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2725 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2726 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2727 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2728 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2729 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2730 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2731 mtc2=true;
yabahiro 44:c208a908583c 2732 break;
yabahiro 44:c208a908583c 2733 case 255:
yabahiro 44:c208a908583c 2734 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2735 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2736 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2737 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2738 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2739 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2740 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2741 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2742 mtc2=true;
yabahiro 44:c208a908583c 2743 break;
yabahiro 44:c208a908583c 2744 case 253:
yabahiro 44:c208a908583c 2745 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2746 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2747 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2748 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2749 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2750 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2751 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2752 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2753 mtc2=true;
yabahiro 44:c208a908583c 2754 break;
yabahiro 44:c208a908583c 2755 case 254:
yabahiro 44:c208a908583c 2756 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2757 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2758 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2759 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2760 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2761 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2762 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2763 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2764 mtc2=true;
yabahiro 44:c208a908583c 2765 break;
yabahiro 44:c208a908583c 2766 case 1:
yabahiro 44:c208a908583c 2767 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2768 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2769 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2770 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2771 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2772 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2773 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2774 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2775 mtc2=true;
yabahiro 44:c208a908583c 2776 break;
yabahiro 44:c208a908583c 2777 case 3:
yabahiro 44:c208a908583c 2778 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2779 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2780 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2781 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2782 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2783 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2784 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2785 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2786 mtc2=true;
yabahiro 44:c208a908583c 2787 break;
yabahiro 44:c208a908583c 2788 case 2:
yabahiro 44:c208a908583c 2789 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2790 motor[TIRE_FR].dir = BACK;
yabahiro 44:c208a908583c 2791 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2792 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2793 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2794 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2795 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2796 motor[TIRE_BL].dir = FOR;
yabahiro 44:c208a908583c 2797 mtc2=true;
yabahiro 44:c208a908583c 2798 break;
yabahiro 44:c208a908583c 2799 }
yabahiro 44:c208a908583c 2800 if(g[2]!=98&&mtc2==true) {
yabahiro 44:c208a908583c 2801 switch(g[2]) {
yabahiro 44:c208a908583c 2802 case 0:
yabahiro 44:c208a908583c 2803 mtc2=false;
yabahiro 44:c208a908583c 2804 break;
yabahiro 44:c208a908583c 2805 case 255:
yabahiro 44:c208a908583c 2806 motor[TIRE_FL].pwm += 5;
yabahiro 44:c208a908583c 2807 mtc2=false;
yabahiro 44:c208a908583c 2808 break;
yabahiro 44:c208a908583c 2809 case 253:
yabahiro 44:c208a908583c 2810 motor[TIRE_FL].pwm += 10;
yabahiro 44:c208a908583c 2811 mtc2=false;
yabahiro 44:c208a908583c 2812 break;
yabahiro 44:c208a908583c 2813 case 254:
yabahiro 44:c208a908583c 2814 motor[TIRE_FL].pwm += 20;
yabahiro 44:c208a908583c 2815 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2816 mtc2=false;
yabahiro 44:c208a908583c 2817 break;
yabahiro 44:c208a908583c 2818 case 1:
yabahiro 44:c208a908583c 2819 motor[TIRE_BL].pwm += 5;
yabahiro 44:c208a908583c 2820 mtc2=false;
yabahiro 44:c208a908583c 2821 break;
yabahiro 44:c208a908583c 2822 case 3:
yabahiro 44:c208a908583c 2823 motor[TIRE_BL].pwm += 10;
yabahiro 44:c208a908583c 2824 mtc2=false;
yabahiro 44:c208a908583c 2825 break;
yabahiro 44:c208a908583c 2826 case 2:
yabahiro 44:c208a908583c 2827 motor[TIRE_BL].pwm += 20;
yabahiro 44:c208a908583c 2828 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2829 mtc2=false;
yabahiro 44:c208a908583c 2830 break;
yabahiro 44:c208a908583c 2831 }
yabahiro 44:c208a908583c 2832 }
yabahiro 44:c208a908583c 2833 } else if(mode==41) {
yabahiro 44:c208a908583c 2834 if(LIF||LIB) {
yabahiro 44:c208a908583c 2835 mode=42;
yabahiro 44:c208a908583c 2836 }
yabahiro 44:c208a908583c 2837 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2838 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2839 motor[TIRE_FL].pwm = 30;
yabahiro 44:c208a908583c 2840 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2841 motor[TIRE_BR].pwm = 30;
yabahiro 44:c208a908583c 2842 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2843 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2844 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2845 if(g[1]==0) {
yabahiro 44:c208a908583c 2846 count=0;
yabahiro 44:c208a908583c 2847 mode=70;
yabahiro 45:878f8f385635 2848 normal=60;
yabahiro 45:878f8f385635 2849 fast=70;
yabahiro 45:878f8f385635 2850 slow=40;
yabahiro 44:c208a908583c 2851 }
yabahiro 44:c208a908583c 2852 } else if(mode==42) {
yabahiro 44:c208a908583c 2853 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2854 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2855 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2856 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2857 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2858 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2859 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 2860 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2861 if(g[1]==0) {
yabahiro 44:c208a908583c 2862 count=0;
yabahiro 44:c208a908583c 2863 mode=70;
yabahiro 44:c208a908583c 2864 }
yabahiro 44:c208a908583c 2865 } else if(mode==70) {
yabahiro 44:c208a908583c 2866 switch(g[1]) {
yabahiro 44:c208a908583c 2867 case 99:
yabahiro 44:c208a908583c 2868 if(count>=100000) {
yabahiro 44:c208a908583c 2869 mode=100;
yabahiro 44:c208a908583c 2870 }
yabahiro 44:c208a908583c 2871 break;
yabahiro 44:c208a908583c 2872 case 98:
yabahiro 44:c208a908583c 2873 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2874 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2875 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2876 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2877 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2878 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2879 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2880 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2881 break;
yabahiro 44:c208a908583c 2882 case 0:
yabahiro 44:c208a908583c 2883 motor[TIRE_FR].pwm = 80;
yabahiro 44:c208a908583c 2884 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2885 motor[TIRE_FL].pwm = 80;
yabahiro 44:c208a908583c 2886 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2887 motor[TIRE_BR].pwm = 80;
yabahiro 44:c208a908583c 2888 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2889 motor[TIRE_BL].pwm = 80;
yabahiro 44:c208a908583c 2890 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2891 mtc=true;
yabahiro 44:c208a908583c 2892 break;
yabahiro 44:c208a908583c 2893 case 255:
yabahiro 44:c208a908583c 2894 motor[TIRE_FR].pwm = fast;
yabahiro 44:c208a908583c 2895 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2896 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2897 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2898 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2899 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2900 motor[TIRE_BL].pwm = fast;
yabahiro 44:c208a908583c 2901 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2902 mtc=true;
yabahiro 44:c208a908583c 2903 break;
yabahiro 44:c208a908583c 2904 case 253:
yabahiro 44:c208a908583c 2905 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2906 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2907 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2908 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2909 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2910 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2911 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2912 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2913 mtc=true;
yabahiro 44:c208a908583c 2914 break;
yabahiro 44:c208a908583c 2915 case 254:
yabahiro 44:c208a908583c 2916 motor[TIRE_FR].pwm = normal;
yabahiro 44:c208a908583c 2917 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2918 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2919 motor[TIRE_FL].dir = FREE;
yabahiro 44:c208a908583c 2920 motor[TIRE_BR].pwm = 0;
yabahiro 44:c208a908583c 2921 motor[TIRE_BR].dir = FREE;
yabahiro 44:c208a908583c 2922 motor[TIRE_BL].pwm = normal;
yabahiro 44:c208a908583c 2923 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2924 mtc=true;
yabahiro 44:c208a908583c 2925 break;
yabahiro 44:c208a908583c 2926 case 1:
yabahiro 44:c208a908583c 2927 motor[TIRE_FR].pwm = slow;
yabahiro 44:c208a908583c 2928 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2929 motor[TIRE_FL].pwm = fast;
yabahiro 44:c208a908583c 2930 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2931 motor[TIRE_BR].pwm = fast;
yabahiro 44:c208a908583c 2932 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2933 motor[TIRE_BL].pwm = slow;
yabahiro 44:c208a908583c 2934 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 2935 mtc=true;
yabahiro 44:c208a908583c 2936 break;
yabahiro 44:c208a908583c 2937 case 3:
yabahiro 44:c208a908583c 2938 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2939 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2940 motor[TIRE_FL].pwm = slow;
yabahiro 44:c208a908583c 2941 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2942 motor[TIRE_BR].pwm = slow;
yabahiro 44:c208a908583c 2943 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2944 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2945 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2946 mtc=true;
yabahiro 44:c208a908583c 2947 break;
yabahiro 44:c208a908583c 2948 case 2:
yabahiro 44:c208a908583c 2949 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2950 motor[TIRE_FR].dir = FREE;
yabahiro 44:c208a908583c 2951 motor[TIRE_FL].pwm = normal;
yabahiro 44:c208a908583c 2952 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2953 motor[TIRE_BR].pwm = normal;
yabahiro 44:c208a908583c 2954 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 2955 motor[TIRE_BL].pwm = 0;
yabahiro 44:c208a908583c 2956 motor[TIRE_BL].dir = FREE;
yabahiro 44:c208a908583c 2957 mtc=true;
yabahiro 44:c208a908583c 2958 break;
yabahiro 44:c208a908583c 2959 }
yabahiro 44:c208a908583c 2960 if(g[1]!=98&&mtc==true) {
yabahiro 44:c208a908583c 2961 switch(g[0]) {
yabahiro 44:c208a908583c 2962 case 0:
yabahiro 44:c208a908583c 2963 mtc=false;
yabahiro 44:c208a908583c 2964 break;
yabahiro 44:c208a908583c 2965 case 255:
yabahiro 44:c208a908583c 2966 motor[TIRE_FL].pwm += 5;
yabahiro 44:c208a908583c 2967 mtc=false;
yabahiro 44:c208a908583c 2968 break;
yabahiro 44:c208a908583c 2969 case 253:
yabahiro 44:c208a908583c 2970 motor[TIRE_FL].pwm += 10;
yabahiro 44:c208a908583c 2971 mtc=false;
yabahiro 44:c208a908583c 2972 break;
yabahiro 44:c208a908583c 2973 case 254:
yabahiro 44:c208a908583c 2974 motor[TIRE_FL].pwm += 20;
yabahiro 44:c208a908583c 2975 motor[TIRE_FR].pwm = 0;
yabahiro 44:c208a908583c 2976 mtc=false;
yabahiro 44:c208a908583c 2977 break;
yabahiro 44:c208a908583c 2978 case 1:
yabahiro 44:c208a908583c 2979 motor[TIRE_FR].pwm += 5;
yabahiro 44:c208a908583c 2980 mtc=false;
yabahiro 44:c208a908583c 2981 break;
yabahiro 44:c208a908583c 2982 case 3:
yabahiro 44:c208a908583c 2983 motor[TIRE_FR].pwm += 10;
yabahiro 44:c208a908583c 2984 mtc=false;
yabahiro 44:c208a908583c 2985 break;
yabahiro 44:c208a908583c 2986 case 2:
yabahiro 44:c208a908583c 2987 motor[TIRE_FR].pwm += 20;
yabahiro 44:c208a908583c 2988 motor[TIRE_FL].pwm = 0;
yabahiro 44:c208a908583c 2989 mtc=false;
yabahiro 44:c208a908583c 2990 break;
yabahiro 44:c208a908583c 2991 }
yabahiro 44:c208a908583c 2992 }
yabahiro 44:c208a908583c 2993 } else if(mode==100) {
yabahiro 44:c208a908583c 2994 motor[TIRE_FR].pwm = 20;
yabahiro 44:c208a908583c 2995 motor[TIRE_FR].dir = FOR;
yabahiro 44:c208a908583c 2996 motor[TIRE_FL].pwm = 20;
yabahiro 44:c208a908583c 2997 motor[TIRE_FL].dir = BACK;
yabahiro 44:c208a908583c 2998 motor[TIRE_BR].pwm = 23;
yabahiro 44:c208a908583c 2999 motor[TIRE_BR].dir = FOR;
yabahiro 44:c208a908583c 3000 motor[TIRE_BL].pwm = 20;
yabahiro 44:c208a908583c 3001 motor[TIRE_BL].dir = BACK;
yabahiro 44:c208a908583c 3002 } else {
yabahiro 44:c208a908583c 3003 }
kishibekairohan 13:b6e02d6261d7 3004 }
kishibekairohan 13:b6e02d6261d7 3005 #endif
kishibekairohan 13:b6e02d6261d7 3006
kishibekairohan 13:b6e02d6261d7 3007 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 3008 static void Process7()
kishibekairohan 13:b6e02d6261d7 3009 {
yabahiro 21:1f1e9c585da8 3010
kishibekairohan 12:c09b3e08a316 3011 }
kishibekairohan 12:c09b3e08a316 3012 #endif
kishibekairohan 12:c09b3e08a316 3013
yabahiro 21:1f1e9c585da8 3014 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 3015 static void Process8()
kishibekairohan 12:c09b3e08a316 3016 {
yabahiro 21:1f1e9c585da8 3017
kishibekairohan 12:c09b3e08a316 3018 }
kishibekairohan 12:c09b3e08a316 3019 #endif
kishibekairohan 12:c09b3e08a316 3020
kishibekairohan 13:b6e02d6261d7 3021 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 3022 static void Process9()
kishibekairohan 12:c09b3e08a316 3023 {
yabahiro 21:1f1e9c585da8 3024
t_yamamoto 0:669ef71cba68 3025 }
t_yamamoto 0:669ef71cba68 3026 #endif
t_yamamoto 0:669ef71cba68 3027 #endif
t_yamamoto 0:669ef71cba68 3028 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 3029
t_yamamoto 0:669ef71cba68 3030 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 3031 {
t_yamamoto 0:669ef71cba68 3032
yabahiro 21:1f1e9c585da8 3033 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 3034 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 3035 #endif
t_yamamoto 0:669ef71cba68 3036
yabahiro 21:1f1e9c585da8 3037 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 3038 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 21:1f1e9c585da8 3039 motor[i].dir = FREE;
yabahiro 21:1f1e9c585da8 3040 motor[i].pwm = 0;
yabahiro 21:1f1e9c585da8 3041 }
yabahiro 21:1f1e9c585da8 3042 #endif
t_yamamoto 0:669ef71cba68 3043 }
t_yamamoto 0:669ef71cba68 3044
yabahiro 21:1f1e9c585da8 3045 /*
yabahiro 21:1f1e9c585da8 3046 void BuzzerTimer_func()
yabahiro 21:1f1e9c585da8 3047 {
kishibekairohan 16:3f2c2d89372b 3048 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 3049 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 3050 }
yabahiro 21:1f1e9c585da8 3051 */
yabahiro 21:1f1e9c585da8 3052 void TapeLedEms_func()
yabahiro 21:1f1e9c585da8 3053 {
kishibekairohan 16:3f2c2d89372b 3054 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 3055 }
kishibekairohan 16:3f2c2d89372b 3056
kishibekairohan 16:3f2c2d89372b 3057 #pragma region USER-DEFINED-FUNCTIONS
kishibekairohan 16:3f2c2d89372b 3058
kishibekairohan 16:3f2c2d89372b 3059
t_yamamoto 0:669ef71cba68 3060 #pragma endregion