The final program for the #include AIR robot

Dependencies:   Biquad HIDScope QEI angleandposition controlandadjust mbed

Fork of includeair by BioRobotics

Committer:
Gerth
Date:
Wed Oct 14 14:17:14 2015 +0000
Revision:
8:54a7da09ccad
Parent:
7:7fbb2c028778
Child:
9:4ee354663560
added calibration for left arm, now right arm and emg control

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gerth 0:dd66fff537d7 1 #include "mbed.h"
Gerth 1:917c07a4f3ec 2 #include "QEI.h"
Gerth 1:917c07a4f3ec 3 #include "HIDScope.h"
Gerth 1:917c07a4f3ec 4 #include "Biquad.h"
Gerth 1:917c07a4f3ec 5 #include "controlandadjust.h"
Gerth 1:917c07a4f3ec 6
Gerth 1:917c07a4f3ec 7 //info out
Gerth 1:917c07a4f3ec 8 HIDScope scope(4);
Gerth 1:917c07a4f3ec 9 Ticker scope_ticker;
Gerth 3:48438eea184e 10 const double scope_frequency=500;
Gerth 1:917c07a4f3ec 11 Serial pc(USBTX,USBRX);
Gerth 1:917c07a4f3ec 12
Gerth 1:917c07a4f3ec 13 ////////////////ENCODERS
Gerth 7:7fbb2c028778 14 const float cpr=32;
Gerth 7:7fbb2c028778 15 QEI encoder1(D12,D13,NC,cpr);/// maybe use Encoder in stead of QEI, because Encoder had setposition
Gerth 7:7fbb2c028778 16 QEI encoder2(D10,D11,NC,cpr);
Gerth 7:7fbb2c028778 17 const float PIE=3.14159265359;
Gerth 7:7fbb2c028778 18 const float counttorad=(cpr/(2*PIE));
Gerth 1:917c07a4f3ec 19
Gerth 6:37c94a5e205f 20 /////////////////////////////////CALIBRATION (MODE)
Gerth 8:54a7da09ccad 21 int modecounter=1;
Gerth 6:37c94a5e205f 22 DigitalIn changemodebutton(PTA4);
Gerth 6:37c94a5e205f 23
Gerth 7:7fbb2c028778 24 Ticker readbuttoncalibrate_ticker;
Gerth 7:7fbb2c028778 25 const double readbuttoncalibrate_frequency=10;
Gerth 7:7fbb2c028778 26
Gerth 8:54a7da09ccad 27 const double radpersec_calibrate=0.1;
Gerth 8:54a7da09ccad 28
Gerth 8:54a7da09ccad 29 DigitalIn buttonR(D2);
Gerth 8:54a7da09ccad 30 DigitalIn buttonL(D3);
Gerth 8:54a7da09ccad 31
Gerth 1:917c07a4f3ec 32 //////////////////////////////////CONTROLLER
Gerth 1:917c07a4f3ec 33 controlandadjust mycontroller; // make a controller
Gerth 1:917c07a4f3ec 34 //controller constants
Gerth 1:917c07a4f3ec 35 float Kp=0.5;
Gerth 8:54a7da09ccad 36 float Ki=0.001;
Gerth 1:917c07a4f3ec 37 float Kd=0.001;
Gerth 1:917c07a4f3ec 38 Ticker control_ticker;
Gerth 8:54a7da09ccad 39 const double control_frequency=50;
Gerth 7:7fbb2c028778 40 const double Ts_control=1.0/control_frequency;
Gerth 1:917c07a4f3ec 41
Gerth 7:7fbb2c028778 42 float error1_int=0;// storage variables for the errors
Gerth 7:7fbb2c028778 43 float error2_int=0;
Gerth 7:7fbb2c028778 44 float error1_prev=0;
Gerth 7:7fbb2c028778 45 float error2_prev=0;
Gerth 1:917c07a4f3ec 46
Gerth 1:917c07a4f3ec 47 InterruptIn valuechangebutton(PTC6);//button to change controller constants
Gerth 1:917c07a4f3ec 48
Gerth 1:917c07a4f3ec 49 //safetyandthreshold
Gerth 3:48438eea184e 50 AnalogIn safety_pot(A3);//pot 2, used for the safety cutoff value for the pwm
Gerth 3:48438eea184e 51 AnalogIn threshold_pot(A2);//pot1, used to adjust threshold if signal differs per person
Gerth 1:917c07a4f3ec 52
Gerth 1:917c07a4f3ec 53 Ticker safetyandthreshold_ticker; // ticker to read potmeters
Gerth 3:48438eea184e 54 const double safetyandthreshold_frequency=1; // frequency for the ticker
Gerth 3:48438eea184e 55
Gerth 4:bf7765b0f612 56 float threshold_value=1;//initial threshold value
Gerth 1:917c07a4f3ec 57
Gerth 1:917c07a4f3ec 58 ////////////////////////////////FILTER
Gerth 1:917c07a4f3ec 59 #include "filtervalues.h"
Gerth 1:917c07a4f3ec 60 Ticker filter_ticker;
Gerth 3:48438eea184e 61 const double filter_frequency=500;
Gerth 1:917c07a4f3ec 62 Biquad myfilter1;
Gerth 1:917c07a4f3ec 63 Biquad myfilter2;
Gerth 1:917c07a4f3ec 64
Gerth 1:917c07a4f3ec 65 AnalogIn emg1_input(A0);
Gerth 1:917c07a4f3ec 66 AnalogIn emg2_input(A1);
Gerth 1:917c07a4f3ec 67
Gerth 1:917c07a4f3ec 68 double filteredsignal1=0;
Gerth 1:917c07a4f3ec 69 double filteredsignal2=0;
Gerth 5:8ac5d0651e4d 70 float filter_extragain=1;
Gerth 1:917c07a4f3ec 71
Gerth 3:48438eea184e 72 /////////////////READSIGNAL
Gerth 3:48438eea184e 73 Ticker readsignal_ticker;
Gerth 3:48438eea184e 74 const double readsignal_frequency=25;
Gerth 3:48438eea184e 75
Gerth 4:bf7765b0f612 76 DigitalOut led1(D8);
Gerth 4:bf7765b0f612 77 DigitalOut led2(D9);
Gerth 4:bf7765b0f612 78
Gerth 4:bf7765b0f612 79 //////////////////////////////// POSITION AND ANGLE SHIZZLE
Gerth 4:bf7765b0f612 80 float desired_position=0;
Gerth 4:bf7765b0f612 81 float desired_angle[]= {0,0};
Gerth 3:48438eea184e 82
Gerth 1:917c07a4f3ec 83 //////////////////////GO FLAGS AND ACTIVATION FUNCTIONS
Gerth 1:917c07a4f3ec 84 volatile bool scopedata_go=false,
Gerth 1:917c07a4f3ec 85 control_go=false,
Gerth 1:917c07a4f3ec 86 filter_go=false,
Gerth 3:48438eea184e 87 safetyandthreshold_go=false,
Gerth 6:37c94a5e205f 88 readsignal_go=false,
Gerth 8:54a7da09ccad 89 switchedmode=true,
Gerth 7:7fbb2c028778 90 readbuttoncalibrate_go=false;
Gerth 1:917c07a4f3ec 91
Gerth 1:917c07a4f3ec 92 void scopedata_activate()
Gerth 1:917c07a4f3ec 93 {
Gerth 1:917c07a4f3ec 94 scopedata_go=true;
Gerth 1:917c07a4f3ec 95 }
Gerth 1:917c07a4f3ec 96 void control_activate()
Gerth 1:917c07a4f3ec 97 {
Gerth 1:917c07a4f3ec 98 control_go=true;
Gerth 1:917c07a4f3ec 99 }
Gerth 1:917c07a4f3ec 100 void filter_activate()
Gerth 1:917c07a4f3ec 101 {
Gerth 1:917c07a4f3ec 102 filter_go=true;
Gerth 1:917c07a4f3ec 103 }
Gerth 1:917c07a4f3ec 104 void safetyandthreshold_activate()
Gerth 1:917c07a4f3ec 105 {
Gerth 1:917c07a4f3ec 106 safetyandthreshold_go=true;
Gerth 1:917c07a4f3ec 107 }
Gerth 3:48438eea184e 108 void readsignal_activate()
Gerth 3:48438eea184e 109 {
Gerth 3:48438eea184e 110 readsignal_go=true;
Gerth 3:48438eea184e 111 }
Gerth 7:7fbb2c028778 112 void readbuttoncalibrate_activate()
Gerth 7:7fbb2c028778 113 {
Gerth 7:7fbb2c028778 114 readbuttoncalibrate_go=true;
Gerth 7:7fbb2c028778 115 }
Gerth 1:917c07a4f3ec 116
Gerth 1:917c07a4f3ec 117 ////////////////////////FUNCTIONS
Gerth 1:917c07a4f3ec 118 //gather data and send to scope
Gerth 1:917c07a4f3ec 119 void scopedata()
Gerth 1:917c07a4f3ec 120 {
Gerth 8:54a7da09ccad 121 scope.set(0,desired_angle[1]);
Gerth 8:54a7da09ccad 122 scope.set(1,counttorad*encoder2.getPulses());
Gerth 8:54a7da09ccad 123 scope.set(2,mycontroller.motor2pwm());
Gerth 3:48438eea184e 124 scope.send();
Gerth 4:bf7765b0f612 125 }
Gerth 1:917c07a4f3ec 126 //read potmeters and adjust the safetyfactor and threshold
Gerth 1:917c07a4f3ec 127 void safetyandthreshold()
Gerth 1:917c07a4f3ec 128 {
Gerth 3:48438eea184e 129 mycontroller.cutoff((ceil (10*safety_pot.read()) )/10); // adjust the safetyfactor value between 0 and 1 rounded to 1 decimal
Gerth 3:48438eea184e 130 threshold_value=((ceil (10*threshold_pot.read()) )/10); // adjust the threshold value between 0 and 1 rounded to 1 decimal
Gerth 1:917c07a4f3ec 131 }
Gerth 1:917c07a4f3ec 132 /////filter
Gerth 1:917c07a4f3ec 133 void filtereverything()
Gerth 1:917c07a4f3ec 134 {
Gerth 1:917c07a4f3ec 135 //filter_timer.reset();
Gerth 1:917c07a4f3ec 136 // filter_timer.start();
Gerth 1:917c07a4f3ec 137 //pass1 so f1
Gerth 2:c7707856d137 138 double pass1_emg1 = myfilter1.filter(emg1_input.read(), v1_f1_emg1 , v2_f1_emg1 , a1_f1 , a2_f1 , b0_f1 , b1_f1 , b2_f1);
Gerth 2:c7707856d137 139 double pass1_emg2 = myfilter2.filter(emg2_input.read(), v1_f1_emg2 , v2_f1_emg2 , a1_f1 , a2_f1 , b0_f1 , b1_f1 , b2_f1);
Gerth 1:917c07a4f3ec 140
Gerth 1:917c07a4f3ec 141 //pass2 so f2
Gerth 2:c7707856d137 142 double pass2_emg1 = myfilter1.filter(pass1_emg1, v1_f2_emg1 , v2_f2_emg1 , a1_f2 , a2_f2 , b0_f2 , b1_f2 , b2_f2);
Gerth 2:c7707856d137 143 double pass2_emg2 = myfilter2.filter(pass1_emg2, v1_f2_emg2 , v2_f2_emg2 , a1_f2 , a2_f2 , b0_f2 , b1_f2 , b2_f2);
Gerth 1:917c07a4f3ec 144
Gerth 1:917c07a4f3ec 145 //pass3 so f3
Gerth 2:c7707856d137 146 double pass3_emg1 = myfilter1.filter(pass2_emg1, v1_f3_emg1 , v2_f3_emg1 , a1_f3 , a2_f3 , b0_f3 , b1_f3 , b2_f3);
Gerth 2:c7707856d137 147 double pass3_emg2 = myfilter2.filter(pass2_emg2, v1_f3_emg2 , v2_f3_emg2 , a1_f3 , a2_f3 , b0_f3 , b1_f3 , b2_f3);
Gerth 1:917c07a4f3ec 148
Gerth 1:917c07a4f3ec 149 //pass4 so f4
Gerth 2:c7707856d137 150 double pass4_emg1 = myfilter1.filter(pass3_emg1, v1_f4_emg1 , v2_f4_emg1 , a1_f4 , a2_f4 , b0_f4 , b1_f4 , b2_f4);
Gerth 2:c7707856d137 151 double pass4_emg2 = myfilter2.filter(pass3_emg2, v1_f4_emg2 , v2_f4_emg2 , a1_f4 , a2_f4 , b0_f4 , b1_f4 , b2_f4);
Gerth 1:917c07a4f3ec 152
Gerth 1:917c07a4f3ec 153 //pass5 so f5
Gerth 2:c7707856d137 154 double pass5_emg1 = myfilter1.filter(pass4_emg1, v1_f5_emg1 , v2_f5_emg1 , a1_f5 , a2_f5 , b0_f5 , b1_f5 , b2_f5);
Gerth 2:c7707856d137 155 double pass5_emg2 = myfilter2.filter(pass4_emg2, v1_f5_emg2 , v2_f5_emg2 , a1_f5 , a2_f5 , b0_f5 , b1_f5 , b2_f5);
Gerth 1:917c07a4f3ec 156
Gerth 1:917c07a4f3ec 157 ///// take absolute value
Gerth 2:c7707856d137 158 double pass5_emg1_abs=(fabs(pass5_emg1));
Gerth 2:c7707856d137 159 double pass5_emg2_abs=(fabs(pass5_emg2));
Gerth 1:917c07a4f3ec 160
Gerth 1:917c07a4f3ec 161 //pass6 so f6
Gerth 2:c7707856d137 162 double pass6_emg1 = myfilter1.filter(pass5_emg1_abs, v1_f6_emg1 , v2_f6_emg1 , a1_f6 , a2_f6 , b0_f6 , b1_f6 , b2_f6);
Gerth 2:c7707856d137 163 double pass6_emg2 = myfilter2.filter(pass5_emg2_abs, v1_f6_emg2 , v2_f6_emg2 , a1_f6 , a2_f6 , b0_f6 , b1_f6 , b2_f6);
Gerth 1:917c07a4f3ec 164
Gerth 1:917c07a4f3ec 165
Gerth 1:917c07a4f3ec 166 //pass7 so f7
Gerth 2:c7707856d137 167 double pass7_emg1 = myfilter1.filter(pass6_emg1, v1_f7_emg1 , v2_f7_emg1 , a1_f7 , a2_f7 , b0_f7 , b1_f7 , b2_f7);
Gerth 2:c7707856d137 168 double pass7_emg2 = myfilter2.filter(pass6_emg2, v1_f7_emg2 , v2_f7_emg2 , a1_f7 , a2_f7 , b0_f7 , b1_f7 , b2_f7);
Gerth 1:917c07a4f3ec 169
Gerth 2:c7707856d137 170 filteredsignal1=(pass7_emg1*9e11*filter_extragain);
Gerth 2:c7707856d137 171 filteredsignal2=(pass7_emg2*9e11*filter_extragain);
Gerth 1:917c07a4f3ec 172
Gerth 1:917c07a4f3ec 173 //filter_timer.stop();
Gerth 1:917c07a4f3ec 174 }
Gerth 1:917c07a4f3ec 175
Gerth 7:7fbb2c028778 176
Gerth 1:917c07a4f3ec 177
Gerth 1:917c07a4f3ec 178 //adjust controller values when sw2 is pressed
Gerth 1:917c07a4f3ec 179 void valuechange()
Gerth 1:917c07a4f3ec 180 {
Gerth 3:48438eea184e 181 mycontroller.STOP();
Gerth 5:8ac5d0651e4d 182 pc.printf("KP is now %f, enter new value\n",Kp);
Gerth 1:917c07a4f3ec 183 pc.scanf("%f", &Kp);
Gerth 1:917c07a4f3ec 184
Gerth 1:917c07a4f3ec 185 pc.printf("KI is now %f, enter new value\n",Ki);
Gerth 1:917c07a4f3ec 186 pc.scanf("%f", &Ki);
Gerth 1:917c07a4f3ec 187
Gerth 1:917c07a4f3ec 188 pc.printf("KD is now %f, enter new value\n",Kd);
Gerth 5:8ac5d0651e4d 189 pc.scanf("%f", &Kd);
Gerth 3:48438eea184e 190
Gerth 3:48438eea184e 191 pc.printf("Extra gain is now %f, enter new value\n",filter_extragain);
Gerth 5:8ac5d0651e4d 192 pc.scanf("%f", &filter_extragain);
Gerth 1:917c07a4f3ec 193 }
Gerth 3:48438eea184e 194 void readsignal()
Gerth 3:48438eea184e 195 {
Gerth 4:bf7765b0f612 196 if (filteredsignal1>=threshold_value && filteredsignal2>=threshold_value) {
Gerth 4:bf7765b0f612 197 led1=led2=1;
Gerth 4:bf7765b0f612 198 } else if (filteredsignal1>=threshold_value && filteredsignal2<=threshold_value) {
Gerth 4:bf7765b0f612 199 led1=1;
Gerth 4:bf7765b0f612 200 led2=0;
Gerth 4:bf7765b0f612 201 } else if (filteredsignal1<=threshold_value && filteredsignal2>=threshold_value) {
Gerth 4:bf7765b0f612 202 led1=0;
Gerth 4:bf7765b0f612 203 led2=1;
Gerth 3:48438eea184e 204 } else {
Gerth 4:bf7765b0f612 205 led1=led2=0;
Gerth 3:48438eea184e 206 }
Gerth 4:bf7765b0f612 207
Gerth 3:48438eea184e 208 }
Gerth 3:48438eea184e 209
Gerth 6:37c94a5e205f 210 void changemode()
Gerth 6:37c94a5e205f 211 {
Gerth 6:37c94a5e205f 212 switchedmode=true;
Gerth 6:37c94a5e205f 213 modecounter++;
Gerth 6:37c94a5e205f 214 if (modecounter==3) {
Gerth 6:37c94a5e205f 215 modecounter=0;
Gerth 6:37c94a5e205f 216 } else {
Gerth 6:37c94a5e205f 217 modecounter=modecounter;
Gerth 6:37c94a5e205f 218 }
Gerth 6:37c94a5e205f 219 wait(1);
Gerth 6:37c94a5e205f 220 }
Gerth 0:dd66fff537d7 221
Gerth 7:7fbb2c028778 222
Gerth 7:7fbb2c028778 223
Gerth 0:dd66fff537d7 224 int main()
Gerth 0:dd66fff537d7 225 {
Gerth 1:917c07a4f3ec 226 //tickers
Gerth 1:917c07a4f3ec 227 safetyandthreshold_ticker.attach(&safetyandthreshold_activate,1.0/safetyandthreshold_frequency);
Gerth 1:917c07a4f3ec 228 filter_ticker.attach(&filter_activate,1.0/filter_frequency);
Gerth 1:917c07a4f3ec 229 control_ticker.attach(&control_activate,1.0/control_frequency);
Gerth 1:917c07a4f3ec 230 scope_ticker.attach(&scopedata_activate,1.0/scope_frequency);
Gerth 3:48438eea184e 231 readsignal_ticker.attach(&readsignal_activate, 1.0/readsignal_frequency);
Gerth 7:7fbb2c028778 232 readbuttoncalibrate_ticker.attach(&readbuttoncalibrate_activate, 1.0/readbuttoncalibrate_frequency);
Gerth 1:917c07a4f3ec 233
Gerth 1:917c07a4f3ec 234 while(1) {
Gerth 6:37c94a5e205f 235 if (changemodebutton==0) {
Gerth 6:37c94a5e205f 236 changemode();
Gerth 1:917c07a4f3ec 237 }
Gerth 7:7fbb2c028778 238 ///////////////////////////////////////////NORMAL RUNNING MODE
Gerth 7:7fbb2c028778 239 if(modecounter==0) {
Gerth 6:37c94a5e205f 240 if (switchedmode==true) {
Gerth 6:37c94a5e205f 241 encoder1.reset();
Gerth 6:37c94a5e205f 242 encoder2.reset();
Gerth 6:37c94a5e205f 243 pc.printf("Program running\n");//
Gerth 6:37c94a5e205f 244 switchedmode=false;
Gerth 6:37c94a5e205f 245 }
Gerth 6:37c94a5e205f 246 if (scopedata_go==true) {
Gerth 6:37c94a5e205f 247 scopedata();
Gerth 6:37c94a5e205f 248 scopedata_go=false;
Gerth 6:37c94a5e205f 249 }
Gerth 6:37c94a5e205f 250 if (filter_go==true) {
Gerth 6:37c94a5e205f 251 filtereverything();
Gerth 6:37c94a5e205f 252 filter_go=false;
Gerth 6:37c94a5e205f 253 }
Gerth 6:37c94a5e205f 254 if (safetyandthreshold_go==true) {
Gerth 6:37c94a5e205f 255 safetyandthreshold();
Gerth 6:37c94a5e205f 256 safetyandthreshold_go=false;
Gerth 6:37c94a5e205f 257 }
Gerth 6:37c94a5e205f 258 if (control_go==true) {
Gerth 7:7fbb2c028778 259 float error1=0;
Gerth 7:7fbb2c028778 260 float error2=0;
Gerth 7:7fbb2c028778 261 mycontroller.PI(error1,error2,Kp,Ki,Ts_control,error1_int,error2_int);
Gerth 6:37c94a5e205f 262 control_go=false;
Gerth 6:37c94a5e205f 263 }
Gerth 6:37c94a5e205f 264 if (readsignal_go==true) {
Gerth 6:37c94a5e205f 265 readsignal();
Gerth 6:37c94a5e205f 266 readsignal_go=false;
Gerth 6:37c94a5e205f 267 }
Gerth 6:37c94a5e205f 268 valuechangebutton.fall(&valuechange);
Gerth 1:917c07a4f3ec 269 }
Gerth 7:7fbb2c028778 270 ////////////////////////////////////////////////////CALIBRATE RIGHT ARM
Gerth 6:37c94a5e205f 271 if (modecounter==1) {
Gerth 6:37c94a5e205f 272 if(switchedmode==true) {
Gerth 6:37c94a5e205f 273 pc.printf("Calibration mode! Use buttons to move rigth arm to 0 degrees\n");
Gerth 6:37c94a5e205f 274 switchedmode=false;
Gerth 6:37c94a5e205f 275 }
Gerth 7:7fbb2c028778 276 if (control_go==true) {
Gerth 7:7fbb2c028778 277 float error1=(desired_angle[0]-counttorad*encoder1.getPulses()); // this is the error you want to use
Gerth 7:7fbb2c028778 278 float error2=0;
Gerth 7:7fbb2c028778 279 mycontroller.PI(error1,error2,Kp,Ki,Ts_control,error1_int,error2_int);
Gerth 7:7fbb2c028778 280 control_go=false;
Gerth 7:7fbb2c028778 281 }
Gerth 8:54a7da09ccad 282 }
Gerth 8:54a7da09ccad 283 ////////////////////////////////////////////CALIBRATE LEFT ARM
Gerth 8:54a7da09ccad 284 if (modecounter==2) {
Gerth 8:54a7da09ccad 285 if(switchedmode==true) {
Gerth 8:54a7da09ccad 286 pc.printf("Calibration mode! Use buttons to move left arm to 0 degrees\n");
Gerth 8:54a7da09ccad 287 switchedmode=false;
Gerth 8:54a7da09ccad 288 }
Gerth 8:54a7da09ccad 289 if (control_go==true) {
Gerth 8:54a7da09ccad 290 float error1=0;
Gerth 8:54a7da09ccad 291 float error2=(desired_angle[1]-counttorad*encoder2.getPulses());// this is the error you want to use
Gerth 8:54a7da09ccad 292 mycontroller.PI(error1,error2,Kp,Ki,Ts_control,error1_int,error2_int);
Gerth 8:54a7da09ccad 293 control_go=false;
Gerth 8:54a7da09ccad 294
Gerth 8:54a7da09ccad 295 }
Gerth 8:54a7da09ccad 296 if (scopedata_go==true) {
Gerth 8:54a7da09ccad 297 scopedata();
Gerth 8:54a7da09ccad 298 scopedata_go=false;
Gerth 8:54a7da09ccad 299 }
Gerth 8:54a7da09ccad 300 if (safetyandthreshold_go==true) {
Gerth 8:54a7da09ccad 301 safetyandthreshold();
Gerth 8:54a7da09ccad 302 safetyandthreshold_go=false;
Gerth 8:54a7da09ccad 303 }
Gerth 8:54a7da09ccad 304 if (readbuttoncalibrate_go==true) {
Gerth 8:54a7da09ccad 305 if (buttonR.read()==0 && buttonL.read()==1) {
Gerth 8:54a7da09ccad 306 desired_angle[1] += (radpersec_calibrate/readbuttoncalibrate_frequency);
Gerth 8:54a7da09ccad 307 readbuttoncalibrate_go=false;
Gerth 7:7fbb2c028778 308 }
Gerth 8:54a7da09ccad 309 if (buttonR.read()==1 && buttonL.read()==0) {
Gerth 8:54a7da09ccad 310 desired_angle[1] -= (radpersec_calibrate/readbuttoncalibrate_frequency);
Gerth 8:54a7da09ccad 311 readbuttoncalibrate_go=false;
Gerth 7:7fbb2c028778 312 }
Gerth 6:37c94a5e205f 313 }
Gerth 3:48438eea184e 314 }
Gerth 0:dd66fff537d7 315 }
Gerth 8:54a7da09ccad 316 }