aa

Dependencies:   mbed TrapezoidControl QEI

Committer:
kishibekairohan
Date:
Sat Sep 14 00:10:57 2019 +0000
Revision:
22:c47f29caded6
Parent:
21:1f1e9c585da8
Child:
23:694ecfa97839
aaaaa

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
t_yamamoto 0:669ef71cba68 107 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 108
t_yamamoto 0:669ef71cba68 109 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 110 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 111 static void Process0(void);
t_yamamoto 0:669ef71cba68 112 #endif
t_yamamoto 0:669ef71cba68 113 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 114 static void Process1(void);
t_yamamoto 0:669ef71cba68 115 #endif
t_yamamoto 0:669ef71cba68 116 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 117 static void Process2(void);
t_yamamoto 0:669ef71cba68 118 #endif
t_yamamoto 0:669ef71cba68 119 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 120 static void Process3(void);
t_yamamoto 0:669ef71cba68 121 #endif
t_yamamoto 0:669ef71cba68 122 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 123 static void Process4(void);
t_yamamoto 0:669ef71cba68 124 #endif
t_yamamoto 0:669ef71cba68 125 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 126 static void Process5(void);
t_yamamoto 0:669ef71cba68 127 #endif
t_yamamoto 0:669ef71cba68 128 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 129 static void Process6(void);
t_yamamoto 0:669ef71cba68 130 #endif
t_yamamoto 0:669ef71cba68 131 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 132 static void Process7(void);
t_yamamoto 0:669ef71cba68 133 #endif
t_yamamoto 0:669ef71cba68 134 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 135 static void Process8(void);
t_yamamoto 0:669ef71cba68 136 #endif
t_yamamoto 0:669ef71cba68 137 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 138 static void Process9(void);
t_yamamoto 0:669ef71cba68 139 #endif
t_yamamoto 0:669ef71cba68 140 #endif
t_yamamoto 0:669ef71cba68 141
t_yamamoto 0:669ef71cba68 142 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 143 {
yabahiro 21:1f1e9c585da8 144 #pragma region USER-DEFINED_VARIABLE_INIT
yabahiro 21:1f1e9c585da8 145 /*Replace here with the initialization code of your variables.*/
yabahiro 21:1f1e9c585da8 146 #pragma endregion USER-DEFINED_VARIABLE_INIT
t_yamamoto 0:669ef71cba68 147
yabahiro 21:1f1e9c585da8 148 lock = true;
yabahiro 21:1f1e9c585da8 149 processChangeComp = true;
yabahiro 21:1f1e9c585da8 150 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 151
yabahiro 21:1f1e9c585da8 152 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 153 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 154 Process[0] = Process0;
yabahiro 21:1f1e9c585da8 155 #endif
yabahiro 21:1f1e9c585da8 156 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 157 Process[1] = Process1;
yabahiro 21:1f1e9c585da8 158 #endif
yabahiro 21:1f1e9c585da8 159 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 160 Process[2] = Process2;
yabahiro 21:1f1e9c585da8 161 #endif
yabahiro 21:1f1e9c585da8 162 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 163 Process[3] = Process3;
yabahiro 21:1f1e9c585da8 164 #endif
yabahiro 21:1f1e9c585da8 165 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 166 Process[4] = Process4;
yabahiro 21:1f1e9c585da8 167 #endif
yabahiro 21:1f1e9c585da8 168 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 169 Process[5] = Process5;
yabahiro 21:1f1e9c585da8 170 #endif
yabahiro 21:1f1e9c585da8 171 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 172 Process[6] = Process6;
yabahiro 21:1f1e9c585da8 173 #endif
yabahiro 21:1f1e9c585da8 174 #if USE_PROCESS_NUM>7
yabahiro 21:1f1e9c585da8 175 Process[7] = Process7;
yabahiro 21:1f1e9c585da8 176 #endif
yabahiro 21:1f1e9c585da8 177 #if USE_PROCESS_NUM>8
yabahiro 21:1f1e9c585da8 178 Process[8] = Process8;
yabahiro 21:1f1e9c585da8 179 #endif
yabahiro 21:1f1e9c585da8 180 #if USE_PROCESS_NUM>9
yabahiro 21:1f1e9c585da8 181 Process[9] = Process9;
yabahiro 21:1f1e9c585da8 182 #endif
yabahiro 21:1f1e9c585da8 183 #endif
t_yamamoto 0:669ef71cba68 184 }
t_yamamoto 0:669ef71cba68 185
t_yamamoto 0:669ef71cba68 186 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 187 {
yabahiro 21:1f1e9c585da8 188 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 189 if(controller->Button.HOME) lock = false;
yabahiro 21:1f1e9c585da8 190
yabahiro 21:1f1e9c585da8 191 if(controller->Button.START && processChangeComp) {
yabahiro 21:1f1e9c585da8 192 current++;
yabahiro 21:1f1e9c585da8 193 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
yabahiro 21:1f1e9c585da8 194 processChangeComp = false;
yabahiro 21:1f1e9c585da8 195 } else if(controller->Button.SELECT && processChangeComp) {
yabahiro 21:1f1e9c585da8 196 current--;
yabahiro 21:1f1e9c585da8 197 if (current < 0) current = 0;
yabahiro 21:1f1e9c585da8 198 processChangeComp = false;
yabahiro 21:1f1e9c585da8 199 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
yabahiro 21:1f1e9c585da8 200 #endif
yabahiro 21:1f1e9c585da8 201
yabahiro 21:1f1e9c585da8 202 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 203 ACTUATORHUB::MOTOR::Motor::Update(motor);
yabahiro 21:1f1e9c585da8 204 #endif
yabahiro 21:1f1e9c585da8 205
yabahiro 21:1f1e9c585da8 206 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 207 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
yabahiro 21:1f1e9c585da8 208 #endif
yabahiro 21:1f1e9c585da8 209
yabahiro 21:1f1e9c585da8 210 #ifdef USE_RS485
yabahiro 21:1f1e9c585da8 211 ACTUATORHUB::ActuatorHub::Update();
yabahiro 21:1f1e9c585da8 212 #endif
yabahiro 21:1f1e9c585da8 213
yabahiro 21:1f1e9c585da8 214 }
yabahiro 21:1f1e9c585da8 215
yabahiro 21:1f1e9c585da8 216 int g[8];
yabahiro 21:1f1e9c585da8 217
yabahiro 21:1f1e9c585da8 218 void SystemProcess()
yabahiro 21:1f1e9c585da8 219 {
yabahiro 21:1f1e9c585da8 220 SystemProcessInitialize();
yabahiro 21:1f1e9c585da8 221
yabahiro 21:1f1e9c585da8 222 while(1) {
yabahiro 21:1f1e9c585da8 223 for(int i = 0; i < 8; i++) {
yabahiro 21:1f1e9c585da8 224 g[i] = LineHub::GetPara(i);
yabahiro 21:1f1e9c585da8 225 }
t_yamamoto 0:669ef71cba68 226
yabahiro 21:1f1e9c585da8 227 #ifdef USE_MU
yabahiro 21:1f1e9c585da8 228 controller = CONTROLLER::Controller::GetData();
yabahiro 21:1f1e9c585da8 229 #endif
yabahiro 21:1f1e9c585da8 230
yabahiro 21:1f1e9c585da8 231 #ifdef USE_ERRORCHECK
yabahiro 21:1f1e9c585da8 232 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost) {
yabahiro 21:1f1e9c585da8 233 CONTROLLER::Controller::DataReset();
yabahiro 21:1f1e9c585da8 234 AllActuatorReset();
yabahiro 21:1f1e9c585da8 235 lock = true;
yabahiro 21:1f1e9c585da8 236 } else
yabahiro 21:1f1e9c585da8 237 #endif
yabahiro 21:1f1e9c585da8 238 {
yabahiro 21:1f1e9c585da8 239
yabahiro 21:1f1e9c585da8 240 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 241 if(!lock) {
yabahiro 21:1f1e9c585da8 242 Process[current]();
yabahiro 21:1f1e9c585da8 243 } else
yabahiro 21:1f1e9c585da8 244 #endif
yabahiro 21:1f1e9c585da8 245 {
yabahiro 21:1f1e9c585da8 246 //ロック時の処理
yabahiro 21:1f1e9c585da8 247 }
yabahiro 21:1f1e9c585da8 248 }
yabahiro 21:1f1e9c585da8 249 /*
yabahiro 21:1f1e9c585da8 250 //Emergency!
yabahiro 21:1f1e9c585da8 251 if(!EMG_0 && !EMG_1 && !EMGflag) {
yabahiro 21:1f1e9c585da8 252 buzzer = 0;
yabahiro 21:1f1e9c585da8 253 BuzzerTimer.attach(BuzzerTimer_func, 1);
yabahiro 21:1f1e9c585da8 254 EMGflag = true;
yabahiro 21:1f1e9c585da8 255 LED_DEBUG0 = 1;
yabahiro 21:1f1e9c585da8 256 }
yabahiro 21:1f1e9c585da8 257 if(EMG_0 && EMG_1 && EMGflag) {
yabahiro 21:1f1e9c585da8 258 buzzer = 1;
yabahiro 21:1f1e9c585da8 259 BuzzerTimer.detach();
yabahiro 21:1f1e9c585da8 260 EMGflag = false;
yabahiro 21:1f1e9c585da8 261 }
yabahiro 21:1f1e9c585da8 262 */
yabahiro 21:1f1e9c585da8 263 SystemProcessUpdate();
yabahiro 21:1f1e9c585da8 264 }
t_yamamoto 0:669ef71cba68 265 }
t_yamamoto 0:669ef71cba68 266
kishibekairohan 2:c015739085d3 267
kishibekairohan 2:c015739085d3 268
kishibekairohan 2:c015739085d3 269
t_yamamoto 0:669ef71cba68 270 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 271 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 272 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 273 static void Process0()
yabahiro 21:1f1e9c585da8 274 {
yabahiro 21:1f1e9c585da8 275
t_yamamoto 0:669ef71cba68 276 }
t_yamamoto 0:669ef71cba68 277 #endif
t_yamamoto 0:669ef71cba68 278
t_yamamoto 0:669ef71cba68 279 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 280
yabahiro 21:1f1e9c585da8 281
yabahiro 21:1f1e9c585da8 282 bool dz1=true;
yabahiro 21:1f1e9c585da8 283 bool dz1i=false;
yabahiro 21:1f1e9c585da8 284 bool dz2=true;
yabahiro 21:1f1e9c585da8 285 bool dz2i=false;
yabahiro 21:1f1e9c585da8 286 bool dz3=true;
yabahiro 21:1f1e9c585da8 287 bool dz3i=false;
yabahiro 21:1f1e9c585da8 288 bool dz4=true;
yabahiro 21:1f1e9c585da8 289 bool dz4i=false;
yabahiro 21:1f1e9c585da8 290
yabahiro 21:1f1e9c585da8 291 int mode=0;
yabahiro 21:1f1e9c585da8 292 int mode1=0;
yabahiro 21:1f1e9c585da8 293 int mode1g0=100000;
yabahiro 21:1f1e9c585da8 294
kishibekairohan 22:c47f29caded6 295
kishibekairohan 16:3f2c2d89372b 296 static void Process1()
t_yamamoto 0:669ef71cba68 297 {
yabahiro 21:1f1e9c585da8 298 mode1g0=100000;
yabahiro 21:1f1e9c585da8 299 mode=0;
yabahiro 21:1f1e9c585da8 300 mode1=0;
yabahiro 21:1f1e9c585da8 301 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 302 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 303 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 304 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 305
yabahiro 21:1f1e9c585da8 306 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 307 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 308 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 309 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 310
yabahiro 21:1f1e9c585da8 311 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 312
yabahiro 21:1f1e9c585da8 313 if(controller->Button.UP) {
yabahiro 21:1f1e9c585da8 314 motor[MOTOR_0].pwm = 110;
yabahiro 21:1f1e9c585da8 315 motor[MOTOR_0].dir = FOR;
yabahiro 21:1f1e9c585da8 316 }
yabahiro 21:1f1e9c585da8 317 if(controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 318 motor[MOTOR_0].pwm = 50;
yabahiro 21:1f1e9c585da8 319 motor[MOTOR_0].dir = BACK;
yabahiro 21:1f1e9c585da8 320 }
yabahiro 21:1f1e9c585da8 321 } else {
yabahiro 21:1f1e9c585da8 322 motor[MOTOR_0].pwm = 0;
yabahiro 21:1f1e9c585da8 323 motor[MOTOR_0].dir = BRAKE;
yabahiro 21:1f1e9c585da8 324 }
yabahiro 21:1f1e9c585da8 325 if(controller->Button.X) {
yabahiro 21:1f1e9c585da8 326 if(dz1==true) {
yabahiro 21:1f1e9c585da8 327 if(dz1i==false) {
yabahiro 21:1f1e9c585da8 328 solenoid.solenoid1 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 329 dz1i=true;
yabahiro 21:1f1e9c585da8 330 } else {
yabahiro 21:1f1e9c585da8 331 solenoid.solenoid1 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 332 dz1i=false;
yabahiro 21:1f1e9c585da8 333 }
yabahiro 21:1f1e9c585da8 334 dz1=false;
yabahiro 21:1f1e9c585da8 335 }
yabahiro 21:1f1e9c585da8 336 } else {
yabahiro 21:1f1e9c585da8 337 dz1=true;
yabahiro 21:1f1e9c585da8 338 }
yabahiro 21:1f1e9c585da8 339
yabahiro 21:1f1e9c585da8 340 if(controller->Button.Y) {
yabahiro 21:1f1e9c585da8 341 if(dz2==true) {
yabahiro 21:1f1e9c585da8 342 if(dz2i==false) {
yabahiro 21:1f1e9c585da8 343 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 344 dz2i=true;
yabahiro 21:1f1e9c585da8 345 } else {
yabahiro 21:1f1e9c585da8 346 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 347 dz2i=false;
yabahiro 21:1f1e9c585da8 348 }
yabahiro 21:1f1e9c585da8 349 dz2=false;
yabahiro 21:1f1e9c585da8 350 }
yabahiro 21:1f1e9c585da8 351 } else {
yabahiro 21:1f1e9c585da8 352 dz2=true;
yabahiro 21:1f1e9c585da8 353 }
yabahiro 21:1f1e9c585da8 354
yabahiro 21:1f1e9c585da8 355 if(controller->Button.A) {
yabahiro 21:1f1e9c585da8 356 if(dz3==true) {
yabahiro 21:1f1e9c585da8 357 if(dz3i==false) {
yabahiro 21:1f1e9c585da8 358 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 359 dz3i=true;
yabahiro 21:1f1e9c585da8 360 } else {
yabahiro 21:1f1e9c585da8 361 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 362 dz3i=false;
yabahiro 21:1f1e9c585da8 363 }
yabahiro 21:1f1e9c585da8 364 dz3=false;
yabahiro 21:1f1e9c585da8 365 }
yabahiro 21:1f1e9c585da8 366 } else {
yabahiro 21:1f1e9c585da8 367 dz3=true;
yabahiro 21:1f1e9c585da8 368 }
yabahiro 21:1f1e9c585da8 369
yabahiro 21:1f1e9c585da8 370 if(controller->Button.B) {
yabahiro 21:1f1e9c585da8 371 if(dz4==true) {
yabahiro 21:1f1e9c585da8 372 if(dz4i==false) {
yabahiro 21:1f1e9c585da8 373 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 374 dz4i=true;
yabahiro 21:1f1e9c585da8 375 } else {
yabahiro 21:1f1e9c585da8 376 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 377 dz4i=false;
yabahiro 21:1f1e9c585da8 378 }
yabahiro 21:1f1e9c585da8 379 dz4=false;
yabahiro 21:1f1e9c585da8 380 }
yabahiro 21:1f1e9c585da8 381 } else {
yabahiro 21:1f1e9c585da8 382 dz4=true;
yabahiro 21:1f1e9c585da8 383 }
yabahiro 21:1f1e9c585da8 384 /*
yabahiro 21:1f1e9c585da8 385 if(controller->Button.RIGHT){
yabahiro 21:1f1e9c585da8 386 motor[MOTOR_1].dir = FOR;
yabahiro 21:1f1e9c585da8 387 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 388 if (ARM_1){
yabahiro 21:1f1e9c585da8 389 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 390 }
yabahiro 21:1f1e9c585da8 391 }
yabahiro 21:1f1e9c585da8 392 else if(controller->Button.LEFT){
yabahiro 21:1f1e9c585da8 393 motor[MOTOR_1].dir = BACK;
yabahiro 21:1f1e9c585da8 394 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 395 if (ARM_0){
yabahiro 21:1f1e9c585da8 396 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 397 }
yabahiro 21:1f1e9c585da8 398 }
yabahiro 21:1f1e9c585da8 399 */
t_yamamoto 0:669ef71cba68 400 }
t_yamamoto 0:669ef71cba68 401 #endif
t_yamamoto 0:669ef71cba68 402
t_yamamoto 0:669ef71cba68 403 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 404 bool mtc=false;
kishibekairohan 22:c47f29caded6 405 //追加
kishibekairohan 22:c47f29caded6 406 bool mtc2 = false;
yabahiro 21:1f1e9c585da8 407
kishibekairohan 16:3f2c2d89372b 408 static void Process2()
yabahiro 21:1f1e9c585da8 409 {
yabahiro 21:1f1e9c585da8 410 // 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 21:1f1e9c585da8 411 mode1g0++;
yabahiro 21:1f1e9c585da8 412 if(g[0]!=99&&mode==0) {
yabahiro 21:1f1e9c585da8 413 switch(g[0]) {
yabahiro 21:1f1e9c585da8 414 case 98:
yabahiro 21:1f1e9c585da8 415 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 416 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 417 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 418 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 419 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 420 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 421 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 422 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 423 if(mode1g0>100000) {
yabahiro 21:1f1e9c585da8 424 mode1++;
yabahiro 21:1f1e9c585da8 425 mode1g0=0;
yabahiro 21:1f1e9c585da8 426 }
yabahiro 21:1f1e9c585da8 427 mtc=true;
yabahiro 21:1f1e9c585da8 428 if(mode1==2) {
yabahiro 21:1f1e9c585da8 429 mode=1;
yabahiro 21:1f1e9c585da8 430 }
yabahiro 21:1f1e9c585da8 431 break;
yabahiro 21:1f1e9c585da8 432 case 0:
yabahiro 21:1f1e9c585da8 433 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 434 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 435 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 436 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 437 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 438 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 439 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 440 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 441 mtc=true;
yabahiro 21:1f1e9c585da8 442 break;
yabahiro 21:1f1e9c585da8 443 case 255:
yabahiro 21:1f1e9c585da8 444 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 445 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 446 motor[TIRE_FL].pwm = 40;
yabahiro 21:1f1e9c585da8 447 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 448 motor[TIRE_BR].pwm = 40;
yabahiro 21:1f1e9c585da8 449 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 450 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 451 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 452 mtc=true;
yabahiro 21:1f1e9c585da8 453 break;
yabahiro 21:1f1e9c585da8 454 case 253:
yabahiro 21:1f1e9c585da8 455 motor[TIRE_FR].pwm = 20;
yabahiro 21:1f1e9c585da8 456 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 457 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 458 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 459 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 460 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 461 motor[TIRE_BL].pwm = 20;
yabahiro 21:1f1e9c585da8 462 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 463 mtc=true;
yabahiro 21:1f1e9c585da8 464 break;
yabahiro 21:1f1e9c585da8 465 case 254:
yabahiro 21:1f1e9c585da8 466 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 467 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 468 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 469 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 470 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 471 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 472 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 473 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 474 mtc=true;
yabahiro 21:1f1e9c585da8 475 break;
yabahiro 21:1f1e9c585da8 476 case 1:
yabahiro 21:1f1e9c585da8 477 motor[TIRE_FR].pwm = 40;
yabahiro 21:1f1e9c585da8 478 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 479 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 480 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 481 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 482 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 483 motor[TIRE_BL].pwm = 40;
yabahiro 21:1f1e9c585da8 484 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 485 mtc=true;
yabahiro 21:1f1e9c585da8 486 break;
yabahiro 21:1f1e9c585da8 487 case 3:
yabahiro 21:1f1e9c585da8 488 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 489 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 490 motor[TIRE_FL].pwm = 20;
yabahiro 21:1f1e9c585da8 491 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 492 motor[TIRE_BR].pwm = 20;
yabahiro 21:1f1e9c585da8 493 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 494 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 495 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 496 mtc=true;
yabahiro 21:1f1e9c585da8 497 break;
yabahiro 21:1f1e9c585da8 498 case 2:
yabahiro 21:1f1e9c585da8 499 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 500 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 501 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 502 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 503 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 504 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 505 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 506 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 507 mtc=true;
yabahiro 21:1f1e9c585da8 508 break;
yabahiro 21:1f1e9c585da8 509 }
yabahiro 21:1f1e9c585da8 510 if(g[0]!=98&&mtc==true) {
yabahiro 21:1f1e9c585da8 511 switch(g[1]) {
yabahiro 21:1f1e9c585da8 512 case 0:
yabahiro 21:1f1e9c585da8 513 mtc=false;
yabahiro 21:1f1e9c585da8 514 break;
yabahiro 21:1f1e9c585da8 515 case 255:
yabahiro 21:1f1e9c585da8 516 motor[TIRE_BR].pwm += 5;
yabahiro 21:1f1e9c585da8 517 mtc=false;
yabahiro 21:1f1e9c585da8 518 break;
yabahiro 21:1f1e9c585da8 519 case 253:
yabahiro 21:1f1e9c585da8 520 motor[TIRE_BR].pwm += 10;
yabahiro 21:1f1e9c585da8 521 mtc=false;
yabahiro 21:1f1e9c585da8 522 break;
yabahiro 21:1f1e9c585da8 523 case 254:
yabahiro 21:1f1e9c585da8 524 motor[TIRE_BR].pwm += 20;
yabahiro 21:1f1e9c585da8 525 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 526 mtc=false;
yabahiro 21:1f1e9c585da8 527 break;
yabahiro 21:1f1e9c585da8 528 case 1:
yabahiro 21:1f1e9c585da8 529 motor[TIRE_BL].pwm += 5;
yabahiro 21:1f1e9c585da8 530 mtc=false;
yabahiro 21:1f1e9c585da8 531 break;
yabahiro 21:1f1e9c585da8 532 case 3:
yabahiro 21:1f1e9c585da8 533 motor[TIRE_BL].pwm += 10;
yabahiro 21:1f1e9c585da8 534 mtc=false;
yabahiro 21:1f1e9c585da8 535 break;
yabahiro 21:1f1e9c585da8 536 case 2:
yabahiro 21:1f1e9c585da8 537 motor[TIRE_BL].pwm += 20;
yabahiro 21:1f1e9c585da8 538 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 539 mtc=false;
yabahiro 21:1f1e9c585da8 540 break;
yabahiro 21:1f1e9c585da8 541 }
yabahiro 21:1f1e9c585da8 542 }
yabahiro 21:1f1e9c585da8 543 } else if(mode==1) {
yabahiro 21:1f1e9c585da8 544 motor[TIRE_FR].pwm = 5;
yabahiro 21:1f1e9c585da8 545 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 546 motor[TIRE_FL].pwm = 5;
yabahiro 21:1f1e9c585da8 547 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 548 motor[TIRE_BR].pwm = 5;
yabahiro 21:1f1e9c585da8 549 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 550 motor[TIRE_BL].pwm = 5;
yabahiro 21:1f1e9c585da8 551 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 552 if(g[2]==0) {
yabahiro 21:1f1e9c585da8 553 mode=2;
yabahiro 21:1f1e9c585da8 554 }
yabahiro 21:1f1e9c585da8 555 } else if(mode==2) {
yabahiro 21:1f1e9c585da8 556 motor[TIRE_FR].pwm = 15;
yabahiro 21:1f1e9c585da8 557 motor[TIRE_FR].dir = FOR;
yabahiro 21:1f1e9c585da8 558 motor[TIRE_FL].pwm = 15;
yabahiro 21:1f1e9c585da8 559 motor[TIRE_FL].dir = BACK;
yabahiro 21:1f1e9c585da8 560 motor[TIRE_BR].pwm = 15;
yabahiro 21:1f1e9c585da8 561 motor[TIRE_BR].dir = FOR;
yabahiro 21:1f1e9c585da8 562 motor[TIRE_BL].pwm = 15;
yabahiro 21:1f1e9c585da8 563 motor[TIRE_BL].dir = BACK;
yabahiro 21:1f1e9c585da8 564 mode1g0++;
yabahiro 21:1f1e9c585da8 565 if(mode1g0>10000&&g[2]==0) {
yabahiro 21:1f1e9c585da8 566 mode=3;
yabahiro 21:1f1e9c585da8 567 }
yabahiro 21:1f1e9c585da8 568 } else if(mode==3) {
kishibekairohan 22:c47f29caded6 569 switch(g[2]) {
kishibekairohan 22:c47f29caded6 570 case 98:
kishibekairohan 22:c47f29caded6 571 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 572 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 573 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 574 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 575 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 576 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 577 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 578 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 579
kishibekairohan 22:c47f29caded6 580 mtc2=true;
kishibekairohan 22:c47f29caded6 581
kishibekairohan 22:c47f29caded6 582 if(mode1g0>100000) {
kishibekairohan 22:c47f29caded6 583 mode1++;
kishibekairohan 22:c47f29caded6 584 mode1g0=0;
kishibekairohan 22:c47f29caded6 585 }
kishibekairohan 22:c47f29caded6 586
kishibekairohan 22:c47f29caded6 587 mtc2=true;
kishibekairohan 22:c47f29caded6 588
kishibekairohan 22:c47f29caded6 589 if(mode1==2) {
kishibekairohan 22:c47f29caded6 590 mode=3;
kishibekairohan 22:c47f29caded6 591 }
kishibekairohan 22:c47f29caded6 592 break;
kishibekairohan 22:c47f29caded6 593 case 0:
kishibekairohan 22:c47f29caded6 594 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 595 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 596 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 597 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 598 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 599 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 600 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 601 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 602 mtc2=true;
kishibekairohan 22:c47f29caded6 603 break;
kishibekairohan 22:c47f29caded6 604 case 255:
kishibekairohan 22:c47f29caded6 605 motor[TIRE_FR].pwm = 40;
kishibekairohan 22:c47f29caded6 606 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 607 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 608 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 609 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 610 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 611 motor[TIRE_BL].pwm = 40;
kishibekairohan 22:c47f29caded6 612 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 613 mtc2=true;
kishibekairohan 22:c47f29caded6 614 break;
kishibekairohan 22:c47f29caded6 615 case 253:
kishibekairohan 22:c47f29caded6 616 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 617 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 618 motor[TIRE_FL].pwm = 20;
kishibekairohan 22:c47f29caded6 619 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 620 motor[TIRE_BR].pwm = 20;
kishibekairohan 22:c47f29caded6 621 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 622 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 623 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 624 mtc2=true;
kishibekairohan 22:c47f29caded6 625 break;
kishibekairohan 22:c47f29caded6 626 case 254:
kishibekairohan 22:c47f29caded6 627 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 628 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 629 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 630 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 631 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 632 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 633 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 634 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 635 mtc2=true;
kishibekairohan 22:c47f29caded6 636 break;
kishibekairohan 22:c47f29caded6 637 case 1:
kishibekairohan 22:c47f29caded6 638 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 639 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 640 motor[TIRE_FL].pwm = 40;
kishibekairohan 22:c47f29caded6 641 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 642 motor[TIRE_BR].pwm = 40;
kishibekairohan 22:c47f29caded6 643 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 644 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 645 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 646 mtc2=true;
kishibekairohan 22:c47f29caded6 647 break;
kishibekairohan 22:c47f29caded6 648 case 3:
kishibekairohan 22:c47f29caded6 649 motor[TIRE_FR].pwm = 20;
kishibekairohan 22:c47f29caded6 650 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 651 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 652 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 653 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 654 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 655 motor[TIRE_BL].pwm = 20;
kishibekairohan 22:c47f29caded6 656 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 657 mtc2=true;
kishibekairohan 22:c47f29caded6 658 break;
kishibekairohan 22:c47f29caded6 659 case 2:
kishibekairohan 22:c47f29caded6 660 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 661 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 662 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 663 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 664 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 665 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 666 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 667 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 668 mtc2=true;
kishibekairohan 22:c47f29caded6 669 break;
kishibekairohan 22:c47f29caded6 670 }
kishibekairohan 22:c47f29caded6 671 if(g[2]!=98&&mtc2==true) {
kishibekairohan 22:c47f29caded6 672 switch(g[3]) {
kishibekairohan 22:c47f29caded6 673 case 0:
kishibekairohan 22:c47f29caded6 674 mtc2=false;
kishibekairohan 22:c47f29caded6 675 break;
kishibekairohan 22:c47f29caded6 676 case 255:
kishibekairohan 22:c47f29caded6 677 motor[TIRE_BL].pwm += 5;
kishibekairohan 22:c47f29caded6 678 mtc2=false;
kishibekairohan 22:c47f29caded6 679 break;
kishibekairohan 22:c47f29caded6 680 case 253:
kishibekairohan 22:c47f29caded6 681 motor[TIRE_BL].pwm += 10;
kishibekairohan 22:c47f29caded6 682 mtc2=false;
kishibekairohan 22:c47f29caded6 683 break;
kishibekairohan 22:c47f29caded6 684 case 254:
kishibekairohan 22:c47f29caded6 685 motor[TIRE_BL].pwm += 20;
kishibekairohan 22:c47f29caded6 686 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 687 mtc2=false;
kishibekairohan 22:c47f29caded6 688 break;
kishibekairohan 22:c47f29caded6 689 case 1:
kishibekairohan 22:c47f29caded6 690 motor[TIRE_FL].pwm += 5;
kishibekairohan 22:c47f29caded6 691 mtc2=false;
kishibekairohan 22:c47f29caded6 692 break;
kishibekairohan 22:c47f29caded6 693 case 3:
kishibekairohan 22:c47f29caded6 694 motor[TIRE_FL].pwm += 10;
kishibekairohan 22:c47f29caded6 695 mtc2=false;
kishibekairohan 22:c47f29caded6 696 break;
kishibekairohan 22:c47f29caded6 697 case 2:
kishibekairohan 22:c47f29caded6 698 motor[TIRE_FL].pwm += 20;
kishibekairohan 22:c47f29caded6 699 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 700 mtc2=false;
kishibekairohan 22:c47f29caded6 701 break;
kishibekairohan 22:c47f29caded6 702 }
kishibekairohan 22:c47f29caded6 703 }
kishibekairohan 22:c47f29caded6 704 }
kishibekairohan 22:c47f29caded6 705
kishibekairohan 22:c47f29caded6 706 else {
yabahiro 21:1f1e9c585da8 707 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 708 motor[TIRE_FR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 709 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 710 motor[TIRE_FL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 711 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 712 motor[TIRE_BR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 713 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 714 motor[TIRE_BL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 715 }
yabahiro 21:1f1e9c585da8 716
kishibekairohan 13:b6e02d6261d7 717 }
kishibekairohan 13:b6e02d6261d7 718 #endif
kishibekairohan 13:b6e02d6261d7 719
kishibekairohan 13:b6e02d6261d7 720 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 721 static void Process3()
kishibekairohan 13:b6e02d6261d7 722 {
kishibekairohan 13:b6e02d6261d7 723 }
kishibekairohan 13:b6e02d6261d7 724 #endif
kishibekairohan 13:b6e02d6261d7 725
kishibekairohan 13:b6e02d6261d7 726 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 727 static void Process4()
yabahiro 21:1f1e9c585da8 728 {
kishibekairohan 15:dfcec98f5aa9 729
kishibekairohan 13:b6e02d6261d7 730 }
kishibekairohan 13:b6e02d6261d7 731 #endif
kishibekairohan 13:b6e02d6261d7 732
kishibekairohan 13:b6e02d6261d7 733 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 734 static void Process5()
yabahiro 21:1f1e9c585da8 735 {
yabahiro 21:1f1e9c585da8 736
kishibekairohan 13:b6e02d6261d7 737 }
kishibekairohan 13:b6e02d6261d7 738 #endif
kishibekairohan 13:b6e02d6261d7 739
kishibekairohan 13:b6e02d6261d7 740 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 741 static void Process6()
kishibekairohan 13:b6e02d6261d7 742 {
yabahiro 21:1f1e9c585da8 743
kishibekairohan 13:b6e02d6261d7 744 }
kishibekairohan 13:b6e02d6261d7 745 #endif
kishibekairohan 13:b6e02d6261d7 746
kishibekairohan 13:b6e02d6261d7 747 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 748 static void Process7()
kishibekairohan 13:b6e02d6261d7 749 {
yabahiro 21:1f1e9c585da8 750
kishibekairohan 12:c09b3e08a316 751 }
kishibekairohan 12:c09b3e08a316 752 #endif
kishibekairohan 12:c09b3e08a316 753
yabahiro 21:1f1e9c585da8 754 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 755 static void Process8()
kishibekairohan 12:c09b3e08a316 756 {
yabahiro 21:1f1e9c585da8 757
kishibekairohan 12:c09b3e08a316 758 }
kishibekairohan 12:c09b3e08a316 759 #endif
kishibekairohan 12:c09b3e08a316 760
kishibekairohan 13:b6e02d6261d7 761 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 762 static void Process9()
kishibekairohan 12:c09b3e08a316 763 {
yabahiro 21:1f1e9c585da8 764
t_yamamoto 0:669ef71cba68 765 }
t_yamamoto 0:669ef71cba68 766 #endif
t_yamamoto 0:669ef71cba68 767 #endif
t_yamamoto 0:669ef71cba68 768 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 769
t_yamamoto 0:669ef71cba68 770 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 771 {
t_yamamoto 0:669ef71cba68 772
yabahiro 21:1f1e9c585da8 773 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 774 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 775 #endif
t_yamamoto 0:669ef71cba68 776
yabahiro 21:1f1e9c585da8 777 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 778 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 21:1f1e9c585da8 779 motor[i].dir = FREE;
yabahiro 21:1f1e9c585da8 780 motor[i].pwm = 0;
yabahiro 21:1f1e9c585da8 781 }
yabahiro 21:1f1e9c585da8 782 #endif
t_yamamoto 0:669ef71cba68 783 }
t_yamamoto 0:669ef71cba68 784
yabahiro 21:1f1e9c585da8 785 /*
yabahiro 21:1f1e9c585da8 786 void BuzzerTimer_func()
yabahiro 21:1f1e9c585da8 787 {
kishibekairohan 16:3f2c2d89372b 788 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 789 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 790 }
yabahiro 21:1f1e9c585da8 791 */
yabahiro 21:1f1e9c585da8 792 void TapeLedEms_func()
yabahiro 21:1f1e9c585da8 793 {
kishibekairohan 16:3f2c2d89372b 794 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 795 }
kishibekairohan 16:3f2c2d89372b 796
kishibekairohan 16:3f2c2d89372b 797 #pragma region USER-DEFINED-FUNCTIONS
kishibekairohan 16:3f2c2d89372b 798
kishibekairohan 16:3f2c2d89372b 799
t_yamamoto 0:669ef71cba68 800 #pragma endregion