SwitchMode

Dependencies:   BEAR_Protocol InverseLeg iSerial mbed

Fork of SwitchMode by Arsapol Manamunchaiyaporn

Committer:
icyzkungz
Date:
Fri Jan 22 07:46:51 2016 +0000
Revision:
0:f73c80b36c20
Child:
1:183e6088a1fa
First Public

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 0:f73c80b36c20 7
icyzkungz 0:f73c80b36c20 8 DigitalIn button(USER_BUTTON);
icyzkungz 0:f73c80b36c20 9
icyzkungz 0:f73c80b36c20 10 #define LEFT_SIDE 0x01
icyzkungz 0:f73c80b36c20 11 #define RIGHT_SIDE 0x02
icyzkungz 0:f73c80b36c20 12
icyzkungz 0:f73c80b36c20 13 void SwMode()
icyzkungz 0:f73c80b36c20 14 {
icyzkungz 0:f73c80b36c20 15 int option; // user's entered option will be saved in this variable
icyzkungz 0:f73c80b36c20 16 float temp;
icyzkungz 0:f73c80b36c20 17 float LH,LK,RH,RK;
icyzkungz 0:f73c80b36c20 18 float LLink[2],RLink[2];
icyzkungz 0:f73c80b36c20 19 struct max_ang {
icyzkungz 0:f73c80b36c20 20 float Hip;
icyzkungz 0:f73c80b36c20 21 float Knee;
icyzkungz 0:f73c80b36c20 22 };
icyzkungz 0:f73c80b36c20 23 struct min_ang {
icyzkungz 0:f73c80b36c20 24 float Hip;
icyzkungz 0:f73c80b36c20 25 float Knee;
icyzkungz 0:f73c80b36c20 26 };
icyzkungz 0:f73c80b36c20 27 max_ang Lmax,Lmin;
icyzkungz 0:f73c80b36c20 28 min_ang Rmax,Rmin;
icyzkungz 0:f73c80b36c20 29 Lmax.Knee = Lmax.knee = Lmin.Knee = Lmin.knee = Rmax.Knee = Rmax.knee = Rmin.Knee = Rmin.knee = 0;
icyzkungz 0:f73c80b36c20 30 bool a,b,c,d;
icyzkungz 0:f73c80b36c20 31 a = b = c = d = false;
icyzkungz 0:f73c80b36c20 32 float temp_LH=0,temp_LK=0,temp_RH=0,temp_RK=0;
icyzkungz 0:f73c80b36c20 33 do { // do-while loop starts here.that display menu again and again until user select to exit program
icyzkungz 0:f73c80b36c20 34 // Displaying Options for the menu
icyzkungz 0:f73c80b36c20 35 pc.printf("************Don't Forget to Save Data************\n");
icyzkungz 0:f73c80b36c20 36 pc.printf("*\t1) Motor Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 37 pc.printf("*\t2) Motor Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 38 pc.printf("*\t3) Motor Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 39 pc.printf("*\t4) Motor Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 40 pc.printf("*\t5) Kp : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 41 pc.printf("*\t6) Ki : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 42 pc.printf("*\t7) Kd : Left Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 43 pc.printf("*\t8) Save Left Hip(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 44 pc.printf("*\t9) Kp : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 45 pc.printf("*\t10) Ki : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 46 pc.printf("*\t11) Kd : Left Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 47 pc.printf("*\t12) Save Left Knee(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 48 pc.printf("*\t13) Kp : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 49 pc.printf("*\t14) Ki : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 50 pc.printf("*\t15) Kd : Right Hip \t\t\t*\n");
icyzkungz 0:f73c80b36c20 51 pc.printf("*\t16) Save Right Hip(p,i,d) data\t\t*\n");
icyzkungz 0:f73c80b36c20 52 pc.printf("*\t17) Kp : Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 53 pc.printf("*\t18) Ki : Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 54 pc.printf("*\t19) Kd : Right Knee \t\t\t*\n");
icyzkungz 0:f73c80b36c20 55 pc.printf("*\t20) Save Right Knee data\t\t\t*\n");
icyzkungz 0:f73c80b36c20 56 pc.printf("*\t21) Set Left Hip Margin\n");
icyzkungz 0:f73c80b36c20 57 pc.printf("*\t22) Set Left Knee Margin\n");
icyzkungz 0:f73c80b36c20 58 pc.printf("*\t23) Set Right Hip Margin\n");
icyzkungz 0:f73c80b36c20 59 pc.printf("*\t24) Set Right Knee Margin\n");
icyzkungz 0:f73c80b36c20 60 /*pc.printf("*\t25) Set Lenght of Left Link Hip\n");
icyzkungz 0:f73c80b36c20 61 pc.printf("*\t26) Set Lenght of Left Link Knee\n");
icyzkungz 0:f73c80b36c20 62 pc.printf("*\t27) Set Lenght of Right Link Hip\n");
icyzkungz 0:f73c80b36c20 63 pc.printf("*\t28) Set Lenght of Right Link Knee\n");*/
icyzkungz 0:f73c80b36c20 64 pc.printf("*\t29) Set Offset\n");
icyzkungz 0:f73c80b36c20 65 pc.printf("*\t30) Set Body Lenght of Left Side\n");
icyzkungz 0:f73c80b36c20 66 pc.printf("*\t31) Set Body Lenght of Right Side\n");
icyzkungz 0:f73c80b36c20 67 pc.printf("*\t32) Set Maximum Hip Angle Range\n");
icyzkungz 0:f73c80b36c20 68 pc.printf("*\t33) Set Minimum Hip Angle Range\n");
icyzkungz 0:f73c80b36c20 69 pc.printf("*\t34) Set Maximum Knee Angle Range\n");
icyzkungz 0:f73c80b36c20 70 pc.printf("*\t35) 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 0:f73c80b36c20 394 /*else if(option == 25) { //Lenght of Left Link Hip
icyzkungz 0:f73c80b36c20 395 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 396 pc.printf("Input Lenght of Left Link Hip\n");
icyzkungz 0:f73c80b36c20 397 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 398
icyzkungz 0:f73c80b36c20 399 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 400 pc.printf("\nLenght of Left Link Hip = %f\n",temp);
icyzkungz 0:f73c80b36c20 401 LLink[0] = temp;
icyzkungz 0:f73c80b36c20 402 a = true;
icyzkungz 0:f73c80b36c20 403 bcom.setUpAngleRange(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 404 } else bcom.saveDataToEEPROM(LEFT_SIDE,UP_LINK_LENGTH);
icyzkungz 0:f73c80b36c20 405 }
icyzkungz 0:f73c80b36c20 406
icyzkungz 0:f73c80b36c20 407 else if(option == 26) { //Lenght of Left Link Knee
icyzkungz 0:f73c80b36c20 408 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 409 pc.printf("Input Lenght of Left Link Knee\n");
icyzkungz 0:f73c80b36c20 410 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 411
icyzkungz 0:f73c80b36c20 412 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 413 pc.printf("\nLenght of Left Link Knee = %f\n",temp);
icyzkungz 0:f73c80b36c20 414 LLink[1] = temp;
icyzkungz 0:f73c80b36c20 415 b = true;
icyzkungz 0:f73c80b36c20 416 bcom.setLowAngleRange(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 417 } else bcom.saveDataToEEPROM(LEFT_SIDE,LOW_LINK_LENGTH);
icyzkungz 0:f73c80b36c20 418 }
icyzkungz 0:f73c80b36c20 419
icyzkungz 0:f73c80b36c20 420 else if(option == 27) { //Lenght of Right Link Hip
icyzkungz 0:f73c80b36c20 421 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 422 pc.printf("Input Lenght of Right Link Hip\n");
icyzkungz 0:f73c80b36c20 423 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 424
icyzkungz 0:f73c80b36c20 425 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 426 pc.printf("\nLenght of Right Link Hip = %f\n",temp);
icyzkungz 0:f73c80b36c20 427 RLink[0] = temp;
icyzkungz 0:f73c80b36c20 428 c = true;
icyzkungz 0:f73c80b36c20 429 bcom.setUpAngleRange(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 430 } else bcom.saveDataToEEPROM(RIGHT_SIDE,UP_LINK_LENGTH);
icyzkungz 0:f73c80b36c20 431 }
icyzkungz 0:f73c80b36c20 432
icyzkungz 0:f73c80b36c20 433 else if(option == 29) { //Lenght of Right Link Knee
icyzkungz 0:f73c80b36c20 434 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 435 pc.printf("Input Lenght of Right Link Knee\n");
icyzkungz 0:f73c80b36c20 436 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 437
icyzkungz 0:f73c80b36c20 438 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 439 pc.printf("\nLenght of Right Link Knee = %f\n",temp);
icyzkungz 0:f73c80b36c20 440 RLink[1] = temp;
icyzkungz 0:f73c80b36c20 441 d = true;
icyzkungz 0:f73c80b36c20 442 bcom.setLowAngleRange(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 443 } else bcom.saveDataToEEPROM(RIGHT_SIDE,LOW_LINK_LENGTH);
icyzkungz 0:f73c80b36c20 444 }*/
icyzkungz 0:f73c80b36c20 445
icyzkungz 0:f73c80b36c20 446 else if(option == 29) { //Offset
icyzkungz 0:f73c80b36c20 447 if(a == true && b == true && c == true && d == true) {
icyzkungz 0:f73c80b36c20 448 //float HipAngle[2],KneeAngle[2];
icyzkungz 0:f73c80b36c20 449 float LHipAngle,LKneeAngle;
icyzkungz 0:f73c80b36c20 450 float RHipAngle,RKneeAngle;
icyzkungz 0:f73c80b36c20 451 bcom.getMotorPos(LEFT_SIDE,&LHipAngle,&LKneeAngle);
icyzkungz 0:f73c80b36c20 452 bcom.getMotorPos(RIGHT_SIDE,&RHipAngle,&RKneeAngle);
icyzkungz 0:f73c80b36c20 453
icyzkungz 0:f73c80b36c20 454 Kinematic L( 'Z', LLink[0], LLink[1], LHipAngle, LKneeAngle);
icyzkungz 0:f73c80b36c20 455 Kinematic R( 'Z', RLink[0], RLink[1], RHipAngle, RKneeAngle);
icyzkungz 0:f73c80b36c20 456
icyzkungz 0:f73c80b36c20 457 L.ForwardKinematicCalculation();
icyzkungz 0:f73c80b36c20 458 R.ForwardKinematicCalculation();
icyzkungz 0:f73c80b36c20 459
icyzkungz 0:f73c80b36c20 460 float offset_Y,offset_Z;
icyzkungz 0:f73c80b36c20 461 offset_Y = L.get_Position_Y()-R.get_Position_Y();
icyzkungz 0:f73c80b36c20 462 offset_Z = L.get_Position_Z()-R.get_Position_Z();
icyzkungz 0:f73c80b36c20 463
icyzkungz 0:f73c80b36c20 464 bcom.setOffset(LEFT_SIDE,offset_Y,offset_Z);
icyzkungz 0:f73c80b36c20 465 bcom.saveDataToEEPROM(LEFT_SIDE,OFFSET);
icyzkungz 0:f73c80b36c20 466
icyzkungz 0:f73c80b36c20 467 } else pc.printf("\nYou have to do choice 25-28 first\n\n");
icyzkungz 0:f73c80b36c20 468 }
icyzkungz 0:f73c80b36c20 469
icyzkungz 0:f73c80b36c20 470 else if(option == 30) { //Body Lenght of Left Side
icyzkungz 0:f73c80b36c20 471 do {
icyzkungz 0:f73c80b36c20 472 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 473 pc.printf("Input Body Lenght of Left Side\n");
icyzkungz 0:f73c80b36c20 474 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 475
icyzkungz 0:f73c80b36c20 476 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 477 pc.printf("\nBody Lenght = %f\n",temp);
icyzkungz 0:f73c80b36c20 478 bcom.setBodyLength(LEFT_SIDE,temp);
icyzkungz 0:f73c80b36c20 479 } else bcom.saveDataToEEPROM(LEFT_SIDE,BODY_LENGTH);
icyzkungz 0:f73c80b36c20 480
icyzkungz 0:f73c80b36c20 481 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 482 }
icyzkungz 0:f73c80b36c20 483
icyzkungz 0:f73c80b36c20 484 else if(option == 31) { //Body Lenght of Right Side
icyzkungz 0:f73c80b36c20 485 do {
icyzkungz 0:f73c80b36c20 486 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 487 pc.printf("Input Body Lenght of Right Side\n");
icyzkungz 0:f73c80b36c20 488 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 489
icyzkungz 0:f73c80b36c20 490 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 491 pc.printf("\nBody Lenght = %f\n",temp);
icyzkungz 0:f73c80b36c20 492 bcom.setBodyLength(RIGHT_SIDE,temp);
icyzkungz 0:f73c80b36c20 493 } else bcom.saveDataToEEPROM(RIGHT_SIDE,BODY_LENGTH);
icyzkungz 0:f73c80b36c20 494
icyzkungz 0:f73c80b36c20 495 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 496 }
icyzkungz 0:f73c80b36c20 497
icyzkungz 0:f73c80b36c20 498 else if(option == 32) { //Set Maximum Hip Angle Range
icyzkungz 0:f73c80b36c20 499 do {
icyzkungz 0:f73c80b36c20 500 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 501 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 502 pc.printf("2) Right Side\n");
icyzkungz 0:f73c80b36c20 503 pc.scanf("%f\n",&temp);
icyzkungz 0:f73c80b36c20 504
icyzkungz 0:f73c80b36c20 505 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 506 pc.printf("Input Maximum Hip Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 507 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 508
icyzkungz 0:f73c80b36c20 509 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 510 pc.printf("\nMaximum Hip Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 511 bcom.setUpAngleRange(LEFT_SIDE,temp,Lmin.Hip);
icyzkungz 0:f73c80b36c20 512 Lmax.Hip = temp;
icyzkungz 0:f73c80b36c20 513 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 514
icyzkungz 0:f73c80b36c20 515 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 516 pc.printf("Input Maximum Hip Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 517 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 518
icyzkungz 0:f73c80b36c20 519 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 520 pc.printf("\nMaximum Hip Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 521 bcom.setUpAngleRange(RIGHT_SIDE,temp,Rmin.Hip);
icyzkungz 0:f73c80b36c20 522 Rmax.Hip = temp;
icyzkungz 0:f73c80b36c20 523 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 524 }
icyzkungz 0:f73c80b36c20 525 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 526 }
icyzkungz 0:f73c80b36c20 527
icyzkungz 0:f73c80b36c20 528 else if(option == 33) { //Set Minumum Hip Angle Range
icyzkungz 0:f73c80b36c20 529 do {
icyzkungz 0:f73c80b36c20 530 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 531 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 532 pc.printf("2) Right Side\n");
icyzkungz 0:f73c80b36c20 533 pc.scanf("%f\n",&temp);
icyzkungz 0:f73c80b36c20 534
icyzkungz 0:f73c80b36c20 535 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 536 pc.printf("Input Minumum Hip Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 537 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 538
icyzkungz 0:f73c80b36c20 539 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 540 pc.printf("\nMinumum Hip Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 541 bcom.setLowAngleRange(LEFT_SIDE,Lmax.Hip,temp);
icyzkungz 0:f73c80b36c20 542 Lmin.Hip = temp;
icyzkungz 0:f73c80b36c20 543 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 544
icyzkungz 0:f73c80b36c20 545 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 546 pc.printf("Input Minumum Hip Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 547 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 548
icyzkungz 0:f73c80b36c20 549 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 550 pc.printf("\nMinumum Hip Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 551 bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Hip,temp);
icyzkungz 0:f73c80b36c20 552 Rmin.Hip = temp;
icyzkungz 0:f73c80b36c20 553 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_UP);
icyzkungz 0:f73c80b36c20 554 }
icyzkungz 0:f73c80b36c20 555 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 556 }
icyzkungz 0:f73c80b36c20 557
icyzkungz 0:f73c80b36c20 558
icyzkungz 0:f73c80b36c20 559 else if(option == 34) { //Set Maximum Knee Angle Range
icyzkungz 0:f73c80b36c20 560 do {
icyzkungz 0:f73c80b36c20 561 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 562 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 563 pc.printf("2) Right Side\n");
icyzkungz 0:f73c80b36c20 564 pc.scanf("%f\n",&temp);
icyzkungz 0:f73c80b36c20 565
icyzkungz 0:f73c80b36c20 566 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 567 pc.printf("Input Maximum Knee Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 568 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 569
icyzkungz 0:f73c80b36c20 570 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 571 pc.printf("\nMaximum Knee Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 572 bcom.setLowAngleRange(LEFT_SIDE,temp,Lmin.Knee);
icyzkungz 0:f73c80b36c20 573 Lmax.Knee = temp;
icyzkungz 0:f73c80b36c20 574 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 575
icyzkungz 0:f73c80b36c20 576 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 577 pc.printf("Input Maximum Knee Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 578 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 579
icyzkungz 0:f73c80b36c20 580 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 581 pc.printf("\nMaximum Knee Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 582 bcom.setLowAngleRange(RIGHT_SIDE,temp,Rmin.Knee);
icyzkungz 0:f73c80b36c20 583 Rmax.Knee = temp;
icyzkungz 0:f73c80b36c20 584 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 585 }
icyzkungz 0:f73c80b36c20 586 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 587 }
icyzkungz 0:f73c80b36c20 588
icyzkungz 0:f73c80b36c20 589 else if(option == 32) { //Set Minumum Knee Angle Range
icyzkungz 0:f73c80b36c20 590 do {
icyzkungz 0:f73c80b36c20 591 pc.printf("\nType 9999 to Exit to Main Menu\n");
icyzkungz 0:f73c80b36c20 592 pc.printf("1) Left Side\n");
icyzkungz 0:f73c80b36c20 593 pc.printf("2) Right Side\n");
icyzkungz 0:f73c80b36c20 594 pc.scanf("%f\n",&temp);
icyzkungz 0:f73c80b36c20 595
icyzkungz 0:f73c80b36c20 596 if(temp==1) { //Left
icyzkungz 0:f73c80b36c20 597 pc.printf("Input Minumum Knee Angle Range of Left Side\n");
icyzkungz 0:f73c80b36c20 598 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 599
icyzkungz 0:f73c80b36c20 600 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 601 pc.printf("\nMinumum Knee Angle Range of Left Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 602 bcom.setLowAngleRange(LEFT_SIDE,Lmax.Knee,temp);
icyzkungz 0:f73c80b36c20 603 Lmin.Knee = temp;
icyzkungz 0:f73c80b36c20 604 } else bcom.saveDataToEEPROM(LEFT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 605
icyzkungz 0:f73c80b36c20 606 } else if(temp==2) { //Right
icyzkungz 0:f73c80b36c20 607 pc.printf("Input Minumum Knee Angle Range of Right Side\n");
icyzkungz 0:f73c80b36c20 608 pc.scanf("%f",&temp);
icyzkungz 0:f73c80b36c20 609
icyzkungz 0:f73c80b36c20 610 if(temp != 9999) {
icyzkungz 0:f73c80b36c20 611 pc.printf("\nMinumum Knee Angle Range of Right Side = %f\n",temp);
icyzkungz 0:f73c80b36c20 612 bcom.setLowAngleRange(RIGHT_SIDE,Rmax.Knee,temp);
icyzkungz 0:f73c80b36c20 613 Rmin.Knee = temp;
icyzkungz 0:f73c80b36c20 614 } else bcom.saveDataToEEPROM(RIGHT_SIDE,ANGLE_RANGE_LOW);
icyzkungz 0:f73c80b36c20 615 }
icyzkungz 0:f73c80b36c20 616 } while(temp!=9999);
icyzkungz 0:f73c80b36c20 617 }
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 else if(option == 33) {
icyzkungz 0:f73c80b36c20 625 pc.printf("Are You Sure ?\n");
icyzkungz 0:f73c80b36c20 626 pc.printf("\n1) Yes\n");
icyzkungz 0:f73c80b36c20 627 pc.printf("2) No\n");
icyzkungz 0:f73c80b36c20 628
icyzkungz 0:f73c80b36c20 629 pc.scanf("%d",&option);
icyzkungz 0:f73c80b36c20 630 if(option==1) {
icyzkungz 0:f73c80b36c20 631 option = 23;
icyzkungz 0:f73c80b36c20 632 pc.printf("Please Push Button Restart\n");
icyzkungz 0:f73c80b36c20 633 } else pc.printf("Return to Main Menu\n");
icyzkungz 0:f73c80b36c20 634
icyzkungz 0:f73c80b36c20 635 }
icyzkungz 0:f73c80b36c20 636
icyzkungz 0:f73c80b36c20 637
icyzkungz 0:f73c80b36c20 638 else { // if user has entered invalid choice (other than 1,2,3 or 4)
icyzkungz 0:f73c80b36c20 639 // Displaying error message
icyzkungz 0:f73c80b36c20 640 pc.printf("Invalid Option entered\n");
icyzkungz 0:f73c80b36c20 641 }
icyzkungz 0:f73c80b36c20 642 } while(option != 40); // condition of do-while loop
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 0:f73c80b36c20 649
icyzkungz 0:f73c80b36c20 650 if(button==1)
icyzkungz 0:f73c80b36c20 651 SwMode();
icyzkungz 0:f73c80b36c20 652 }
icyzkungz 0:f73c80b36c20 653
icyzkungz 0:f73c80b36c20 654 /*int main()
icyzkungz 0:f73c80b36c20 655 {
icyzkungz 0:f73c80b36c20 656 pc.baud(115200);
icyzkungz 0:f73c80b36c20 657 int num;
icyzkungz 0:f73c80b36c20 658 do {
icyzkungz 0:f73c80b36c20 659 //float num;
icyzkungz 0:f73c80b36c20 660 //Float number --> Working
icyzkungz 0:f73c80b36c20 661 pc.printf("Start\n");
icyzkungz 0:f73c80b36c20 662 pc.scanf("%d",&num);
icyzkungz 0:f73c80b36c20 663 pc.printf("temp : %d\n",num);
icyzkungz 0:f73c80b36c20 664 if( num == 15 )
icyzkungz 0:f73c80b36c20 665 pc.printf("Yes\n");
icyzkungz 0:f73c80b36c20 666 pc.printf("End\n");
icyzkungz 0:f73c80b36c20 667 } while(num!=20);
icyzkungz 0:f73c80b36c20 668 }*/