SwitchMode

Dependencies:   BEAR_Protocol InverseLeg iSerial mbed

Fork of SwitchMode by Arsapol Manamunchaiyaporn

Committer:
icyzkungz
Date:
Sat Jan 23 01:21:22 2016 +0000
Revision:
3:b7a8a60085c1
Parent:
2:d6be1c49d9d5
Child:
4:16cadf26dbab
solve kinematic problem in offset

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icyzkungz 0:f73c80b36c20 1 #include "string"
icyzkungz 0:f73c80b36c20 2 #include "BEAR_Protocol.h"
icyzkungz 0:f73c80b36c20 3 #include "Kinematic.h"
icyzkungz 0:f73c80b36c20 4
icyzkungz 0:f73c80b36c20 5 Serial pc(SERIAL_TX,SERIAL_RX);
icyzkungz 0:f73c80b36c20 6 Bear_Communicate bcom(PA_15,PB_7,115200);
icyzkungz 3:b7a8a60085c1 7 Kinematic Left(0,0),Right(0,0);
icyzkungz 0:f73c80b36c20 8
icyzkungz 0:f73c80b36c20 9 DigitalIn button(USER_BUTTON);
icyzkungz 0:f73c80b36c20 10
icyzkungz 3:b7a8a60085c1 11 #define LEFT_SIDE 0x01
icyzkungz 0:f73c80b36c20 12 #define RIGHT_SIDE 0x02
icyzkungz 0:f73c80b36c20 13
icyzkungz 0:f73c80b36c20 14 void SwMode()
icyzkungz 0:f73c80b36c20 15 {
icyzkungz 2:d6be1c49d9d5 16 int option;
icyzkungz 0:f73c80b36c20 17 float temp;
icyzkungz 0:f73c80b36c20 18 float LH,LK,RH,RK;
icyzkungz 0:f73c80b36c20 19 float LLink[2],RLink[2];
icyzkungz 3:b7a8a60085c1 20 float LLink0,LLink1,RLink0,RLink1;
icyzkungz 0:f73c80b36c20 21 struct max_ang {
icyzkungz 0:f73c80b36c20 22 float Hip;
icyzkungz 0:f73c80b36c20 23 float Knee;
icyzkungz 0:f73c80b36c20 24 };
icyzkungz 0:f73c80b36c20 25 struct min_ang {
icyzkungz 0:f73c80b36c20 26 float Hip;
icyzkungz 0:f73c80b36c20 27 float Knee;
icyzkungz 0:f73c80b36c20 28 };
icyzkungz 0:f73c80b36c20 29 max_ang Lmax,Lmin;
icyzkungz 0:f73c80b36c20 30 min_ang Rmax,Rmin;
icyzkungz 1:183e6088a1fa 31 Lmax.Knee = Lmax.Hip = Lmin.Knee = Lmin.Hip = Rmax.Knee = Rmax.Hip = Rmin.Knee = Rmin.Hip = 0;
icyzkungz 0:f73c80b36c20 32 bool a,b,c,d;
icyzkungz 0:f73c80b36c20 33 a = b = c = d = false;
icyzkungz 0:f73c80b36c20 34 float temp_LH=0,temp_LK=0,temp_RH=0,temp_RK=0;
icyzkungz 2:d6be1c49d9d5 35 do {
icyzkungz 0:f73c80b36c20 36 pc.printf("************Don't Forget to Save Data************\n");
icyzkungz 0:f73c80b36c20 37 pc.printf("*\t1) Motor Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 38 pc.printf("*\t2) Motor Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 39 pc.printf("*\t3) Motor Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 40 pc.printf("*\t4) Motor Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 41 pc.printf("*\t5) Kp : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 42 pc.printf("*\t6) Ki : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 43 pc.printf("*\t7) Kd : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 44 pc.printf("*\t8) Save Left Hip(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 45 pc.printf("*\t9) Kp : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 46 pc.printf("*\t10) Ki : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 47 pc.printf("*\t11) Kd : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 48 pc.printf("*\t12) Save Left Knee(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 49 pc.printf("*\t13) Kp : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 50 pc.printf("*\t14) Ki : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 51 pc.printf("*\t15) Kd : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 52 pc.printf("*\t16) Save Right Hip(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 53 pc.printf("*\t17) Kp : Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 54 pc.printf("*\t18) Ki : Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 55 pc.printf("*\t19) Kd : Right Knee \t\t\t*\n");
icyzkungz 3:b7a8a60085c1 56 pc.printf("*\t20) Save Right K(p,i,d) data\t\t\t*\n");
icyzkungz 0:f73c80b36c20 57 pc.printf("*\t21) Set Left Hip Margin\n");
icyzkungz 0:f73c80b36c20 58 pc.printf("*\t22) Set Left Knee Margin\n");
icyzkungz 0:f73c80b36c20 59 pc.printf("*\t23) Set Right Hip Margin\n");
icyzkungz 0:f73c80b36c20 60 pc.printf("*\t24) Set Right Knee Margin\n");
icyzkungz 3:b7a8a60085c1 61 pc.printf("*\t25) Set Lenght of Left Link Hip\n");
icyzkungz 3:b7a8a60085c1 62 pc.printf("*\t26) Set Lenght of Left Link Knee\n");
icyzkungz 3:b7a8a60085c1 63 pc.printf("*\t27) Set Lenght of Right Link Hip\n");
icyzkungz 3:b7a8a60085c1 64 pc.printf("*\t28) Set Lenght of Right Link Knee\n");
icyzkungz 3:b7a8a60085c1 65 pc.printf("*\t29) Set Offset\n");
icyzkungz 3:b7a8a60085c1 66 pc.printf("*\t30) Set Body Width\n");
icyzkungz 3:b7a8a60085c1 67 pc.printf("*\t31) Set Maximum Hip Angle Range\n");
icyzkungz 3:b7a8a60085c1 68 pc.printf("*\t32) Set Minimum Hip Angle Range\n");
icyzkungz 3:b7a8a60085c1 69 pc.printf("*\t33) Set Maximum Knee Angle Range\n");
icyzkungz 3:b7a8a60085c1 70 pc.printf("*\t34) Set Minimum Knee Angle Range\n");
icyzkungz 0:f73c80b36c20 71
icyzkungz 0:f73c80b36c20 72 pc.printf("*\t40) Exit Program \t\t\t*\n");
icyzkungz 0:f73c80b36c20 73 pc.printf("************Don't Forget to Save Data************\n");
icyzkungz 0:f73c80b36c20 74 // Prompting user to enter an option according to menu
icyzkungz 0:f73c80b36c20 75 pc.printf("Please select an option : ");
icyzkungz 0:f73c80b36c20 76
icyzkungz 0:f73c80b36c20 77 pc.scanf("%d",&option);
icyzkungz 0:f73c80b36c20 78
icyzkungz 0:f73c80b36c20 79 pc.printf("\n");
icyzkungz 0:f73c80b36c20 80
icyzkungz 0:f73c80b36c20 81 if(option == 1)// Left Hip
icyzkungz 0:f73c80b36c20 82 do {
icyzkungz 0:f73c80b36c20 83 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 84 //Send Position to Motor
icyzkungz 0:f73c80b36c20 85 pc.printf("Input Degree : \n");
icyzkungz 0:f73c80b36c20 86 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 87 if(temp!=9999) {
icyzkungz 0:f73c80b36c20 88 LH = temp;
icyzkungz 0:f73c80b36c20 89 pc.printf("Move Left Hip Motor to %f Degree\n",LH);
icyzkungz 0:f73c80b36c20 90
icyzkungz 0:f73c80b36c20 91 bcom.setMotorPos(LEFT_SIDE,LH,temp_LK);
icyzkungz 0:f73c80b36c20 92 temp_LH = LH;
icyzkungz 0:f73c80b36c20 93
icyzkungz 0:f73c80b36c20 94 /********************Save Data*********************/
icyzkungz 0:f73c80b36c20 95 } else bcom.saveDataToEEPROM(LEFT_SIDE,MOTOR_UPPER_ANG);
icyzkungz 0:f73c80b36c20 96
icyzkungz 0:f73c80b36c20 97 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 98
icyzkungz 0:f73c80b36c20 99 else if(option == 2) //Left Knee
icyzkungz 0:f73c80b36c20 100 do {
icyzkungz 0:f73c80b36c20 101 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 102
icyzkungz 0:f73c80b36c20 103 //Send Position to Motor
icyzkungz 0:f73c80b36c20 104 pc.printf("Input Degree : \n");
icyzkungz 0:f73c80b36c20 105 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 106 if(temp!=9999) {
icyzkungz 0:f73c80b36c20 107 LK = temp;
icyzkungz 0:f73c80b36c20 108 pc.printf("Move Left Knee Motor to %f Degree\n",LK);
icyzkungz 0:f73c80b36c20 109
icyzkungz 0:f73c80b36c20 110 bcom.setMotorPos(LEFT_SIDE,temp_LH,LK);
icyzkungz 0:f73c80b36c20 111 temp_LK = LK;
icyzkungz 0:f73c80b36c20 112
icyzkungz 0:f73c80b36c20 113
icyzkungz 0:f73c80b36c20 114 /********************Save Data*********************/
icyzkungz 0:f73c80b36c20 115 } else bcom.saveDataToEEPROM(LEFT_SIDE,MOTOR_LOWER_ANG);
icyzkungz 0:f73c80b36c20 116
icyzkungz 0:f73c80b36c20 117 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 118
icyzkungz 0:f73c80b36c20 119
icyzkungz 0:f73c80b36c20 120 else if(option == 3) { //Right Hip
icyzkungz 0:f73c80b36c20 121 do {
icyzkungz 0:f73c80b36c20 122 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 123
icyzkungz 0:f73c80b36c20 124 //Send Position to Motor
icyzkungz 0:f73c80b36c20 125 pc.printf("Input Degree : \n");
icyzkungz 0:f73c80b36c20 126 pc.scanf("%f",&RH);
icyzkungz 0:f73c80b36c20 127 if(temp!=9999) {
icyzkungz 0:f73c80b36c20 128 RH = temp;
icyzkungz 0:f73c80b36c20 129 pc.printf("Move Right Hip Motor to %f Degree\n",RH);
icyzkungz 0:f73c80b36c20 130
icyzkungz 0:f73c80b36c20 131 bcom.setMotorPos(RIGHT_SIDE,RH,temp_RK);
icyzkungz 0:f73c80b36c20 132 temp_RH = RH;
icyzkungz 0:f73c80b36c20 133
icyzkungz 0:f73c80b36c20 134
icyzkungz 0:f73c80b36c20 135 /********************Save Data*********************/
icyzkungz 0:f73c80b36c20 136 } else bcom.saveDataToEEPROM(RIGHT_SIDE,MOTOR_UPPER_ANG);
icyzkungz 0:f73c80b36c20 137
icyzkungz 0:f73c80b36c20 138 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 139
icyzkungz 0:f73c80b36c20 140 } else if(option == 4) { //Right Knee
icyzkungz 0:f73c80b36c20 141 do {
icyzkungz 0:f73c80b36c20 142 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 143
icyzkungz 0:f73c80b36c20 144 //Send Position to Motor
icyzkungz 0:f73c80b36c20 145 pc.printf("Input Degree : \n");
icyzkungz 0:f73c80b36c20 146 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 147
icyzkungz 0:f73c80b36c20 148 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 149 RK = temp;
icyzkungz 0:f73c80b36c20 150 pc.printf("Move Right Knee Motor to %f Degree\n",RK);
icyzkungz 0:f73c80b36c20 151
icyzkungz 0:f73c80b36c20 152 bcom.setMotorPos(RIGHT_SIDE,temp_RH,RK);
icyzkungz 0:f73c80b36c20 153 temp_RK = RK;
icyzkungz 0:f73c80b36c20 154
icyzkungz 0:f73c80b36c20 155
icyzkungz 0:f73c80b36c20 156 /********************Save Data*********************/
icyzkungz 0:f73c80b36c20 157 } else bcom.saveDataToEEPROM(RIGHT_SIDE,MOTOR_LOWER_ANG);
icyzkungz 0:f73c80b36c20 158
icyzkungz 0:f73c80b36c20 159 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 160
icyzkungz 0:f73c80b36c20 161 } else if(option == 5) { //Left Hip
icyzkungz 0:f73c80b36c20 162 do {
icyzkungz 0:f73c80b36c20 163 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 164 pc.printf("\nInput Kp of Left Hip\n");
icyzkungz 0:f73c80b36c20 165 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 166
icyzkungz 0:f73c80b36c20 167 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 168 pc.printf("\nChange Kp of Left Hip to %f",temp);
icyzkungz 0:f73c80b36c20 169
icyzkungz 0:f73c80b36c20 170 bcom.setUpMotorKp(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 171 } else bcom.saveDataToEEPROM(LEFT_SIDE,KP_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 172
icyzkungz 0:f73c80b36c20 173 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 174
icyzkungz 0:f73c80b36c20 175 } else if(option == 6) { //Left Hip
icyzkungz 0:f73c80b36c20 176 do {
icyzkungz 0:f73c80b36c20 177 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 178 pc.printf("\nInput Ki of Left Hip\n");
icyzkungz 0:f73c80b36c20 179 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 180
icyzkungz 0:f73c80b36c20 181 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 182 pc.printf("\nChange Ki of Left Hip to %f",temp);
icyzkungz 0:f73c80b36c20 183
icyzkungz 0:f73c80b36c20 184 bcom.setUpMotorKi(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 185 } else bcom.saveDataToEEPROM(LEFT_SIDE,KI_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 186
icyzkungz 0:f73c80b36c20 187 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 188
icyzkungz 0:f73c80b36c20 189 } else if(option == 7) { //Left Hip
icyzkungz 0:f73c80b36c20 190 do {
icyzkungz 0:f73c80b36c20 191 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 192 pc.printf("\nInput Kd of Left Hip\n");
icyzkungz 0:f73c80b36c20 193 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 194
icyzkungz 0:f73c80b36c20 195 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 196 pc.printf("\nChange Kd of Left Hip to %f",temp);
icyzkungz 0:f73c80b36c20 197
icyzkungz 0:f73c80b36c20 198 bcom.setUpMotorKd(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 199 } else bcom.saveDataToEEPROM(LEFT_SIDE,KD_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 200
icyzkungz 0:f73c80b36c20 201 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 202
icyzkungz 0:f73c80b36c20 203 } else if(option == 8) {
icyzkungz 0:f73c80b36c20 204 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 205 /*******************************Save Left Hip data*************************************/
icyzkungz 0:f73c80b36c20 206
icyzkungz 0:f73c80b36c20 207 } else if(option == 9) { //Left Knee
icyzkungz 0:f73c80b36c20 208 do {
icyzkungz 0:f73c80b36c20 209 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 210 pc.printf("\nInput Kp of Left Knee\n");
icyzkungz 0:f73c80b36c20 211 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 212
icyzkungz 0:f73c80b36c20 213 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 214 pc.printf("\nChange Kp of Left Knee to %f",temp);
icyzkungz 0:f73c80b36c20 215
icyzkungz 0:f73c80b36c20 216 bcom.setLowMotorKp(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 217 } else bcom.saveDataToEEPROM(LEFT_SIDE,KP_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 218
icyzkungz 0:f73c80b36c20 219 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 220
icyzkungz 0:f73c80b36c20 221 } else if(option == 10) { //Left Knee
icyzkungz 0:f73c80b36c20 222 do {
icyzkungz 0:f73c80b36c20 223 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 224 pc.printf("\nInput Ki of Left Knee\n");
icyzkungz 0:f73c80b36c20 225 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 226
icyzkungz 0:f73c80b36c20 227 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 228 pc.printf("\nChange Ki of Left Knee to %f",temp);
icyzkungz 0:f73c80b36c20 229
icyzkungz 0:f73c80b36c20 230 bcom.setLowMotorKi(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 231 } else bcom.saveDataToEEPROM(LEFT_SIDE,KI_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 232
icyzkungz 0:f73c80b36c20 233 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 234
icyzkungz 0:f73c80b36c20 235 } else if(option == 11) { //Left Knee
icyzkungz 0:f73c80b36c20 236 do {
icyzkungz 0:f73c80b36c20 237 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 238 pc.printf("\nInput Kd of Left Knee\n");
icyzkungz 0:f73c80b36c20 239 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 240
icyzkungz 0:f73c80b36c20 241 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 242 pc.printf("\nChange Kd of Left Knee to %f",temp);
icyzkungz 0:f73c80b36c20 243
icyzkungz 0:f73c80b36c20 244 bcom.setLowMotorKd(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 245 } else bcom.saveDataToEEPROM(LEFT_SIDE,KD_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 246
icyzkungz 0:f73c80b36c20 247 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 248
icyzkungz 0:f73c80b36c20 249
icyzkungz 0:f73c80b36c20 250 } else if(option == 12) {
icyzkungz 0:f73c80b36c20 251 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 252 /*******************************Save Left Knee data*************************************/
icyzkungz 0:f73c80b36c20 253
icyzkungz 0:f73c80b36c20 254
icyzkungz 0:f73c80b36c20 255 } else if(option == 13) { //Right Hip
icyzkungz 0:f73c80b36c20 256 do {
icyzkungz 0:f73c80b36c20 257 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 258 pc.printf("\nInput Kp of Right Hip\n");
icyzkungz 0:f73c80b36c20 259 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 260
icyzkungz 0:f73c80b36c20 261 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 262 pc.printf("\nChange Kp of Right Hip to %f",temp);
icyzkungz 0:f73c80b36c20 263
icyzkungz 0:f73c80b36c20 264 bcom.setUpMotorKp(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 265 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KP_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 266
icyzkungz 0:f73c80b36c20 267 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 268
icyzkungz 0:f73c80b36c20 269 } else if(option == 14) { //Right Hip
icyzkungz 0:f73c80b36c20 270 do {
icyzkungz 0:f73c80b36c20 271 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 272 pc.printf("\nInput Ki of Right Hip\n");
icyzkungz 0:f73c80b36c20 273 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 274
icyzkungz 0:f73c80b36c20 275 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 276 pc.printf("\nChange Ki of Right Hip to %f",temp);
icyzkungz 0:f73c80b36c20 277
icyzkungz 0:f73c80b36c20 278 bcom.setUpMotorKi(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 279 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KI_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 280
icyzkungz 0:f73c80b36c20 281 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 282
icyzkungz 0:f73c80b36c20 283 } else if(option == 15) { //Right Hip
icyzkungz 0:f73c80b36c20 284 do {
icyzkungz 0:f73c80b36c20 285 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 286 pc.printf("\nInput Kd of Right Hip\n");
icyzkungz 0:f73c80b36c20 287 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 288
icyzkungz 0:f73c80b36c20 289 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 290 pc.printf("\nChange Kd of Right Hip to %f",temp);
icyzkungz 0:f73c80b36c20 291
icyzkungz 0:f73c80b36c20 292 bcom.setUpMotorKd(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 293 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KD_UPPER_MOTOR);
icyzkungz 0:f73c80b36c20 294
icyzkungz 0:f73c80b36c20 295 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 296
icyzkungz 0:f73c80b36c20 297
icyzkungz 0:f73c80b36c20 298 } else if(option == 16) {
icyzkungz 0:f73c80b36c20 299 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 300 /*******************************Save Right Hip data*************************************/
icyzkungz 0:f73c80b36c20 301
icyzkungz 0:f73c80b36c20 302
icyzkungz 0:f73c80b36c20 303 } else if(option == 17) { //Right Knee
icyzkungz 0:f73c80b36c20 304 do {
icyzkungz 0:f73c80b36c20 305 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 306 pc.printf("\nInput Kp of Right Knee\n");
icyzkungz 0:f73c80b36c20 307 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 308
icyzkungz 0:f73c80b36c20 309 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 310 pc.printf("\nChange Kp of Right Knee to %f",temp);
icyzkungz 0:f73c80b36c20 311
icyzkungz 0:f73c80b36c20 312 bcom.setLowMotorKp(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 313 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KP_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 314
icyzkungz 0:f73c80b36c20 315 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 316
icyzkungz 0:f73c80b36c20 317 } else if(option == 18) { //Right Knee
icyzkungz 0:f73c80b36c20 318 do {
icyzkungz 0:f73c80b36c20 319 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 320 pc.printf("\nInput Ki of Right Knee\n");
icyzkungz 0:f73c80b36c20 321 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 322
icyzkungz 0:f73c80b36c20 323 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 324 pc.printf("\nChange Ki of Right Knee to %f Degree\n",temp);
icyzkungz 0:f73c80b36c20 325
icyzkungz 0:f73c80b36c20 326 bcom.setLowMotorKi(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 327 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KI_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 328
icyzkungz 0:f73c80b36c20 329 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 330
icyzkungz 0:f73c80b36c20 331 } else if(option == 19) { //Right Knee
icyzkungz 0:f73c80b36c20 332 do {
icyzkungz 0:f73c80b36c20 333 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 334 pc.printf("\nInput Kd of Right Knee\n");
icyzkungz 0:f73c80b36c20 335 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 336
icyzkungz 0:f73c80b36c20 337 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 338 pc.printf("\nChange Kd of Right Knee to %f",temp);
icyzkungz 0:f73c80b36c20 339
icyzkungz 0:f73c80b36c20 340 bcom.setLowMotorKd(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 341 } else bcom.saveDataToEEPROM(RIGHT_SIDE,KD_LOWER_MOTOR);
icyzkungz 0:f73c80b36c20 342
icyzkungz 0:f73c80b36c20 343 } while(temp != 9999);
icyzkungz 0:f73c80b36c20 344
icyzkungz 0:f73c80b36c20 345 } else if(option == 20) {
icyzkungz 0:f73c80b36c20 346 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 347 /*******************************Save Right Knee data*************************************/
icyzkungz 0:f73c80b36c20 348
icyzkungz 0:f73c80b36c20 349
icyzkungz 0:f73c80b36c20 350 } else if(option == 21) { //Left Hip Margin
icyzkungz 0:f73c80b36c20 351 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 352 pc.printf("Input Margin\n");
icyzkungz 0:f73c80b36c20 353 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 354
icyzkungz 0:f73c80b36c20 355 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 356 pc.printf("\nChange Left Hip Margin to %f\n",temp);
icyzkungz 0:f73c80b36c20 357 bcom.setUpMargin(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 358 } else bcom.saveDataToEEPROM(LEFT_SIDE,UP_MARGIN);
icyzkungz 0:f73c80b36c20 359 }
icyzkungz 0:f73c80b36c20 360
icyzkungz 0:f73c80b36c20 361 else if(option == 22) { //Left Knee Margin
icyzkungz 0:f73c80b36c20 362 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 363 pc.printf("Input Margin\n");
icyzkungz 0:f73c80b36c20 364 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 365
icyzkungz 0:f73c80b36c20 366 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 367 pc.printf("\nChange Left Knee Margin to %f\n",temp);
icyzkungz 0:f73c80b36c20 368 bcom.setLowMargin(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 369 } else bcom.saveDataToEEPROM(LEFT_SIDE,LOW_MARGIN);
icyzkungz 0:f73c80b36c20 370 }
icyzkungz 0:f73c80b36c20 371
icyzkungz 0:f73c80b36c20 372 else if(option == 23) { //Right Hip Margin
icyzkungz 0:f73c80b36c20 373 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 374 pc.printf("Input Margin\n");
icyzkungz 0:f73c80b36c20 375 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 376
icyzkungz 0:f73c80b36c20 377 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 378 pc.printf("\nChange Right Hip Margin to %f\n",temp);
icyzkungz 0:f73c80b36c20 379 bcom.setUpMargin(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 380 } else bcom.saveDataToEEPROM(RIGHT_SIDE,UP_MARGIN);
icyzkungz 0:f73c80b36c20 381 }
icyzkungz 0:f73c80b36c20 382
icyzkungz 0:f73c80b36c20 383 else if(option == 24) { //Right Knee Margin
icyzkungz 0:f73c80b36c20 384 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 385 pc.printf("Input Margin\n");
icyzkungz 0:f73c80b36c20 386 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 387
icyzkungz 0:f73c80b36c20 388 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 389 pc.printf("\nChange Right Knee Margin to %f\n",temp);
icyzkungz 0:f73c80b36c20 390 bcom.setLowMargin(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 391 } else bcom.saveDataToEEPROM(RIGHT_SIDE,LOW_MARGIN);
icyzkungz 0:f73c80b36c20 392 }
icyzkungz 0:f73c80b36c20 393
icyzkungz 3:b7a8a60085c1 394 else if(option == 25) { //Lenght of Left Link Hip
icyzkungz 3:b7a8a60085c1 395 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 3:b7a8a60085c1 396 pc.printf("Input Lenght of Left Link Hip\n");
icyzkungz 3:b7a8a60085c1 397 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 398
icyzkungz 3:b7a8a60085c1 399 if(temp != 9999) {
icyzkungz 3:b7a8a60085c1 400 pc.printf("\nLenght of Left Link Hip = %f\n",temp);
icyzkungz 3:b7a8a60085c1 401 LLink0 = temp;
icyzkungz 3:b7a8a60085c1 402 a = true;
icyzkungz 3:b7a8a60085c1 403 bcom.setUpLinkLength(LEFT_SIDE,temp);
icyzkungz 3:b7a8a60085c1 404 } else bcom.saveDataToEEPROM(LEFT_SIDE,UP_LINK_LENGTH);
icyzkungz 3:b7a8a60085c1 405 }
icyzkungz 3:b7a8a60085c1 406
icyzkungz 3:b7a8a60085c1 407 else if(option == 26) { //Lenght of Left Link Knee
icyzkungz 3:b7a8a60085c1 408 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 3:b7a8a60085c1 409 pc.printf("Input Lenght of Left Link Knee\n");
icyzkungz 3:b7a8a60085c1 410 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 411
icyzkungz 3:b7a8a60085c1 412 if(temp != 9999) {
icyzkungz 3:b7a8a60085c1 413 pc.printf("\nLenght of Left Link Knee = %f\n",temp);
icyzkungz 3:b7a8a60085c1 414 LLink1 = temp;
icyzkungz 3:b7a8a60085c1 415 b = true;
icyzkungz 3:b7a8a60085c1 416 bcom.setLowLinkLength(LEFT_SIDE,temp);
icyzkungz 3:b7a8a60085c1 417 } else bcom.saveDataToEEPROM(LEFT_SIDE,LOW_LINK_LENGTH);
icyzkungz 3:b7a8a60085c1 418 }
icyzkungz 3:b7a8a60085c1 419
icyzkungz 3:b7a8a60085c1 420 else if(option == 27) { //Lenght of Right Link Hip
icyzkungz 3:b7a8a60085c1 421 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 3:b7a8a60085c1 422 pc.printf("Input Lenght of Right Link Hip\n");
icyzkungz 3:b7a8a60085c1 423 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 424
icyzkungz 3:b7a8a60085c1 425 if(temp != 9999) {
icyzkungz 3:b7a8a60085c1 426 pc.printf("\nLenght of Right Link Hip = %f\n",temp);
icyzkungz 3:b7a8a60085c1 427 RLink0 = temp;
icyzkungz 3:b7a8a60085c1 428 c = true;
icyzkungz 3:b7a8a60085c1 429 bcom.setUpLinkLength(RIGHT_SIDE,temp);
icyzkungz 3:b7a8a60085c1 430 } else bcom.saveDataToEEPROM(RIGHT_SIDE,UP_LINK_LENGTH);
icyzkungz 3:b7a8a60085c1 431 }
icyzkungz 0:f73c80b36c20 432
icyzkungz 3:b7a8a60085c1 433 else if(option == 28) { //Lenght of Right Link Knee
icyzkungz 3:b7a8a60085c1 434 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 3:b7a8a60085c1 435 pc.printf("Input Lenght of Right Link Knee\n");
icyzkungz 3:b7a8a60085c1 436 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 437
icyzkungz 3:b7a8a60085c1 438 if(temp != 9999) {
icyzkungz 3:b7a8a60085c1 439 pc.printf("\nLenght of Right Link Knee = %f\n",temp);
icyzkungz 3:b7a8a60085c1 440 RLink1 = temp;
icyzkungz 3:b7a8a60085c1 441 d = true;
icyzkungz 3:b7a8a60085c1 442 bcom.setLowLinkLength(RIGHT_SIDE,temp);
icyzkungz 3:b7a8a60085c1 443 } else bcom.saveDataToEEPROM(RIGHT_SIDE,LOW_LINK_LENGTH);
icyzkungz 0:f73c80b36c20 444 }
icyzkungz 0:f73c80b36c20 445
icyzkungz 3:b7a8a60085c1 446 else if(option == 29) { //Offset
icyzkungz 3:b7a8a60085c1 447 if(a == true && b == true && c == true && d == true) {
icyzkungz 3:b7a8a60085c1 448 float LHipAngle,LKneeAngle;
icyzkungz 3:b7a8a60085c1 449 float RHipAngle,RKneeAngle;
icyzkungz 3:b7a8a60085c1 450 //bcom.getMotorPos(LEFT_SIDE,&LHipAngle,&LKneeAngle);
icyzkungz 3:b7a8a60085c1 451 pc.printf("1\n");
icyzkungz 3:b7a8a60085c1 452 //bcom.getMotorPos(RIGHT_SIDE,&RHipAngle,&RKneeAngle);
icyzkungz 3:b7a8a60085c1 453 pc.printf("2\n");
icyzkungz 0:f73c80b36c20 454
icyzkungz 3:b7a8a60085c1 455 pc.printf("Kinematic");
icyzkungz 3:b7a8a60085c1 456 Left.set_Link_Hip(LLink0);
icyzkungz 3:b7a8a60085c1 457 Left.set_Link_Knee(LLink1);
icyzkungz 3:b7a8a60085c1 458 Left.set_Zeta_Hip(LHipAngle);
icyzkungz 3:b7a8a60085c1 459 Left.set_Zeta_Knee(LKneeAngle);
icyzkungz 3:b7a8a60085c1 460
icyzkungz 3:b7a8a60085c1 461 Right.set_Link_Hip(RLink0);
icyzkungz 3:b7a8a60085c1 462 Right.set_Link_Knee(RLink1);
icyzkungz 3:b7a8a60085c1 463 Right.set_Zeta_Hip(RHipAngle);
icyzkungz 3:b7a8a60085c1 464 Right.set_Zeta_Knee(RKneeAngle);
icyzkungz 3:b7a8a60085c1 465 //LHipAngle = RHipAngle = LKneeAngle = RKneeAngle = 20; //Test Recieve Value
icyzkungz 3:b7a8a60085c1 466 //Kinematic Left('Z',LLink0,LLink1,LHipAngle,LKneeAngle);
icyzkungz 3:b7a8a60085c1 467 pc.printf("Obj1\n");
icyzkungz 3:b7a8a60085c1 468 //Kinematic Right('Z',RLink0,RLink1,RHipAngle,RKneeAngle);
icyzkungz 3:b7a8a60085c1 469 pc.printf("End Kinematic\n");
icyzkungz 0:f73c80b36c20 470
icyzkungz 3:b7a8a60085c1 471 float offset_Y,offset_Z;
icyzkungz 3:b7a8a60085c1 472 float y1,y2,z1,z2;
icyzkungz 3:b7a8a60085c1 473 y1 = Left.get_Position_Y();
icyzkungz 3:b7a8a60085c1 474 y2 = Right.get_Position_Y();
icyzkungz 3:b7a8a60085c1 475 z1 = Left.get_Position_Z();
icyzkungz 3:b7a8a60085c1 476 z2 = Right.get_Position_Z();
icyzkungz 3:b7a8a60085c1 477 offset_Y = y1-y2;
icyzkungz 3:b7a8a60085c1 478 offset_Z = z1-z2;
icyzkungz 3:b7a8a60085c1 479
icyzkungz 3:b7a8a60085c1 480 bcom.setOffset(LEFT_SIDE,offset_Y,offset_Z);
icyzkungz 3:b7a8a60085c1 481 pc.printf("3\n");
icyzkungz 3:b7a8a60085c1 482 bcom.saveDataToEEPROM(LEFT_SIDE,OFFSET);
icyzkungz 3:b7a8a60085c1 483
icyzkungz 3:b7a8a60085c1 484 } else {
icyzkungz 3:b7a8a60085c1 485 pc.printf("\nYou have to do choice 25-27 first\n\n");
icyzkungz 3:b7a8a60085c1 486 wait(2);
icyzkungz 3:b7a8a60085c1 487 }
icyzkungz 0:f73c80b36c20 488 }
icyzkungz 0:f73c80b36c20 489
icyzkungz 3:b7a8a60085c1 490 else if(option == 30) { //setBodyWidth
icyzkungz 3:b7a8a60085c1 491 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 3:b7a8a60085c1 492 pc.printf("Input Body Width\n");
icyzkungz 3:b7a8a60085c1 493 pc.scanf("%f",&temp);
icyzkungz 3:b7a8a60085c1 494 pc.printf("\nBody Lenght = %f\n",temp);
icyzkungz 3:b7a8a60085c1 495 bcom.setBodyWidth(LEFT_SIDE,temp);
icyzkungz 3:b7a8a60085c1 496 bcom.saveDataToEEPROM(LEFT_SIDE,BODY_WIDTH);
icyzkungz 0:f73c80b36c20 497 }
icyzkungz 0:f73c80b36c20 498
icyzkungz 3:b7a8a60085c1 499 else if(option == 31) { //Set Maximum Hip Angle Range
icyzkungz 0:f73c80b36c20 500 do {
icyzkungz 0:f73c80b36c20 501 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 502 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 503 pc.printf("2) Right Side\n");
icyzkungz 3:b7a8a60085c1 504 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 505
icyzkungz 0:f73c80b36c20 506 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 507 pc.printf("Input Maximum Hip Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 508 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 509
icyzkungz 0:f73c80b36c20 510 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 511 pc.printf("\nMaximum Hip Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 512 bcom.setUpAngleRange(LEFT_SIDE,temp,Lmin.Hip);
icyzkungz 0:f73c80b36c20 513 Lmax.Hip = temp;
icyzkungz 0:f73c80b36c20 514 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 515
icyzkungz 0:f73c80b36c20 516 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 517 pc.printf("Input Maximum Hip Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 518 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 519
icyzkungz 0:f73c80b36c20 520 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 521 pc.printf("\nMaximum Hip Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 522 bcom.setUpAngleRange(RIGHT_SIDE,temp,Rmin.Hip);
icyzkungz 0:f73c80b36c20 523 Rmax.Hip = temp;
icyzkungz 0:f73c80b36c20 524 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 525 }
icyzkungz 0:f73c80b36c20 526 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 527 }
icyzkungz 0:f73c80b36c20 528
icyzkungz 3:b7a8a60085c1 529 else if(option == 32) { //Set Minumum Hip Angle Range
icyzkungz 0:f73c80b36c20 530 do {
icyzkungz 0:f73c80b36c20 531 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 532 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 533 pc.printf("2) Right Side\n");
icyzkungz 3:b7a8a60085c1 534 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 535
icyzkungz 0:f73c80b36c20 536 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 537 pc.printf("Input Minumum Hip Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 538 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 539
icyzkungz 0:f73c80b36c20 540 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 541 pc.printf("\nMinumum Hip Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 542 bcom.setLowAngleRange(LEFT_SIDE,Lmax.Hip,temp);
icyzkungz 0:f73c80b36c20 543 Lmin.Hip = temp;
icyzkungz 0:f73c80b36c20 544 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 545
icyzkungz 0:f73c80b36c20 546 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 547 pc.printf("Input Minumum Hip Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 548 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 549
icyzkungz 0:f73c80b36c20 550 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 551 pc.printf("\nMinumum Hip Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 552 bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Hip,temp);
icyzkungz 0:f73c80b36c20 553 Rmin.Hip = temp;
icyzkungz 0:f73c80b36c20 554 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 555 }
icyzkungz 0:f73c80b36c20 556 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 557 }
icyzkungz 0:f73c80b36c20 558
icyzkungz 0:f73c80b36c20 559
icyzkungz 3:b7a8a60085c1 560 else if(option == 33) { //Set Maximum Knee Angle Range
icyzkungz 0:f73c80b36c20 561 do {
icyzkungz 0:f73c80b36c20 562 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 563 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 564 pc.printf("2) Right Side\n");
icyzkungz 3:b7a8a60085c1 565 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 566
icyzkungz 0:f73c80b36c20 567 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 568 pc.printf("Input Maximum Knee Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 569 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 570
icyzkungz 0:f73c80b36c20 571 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 572 pc.printf("\nMaximum Knee Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 573 bcom.setLowAngleRange(LEFT_SIDE,temp,Lmin.Knee);
icyzkungz 0:f73c80b36c20 574 Lmax.Knee = temp;
icyzkungz 0:f73c80b36c20 575 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 576
icyzkungz 0:f73c80b36c20 577 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 578 pc.printf("Input Maximum Knee Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 579 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 580
icyzkungz 0:f73c80b36c20 581 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 582 pc.printf("\nMaximum Knee Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 583 bcom.setLowAngleRange(RIGHT_SIDE,temp,Rmin.Knee);
icyzkungz 0:f73c80b36c20 584 Rmax.Knee = temp;
icyzkungz 0:f73c80b36c20 585 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 586 }
icyzkungz 0:f73c80b36c20 587 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 588 }
icyzkungz 0:f73c80b36c20 589
icyzkungz 3:b7a8a60085c1 590 else if(option == 34) { //Set Minumum Knee Angle Range
icyzkungz 0:f73c80b36c20 591 do {
icyzkungz 0:f73c80b36c20 592 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 593 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 594 pc.printf("2) Right Side\n");
icyzkungz 3:b7a8a60085c1 595 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 596
icyzkungz 0:f73c80b36c20 597 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 598 pc.printf("Input Minumum Knee Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 599 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 600
icyzkungz 0:f73c80b36c20 601 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 602 pc.printf("\nMinumum Knee Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 603 bcom.setLowAngleRange(LEFT_SIDE,Lmax.Knee,temp);
icyzkungz 0:f73c80b36c20 604 Lmin.Knee = temp;
icyzkungz 0:f73c80b36c20 605 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 606
icyzkungz 0:f73c80b36c20 607 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 608 pc.printf("Input Minumum Knee Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 609 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 610
icyzkungz 0:f73c80b36c20 611 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 612 pc.printf("\nMinumum Knee Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 613 bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Knee,temp);
icyzkungz 0:f73c80b36c20 614 Rmin.Knee = temp;
icyzkungz 0:f73c80b36c20 615 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 616 }
icyzkungz 0:f73c80b36c20 617 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 618 }
icyzkungz 0:f73c80b36c20 619
icyzkungz 0:f73c80b36c20 620
icyzkungz 0:f73c80b36c20 621
icyzkungz 0:f73c80b36c20 622
icyzkungz 0:f73c80b36c20 623
icyzkungz 0:f73c80b36c20 624
icyzkungz 1:183e6088a1fa 625 else if(option == 40) {
icyzkungz 0:f73c80b36c20 626 pc.printf("Are You Sure ?\n");
icyzkungz 0:f73c80b36c20 627 pc.printf("\n1) Yes\n");
icyzkungz 0:f73c80b36c20 628 pc.printf("2) No\n");
icyzkungz 0:f73c80b36c20 629
icyzkungz 0:f73c80b36c20 630 pc.scanf("%d",&option);
icyzkungz 0:f73c80b36c20 631 if(option==1) {
icyzkungz 1:183e6088a1fa 632 option = 40;
icyzkungz 0:f73c80b36c20 633 pc.printf("Please Push Button Restart\n");
icyzkungz 0:f73c80b36c20 634 } else pc.printf("Return to Main Menu\n");
icyzkungz 0:f73c80b36c20 635
icyzkungz 0:f73c80b36c20 636 }
icyzkungz 0:f73c80b36c20 637
icyzkungz 0:f73c80b36c20 638
icyzkungz 2:d6be1c49d9d5 639 else { // if user has entered invalid choice
icyzkungz 1:183e6088a1fa 640 pc.printf("\nInvalid Option entered\n");
icyzkungz 0:f73c80b36c20 641 }
icyzkungz 2:d6be1c49d9d5 642 } while(option != 40);
icyzkungz 0:f73c80b36c20 643
icyzkungz 0:f73c80b36c20 644 }
icyzkungz 0:f73c80b36c20 645
icyzkungz 0:f73c80b36c20 646 int main()
icyzkungz 0:f73c80b36c20 647 {
icyzkungz 0:f73c80b36c20 648 pc.baud(115200);
icyzkungz 1:183e6088a1fa 649 pc.printf("Start\n");
icyzkungz 0:f73c80b36c20 650
icyzkungz 1:183e6088a1fa 651 if(!button) {
icyzkungz 1:183e6088a1fa 652 while(!button);
icyzkungz 0:f73c80b36c20 653 SwMode();
icyzkungz 1:183e6088a1fa 654 }
icyzkungz 1:183e6088a1fa 655
icyzkungz 0:f73c80b36c20 656 }
icyzkungz 0:f73c80b36c20 657
icyzkungz 0:f73c80b36c20 658 /*int main()
icyzkungz 0:f73c80b36c20 659 {
icyzkungz 0:f73c80b36c20 660 pc.baud(115200);
icyzkungz 0:f73c80b36c20 661 int num;
icyzkungz 0:f73c80b36c20 662 do {
icyzkungz 0:f73c80b36c20 663 //float num;
icyzkungz 0:f73c80b36c20 664 //Float number --> Working
icyzkungz 0:f73c80b36c20 665 pc.printf("Start\n");
icyzkungz 0:f73c80b36c20 666 pc.scanf("%d",&num);
icyzkungz 0:f73c80b36c20 667 pc.printf("temp : %d\n",num);
icyzkungz 0:f73c80b36c20 668 if( num == 15 )
icyzkungz 0:f73c80b36c20 669 pc.printf("Yes\n");
icyzkungz 0:f73c80b36c20 670 pc.printf("End\n");
icyzkungz 0:f73c80b36c20 671 } while(num!=20);
icyzkungz 0:f73c80b36c20 672 }*/