Robotics Term Project / Mbed 2 deprecated Robottics_Motion

Dependencies:   mbed

Committer:
smilestone520
Date:
Wed May 25 10:36:45 2016 +0000
Revision:
11:44989c0bcea5
Parent:
10:06cc2b1d2aaf
Child:
12:c1a667ca6c53
real one

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smilestone520 10:06cc2b1d2aaf 1 /*LAB_DCMotor*/
smilestone520 10:06cc2b1d2aaf 2 #include "mbed.h"
smilestone520 10:06cc2b1d2aaf 3
smilestone520 10:06cc2b1d2aaf 4 //The number will be compiled as type "double" in default
smilestone520 10:06cc2b1d2aaf 5 //Add a "f" after the number can make it compiled as type "float"
smilestone520 10:06cc2b1d2aaf 6 #define Ts 0.01f //period of timer1 (s)
smilestone520 10:06cc2b1d2aaf 7 #define Kp 0.003f
smilestone520 10:06cc2b1d2aaf 8 #define Ki 0.01f
smilestone520 10:06cc2b1d2aaf 9
smilestone520 10:06cc2b1d2aaf 10 PwmOut pwm1(D7);
smilestone520 10:06cc2b1d2aaf 11 PwmOut pwm1n(D11);
smilestone520 10:06cc2b1d2aaf 12 PwmOut pwm2(D8);
smilestone520 10:06cc2b1d2aaf 13 PwmOut pwm2n(A3);
smilestone520 10:06cc2b1d2aaf 14
smilestone520 10:06cc2b1d2aaf 15 Serial bluetooth(D10,D2);
smilestone520 10:06cc2b1d2aaf 16 Serial pc(D1, D0);
smilestone520 10:06cc2b1d2aaf 17
smilestone520 10:06cc2b1d2aaf 18 DigitalOut led1(A4);
smilestone520 10:06cc2b1d2aaf 19 DigitalOut led2(A5);
smilestone520 10:06cc2b1d2aaf 20
smilestone520 10:06cc2b1d2aaf 21 //Motor1 sensor
smilestone520 10:06cc2b1d2aaf 22 InterruptIn HallA_1(A1);
smilestone520 10:06cc2b1d2aaf 23 InterruptIn HallB_1(A2);
smilestone520 10:06cc2b1d2aaf 24 //Motor2 sensor
smilestone520 10:06cc2b1d2aaf 25 InterruptIn HallA_2(D13);
smilestone520 10:06cc2b1d2aaf 26 InterruptIn HallB_2(D12);
smilestone520 10:06cc2b1d2aaf 27
smilestone520 10:06cc2b1d2aaf 28 Ticker timer1;
smilestone520 10:06cc2b1d2aaf 29 void timer1_interrupt(void);
smilestone520 10:06cc2b1d2aaf 30 void CN_interrupt(void);
smilestone520 10:06cc2b1d2aaf 31
smilestone520 10:06cc2b1d2aaf 32 void init_TIMER(void);
smilestone520 10:06cc2b1d2aaf 33 void init_PWM(void);
smilestone520 10:06cc2b1d2aaf 34 void init_CN(void);
smilestone520 10:06cc2b1d2aaf 35
smilestone520 10:06cc2b1d2aaf 36 int8_t stateA_1=0, stateB_1=0, stateA_2=0, stateB_2=0;
smilestone520 10:06cc2b1d2aaf 37 int8_t state_1 = 0, state_1_old = 0, state_2 = 0, state_2_old = 0;
smilestone520 10:06cc2b1d2aaf 38
smilestone520 10:06cc2b1d2aaf 39 int v1Count = 0;
smilestone520 10:06cc2b1d2aaf 40 int v2Count = 0;
smilestone520 10:06cc2b1d2aaf 41
smilestone520 10:06cc2b1d2aaf 42 float v1 = 0.0, v1_ref = 60.0;
smilestone520 10:06cc2b1d2aaf 43 float v1_err = 0.0, v1_ierr = 0.0, PIout_1 = 0.0, PIout_1_old = 0.0;
smilestone520 10:06cc2b1d2aaf 44 float v2 = 0.0, v2_ref = -60.0;
smilestone520 10:06cc2b1d2aaf 45 float v2_err = 0.0, v2_ierr = 0.0, PIout_2 = 0.0, PIout_2_old = 0.0;
smilestone520 10:06cc2b1d2aaf 46
smilestone520 11:44989c0bcea5 47 //**** receive and return by bluetooth ************** // bluetooth.getc()
smilestone520 11:44989c0bcea5 48 float xC, yC // car's position
smilestone520 11:44989c0bcea5 49
smilestone520 11:44989c0bcea5 50 float angleC // car's angle
smilestone520 11:44989c0bcea5 51
smilestone520 11:44989c0bcea5 52 float xP,yP //position that car need to reach
smilestone520 11:44989c0bcea5 53
smilestone520 11:44989c0bcea5 54 float angleR // angleR = car-nextSpot direction ---> car direction
smilestone520 11:44989c0bcea5 55
smilestone520 11:44989c0bcea5 56 int aI_State = 0;
smilestone520 11:44989c0bcea5 57
smilestone520 10:06cc2b1d2aaf 58 int main() {
smilestone520 10:06cc2b1d2aaf 59
smilestone520 10:06cc2b1d2aaf 60 init_TIMER();
smilestone520 10:06cc2b1d2aaf 61 init_PWM();
smilestone520 10:06cc2b1d2aaf 62 init_CN();
smilestone520 10:06cc2b1d2aaf 63
smilestone520 10:06cc2b1d2aaf 64 bluetooth.baud(115200); //設定鮑率
smilestone520 10:06cc2b1d2aaf 65 pc.baud(57600);
smilestone520 10:06cc2b1d2aaf 66
smilestone520 10:06cc2b1d2aaf 67
smilestone520 10:06cc2b1d2aaf 68 while(1)
smilestone520 10:06cc2b1d2aaf 69 {
smilestone520 10:06cc2b1d2aaf 70 if(pc.readable())
smilestone520 10:06cc2b1d2aaf 71 {
smilestone520 10:06cc2b1d2aaf 72 bluetooth.putc(pc.getc());
smilestone520 10:06cc2b1d2aaf 73 }
smilestone520 10:06cc2b1d2aaf 74 if(bluetooth.readable())
smilestone520 10:06cc2b1d2aaf 75 {
smilestone520 10:06cc2b1d2aaf 76 pc.putc(bluetooth.getc());
smilestone520 10:06cc2b1d2aaf 77 }
smilestone520 10:06cc2b1d2aaf 78 }
smilestone520 10:06cc2b1d2aaf 79 }
smilestone520 10:06cc2b1d2aaf 80
smilestone520 10:06cc2b1d2aaf 81 void timer1_interrupt(void)
smilestone520 10:06cc2b1d2aaf 82 {
smilestone520 10:06cc2b1d2aaf 83 //Motor 1
smilestone520 10:06cc2b1d2aaf 84 v1 = (float)v1Count * 100.0f / 12.0f * 60.0f / 29.0f; //unit: rpm
smilestone520 10:06cc2b1d2aaf 85 v1Count = 0;
smilestone520 10:06cc2b1d2aaf 86
smilestone520 10:06cc2b1d2aaf 87 ///code for PI control///
smilestone520 10:06cc2b1d2aaf 88 v1_err = v1_ref - v1;
smilestone520 10:06cc2b1d2aaf 89 v1_ierr = 0.01f*v1_err + v1_ierr;
smilestone520 10:06cc2b1d2aaf 90 PIout_1 = Kp*v1_err + Ki*v1_ierr;
smilestone520 10:06cc2b1d2aaf 91
smilestone520 10:06cc2b1d2aaf 92 /////////////////////////
smilestone520 10:06cc2b1d2aaf 93
smilestone520 10:06cc2b1d2aaf 94 if(PIout_1 >= 0.5f)PIout_1 = 0.5f;
smilestone520 10:06cc2b1d2aaf 95 else if(PIout_1 <= -0.5f)PIout_1 = -0.5f;
smilestone520 10:06cc2b1d2aaf 96 pwm1.write(PIout_1 + 0.5f);
smilestone520 10:06cc2b1d2aaf 97 TIM1->CCER |= 0x4;
smilestone520 10:06cc2b1d2aaf 98
smilestone520 10:06cc2b1d2aaf 99
smilestone520 10:06cc2b1d2aaf 100 //Motor 2
smilestone520 10:06cc2b1d2aaf 101 v2 = (float)v2Count * 100.0f / 12.0f * 60.0f / 29.0f; //unit: rpm
smilestone520 10:06cc2b1d2aaf 102 v2Count = 0;
smilestone520 10:06cc2b1d2aaf 103
smilestone520 10:06cc2b1d2aaf 104 ///code for PI control///
smilestone520 10:06cc2b1d2aaf 105 v2_err = v2_ref - v2;
smilestone520 10:06cc2b1d2aaf 106 v2_ierr = 0.01f*v2_err + v2_ierr;
smilestone520 10:06cc2b1d2aaf 107 PIout_2 = Kp*v2_err + Ki*v2_ierr;
smilestone520 10:06cc2b1d2aaf 108
smilestone520 10:06cc2b1d2aaf 109 /////////////////////////
smilestone520 10:06cc2b1d2aaf 110
smilestone520 10:06cc2b1d2aaf 111 if(PIout_2 >= 0.5f)PIout_2 = 0.5f;
smilestone520 10:06cc2b1d2aaf 112 else if(PIout_2 <= -0.5f)PIout_2 = -0.5f;
smilestone520 10:06cc2b1d2aaf 113 pwm2.write(PIout_2 + 0.5f);
smilestone520 10:06cc2b1d2aaf 114 TIM1->CCER |= 0x40;
smilestone520 10:06cc2b1d2aaf 115
smilestone520 11:44989c0bcea5 116
smilestone520 11:44989c0bcea5 117
smilestone520 11:44989c0bcea5 118 //***** main AI **************************
smilestone520 11:44989c0bcea5 119
smilestone520 11:44989c0bcea5 120
smilestone520 11:44989c0bcea5 121 //***** get position information from the bluetooth
smilestone520 11:44989c0bcea5 122 xC = ;
smilestone520 11:44989c0bcea5 123 yC = ; // car's position
smilestone520 11:44989c0bcea5 124
smilestone520 11:44989c0bcea5 125 angleC = ; // car's angle
smilestone520 11:44989c0bcea5 126
smilestone520 11:44989c0bcea5 127 xP = ;
smilestone520 11:44989c0bcea5 128 yP = ;//position that car need to reach
smilestone520 11:44989c0bcea5 129
smilestone520 11:44989c0bcea5 130 angleR = ; // angleR = car-nextSpot direction ---> car direction
smilestone520 11:44989c0bcea5 131
smilestone520 11:44989c0bcea5 132 //**** AI_State ********************
smilestone520 11:44989c0bcea5 133
smilestone520 11:44989c0bcea5 134 switch(aI_State)
smilestone520 11:44989c0bcea5 135 {
smilestone520 11:44989c0bcea5 136 case 0:
smilestone520 11:44989c0bcea5 137 break;
smilestone520 11:44989c0bcea5 138 case 1:
smilestone520 11:44989c0bcea5 139 break;
smilestone520 11:44989c0bcea5 140 case 2:
smilestone520 11:44989c0bcea5 141 break;
smilestone520 11:44989c0bcea5 142 case 3:
smilestone520 11:44989c0bcea5 143 break;
smilestone520 11:44989c0bcea5 144 case 4:
smilestone520 11:44989c0bcea5 145
smilestone520 11:44989c0bcea5 146 }
smilestone520 11:44989c0bcea5 147
smilestone520 11:44989c0bcea5 148
smilestone520 11:44989c0bcea5 149
smilestone520 11:44989c0bcea5 150
smilestone520 11:44989c0bcea5 151
smilestone520 11:44989c0bcea5 152
smilestone520 10:06cc2b1d2aaf 153 switch(bluetooth.getc())
smilestone520 10:06cc2b1d2aaf 154 {
smilestone520 10:06cc2b1d2aaf 155 case '1':
smilestone520 10:06cc2b1d2aaf 156 v1_ref = 30;
smilestone520 10:06cc2b1d2aaf 157 v2_ref = -30;
smilestone520 10:06cc2b1d2aaf 158 break;
smilestone520 10:06cc2b1d2aaf 159 case '2':
smilestone520 10:06cc2b1d2aaf 160 v1_ref = 40;
smilestone520 10:06cc2b1d2aaf 161 v2_ref = -40;
smilestone520 10:06cc2b1d2aaf 162 break;
smilestone520 10:06cc2b1d2aaf 163 case '3':
smilestone520 10:06cc2b1d2aaf 164 v1_ref = 50;
smilestone520 10:06cc2b1d2aaf 165 v2_ref = -50;
smilestone520 10:06cc2b1d2aaf 166 break;
smilestone520 10:06cc2b1d2aaf 167 case '4':
smilestone520 10:06cc2b1d2aaf 168 v1_ref = 60;
smilestone520 10:06cc2b1d2aaf 169 v2_ref = -60;
smilestone520 10:06cc2b1d2aaf 170 break;
smilestone520 10:06cc2b1d2aaf 171 case '5':
smilestone520 10:06cc2b1d2aaf 172 v1_ref = -70;
smilestone520 10:06cc2b1d2aaf 173 v2_ref = 70;
smilestone520 10:06cc2b1d2aaf 174 break;
smilestone520 10:06cc2b1d2aaf 175 case '6':
smilestone520 10:06cc2b1d2aaf 176 v1_ref = -80;
smilestone520 10:06cc2b1d2aaf 177 v2_ref = 80;
smilestone520 10:06cc2b1d2aaf 178 break;
smilestone520 10:06cc2b1d2aaf 179 case '7':
smilestone520 10:06cc2b1d2aaf 180 v1_ref = -100;
smilestone520 10:06cc2b1d2aaf 181 v2_ref = 100;
smilestone520 10:06cc2b1d2aaf 182 break;
smilestone520 10:06cc2b1d2aaf 183 case '8':
smilestone520 10:06cc2b1d2aaf 184 v1_ref = 0;
smilestone520 10:06cc2b1d2aaf 185 v2_ref = 0;
smilestone520 10:06cc2b1d2aaf 186 break;
smilestone520 10:06cc2b1d2aaf 187 }
smilestone520 10:06cc2b1d2aaf 188
smilestone520 10:06cc2b1d2aaf 189
smilestone520 10:06cc2b1d2aaf 190 }
smilestone520 10:06cc2b1d2aaf 191
smilestone520 10:06cc2b1d2aaf 192 void CN_interrupt(void)
smilestone520 10:06cc2b1d2aaf 193 {
smilestone520 10:06cc2b1d2aaf 194 //Motor 1
smilestone520 10:06cc2b1d2aaf 195 stateA_1 = HallA_1.read();
smilestone520 10:06cc2b1d2aaf 196 stateB_1 = HallB_1.read();
smilestone520 10:06cc2b1d2aaf 197
smilestone520 10:06cc2b1d2aaf 198 ///code for state determination///
smilestone520 10:06cc2b1d2aaf 199 if(stateA_1==0&&stateB_1==0){
smilestone520 10:06cc2b1d2aaf 200 state_1 = 1;}
smilestone520 10:06cc2b1d2aaf 201 else if(stateA_1==0&&stateB_1==1){
smilestone520 10:06cc2b1d2aaf 202 state_1 = 2;}
smilestone520 10:06cc2b1d2aaf 203 else if(stateA_1==1&&stateB_1==1){
smilestone520 10:06cc2b1d2aaf 204 state_1 = 3;}
smilestone520 10:06cc2b1d2aaf 205 else if(stateA_1==1&&stateB_1==0){
smilestone520 10:06cc2b1d2aaf 206 state_1 = 4;}
smilestone520 10:06cc2b1d2aaf 207
smilestone520 10:06cc2b1d2aaf 208 if(state_1 == 1)
smilestone520 10:06cc2b1d2aaf 209 {
smilestone520 10:06cc2b1d2aaf 210 if(state_1-state_1_old == -3)
smilestone520 10:06cc2b1d2aaf 211 v1Count=v1Count+1;
smilestone520 10:06cc2b1d2aaf 212 else if(state_1-state_1_old == -1)
smilestone520 10:06cc2b1d2aaf 213 v1Count=v1Count-1;
smilestone520 10:06cc2b1d2aaf 214 }
smilestone520 10:06cc2b1d2aaf 215 else if(state_1 == 2)
smilestone520 10:06cc2b1d2aaf 216 {
smilestone520 10:06cc2b1d2aaf 217 if(state_1-state_1_old == 1)
smilestone520 10:06cc2b1d2aaf 218 v1Count=v1Count+1;
smilestone520 10:06cc2b1d2aaf 219 else if(state_1-state_1_old == -1)
smilestone520 10:06cc2b1d2aaf 220 v1Count=v1Count-1;
smilestone520 10:06cc2b1d2aaf 221 }
smilestone520 10:06cc2b1d2aaf 222 else if(state_1 == 3)
smilestone520 10:06cc2b1d2aaf 223 {
smilestone520 10:06cc2b1d2aaf 224 if(state_1-state_1_old == 1)
smilestone520 10:06cc2b1d2aaf 225 v1Count=v1Count+1;
smilestone520 10:06cc2b1d2aaf 226 else if(state_1-state_1_old == -1)
smilestone520 10:06cc2b1d2aaf 227 v1Count=v1Count-1;
smilestone520 10:06cc2b1d2aaf 228 }
smilestone520 10:06cc2b1d2aaf 229 else if(state_1 == 4)
smilestone520 10:06cc2b1d2aaf 230 {
smilestone520 10:06cc2b1d2aaf 231 if(state_1-state_1_old == 1)
smilestone520 10:06cc2b1d2aaf 232 v1Count=v1Count+1;
smilestone520 10:06cc2b1d2aaf 233 else if(state_1-state_1_old == 3)
smilestone520 10:06cc2b1d2aaf 234 v1Count=v1Count-1;
smilestone520 10:06cc2b1d2aaf 235 }
smilestone520 10:06cc2b1d2aaf 236 state_1_old = state_1;
smilestone520 10:06cc2b1d2aaf 237
smilestone520 10:06cc2b1d2aaf 238
smilestone520 10:06cc2b1d2aaf 239 //////////////////////////////////
smilestone520 10:06cc2b1d2aaf 240
smilestone520 10:06cc2b1d2aaf 241 //Forward
smilestone520 10:06cc2b1d2aaf 242 //v1Count +1
smilestone520 10:06cc2b1d2aaf 243 //Inverse
smilestone520 10:06cc2b1d2aaf 244 //v1Count -1
smilestone520 10:06cc2b1d2aaf 245
smilestone520 10:06cc2b1d2aaf 246
smilestone520 10:06cc2b1d2aaf 247 //Motor 2
smilestone520 10:06cc2b1d2aaf 248 stateA_2 = HallA_2.read();
smilestone520 10:06cc2b1d2aaf 249 stateB_2 = HallB_2.read();
smilestone520 10:06cc2b1d2aaf 250
smilestone520 10:06cc2b1d2aaf 251 ///code for state determination///
smilestone520 10:06cc2b1d2aaf 252 if(stateA_2==0&&stateB_2==0){
smilestone520 10:06cc2b1d2aaf 253 state_2 = 1;}
smilestone520 10:06cc2b1d2aaf 254 else if(stateA_2==0&&stateB_2==1){
smilestone520 10:06cc2b1d2aaf 255 state_2 = 2;}
smilestone520 10:06cc2b1d2aaf 256 else if(stateA_2==1&&stateB_2==1){
smilestone520 10:06cc2b1d2aaf 257 state_2 = 3;}
smilestone520 10:06cc2b1d2aaf 258 else if(stateA_2==1&&stateB_2==0){
smilestone520 10:06cc2b1d2aaf 259 state_2 = 4;}
smilestone520 10:06cc2b1d2aaf 260
smilestone520 10:06cc2b1d2aaf 261 if(state_2 == 1)
smilestone520 10:06cc2b1d2aaf 262 {
smilestone520 10:06cc2b1d2aaf 263 if(state_2-state_2_old == -3)
smilestone520 10:06cc2b1d2aaf 264 v2Count=v2Count+1;
smilestone520 10:06cc2b1d2aaf 265 else if(state_2-state_2_old == -1)
smilestone520 10:06cc2b1d2aaf 266 v2Count=v2Count-1;
smilestone520 10:06cc2b1d2aaf 267 }
smilestone520 10:06cc2b1d2aaf 268 else if(state_2 == 2)
smilestone520 10:06cc2b1d2aaf 269 {
smilestone520 10:06cc2b1d2aaf 270 if(state_2-state_2_old == 1)
smilestone520 10:06cc2b1d2aaf 271 v2Count=v2Count+1;
smilestone520 10:06cc2b1d2aaf 272 else if(state_2-state_2_old == -1)
smilestone520 10:06cc2b1d2aaf 273 v2Count=v2Count-1;
smilestone520 10:06cc2b1d2aaf 274 }
smilestone520 10:06cc2b1d2aaf 275 else if(state_2 == 3)
smilestone520 10:06cc2b1d2aaf 276 {
smilestone520 10:06cc2b1d2aaf 277 if(state_2-state_2_old == 1)
smilestone520 10:06cc2b1d2aaf 278 v2Count=v2Count+1;
smilestone520 10:06cc2b1d2aaf 279 else if(state_2-state_2_old == -1)
smilestone520 10:06cc2b1d2aaf 280 v2Count=v2Count-1;
smilestone520 10:06cc2b1d2aaf 281 }
smilestone520 10:06cc2b1d2aaf 282 else if(state_2 == 4)
smilestone520 10:06cc2b1d2aaf 283 {
smilestone520 10:06cc2b1d2aaf 284 if(state_2-state_2_old == 1)
smilestone520 10:06cc2b1d2aaf 285 v2Count=v2Count+1;
smilestone520 10:06cc2b1d2aaf 286 else if(state_2-state_2_old == 3)
smilestone520 10:06cc2b1d2aaf 287 v2Count=v2Count-1;
smilestone520 10:06cc2b1d2aaf 288 }
smilestone520 10:06cc2b1d2aaf 289 state_2_old = state_2;
smilestone520 10:06cc2b1d2aaf 290
smilestone520 10:06cc2b1d2aaf 291 //////////////////////////////////
smilestone520 10:06cc2b1d2aaf 292
smilestone520 10:06cc2b1d2aaf 293 //Forward
smilestone520 10:06cc2b1d2aaf 294 //v2Count +1
smilestone520 10:06cc2b1d2aaf 295 //Inverse
smilestone520 10:06cc2b1d2aaf 296 //v2Count -1
smilestone520 10:06cc2b1d2aaf 297 }
smilestone520 10:06cc2b1d2aaf 298
smilestone520 10:06cc2b1d2aaf 299 void init_TIMER(void)
smilestone520 10:06cc2b1d2aaf 300 {
smilestone520 10:06cc2b1d2aaf 301 timer1.attach_us(&timer1_interrupt, 10000);//10ms interrupt period (100 Hz)
smilestone520 10:06cc2b1d2aaf 302 }
smilestone520 10:06cc2b1d2aaf 303
smilestone520 10:06cc2b1d2aaf 304 void init_PWM(void)
smilestone520 10:06cc2b1d2aaf 305 {
smilestone520 10:06cc2b1d2aaf 306 pwm1.period_us(50);
smilestone520 10:06cc2b1d2aaf 307 pwm1.write(0.5);
smilestone520 10:06cc2b1d2aaf 308 TIM1->CCER |= 0x4;
smilestone520 10:06cc2b1d2aaf 309
smilestone520 10:06cc2b1d2aaf 310 pwm2.period_us(50);
smilestone520 10:06cc2b1d2aaf 311 pwm2.write(0.5);
smilestone520 10:06cc2b1d2aaf 312 TIM1->CCER |= 0x40;
smilestone520 10:06cc2b1d2aaf 313 }
smilestone520 10:06cc2b1d2aaf 314
smilestone520 10:06cc2b1d2aaf 315 void init_CN(void)
smilestone520 10:06cc2b1d2aaf 316 {
smilestone520 10:06cc2b1d2aaf 317 HallA_1.rise(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 318 HallA_1.fall(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 319 HallB_1.rise(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 320 HallB_1.fall(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 321
smilestone520 10:06cc2b1d2aaf 322 HallA_2.rise(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 323 HallA_2.fall(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 324 HallB_2.rise(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 325 HallB_2.fall(&CN_interrupt);
smilestone520 10:06cc2b1d2aaf 326
smilestone520 10:06cc2b1d2aaf 327 stateA_1 = HallA_1.read();
smilestone520 10:06cc2b1d2aaf 328 stateB_1 = HallB_1.read();
smilestone520 10:06cc2b1d2aaf 329 stateA_2 = HallA_2.read();
smilestone520 10:06cc2b1d2aaf 330 stateB_2 = HallB_2.read();
smilestone520 10:06cc2b1d2aaf 331 }