aa

Dependencies:   mbed TrapezoidControl QEI

Committer:
yabahiro
Date:
Thu Oct 03 11:09:31 2019 +0000
Revision:
45:878f8f385635
Parent:
44:c208a908583c
Child:
46:4a8bca4cc1fd
a

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