Alle subfiles samengevoegd

Dependencies:   HIDScope biquadFilter mbed MODSERIAL FastPWM QEI

Committer:
s1600907
Date:
Mon Oct 24 09:00:05 2016 +0000
Revision:
3:c524afedf863
Parent:
2:92593c9d6146
Child:
4:05c5da1c8b08
in graden

Who changed what in which revision?

UserRevisionLine numberNew contents of line
s1600907 0:c96cf9760185 1 #include "mbed.h"
s1600907 0:c96cf9760185 2 #include "HIDScope.h"
s1600907 0:c96cf9760185 3 #include "BiQuad.h"
s1600907 0:c96cf9760185 4 #include "math.h"
s1600907 1:e1267e72ade8 5 #include "MODSERIAL.h"
s1600907 0:c96cf9760185 6 #define SERIAL_BAUD 115200
s1600907 0:c96cf9760185 7
s1600907 1:e1267e72ade8 8 MODSERIAL pc(USBTX,USBRX);
s1600907 0:c96cf9760185 9 //EMG aansluitingen
s1600907 0:c96cf9760185 10 AnalogIn emg0( A0 ); //Biceps Rechts
s1600907 2:92593c9d6146 11 AnalogIn emg1( A1 ); //Bicpes Links
s1600907 2:92593c9d6146 12 AnalogIn emg2( A2 ); //Upper leg
s1600907 0:c96cf9760185 13 //HIDScope
s1600907 2:92593c9d6146 14 HIDScope scope( 6 ); // aantal channels op de HIDscope
s1600907 0:c96cf9760185 15 //Button om Calibratie te beëindigen
s1600907 0:c96cf9760185 16 InterruptIn Button1(PTC6); // DIT WORDT EEN ANDERE BUTTON
s1600907 0:c96cf9760185 17
s1600907 0:c96cf9760185 18 // Tickers
s1600907 0:c96cf9760185 19 Ticker sample_timer;
s1600907 0:c96cf9760185 20 Ticker TickerCalculationsForTheta;
s1600907 0:c96cf9760185 21
s1600907 0:c96cf9760185 22 //BiQuad
s1600907 0:c96cf9760185 23 // making the biquads and chains; imported from matlab
s1600907 0:c96cf9760185 24 BiQuadChain bqc; //Chain for right biceps
s1600907 0:c96cf9760185 25 BiQuadChain bqc2; //Chain for left biceps
s1600907 0:c96cf9760185 26 BiQuadChain bqc3; //Chain for Upper leg
s1600907 0:c96cf9760185 27 // 1 to 3 are for right biceps
s1600907 0:c96cf9760185 28 BiQuad bq1( 9.14969e-01, -1.82994e+00, 9.14969e-01, -1.82269e+00, 8.37182e-01 );
s1600907 0:c96cf9760185 29 BiQuad bq2( 9.91104e-01, -1.60364e+00, 9.91104e-01, -1.60364e+00, 9.82207e-01 );
s1600907 0:c96cf9760185 30 BiQuad bq3( 8.76555e-05, 1.75311e-04, 8.76555e-05, -1.97334e+00, 9.73695e-01 );
s1600907 0:c96cf9760185 31 // 4 to 6 are for left biceps
s1600907 0:c96cf9760185 32 BiQuad bq4( 9.14969e-01, -1.82994e+00, 9.14969e-01, -1.82269e+00, 8.37182e-01 );
s1600907 0:c96cf9760185 33 BiQuad bq5( 9.91104e-01, -1.60364e+00, 9.91104e-01, -1.60364e+00, 9.82207e-01 );
s1600907 0:c96cf9760185 34 BiQuad bq6( 8.76555e-05, 1.75311e-04, 8.76555e-05, -1.97334e+00, 9.73695e-01 );
s1600907 0:c96cf9760185 35 // 7 to 9 are for upper leg
s1600907 0:c96cf9760185 36 BiQuad bq7( 9.14969e-01, -1.82994e+00, 9.14969e-01, -1.82269e+00, 8.37182e-01 );
s1600907 0:c96cf9760185 37 BiQuad bq8( 9.91104e-01, -1.60364e+00, 9.91104e-01, -1.60364e+00, 9.82207e-01 );
s1600907 0:c96cf9760185 38 BiQuad bq9( 3.91302e-05, 7.82604e-05, 3.91302e-05, -1.98223e+00, 9.82385e-01 );
s1600907 0:c96cf9760185 39
s1600907 1:e1267e72ade8 40
s1600907 0:c96cf9760185 41 // Variabelen voor filter
s1600907 0:c96cf9760185 42 // spier EMG niet boven treshhold
s1600907 0:c96cf9760185 43 volatile bool BicepsLeft = false;
s1600907 0:c96cf9760185 44 volatile bool BicepsRight = false;
s1600907 0:c96cf9760185 45 volatile bool Leg = false;
s1600907 0:c96cf9760185 46
s1600907 0:c96cf9760185 47 // Variabelen voor MotorHoekBerekenen
s1600907 1:e1267e72ade8 48 volatile double x = 0.0; // beginpositie x en y
s1600907 1:e1267e72ade8 49 volatile double y = 305.5;
s1600907 0:c96cf9760185 50 volatile const double pi = 3.14159265359;
s1600907 3:c524afedf863 51 volatile double Theta1Gear = 60.0; // Beginpositie op 60 graden
s1600907 3:c524afedf863 52 volatile double Theta2Gear = 60.0;
s1600907 1:e1267e72ade8 53 volatile double Theta1 = Theta1Gear*42/12; // Beginpositie van MotorHoek
s1600907 1:e1267e72ade8 54 volatile double Theta2 = Theta2Gear*42/12;
s1600907 0:c96cf9760185 55 double Fr_Speed_Theta = 100.0; // frequentie in Hz waarmee theta wordt uigerekend
s1600907 0:c96cf9760185 56 bool Calibration = true; // beginnen met calibreren
s1600907 0:c96cf9760185 57 volatile bool Stepper_State = false; // false = we zijn niet bezig met flippen
s1600907 0:c96cf9760185 58
s1600907 0:c96cf9760185 59 /////////////////////// functies voor filters /////////////////////////////////////////////
s1600907 0:c96cf9760185 60 void sample()
s1600907 0:c96cf9760185 61 {
s1600907 0:c96cf9760185 62 /* Sample function
s1600907 0:c96cf9760185 63 samples the emg0 (of the rightBiceps)
s1600907 0:c96cf9760185 64 samples the emg1 (of the leftBiceps)
s1600907 0:c96cf9760185 65 samples the emg2 (of the Upper leg)
s1600907 0:c96cf9760185 66 filter the singals
s1600907 0:c96cf9760185 67 sends it to HIDScope
s1600907 0:c96cf9760185 68 */
s1600907 0:c96cf9760185 69
s1600907 0:c96cf9760185 70 // Rechts Biceps
s1600907 0:c96cf9760185 71 double inRechts = emg0.read(); // EMG signal
s1600907 0:c96cf9760185 72 double FilterRechts = bqc.step(inRechts); // High pass + Notch (50 HZ)
s1600907 0:c96cf9760185 73 double RectifyRechts = fabs(FilterRechts); // Rectify
s1600907 0:c96cf9760185 74 double outRechts = bq3.step(RectifyRechts); // Low pass
s1600907 2:92593c9d6146 75
s1600907 0:c96cf9760185 76 // Links Biceps
s1600907 0:c96cf9760185 77 double inLinks = emg1.read(); // EMG signal
s1600907 0:c96cf9760185 78 double FilterLinks = bqc2.step(inLinks); // High pass + Notch (50 HZ)
s1600907 0:c96cf9760185 79 double RectifyLinks = fabs(FilterLinks); // Rectify
s1600907 0:c96cf9760185 80 double outLinks = bq6.step(RectifyLinks); // Low pass
s1600907 0:c96cf9760185 81
s1600907 0:c96cf9760185 82 // Upper leg
s1600907 0:c96cf9760185 83 double inBeen = emg2.read(); // EMG signal
s1600907 0:c96cf9760185 84 double FilterBeen = bqc3.step(inBeen); // High pass + Notch (50 HZ)
s1600907 0:c96cf9760185 85 double RectifyBeen = fabs(FilterBeen); // Rectify
s1600907 2:92593c9d6146 86 double outBeen = bq9.step(RectifyBeen); // Low pass
s1600907 0:c96cf9760185 87
s1600907 0:c96cf9760185 88
s1600907 0:c96cf9760185 89 /* EMG signal in channel 0 (the first channel)
s1600907 0:c96cf9760185 90 and the filtered EMG signal in channel 1 (the second channel)
s1600907 0:c96cf9760185 91 of the HIDscope */
s1600907 0:c96cf9760185 92 scope.set(0,inRechts);
s1600907 0:c96cf9760185 93 scope.set(1,outRechts);
s1600907 2:92593c9d6146 94 scope.set(2,inLinks);
s1600907 0:c96cf9760185 95 scope.set(3,outLinks);
s1600907 0:c96cf9760185 96 scope.set(4,inBeen);
s1600907 0:c96cf9760185 97 scope.set(5,outBeen);
s1600907 0:c96cf9760185 98
s1600907 0:c96cf9760185 99 // To indicate that the function is working, the LED is on
s1600907 1:e1267e72ade8 100 if (outRechts >= 0.04){
s1600907 0:c96cf9760185 101 BicepsRight = true;
s1600907 0:c96cf9760185 102 }
s1600907 0:c96cf9760185 103 else{
s1600907 0:c96cf9760185 104 BicepsRight = false;
s1600907 0:c96cf9760185 105 }
s1600907 2:92593c9d6146 106
s1600907 0:c96cf9760185 107 // If Biceps links is actuated then:
s1600907 1:e1267e72ade8 108 if (outLinks >= 0.04){
s1600907 0:c96cf9760185 109 BicepsLeft = true;
s1600907 0:c96cf9760185 110 }
s1600907 0:c96cf9760185 111 else{
s1600907 0:c96cf9760185 112 BicepsLeft = false;
s1600907 0:c96cf9760185 113 }
s1600907 0:c96cf9760185 114 // If upper leg is actuated then:
s1600907 0:c96cf9760185 115 if (outBeen >= 0.01){
s1600907 0:c96cf9760185 116 Leg = true;
s1600907 0:c96cf9760185 117 }
s1600907 0:c96cf9760185 118 else{
s1600907 0:c96cf9760185 119 Leg = false;
s1600907 0:c96cf9760185 120 }
s1600907 0:c96cf9760185 121 }
s1600907 0:c96cf9760185 122
s1600907 0:c96cf9760185 123 ///////////////////// functies voor motorhoekberekenen //////////////////////////
s1600907 0:c96cf9760185 124 // vorige x berekenen
s1600907 0:c96cf9760185 125 double Calc_Prev_x () {
s1600907 0:c96cf9760185 126 double Prev_x = x;
s1600907 0:c96cf9760185 127 //pc.printf("prev x = %f\r\n", Prev_x);
s1600907 0:c96cf9760185 128 return Prev_x;
s1600907 0:c96cf9760185 129 }
s1600907 0:c96cf9760185 130
s1600907 0:c96cf9760185 131 // vorige y berekenen
s1600907 0:c96cf9760185 132 double Calc_Prev_y () {
s1600907 0:c96cf9760185 133 double Prev_y = y;
s1600907 0:c96cf9760185 134 //pc.printf("prev y = %f\r\n", Prev_y);
s1600907 0:c96cf9760185 135 return Prev_y;
s1600907 0:c96cf9760185 136 }
s1600907 0:c96cf9760185 137
s1600907 2:92593c9d6146 138 void FunctieFlipper(); // declarate function, function discribed below
s1600907 0:c96cf9760185 139 // berekenen van de nieuwe x en y waardes
s1600907 0:c96cf9760185 140 bool CalcXY (bool BicepsLeft, bool BicepsRight, bool Leg, bool Stepper_State) {
s1600907 1:e1267e72ade8 141 double Step = 5/Fr_Speed_Theta ; //10 mm per seconde afleggen
s1600907 0:c96cf9760185 142
s1600907 0:c96cf9760185 143 if (BicepsLeft==true && BicepsRight==true && Leg==true && Stepper_State==false) {
s1600907 0:c96cf9760185 144 Stepper_State = true; // we zijn aan het flipper dus geen andere dingen doen
s1600907 2:92593c9d6146 145 FunctieFlipper() ;
s1600907 0:c96cf9760185 146 }
s1600907 0:c96cf9760185 147 else if (BicepsLeft==true && BicepsRight==false && Leg==false && Stepper_State==false) {
s1600907 0:c96cf9760185 148 x = x - Step;
s1600907 0:c96cf9760185 149 }
s1600907 0:c96cf9760185 150 else if (BicepsLeft==false && BicepsRight==true && Leg==false && Stepper_State==false) {
s1600907 0:c96cf9760185 151 x = x + Step; // naar Right bewegen
s1600907 0:c96cf9760185 152 }
s1600907 0:c96cf9760185 153 else if (BicepsLeft==true && BicepsRight==true && Leg==false && Stepper_State==false) {
s1600907 0:c96cf9760185 154 y = y + Step; // naar voren bewegen
s1600907 0:c96cf9760185 155 }
s1600907 0:c96cf9760185 156 else if (BicepsLeft==false && BicepsRight==true && Leg==true && Stepper_State==false) {
s1600907 0:c96cf9760185 157 y = y - Step; // naar achter bewegen
s1600907 0:c96cf9760185 158 }
s1600907 0:c96cf9760185 159 else if (BicepsLeft==false && BicepsRight==false && Leg==false || Stepper_State==true) {
s1600907 0:c96cf9760185 160 }
s1600907 0:c96cf9760185 161
s1600907 0:c96cf9760185 162 // Grenswaardes LET OP: ARMEN MISSCHIEN GEBLOKKEERD DOOR BALK AAN DE BINNENKANT
s1600907 0:c96cf9760185 163 if (x > 200) {
s1600907 0:c96cf9760185 164 x = 200;
s1600907 0:c96cf9760185 165 }
s1600907 0:c96cf9760185 166 else if (x < -200) {
s1600907 0:c96cf9760185 167 x = -200;
s1600907 0:c96cf9760185 168 }
s1600907 0:c96cf9760185 169 if (y > 306) {
s1600907 0:c96cf9760185 170 y = 306;
s1600907 0:c96cf9760185 171 }
s1600907 0:c96cf9760185 172 else if (y < 50) {
s1600907 0:c96cf9760185 173 y = 50; // GOKJE, UITPROBEREN
s1600907 0:c96cf9760185 174 }
s1600907 3:c524afedf863 175 pc.printf("x = %f, y = %f\r\n", x, y);
s1600907 1:e1267e72ade8 176
s1600907 2:92593c9d6146 177 //scope.set(2,x);
s1600907 2:92593c9d6146 178 //scope.set(3,y);
s1600907 0:c96cf9760185 179
s1600907 0:c96cf9760185 180 return Stepper_State;
s1600907 0:c96cf9760185 181 }
s1600907 0:c96cf9760185 182
s1600907 0:c96cf9760185 183 // diagonaal berekenen voor linker arm
s1600907 0:c96cf9760185 184 double CalcDia1 (double x, double y) {
s1600907 0:c96cf9760185 185 double a = 50.0; // de afstand van gekozen assenstelsel tot de armas (assenstelsel precies in het midden) KEERTJE NAMETEN
s1600907 0:c96cf9760185 186 double BV1 = sqrt(pow((a+x),2) + pow(y,2)); // diagonaal (afstand van armas tot locatie) berekenen
s1600907 0:c96cf9760185 187 double Dia1 = pow(BV1,2)/(2*BV1); // berekenen van de afstand oorsprong tot diagonaal
s1600907 0:c96cf9760185 188
s1600907 0:c96cf9760185 189 //pc.printf("dia = %f, x = %f, y= %f\r\n", Dia1, x, y);
s1600907 0:c96cf9760185 190 return Dia1;
s1600907 0:c96cf9760185 191 }
s1600907 0:c96cf9760185 192
s1600907 0:c96cf9760185 193 // diagonaal berekenen voor rechter arm
s1600907 0:c96cf9760185 194 double CalcDia2 (double x, double y) {
s1600907 0:c96cf9760185 195 double a = 50.0;
s1600907 0:c96cf9760185 196 double BV2 = sqrt(pow((x-a),2) + pow(y,2)); // zelfde nog een keer doen maar nu voor de rechter arm
s1600907 0:c96cf9760185 197 double Dia2 = pow(BV2,2)/(2*BV2);
s1600907 0:c96cf9760185 198
s1600907 0:c96cf9760185 199 //pc.printf("dia = %f, x = %f, y= %f\r\n", Dia2, x, y);
s1600907 0:c96cf9760185 200 return Dia2;
s1600907 0:c96cf9760185 201 }
s1600907 0:c96cf9760185 202
s1600907 0:c96cf9760185 203 // calculate Theta1
s1600907 0:c96cf9760185 204 void CalcTheta1 (double Dia1, double Prev_x, double Prev_y) {
s1600907 0:c96cf9760185 205 double a = 50.0;
s1600907 0:c96cf9760185 206 double Bar = 200.0; // lengte van de armen
s1600907 0:c96cf9760185 207 double Prev_Theta1_Gear = Theta1Gear;
s1600907 3:c524afedf863 208 double MaxThetaGear = 100.0; // de hoek voordat arm het opstakel raakt (max hoek is 107.62 tussen arm en opstakel, maken er 100 van voor veiligheid)
s1600907 0:c96cf9760185 209
s1600907 0:c96cf9760185 210 // Hoek berekenen van het grote tandwiel (gear)
s1600907 0:c96cf9760185 211 if (x > -a) {
s1600907 0:c96cf9760185 212 Theta1Gear = pi - atan(y/(x+a)) - acos(Dia1/Bar);
s1600907 0:c96cf9760185 213 }
s1600907 0:c96cf9760185 214 else if (x > -a) {
s1600907 0:c96cf9760185 215 Theta1Gear = pi - (pi + atan(y/(x+a))) - acos(Dia1/Bar);
s1600907 0:c96cf9760185 216 }
s1600907 0:c96cf9760185 217 else { // als x=-a
s1600907 0:c96cf9760185 218 Theta1Gear = 0.5*pi - acos(Dia1/Bar);
s1600907 0:c96cf9760185 219 }
s1600907 3:c524afedf863 220 Theta1Gear = Theta1Gear*180.0/pi; // veranderen van radialen naar graden
s1600907 0:c96cf9760185 221
s1600907 0:c96cf9760185 222 // limiten (als de hoek te groot wordt, reset dan de hoek en de x en y waardes)
s1600907 0:c96cf9760185 223 if (Theta1Gear >= MaxThetaGear) { // is de maximale hoek in radialen
s1600907 0:c96cf9760185 224 Theta1Gear = Prev_Theta1_Gear;
s1600907 0:c96cf9760185 225 x = Prev_x;
s1600907 0:c96cf9760185 226 y = Prev_y;
s1600907 0:c96cf9760185 227 }
s1600907 0:c96cf9760185 228
s1600907 0:c96cf9760185 229 // omrekenen van grote tandwiel naar motortandwiel
s1600907 0:c96cf9760185 230 Theta1 = Theta1Gear*42.0/12.0; // grote tandwiel heeft 42 tanden. Motortandwiel heeft er 12.
s1600907 0:c96cf9760185 231
s1600907 3:c524afedf863 232 pc.printf("thetaMotor = %f, thetaGear = %f, Prev_Gear = %f\r\n", Theta1, Theta1Gear, Prev_Theta1_Gear);
s1600907 0:c96cf9760185 233 }
s1600907 0:c96cf9760185 234
s1600907 0:c96cf9760185 235 void CalcTheta2 (double Dia2, double Prev_x, double Prev_y) {
s1600907 0:c96cf9760185 236 double a = 50.0;
s1600907 0:c96cf9760185 237 double Bar = 200.0; // lengte van de armen
s1600907 0:c96cf9760185 238 double Prev_Theta2_Gear = Theta2Gear;
s1600907 3:c524afedf863 239 double MaxThetaGear = 100.0; // de hoek voordat arm het opstakel raakt (max hoek is 107.62 tussen arm en opstakel, maken er 100 van voor veiligheid)
s1600907 0:c96cf9760185 240
s1600907 0:c96cf9760185 241 // Hoek berekenen van het grote tandwiel (gear)
s1600907 0:c96cf9760185 242 if (x < a) {
s1600907 0:c96cf9760185 243 Theta2Gear = pi + atan(y/(x-a)) - acos(Dia2/Bar);
s1600907 0:c96cf9760185 244 }
s1600907 0:c96cf9760185 245 else if (x > a) {
s1600907 0:c96cf9760185 246 Theta2Gear = pi - (pi - atan(y/(x-a))) - acos(Dia2/Bar);
s1600907 0:c96cf9760185 247 }
s1600907 0:c96cf9760185 248 else { // als x=a
s1600907 0:c96cf9760185 249 Theta2Gear = 0.5*pi - acos(Dia2/Bar);
s1600907 0:c96cf9760185 250 }
s1600907 3:c524afedf863 251 Theta2Gear = Theta2Gear*180/pi; // veranderen van radialen naar graden
s1600907 0:c96cf9760185 252
s1600907 0:c96cf9760185 253 // limiten (als de hoek te groot wordt, reset dan de hoek en de x en y waardes)
s1600907 0:c96cf9760185 254 if (Theta2Gear >= MaxThetaGear) {
s1600907 0:c96cf9760185 255 Theta2Gear = Prev_Theta2_Gear;
s1600907 0:c96cf9760185 256 x = Prev_x;
s1600907 0:c96cf9760185 257 y = Prev_y;
s1600907 0:c96cf9760185 258 }
s1600907 0:c96cf9760185 259
s1600907 0:c96cf9760185 260 // omrekenen van grote tandwiel naar motortandwiel
s1600907 0:c96cf9760185 261 Theta2 = Theta2Gear*42.0/12.0; // grote tandwiel heeft 42 tanden. Motortandwiel heeft er 12.
s1600907 1:e1267e72ade8 262
s1600907 3:c524afedf863 263 pc.printf("thetaMotor = %f, thetaGear = %f, Prev_Gear = %f\r\n", Theta2, Theta2Gear, Prev_Theta2_Gear);
s1600907 0:c96cf9760185 264 }
s1600907 0:c96cf9760185 265
s1600907 0:c96cf9760185 266 void CalculationsForTheta () {
s1600907 1:e1267e72ade8 267 sample();
s1600907 0:c96cf9760185 268 double Prev_x = Calc_Prev_x ();
s1600907 0:c96cf9760185 269 double Prev_y = Calc_Prev_y ();
s1600907 0:c96cf9760185 270 bool Stepper_State = CalcXY (BicepsLeft, BicepsRight, Leg, Stepper_State);
s1600907 0:c96cf9760185 271 double Dia1 = CalcDia1 (x, y);
s1600907 0:c96cf9760185 272 double Dia2 = CalcDia2 (x, y);
s1600907 0:c96cf9760185 273 CalcTheta1 (Dia1, Prev_x, Prev_y);
s1600907 1:e1267e72ade8 274 CalcTheta2 (Dia2, Prev_x, Prev_y);
s1600907 2:92593c9d6146 275
s1600907 1:e1267e72ade8 276 scope.send();
s1600907 0:c96cf9760185 277 }
s1600907 0:c96cf9760185 278
s1600907 0:c96cf9760185 279 // als de button ingedrukt wordt dan stoppen we met calibreren
s1600907 0:c96cf9760185 280 void EndCalibration () {
s1600907 0:c96cf9760185 281 Calibration = false;
s1600907 0:c96cf9760185 282 }
s1600907 0:c96cf9760185 283
s1600907 2:92593c9d6146 284 //////////////// functies voor aansturing motoren ///////////////////////////////
s1600907 2:92593c9d6146 285 void FunctieFlipper () {
s1600907 2:92593c9d6146 286 Stepper_State = false;
s1600907 1:e1267e72ade8 287 }
s1600907 0:c96cf9760185 288
s1600907 0:c96cf9760185 289 ////////////////////////// main loop ////////////////////////////////////////////
s1600907 0:c96cf9760185 290 int main()
s1600907 0:c96cf9760185 291 {
s1600907 0:c96cf9760185 292 pc.baud(SERIAL_BAUD);
s1600907 0:c96cf9760185 293 pc.printf("\r\n Nieuwe code uitproberen :) \r\n");
s1600907 0:c96cf9760185 294
s1600907 0:c96cf9760185 295 /* making the biquad chain for filtering the emg
s1600907 0:c96cf9760185 296 notch and high pass */
s1600907 0:c96cf9760185 297 bqc.add( &bq1 ).add( &bq2 );
s1600907 0:c96cf9760185 298 bqc2.add( &bq4 ).add( &bq5 );
s1600907 0:c96cf9760185 299 bqc3.add( &bq7 ).add( &bq8 );
s1600907 0:c96cf9760185 300
s1600907 0:c96cf9760185 301 // Calibreren
s1600907 0:c96cf9760185 302 while (Calibration == true) {
s1600907 1:e1267e72ade8 303 //potmeter dingen aanpassen
s1600907 0:c96cf9760185 304
s1600907 0:c96cf9760185 305 pc.printf("calibreren is bezig\r\n");
s1600907 0:c96cf9760185 306 Button1.fall(&EndCalibration);
s1600907 0:c96cf9760185 307 }
s1600907 0:c96cf9760185 308
s1600907 0:c96cf9760185 309 /**Attach the 'sample' function to the timer 'sample_timer'.
s1600907 0:c96cf9760185 310 * this ensures that 'sample' is executed every 0.002 seconds = 500 Hz
s1600907 0:c96cf9760185 311 */
s1600907 1:e1267e72ade8 312 // sample_timer.attach(&sample, 0.002);
s1600907 2:92593c9d6146 313
s1600907 0:c96cf9760185 314 // ticker voor hoek berekenen aanzetten
s1600907 3:c524afedf863 315 TickerCalculationsForTheta.attach(&CalculationsForTheta,0.002);
s1600907 2:92593c9d6146 316
s1600907 0:c96cf9760185 317 //empty loop, sample() is executed periodically
s1600907 1:e1267e72ade8 318 while(1) {
s1600907 1:e1267e72ade8 319
s1600907 1:e1267e72ade8 320 }
s1600907 0:c96cf9760185 321 }