NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
main.cpp@24:c5a3cba48498, 2012-11-24 (annotated)
- Committer:
- maetugr
- Date:
- Sat Nov 24 17:24:32 2012 +0000
- Revision:
- 24:c5a3cba48498
- Parent:
- 23:955a7c7ddf8b
- Child:
- 25:0498d3041afa
bevor logeinf?hrung
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 7:9d4313510646 | 1 | #include "mbed.h" // Standard Library |
maetugr | 7:9d4313510646 | 2 | #include "LED.h" // LEDs framework for blinking ;) |
maetugr | 13:4737ee9ebfee | 3 | #include "PC.h" // Serial Port via USB by Roland Elmiger for debugging with Terminal (driver needed: https://mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe) |
maetugr | 7:9d4313510646 | 4 | #include "L3G4200D.h" // Gyro (Gyroscope) |
maetugr | 7:9d4313510646 | 5 | #include "ADXL345.h" // Acc (Accelerometer) |
maetugr | 7:9d4313510646 | 6 | #include "HMC5883.h" // Comp (Compass) |
maetugr | 14:cf260677ecde | 7 | #include "BMP085_old.h" // Alt (Altitude sensor) |
maetugr | 7:9d4313510646 | 8 | #include "RC_Channel.h" // RemoteControl Chnnels with PPM |
maetugr | 15:753c5d6a63b3 | 9 | #include "Servo_PWM.h" // Motor PPM using PwmOut |
maetugr | 13:4737ee9ebfee | 10 | #include "PID.h" // PID Library by Aaron Berk |
maetugr | 0:0c4fafa398b4 | 11 | |
maetugr | 21:c2a2e7cbabdd | 12 | //#define RAD2DEG 57.295779513082320876798154814105 // ratio between radians and degree (360/2Pi) //TODO not needed?? |
maetugr | 15:753c5d6a63b3 | 13 | #define RATE 0.02 // speed of the interrupt for Sensors and PID |
maetugr | 15:753c5d6a63b3 | 14 | |
maetugr | 24:c5a3cba48498 | 15 | |
maetugr | 24:c5a3cba48498 | 16 | #define P_VALUE 0.05 // PID values |
maetugr | 24:c5a3cba48498 | 17 | #define I_VALUE 20 // Werte die bis jetzt am besten funktioniert haben |
maetugr | 24:c5a3cba48498 | 18 | #define D_VALUE 0.015 |
maetugr | 24:c5a3cba48498 | 19 | |
maetugr | 24:c5a3cba48498 | 20 | /* |
maetugr | 24:c5a3cba48498 | 21 | // agressive Werte |
maetugr | 23:955a7c7ddf8b | 22 | #define P_VALUE 0.035 // PID values |
maetugr | 23:955a7c7ddf8b | 23 | #define I_VALUE 3.5 |
maetugr | 23:955a7c7ddf8b | 24 | #define D_VALUE 0.04 |
maetugr | 24:c5a3cba48498 | 25 | */ |
maetugr | 12:67a06c9b69d5 | 26 | |
maetugr | 14:cf260677ecde | 27 | //#define COMPASSCALIBRATE // decomment if you want to calibrate the Compass on start |
maetugr | 21:c2a2e7cbabdd | 28 | #define PC_CONNECTED // decoment if you want to debug per USB and your PC |
maetugr | 2:93f703d2c4d7 | 29 | |
maetugr | 14:cf260677ecde | 30 | Timer GlobalTimer; // global time to calculate processing speed |
maetugr | 14:cf260677ecde | 31 | Ticker Datagetter; // timecontrolled interrupt to get data form IMU and RC |
maetugr | 14:cf260677ecde | 32 | |
maetugr | 14:cf260677ecde | 33 | // initialisation of hardware (see includes for more info) |
maetugr | 5:818c0668fd2d | 34 | LED LEDs; |
maetugr | 21:c2a2e7cbabdd | 35 | #ifdef PC_CONNECTED |
maetugr | 21:c2a2e7cbabdd | 36 | PC pc(USBTX, USBRX, 115200); |
maetugr | 21:c2a2e7cbabdd | 37 | #endif |
maetugr | 5:818c0668fd2d | 38 | L3G4200D Gyro(p28, p27); |
maetugr | 5:818c0668fd2d | 39 | ADXL345 Acc(p28, p27); |
maetugr | 11:9bf69bc6df45 | 40 | HMC5883 Comp(p28, p27); |
maetugr | 14:cf260677ecde | 41 | BMP085_old Alt(p28, p27); |
maetugr | 21:c2a2e7cbabdd | 42 | RC_Channel RC[] = {p11, p12, p13, p14}; // noooo p19/p20 ! |
maetugr | 21:c2a2e7cbabdd | 43 | Servo_PWM Motor[] = {p21, p22, p23, p24}; // p21 - p26 only ! |
maetugr | 8:d25ecdcdbeb5 | 44 | |
maetugr | 21:c2a2e7cbabdd | 45 | // 0:X:Roll 1:Y:Pitch 2:Z:Yaw |
maetugr | 22:d301b455a1ad | 46 | PID Controller[] = {PID(P_VALUE, I_VALUE, D_VALUE, RATE), PID(P_VALUE, I_VALUE, D_VALUE, RATE), PID(0.02, 100, 0.005, RATE)}; // TODO: RATE != dt immer anpassen |
maetugr | 14:cf260677ecde | 47 | |
maetugr | 22:d301b455a1ad | 48 | // global variables |
maetugr | 20:e116e596e540 | 49 | bool armed = false; // this variable is for security |
maetugr | 14:cf260677ecde | 50 | unsigned long dt_get_data = 0; // TODO: dt namen |
maetugr | 12:67a06c9b69d5 | 51 | unsigned long time_get_data = 0; |
maetugr | 12:67a06c9b69d5 | 52 | unsigned long dt_read_sensors = 0; |
maetugr | 12:67a06c9b69d5 | 53 | unsigned long time_read_sensors = 0; |
maetugr | 14:cf260677ecde | 54 | float angle[3] = {0,0,0}; // calculated values of the position [0: x,roll | 1: y,pitch | 2: z,yaw] |
maetugr | 14:cf260677ecde | 55 | float tempangle = 0; // temporärer winkel für yaw ohne kompass |
maetugr | 20:e116e596e540 | 56 | float Gyro_angle[3] ={0,0,0}; |
maetugr | 21:c2a2e7cbabdd | 57 | float controller_value[] = {0,0,0}; |
maetugr | 21:c2a2e7cbabdd | 58 | float motor_value[] = {0,0,0,0}; |
maetugr | 21:c2a2e7cbabdd | 59 | |
maetugr | 22:d301b455a1ad | 60 | float motor_calc(int rc_value, float contr_value) |
maetugr | 21:c2a2e7cbabdd | 61 | { |
maetugr | 23:955a7c7ddf8b | 62 | return rc_value + contr_value > 50 ? rc_value + contr_value : 50; // nicht unter 0 sinken TODO: nicht Motor halten -> langsame Reaktion |
maetugr | 21:c2a2e7cbabdd | 63 | } |
maetugr | 8:d25ecdcdbeb5 | 64 | |
maetugr | 14:cf260677ecde | 65 | void get_Data() // method which is called by the Ticker Datagetter every RATE seconds |
maetugr | 8:d25ecdcdbeb5 | 66 | { |
maetugr | 12:67a06c9b69d5 | 67 | time_read_sensors = GlobalTimer.read_us(); |
maetugr | 12:67a06c9b69d5 | 68 | |
maetugr | 15:753c5d6a63b3 | 69 | // read data from sensors // ATTENTION! the I2C option repeated true is important because otherwise interrupts while bus communications cause crashes |
maetugr | 14:cf260677ecde | 70 | Gyro.read(); |
maetugr | 15:753c5d6a63b3 | 71 | Acc.read(); // TODO: nicht jeder Sensor immer? höhe nicht so wichtig |
maetugr | 21:c2a2e7cbabdd | 72 | //Comp.read(); |
maetugr | 13:4737ee9ebfee | 73 | //Alt.Update(); TODO braucht zu lange zum auslesen! |
maetugr | 12:67a06c9b69d5 | 74 | |
maetugr | 12:67a06c9b69d5 | 75 | dt_read_sensors = GlobalTimer.read_us() - time_read_sensors; |
maetugr | 8:d25ecdcdbeb5 | 76 | |
maetugr | 8:d25ecdcdbeb5 | 77 | // meassure dt |
maetugr | 12:67a06c9b69d5 | 78 | dt_get_data = GlobalTimer.read_us() - time_get_data; // time in us since last loop |
maetugr | 12:67a06c9b69d5 | 79 | time_get_data = GlobalTimer.read_us(); // set new time for next measurement |
maetugr | 8:d25ecdcdbeb5 | 80 | |
maetugr | 24:c5a3cba48498 | 81 | for(int i = 0; i < 3; i++) |
maetugr | 24:c5a3cba48498 | 82 | Gyro_angle[i] += Gyro.data[i] *dt_get_data/15000000.0; |
maetugr | 20:e116e596e540 | 83 | |
maetugr | 8:d25ecdcdbeb5 | 84 | // calculate angles for roll, pitch an yaw |
maetugr | 24:c5a3cba48498 | 85 | #if 0 // alte berechnung, vielleicht Accelerometer zu stark gewichtet |
maetugr | 24:c5a3cba48498 | 86 | angle[0] += (Acc.angle[0] - angle[0])/50 + Gyro.data[0] *dt_get_data/15000000.0; |
maetugr | 24:c5a3cba48498 | 87 | angle[1] += (Acc.angle[1]+3 - angle[1])/50 + Gyro.data[1] *dt_get_data/15000000.0;// TODO Offset accelerometer einstellen |
maetugr | 24:c5a3cba48498 | 88 | //tempangle += (Comp.get_angle() - tempangle)/50 + Gyro.data[2] *dt_get_data/15000000.0; |
maetugr | 24:c5a3cba48498 | 89 | angle[2] = Gyro_angle[2]; // gyro only here |
maetugr | 24:c5a3cba48498 | 90 | #endif |
maetugr | 12:67a06c9b69d5 | 91 | |
maetugr | 24:c5a3cba48498 | 92 | #if 1 // neuer Test 1 (Formel von http://diydrones.com/m/discussion?id=705844%3ATopic%3A669858) |
maetugr | 24:c5a3cba48498 | 93 | angle[0] = (0.98*(angle[0]+(Gyro.data[0] *dt_get_data/15000000.0)))+(0.02*(Acc.angle[0])); |
maetugr | 24:c5a3cba48498 | 94 | angle[1] = (0.98*(angle[1]+(Gyro.data[1] *dt_get_data/15000000.0)))+(0.02*(Acc.angle[1] + 3)); // TODO Offset accelerometer einstellen |
maetugr | 24:c5a3cba48498 | 95 | //tempangle += (Comp.get_angle() - tempangle)/50 + Gyro.data[2] *dt_get_data/15000000.0; |
maetugr | 24:c5a3cba48498 | 96 | angle[2] = Gyro_angle[2]; // gyro only here |
maetugr | 24:c5a3cba48498 | 97 | #endif |
maetugr | 24:c5a3cba48498 | 98 | |
maetugr | 24:c5a3cba48498 | 99 | #if 0 // neuer Test 2 (funktioniert wahrscheinlich nicht, denkfehler) |
maetugr | 24:c5a3cba48498 | 100 | angle[0] += Gyro_angle[0] * 0.98 + Acc.angle[0] * 0.02; |
maetugr | 24:c5a3cba48498 | 101 | angle[1] += Gyro_angle[1] * 0.98 + (Acc.angle[1] + 3) * 0.02; // TODO: Calibrierung Acc |
maetugr | 24:c5a3cba48498 | 102 | angle[2] = Gyro_angle[2]; // gyro only here |
maetugr | 24:c5a3cba48498 | 103 | #endif |
maetugr | 24:c5a3cba48498 | 104 | |
maetugr | 24:c5a3cba48498 | 105 | #if 0 // rein Gyro |
maetugr | 24:c5a3cba48498 | 106 | for(int i = 0; i < 3; i++) |
maetugr | 24:c5a3cba48498 | 107 | angle[i] = Gyro_angle[i]; |
maetugr | 24:c5a3cba48498 | 108 | #endif |
maetugr | 8:d25ecdcdbeb5 | 109 | |
maetugr | 21:c2a2e7cbabdd | 110 | // Arming / disarming |
maetugr | 21:c2a2e7cbabdd | 111 | if(RC[2].read() < 20 && RC[3].read() > 850) |
maetugr | 21:c2a2e7cbabdd | 112 | armed = true; |
maetugr | 21:c2a2e7cbabdd | 113 | if(RC[2].read() < 30 && RC[3].read() < 30) |
maetugr | 20:e116e596e540 | 114 | armed = false; |
maetugr | 21:c2a2e7cbabdd | 115 | if(RC[3].read() < -10 || RC[2].read() < -10 || RC[1].read() < -10 || RC[0].read() < -10) |
maetugr | 20:e116e596e540 | 116 | armed = false; |
maetugr | 20:e116e596e540 | 117 | |
maetugr | 21:c2a2e7cbabdd | 118 | if (armed) // for SECURITY! |
maetugr | 22:d301b455a1ad | 119 | { |
maetugr | 24:c5a3cba48498 | 120 | // PID controlling |
maetugr | 24:c5a3cba48498 | 121 | if (!(RC[0].read() == -100)) { |
maetugr | 24:c5a3cba48498 | 122 | Controller[0].setSetPoint(-(int)((RC[0].read()-440)/440.0*90.0)); |
maetugr | 24:c5a3cba48498 | 123 | Controller[1].setSetPoint(-(int)((RC[1].read()-430)/430.0*90.0)); |
maetugr | 24:c5a3cba48498 | 124 | //Controller[2].setSetPoint(-(int)((RC[3].read()-424)/424.0*180.0)); // TODO: muss später += werden |
maetugr | 24:c5a3cba48498 | 125 | } |
maetugr | 24:c5a3cba48498 | 126 | for(int i=0;i<3;i++) { |
maetugr | 24:c5a3cba48498 | 127 | Controller[i].setProcessValue(angle[i]); |
maetugr | 24:c5a3cba48498 | 128 | controller_value[i] = Controller[i].compute() - 1000; |
maetugr | 24:c5a3cba48498 | 129 | } |
maetugr | 24:c5a3cba48498 | 130 | |
maetugr | 24:c5a3cba48498 | 131 | // Calculate new motorspeeds |
maetugr | 21:c2a2e7cbabdd | 132 | // Pitch |
maetugr | 21:c2a2e7cbabdd | 133 | motor_value[0] = motor_calc(RC[2].read(), +controller_value[1]); |
maetugr | 21:c2a2e7cbabdd | 134 | motor_value[2] = motor_calc(RC[2].read(), -controller_value[1]); |
maetugr | 21:c2a2e7cbabdd | 135 | |
maetugr | 24:c5a3cba48498 | 136 | #if 1 |
maetugr | 22:d301b455a1ad | 137 | // Roll |
maetugr | 22:d301b455a1ad | 138 | motor_value[1] = motor_calc(RC[2].read(), +controller_value[0]); |
maetugr | 22:d301b455a1ad | 139 | motor_value[3] = motor_calc(RC[2].read(), -controller_value[0]); |
maetugr | 22:d301b455a1ad | 140 | |
maetugr | 22:d301b455a1ad | 141 | // Yaw |
maetugr | 22:d301b455a1ad | 142 | motor_value[0] -= controller_value[2]; |
maetugr | 22:d301b455a1ad | 143 | motor_value[2] -= controller_value[2]; |
maetugr | 22:d301b455a1ad | 144 | |
maetugr | 22:d301b455a1ad | 145 | motor_value[1] += controller_value[2]; |
maetugr | 22:d301b455a1ad | 146 | motor_value[3] += controller_value[2]; |
maetugr | 22:d301b455a1ad | 147 | #endif |
maetugr | 21:c2a2e7cbabdd | 148 | |
maetugr | 15:753c5d6a63b3 | 149 | } else { |
maetugr | 24:c5a3cba48498 | 150 | for(int i=0;i<3;i++) |
maetugr | 24:c5a3cba48498 | 151 | Controller[i].reset(); |
maetugr | 21:c2a2e7cbabdd | 152 | for(int i=0;i<4;i++) |
maetugr | 21:c2a2e7cbabdd | 153 | motor_value[i] = 0; |
maetugr | 21:c2a2e7cbabdd | 154 | } |
maetugr | 21:c2a2e7cbabdd | 155 | // Set new motorspeeds |
maetugr | 21:c2a2e7cbabdd | 156 | for(int i=0;i<4;i++) |
maetugr | 22:d301b455a1ad | 157 | Motor[i] = (int)motor_value[i]; |
maetugr | 8:d25ecdcdbeb5 | 158 | } |
maetugr | 5:818c0668fd2d | 159 | |
maetugr | 14:cf260677ecde | 160 | int main() { // main programm only used for initialisation and debug output |
maetugr | 16:74a6531350b5 | 161 | NVIC_SetPriority(TIMER3_IRQn, 1); // set priorty of tickers below hardware interrupts (standard priority is 0) |
maetugr | 15:753c5d6a63b3 | 162 | |
maetugr | 21:c2a2e7cbabdd | 163 | for(int i=0;i<3;i++) { |
maetugr | 21:c2a2e7cbabdd | 164 | Controller[i].setInputLimits(-90.0, 90.0); |
maetugr | 21:c2a2e7cbabdd | 165 | Controller[i].setOutputLimits(0.0, 2000.0); |
maetugr | 21:c2a2e7cbabdd | 166 | Controller[i].setBias(1000); |
maetugr | 21:c2a2e7cbabdd | 167 | Controller[i].setMode(MANUAL_MODE);//AUTO_MODE); |
maetugr | 21:c2a2e7cbabdd | 168 | Controller[i].setSetPoint(0); |
maetugr | 21:c2a2e7cbabdd | 169 | } |
maetugr | 24:c5a3cba48498 | 170 | Controller[2].setInputLimits(-180.0, 180.0); // yaw 360 grad |
maetugr | 12:67a06c9b69d5 | 171 | |
maetugr | 21:c2a2e7cbabdd | 172 | #ifdef PC_CONNECTED |
maetugr | 21:c2a2e7cbabdd | 173 | #ifdef COMPASSCALIBRATE |
maetugr | 21:c2a2e7cbabdd | 174 | pc.locate(10,5); |
maetugr | 21:c2a2e7cbabdd | 175 | pc.printf("CALIBRATING"); |
maetugr | 21:c2a2e7cbabdd | 176 | Comp.calibrate(60); |
maetugr | 21:c2a2e7cbabdd | 177 | #endif |
maetugr | 21:c2a2e7cbabdd | 178 | |
maetugr | 21:c2a2e7cbabdd | 179 | // init screen |
maetugr | 12:67a06c9b69d5 | 180 | pc.locate(10,5); |
maetugr | 21:c2a2e7cbabdd | 181 | pc.printf("Flybed v0.2"); |
maetugr | 12:67a06c9b69d5 | 182 | #endif |
maetugr | 1:5a64632b1eb9 | 183 | LEDs.roll(2); |
maetugr | 5:818c0668fd2d | 184 | |
maetugr | 21:c2a2e7cbabdd | 185 | // Start! |
maetugr | 2:93f703d2c4d7 | 186 | GlobalTimer.start(); |
maetugr | 12:67a06c9b69d5 | 187 | Datagetter.attach(&get_Data, RATE); // start to get data all RATEms |
maetugr | 12:67a06c9b69d5 | 188 | |
maetugr | 12:67a06c9b69d5 | 189 | while(1) { |
maetugr | 21:c2a2e7cbabdd | 190 | #ifdef PC_CONNECTED |
maetugr | 21:c2a2e7cbabdd | 191 | pc.locate(30,0); // PC output |
maetugr | 21:c2a2e7cbabdd | 192 | pc.printf("dt:%dms dt_sensors:%dus Altitude:%6.1fm ", dt_get_data/1000, dt_read_sensors, Alt.CalcAltitude(Alt.Pressure)); |
maetugr | 21:c2a2e7cbabdd | 193 | pc.locate(5,1); |
maetugr | 21:c2a2e7cbabdd | 194 | if(armed) |
maetugr | 21:c2a2e7cbabdd | 195 | pc.printf("ARMED!!!!!!!!!!!!!"); |
maetugr | 21:c2a2e7cbabdd | 196 | else |
maetugr | 21:c2a2e7cbabdd | 197 | pc.printf("DIS_ARMED "); |
maetugr | 21:c2a2e7cbabdd | 198 | pc.locate(5,3); |
maetugr | 21:c2a2e7cbabdd | 199 | pc.printf("Roll:%6.1f Pitch:%6.1f Yaw:%6.1f ", angle[0], angle[1], angle[2]); |
maetugr | 21:c2a2e7cbabdd | 200 | pc.printf("\n\r control Roll: %d control Pitch: %d ", (int)((RC[0].read()-440)/440.0*90.0), (int)((RC[1].read()-430)/430.0*90.0)); |
maetugr | 21:c2a2e7cbabdd | 201 | |
maetugr | 21:c2a2e7cbabdd | 202 | pc.locate(5,5); |
maetugr | 21:c2a2e7cbabdd | 203 | pc.printf("Gyro.data: X:%6.1f Y:%6.1f Z:%6.1f", Gyro.data[0], Gyro.data[1], Gyro.data[2]); |
maetugr | 21:c2a2e7cbabdd | 204 | pc.locate(5,6); |
maetugr | 21:c2a2e7cbabdd | 205 | pc.printf("Gyro_angle: X:%6.1f Y:%6.1f Z:%6.1f", Gyro_angle[0], Gyro_angle[1], Gyro_angle[2]); |
maetugr | 21:c2a2e7cbabdd | 206 | |
maetugr | 21:c2a2e7cbabdd | 207 | pc.locate(5,8); |
maetugr | 21:c2a2e7cbabdd | 208 | pc.printf("Acc.data: X:%6d Y:%6d Z:%6d", Acc.data[0], Acc.data[1], Acc.data[2]); |
maetugr | 21:c2a2e7cbabdd | 209 | pc.locate(5,9); |
maetugr | 21:c2a2e7cbabdd | 210 | pc.printf("Acc.angle: Roll:%6.1f Pitch:%6.1f Yaw:%6.1f ", Acc.angle[0], Acc.angle[1], Acc.angle[2]); |
maetugr | 21:c2a2e7cbabdd | 211 | |
maetugr | 21:c2a2e7cbabdd | 212 | pc.locate(5,11); |
maetugr | 21:c2a2e7cbabdd | 213 | pc.printf("PID Result:"); |
maetugr | 21:c2a2e7cbabdd | 214 | for(int i=0;i<3;i++) |
maetugr | 21:c2a2e7cbabdd | 215 | pc.printf(" %d: %6.1f", i, controller_value[i]); |
maetugr | 21:c2a2e7cbabdd | 216 | |
maetugr | 23:955a7c7ddf8b | 217 | pc.locate(5,12); |
maetugr | 22:d301b455a1ad | 218 | pc.printf("Motor Result:"); |
maetugr | 22:d301b455a1ad | 219 | for(int i=0;i<4;i++) |
maetugr | 22:d301b455a1ad | 220 | pc.printf(" %d: %6.1f", i, motor_value[i]); |
maetugr | 21:c2a2e7cbabdd | 221 | |
maetugr | 23:955a7c7ddf8b | 222 | pc.locate(5,14); |
maetugr | 23:955a7c7ddf8b | 223 | pc.printf(" roll: %d pitch: %d ", -(int)((RC[0].read()-440)/440.0*90.0), -(int)((RC[1].read()-430)/430.0*90.0)); |
maetugr | 23:955a7c7ddf8b | 224 | |
maetugr | 21:c2a2e7cbabdd | 225 | pc.locate(10,15); |
maetugr | 21:c2a2e7cbabdd | 226 | pc.printf("Debug_Yaw: Comp:%6.1f tempangle:%6.1f ", Comp.get_angle(), tempangle); |
maetugr | 21:c2a2e7cbabdd | 227 | pc.locate(10,16); |
maetugr | 21:c2a2e7cbabdd | 228 | pc.printf("Comp_data: %6.1f %6.1f %6.1f |||| %6.1f ", Comp.data[0], Comp.data[1], Comp.data[2], Comp.get_angle()); |
maetugr | 21:c2a2e7cbabdd | 229 | pc.locate(10,17); |
maetugr | 21:c2a2e7cbabdd | 230 | //pc.printf("Comp_scale: %6.4f %6.4f %6.4f ", Comp.scale[0], Comp.scale[1], Comp.scale[2]); no more accessible its private |
maetugr | 21:c2a2e7cbabdd | 231 | pc.locate(10,18); |
maetugr | 21:c2a2e7cbabdd | 232 | pc.printf("Comp_data: %6.1f %6.1f %6.1f |||| %6.1f ", Comp.data[0], Comp.data[1], Comp.data[2], Comp.get_angle()); |
maetugr | 21:c2a2e7cbabdd | 233 | |
maetugr | 21:c2a2e7cbabdd | 234 | pc.locate(10,19); |
maetugr | 21:c2a2e7cbabdd | 235 | pc.printf("RC0: %4d :[", RC[0].read()); |
maetugr | 21:c2a2e7cbabdd | 236 | for (int i = 0; i < RC[0].read()/17; i++) |
maetugr | 21:c2a2e7cbabdd | 237 | pc.printf("="); |
maetugr | 21:c2a2e7cbabdd | 238 | pc.printf(" "); |
maetugr | 21:c2a2e7cbabdd | 239 | pc.locate(10,20); |
maetugr | 21:c2a2e7cbabdd | 240 | pc.printf("RC1: %4d :[", RC[1].read()); |
maetugr | 21:c2a2e7cbabdd | 241 | for (int i = 0; i < RC[1].read()/17; i++) |
maetugr | 21:c2a2e7cbabdd | 242 | pc.printf("="); |
maetugr | 21:c2a2e7cbabdd | 243 | pc.printf(" "); |
maetugr | 21:c2a2e7cbabdd | 244 | pc.locate(10,21); |
maetugr | 21:c2a2e7cbabdd | 245 | pc.printf("RC2: %4d :[", RC[2].read()); |
maetugr | 21:c2a2e7cbabdd | 246 | for (int i = 0; i < RC[2].read()/17; i++) |
maetugr | 21:c2a2e7cbabdd | 247 | pc.printf("="); |
maetugr | 21:c2a2e7cbabdd | 248 | pc.printf(" "); |
maetugr | 21:c2a2e7cbabdd | 249 | pc.locate(10,22); |
maetugr | 21:c2a2e7cbabdd | 250 | pc.printf("RC3: %4d :[", RC[3].read()); |
maetugr | 21:c2a2e7cbabdd | 251 | for (int i = 0; i < RC[3].read()/17; i++) |
maetugr | 21:c2a2e7cbabdd | 252 | pc.printf("="); |
maetugr | 21:c2a2e7cbabdd | 253 | pc.printf(" "); |
maetugr | 21:c2a2e7cbabdd | 254 | #endif |
maetugr | 21:c2a2e7cbabdd | 255 | wait(0.01); |
maetugr | 21:c2a2e7cbabdd | 256 | if(armed){ |
maetugr | 21:c2a2e7cbabdd | 257 | LEDs.rollnext(); |
maetugr | 21:c2a2e7cbabdd | 258 | } else { |
maetugr | 21:c2a2e7cbabdd | 259 | LEDs.set(1); |
maetugr | 21:c2a2e7cbabdd | 260 | LEDs.set(2); |
maetugr | 21:c2a2e7cbabdd | 261 | LEDs.set(3); |
maetugr | 21:c2a2e7cbabdd | 262 | LEDs.set(4); |
maetugr | 21:c2a2e7cbabdd | 263 | } |
maetugr | 0:0c4fafa398b4 | 264 | } |
maetugr | 0:0c4fafa398b4 | 265 | } |