E=MC / Mbed 2 deprecated coolcarsuperfast2

Dependencies:   mbed MODSERIAL telemetry-master

Fork of coolcarsuperfast by Michael Romain

Committer:
cheryl_he
Date:
Thu May 07 22:55:19 2015 +0000
Revision:
27:b9062f7f1e7c
Parent:
26:7439102e0d9f
tele_linescan changed from float to uint8_t

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mawk2311 0:ad375c052b4c 1 #include "mbed.h"
cheryl_he 24:7fc204a3d013 2 #include "telemetry.h"
cheryl_he 24:7fc204a3d013 3 #include "telemetry-mbed.h"
cheryl_he 24:7fc204a3d013 4 #include "MODSERIAL.h"
cheryl_he 24:7fc204a3d013 5
mawk2311 0:ad375c052b4c 6 #include "stdlib.h"
ericoneill 7:6d5ddcf12cf3 7 #include <vector>
cheryl_he 24:7fc204a3d013 8
cheryl_he 25:dbadea3c526d 9 MODSERIAL telemetry_serial(PTA2, PTA1);
cheryl_he 24:7fc204a3d013 10 telemetry::MbedHal telemetry_hal(telemetry_serial);
cheryl_he 24:7fc204a3d013 11 telemetry::Telemetry telemetry_obj(telemetry_hal);
cheryl_he 24:7fc204a3d013 12
cheryl_he 24:7fc204a3d013 13 telemetry::Numeric<uint32_t> tele_time_ms(telemetry_obj, "time", "Time", "ms", 0);
cheryl_he 27:b9062f7f1e7c 14 telemetry::NumericArray<uint8_t, 128> tele_linescan(telemetry_obj, "linescan", "Linescan", "ADC", 0);
cheryl_he 24:7fc204a3d013 15 telemetry::Numeric<float> tele_motor_pwm(telemetry_obj, "motor", "Motor PWM", "%DC", 0);
cheryl_he 24:7fc204a3d013 16
mawk2311 0:ad375c052b4c 17 //Outputs
mawk2311 0:ad375c052b4c 18 DigitalOut led1(LED1);
mawk2311 0:ad375c052b4c 19 DigitalOut clk(PTD5);
mawk2311 0:ad375c052b4c 20 DigitalOut si(PTD4);
mawk2311 5:20223464f7aa 21 PwmOut motor1(PTA12);
mawk2311 5:20223464f7aa 22 PwmOut motor2(PTA4);
mawk2311 5:20223464f7aa 23 DigitalOut break1(PTC7);
mawk2311 5:20223464f7aa 24 DigitalOut break2(PTC0);
mawk2311 0:ad375c052b4c 25 PwmOut servo(PTA5);
mawk2311 0:ad375c052b4c 26
cheryl_he 25:dbadea3c526d 27 //Serial bt(PTA2, PTA1);
cheryl_he 24:7fc204a3d013 28 //Serial pc(USBTX, USBRX); // tx, rx
mawk2311 5:20223464f7aa 29
mawk2311 0:ad375c052b4c 30 //Inputs
mawk2311 0:ad375c052b4c 31 AnalogIn camData(PTC2);
mawk2311 0:ad375c052b4c 32
mawk2311 0:ad375c052b4c 33 //Encoder setup and variables
mawk2311 0:ad375c052b4c 34 InterruptIn interrupt(PTA13);
mawk2311 0:ad375c052b4c 35
mawk2311 0:ad375c052b4c 36 //Line Tracking Variables --------------------------------
mawk2311 0:ad375c052b4c 37 float ADCdata [128];
mawk2311 5:20223464f7aa 38 float maxAccum;
mawk2311 5:20223464f7aa 39 float maxCount;
mawk2311 0:ad375c052b4c 40 float approxPos;
mawk2311 12:48b76450c4b4 41 float prevApproxPos;
mawk2311 15:55e9fffc653a 42 int trackWindow = 30;
mawk2311 14:888495814f3c 43 int startWindow;
mawk2311 14:888495814f3c 44 int endWindow;
mawk2311 5:20223464f7aa 45 float maxVal;
mawk2311 5:20223464f7aa 46 int maxLoc;
mawk2311 12:48b76450c4b4 47
mawk2311 12:48b76450c4b4 48 bool firstTime;
mawk2311 11:b59ec039a712 49
mawk2311 10:e40ad924e935 50 //Data Collection
mawk2311 10:e40ad924e935 51 bool dataCol = false;
mawk2311 11:b59ec039a712 52 int loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime;
mawk2311 10:e40ad924e935 53
mawk2311 5:20223464f7aa 54 //Line Crossing variables
mawk2311 5:20223464f7aa 55 int prevTrackLoc;
mawk2311 18:7941524e0d28 56 int spaceThresh = 3;
mawk2311 18:7941524e0d28 57 int widthThresh = 10;
mawk2311 5:20223464f7aa 58 bool space;
mawk2311 0:ad375c052b4c 59
mawk2311 0:ad375c052b4c 60 //Servo turning parameters
mawk2311 0:ad375c052b4c 61 float straight = 0.00155f;
mawk2311 16:79106efd7a57 62 float hardLeft = 0.0012f;
mawk2311 16:79106efd7a57 63 float hardRight = 0.0020f;
mawk2311 12:48b76450c4b4 64 //float hardLeft = 0.0010f;
mawk2311 12:48b76450c4b4 65 //float hardRight = 0.00195f;
mawk2311 0:ad375c052b4c 66
mawk2311 5:20223464f7aa 67 //Servo Directions
mawk2311 5:20223464f7aa 68 float currDir;
mawk2311 5:20223464f7aa 69 float prevDir;
mawk2311 5:20223464f7aa 70
ericoneill 7:6d5ddcf12cf3 71 // All linescan data for the period the car is running on. To be printed after a set amount of time
ericoneill 7:6d5ddcf12cf3 72 //std::vector<std::vector<int> > frames;
ericoneill 7:6d5ddcf12cf3 73 const int numData = 1000;
ericoneill 7:6d5ddcf12cf3 74 int lineCenters [numData] = {0};
ericoneill 7:6d5ddcf12cf3 75 int times [numData] = {0};
ericoneill 7:6d5ddcf12cf3 76 int loopCtr = 0;
ericoneill 7:6d5ddcf12cf3 77
mawk2311 0:ad375c052b4c 78 //End of Line Tracking Variables -------------------------
mawk2311 0:ad375c052b4c 79
mawk2311 0:ad375c052b4c 80 //Encoder and Motor Driver Variables ---------------------
mawk2311 0:ad375c052b4c 81
mawk2311 0:ad375c052b4c 82 //Intervals used during encoder data collection to measure velocity
mawk2311 0:ad375c052b4c 83 int interval1=0;
mawk2311 0:ad375c052b4c 84 int interval2=0;
mawk2311 0:ad375c052b4c 85 int interval3=0;
mawk2311 0:ad375c052b4c 86 int avg_interval=0;
mawk2311 0:ad375c052b4c 87 int lastchange1 = 0;
mawk2311 0:ad375c052b4c 88 int lastchange2 = 0;
mawk2311 0:ad375c052b4c 89 int lastchange3 = 0;
mawk2311 0:ad375c052b4c 90 int lastchange4 = 0;
mawk2311 0:ad375c052b4c 91
mawk2311 0:ad375c052b4c 92 //Variables used to for velocity control
mawk2311 0:ad375c052b4c 93 float avg_speed = 0;
mawk2311 5:20223464f7aa 94 float last_speed = 0;
mawk2311 5:20223464f7aa 95
mawk2311 0:ad375c052b4c 96 float stall_check = 0;
mawk2311 0:ad375c052b4c 97 float tuning_val = 1;
mawk2311 0:ad375c052b4c 98
mawk2311 6:f1d948d2d6c1 99 int numInterrupts = 0;
mawk2311 5:20223464f7aa 100
mawk2311 19:d9746cc2ec80 101 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Tuning Values that can make it or break it ~~~~~~~~~~~~~~~~~~~~~~~~
mawk2311 23:bf38d7d2255a 102 float pulsewidth = 0.2f;
cheryl_he 27:b9062f7f1e7c 103 int intTimMod = 20;
cheryl_he 27:b9062f7f1e7c 104 float maxValThresh = .05; //~.1 for earlier in the day, reduce it (maybe something like .05 - .01 or something) as it gets darker
mawk2311 23:bf38d7d2255a 105 bool turnSpeedControl = true; //have increased PWMs when turning when true.
mawk2311 14:888495814f3c 106 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mawk2311 16:79106efd7a57 107
mawk2311 5:20223464f7aa 108 // Hardware periods
cheryl_he 26:7439102e0d9f 109 float motorPeriod = .0018;
mawk2311 5:20223464f7aa 110 float servoPeriod = .0025;
mawk2311 5:20223464f7aa 111
mawk2311 0:ad375c052b4c 112 Timer t;
mawk2311 0:ad375c052b4c 113 Timer servoTimer;
ericoneill 7:6d5ddcf12cf3 114 Timer printTimer; //after printTimer reaches a certain value the main loop will terminate and print the frames
mawk2311 0:ad375c052b4c 115
mawk2311 0:ad375c052b4c 116 //End of Encoder and Motor Driver Variables ----------------------
mawk2311 0:ad375c052b4c 117
mawk2311 6:f1d948d2d6c1 118 //Function for speeding up KL25Z ADC
mawk2311 6:f1d948d2d6c1 119 void initADC(void){
mawk2311 6:f1d948d2d6c1 120
mawk2311 6:f1d948d2d6c1 121 ADC0->CFG1 = ADC0->CFG1 & (
mawk2311 6:f1d948d2d6c1 122 ~(
mawk2311 6:f1d948d2d6c1 123 0x80 // LDLPC = 0 ; no low-power mode
mawk2311 6:f1d948d2d6c1 124 | 0x60 // ADIV = 1
mawk2311 6:f1d948d2d6c1 125 | 0x10 // Sample time short
mawk2311 6:f1d948d2d6c1 126 | 0x03 // input clock = BUS CLK
mawk2311 6:f1d948d2d6c1 127 )
mawk2311 6:f1d948d2d6c1 128 ) ; // clkdiv <= 1
mawk2311 6:f1d948d2d6c1 129 ADC0->CFG2 = ADC0->CFG2
mawk2311 6:f1d948d2d6c1 130 | 0x03 ; // Logsample Time 11 = 2 extra ADCK
mawk2311 6:f1d948d2d6c1 131 ADC0->SC3 = ADC0->SC3
mawk2311 6:f1d948d2d6c1 132 & (~(0x03)) ; // hardware avarage off
mawk2311 6:f1d948d2d6c1 133 }
mawk2311 6:f1d948d2d6c1 134
mawk2311 0:ad375c052b4c 135 int main() {
cheryl_he 24:7fc204a3d013 136 telemetry_serial.baud(115200);
cheryl_he 24:7fc204a3d013 137 telemetry_obj.transmit_header();
cheryl_he 24:7fc204a3d013 138
mawk2311 6:f1d948d2d6c1 139 //Alter reg values to speed up KL25Z
mawk2311 6:f1d948d2d6c1 140 initADC();
mawk2311 6:f1d948d2d6c1 141
mawk2311 0:ad375c052b4c 142 //Line Tracker Initializations
mawk2311 0:ad375c052b4c 143 int integrationCounter = 0;
mawk2311 0:ad375c052b4c 144
mawk2311 6:f1d948d2d6c1 145 //Initial values for directions
mawk2311 5:20223464f7aa 146 currDir = 0;
mawk2311 5:20223464f7aa 147 prevDir = 0;
mawk2311 5:20223464f7aa 148
mawk2311 0:ad375c052b4c 149 // Motor Driver Initializations
mawk2311 5:20223464f7aa 150 motor1.period(motorPeriod);
mawk2311 5:20223464f7aa 151 motor2.period(motorPeriod);
mawk2311 0:ad375c052b4c 152
mawk2311 5:20223464f7aa 153 // Servo Initialization
mawk2311 5:20223464f7aa 154 servo.period(servoPeriod);
mawk2311 15:55e9fffc653a 155 servo.pulsewidth(hardRight);
mawk2311 5:20223464f7aa 156 wait(3);
mawk2311 0:ad375c052b4c 157
mawk2311 12:48b76450c4b4 158 motor1.pulsewidth(motorPeriod*pulsewidth);
mawk2311 12:48b76450c4b4 159 motor2.pulsewidth(motorPeriod*pulsewidth);
mawk2311 0:ad375c052b4c 160 break1 = 0;
mawk2311 0:ad375c052b4c 161 break2 = 0;
mawk2311 0:ad375c052b4c 162
mawk2311 12:48b76450c4b4 163 firstTime = true;
mawk2311 12:48b76450c4b4 164
cheryl_he 24:7fc204a3d013 165 t.start();
mawk2311 10:e40ad924e935 166
mawk2311 10:e40ad924e935 167 if(dataCol){
mawk2311 11:b59ec039a712 168 loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime = 0;
mawk2311 10:e40ad924e935 169 printTimer.start();
mawk2311 10:e40ad924e935 170 }
cheryl_he 24:7fc204a3d013 171 //uint16_t* data = camData.read();
mawk2311 0:ad375c052b4c 172 while(1) {
mawk2311 10:e40ad924e935 173 if(dataCol){
mawk2311 10:e40ad924e935 174 //break out of main loop if enough time has passed;
mawk2311 10:e40ad924e935 175 if(loopCtr >= numData && dataCol){
mawk2311 10:e40ad924e935 176 break;
mawk2311 10:e40ad924e935 177 }
ericoneill 7:6d5ddcf12cf3 178 }
mawk2311 0:ad375c052b4c 179 if(integrationCounter % 151== 0){
mawk2311 10:e40ad924e935 180 /*
mawk2311 0:ad375c052b4c 181 //Disable interrupts
mawk2311 5:20223464f7aa 182 interrupt.fall(NULL);
mawk2311 5:20223464f7aa 183 interrupt.rise(NULL);
ericoneill 7:6d5ddcf12cf3 184 */
mawk2311 10:e40ad924e935 185
mawk2311 0:ad375c052b4c 186 //Send start of integration signal
mawk2311 0:ad375c052b4c 187 si = 1;
mawk2311 0:ad375c052b4c 188 clk = 1;
mawk2311 0:ad375c052b4c 189
mawk2311 0:ad375c052b4c 190 si = 0;
mawk2311 0:ad375c052b4c 191 clk = 0;
mawk2311 0:ad375c052b4c 192
mawk2311 0:ad375c052b4c 193 //Reset timing counter for integration
mawk2311 0:ad375c052b4c 194 integrationCounter = 0;
mawk2311 0:ad375c052b4c 195
mawk2311 0:ad375c052b4c 196 //Reset line tracking variables
mawk2311 5:20223464f7aa 197 maxAccum = 0;
mawk2311 5:20223464f7aa 198 maxCount = 0;
mawk2311 0:ad375c052b4c 199 approxPos = 0;
mawk2311 0:ad375c052b4c 200
mawk2311 5:20223464f7aa 201 space = false;
mawk2311 6:f1d948d2d6c1 202
mawk2311 0:ad375c052b4c 203 }
mawk2311 0:ad375c052b4c 204 else if (integrationCounter > 129){
mawk2311 5:20223464f7aa 205 //Start Timer
mawk2311 6:f1d948d2d6c1 206 //t.start();
mawk2311 0:ad375c052b4c 207
mawk2311 5:20223464f7aa 208 //Enable interrupts
mawk2311 6:f1d948d2d6c1 209 //interrupt.fall(&fallInterrupt);
mawk2311 6:f1d948d2d6c1 210 //interrupt.rise(&riseInterrupt);
cheryl_he 25:dbadea3c526d 211 tele_time_ms = t.read_ms();
cheryl_he 25:dbadea3c526d 212 for (uint16_t i=0; i<128; i++) {
cheryl_he 27:b9062f7f1e7c 213 tele_linescan[i] = (uint8_t) (ADCdata[i] * 128);
cheryl_he 25:dbadea3c526d 214 }
cheryl_he 25:dbadea3c526d 215 telemetry_obj.do_io();
mawk2311 12:48b76450c4b4 216 if (firstTime){
mawk2311 12:48b76450c4b4 217
mawk2311 12:48b76450c4b4 218 maxVal = ADCdata[10];
mawk2311 12:48b76450c4b4 219 for (int c = 11; c < 118; c++) {
mawk2311 12:48b76450c4b4 220 if (ADCdata[c] > maxVal){
mawk2311 12:48b76450c4b4 221 maxVal = ADCdata[c];
mawk2311 12:48b76450c4b4 222 maxLoc = c;
mawk2311 12:48b76450c4b4 223 }
mawk2311 0:ad375c052b4c 224 }
mawk2311 12:48b76450c4b4 225
mawk2311 12:48b76450c4b4 226 for (int c = 10; c < 118; c++) {
mawk2311 19:d9746cc2ec80 227 if (ADCdata[c] <= maxVal && maxVal - ADCdata[c] < maxValThresh){
mawk2311 12:48b76450c4b4 228 maxAccum += c;
mawk2311 12:48b76450c4b4 229 maxCount++;
mawk2311 15:55e9fffc653a 230 if (c > prevTrackLoc + spaceThresh || maxCount > widthThresh){
mawk2311 12:48b76450c4b4 231 space = true;
mawk2311 12:48b76450c4b4 232 }
mawk2311 12:48b76450c4b4 233 prevTrackLoc = c;
mawk2311 12:48b76450c4b4 234 }
mawk2311 12:48b76450c4b4 235 }
mawk2311 12:48b76450c4b4 236
mawk2311 16:79106efd7a57 237 //firstTime = false;
mawk2311 12:48b76450c4b4 238 } else {
mawk2311 12:48b76450c4b4 239
mawk2311 14:888495814f3c 240 startWindow = prevApproxPos - trackWindow;
mawk2311 14:888495814f3c 241 endWindow = prevApproxPos + trackWindow;
mawk2311 14:888495814f3c 242 if (startWindow < 0){
mawk2311 14:888495814f3c 243 startWindow = 0;
mawk2311 14:888495814f3c 244 }
mawk2311 14:888495814f3c 245 if (endWindow > 118){
mawk2311 14:888495814f3c 246 endWindow = 118;
mawk2311 14:888495814f3c 247 }
mawk2311 12:48b76450c4b4 248 maxVal = ADCdata[10];
mawk2311 14:888495814f3c 249 for (int c = startWindow; c < endWindow; c++) {
mawk2311 12:48b76450c4b4 250 if (ADCdata[c] > maxVal){
mawk2311 12:48b76450c4b4 251 maxVal = ADCdata[c];
mawk2311 12:48b76450c4b4 252 maxLoc = c;
mawk2311 12:48b76450c4b4 253 }
mawk2311 12:48b76450c4b4 254 }
mawk2311 12:48b76450c4b4 255
mawk2311 14:888495814f3c 256 for (int c = startWindow; c < endWindow; c++) {
mawk2311 19:d9746cc2ec80 257 if (ADCdata[c] <= maxVal && maxVal - ADCdata[c] < maxValThresh){
mawk2311 11:b59ec039a712 258 maxAccum += c;
mawk2311 11:b59ec039a712 259 maxCount++;
mawk2311 15:55e9fffc653a 260 if (c > prevTrackLoc + spaceThresh || maxCount > widthThresh){
mawk2311 11:b59ec039a712 261 space = true;
mawk2311 11:b59ec039a712 262 }
mawk2311 11:b59ec039a712 263 prevTrackLoc = c;
mawk2311 5:20223464f7aa 264 }
mawk2311 12:48b76450c4b4 265 }
mawk2311 11:b59ec039a712 266 }
mawk2311 12:48b76450c4b4 267 /*
mawk2311 11:b59ec039a712 268 //Check if we need to alter integration time due to brightness
mawk2311 11:b59ec039a712 269 if (maxVal < 0.15f){
mawk2311 11:b59ec039a712 270 intTimMod += 10;
mawk2311 11:b59ec039a712 271 } else if (maxVal >= 1) {
mawk2311 11:b59ec039a712 272 if (intTimMod > 0) {
mawk2311 11:b59ec039a712 273 intTimMod -= 10;
mawk2311 0:ad375c052b4c 274 }
mawk2311 0:ad375c052b4c 275 }
mawk2311 12:48b76450c4b4 276 */
mawk2311 11:b59ec039a712 277
mawk2311 6:f1d948d2d6c1 278 //Line Crossing Checks
mawk2311 10:e40ad924e935 279 if (space) {
mawk2311 5:20223464f7aa 280 currDir = prevDir;
mawk2311 15:55e9fffc653a 281 firstTime = true;
mawk2311 5:20223464f7aa 282 } else {
mawk2311 15:55e9fffc653a 283 approxPos = (float)maxAccum/(float)maxCount;
ericoneill 8:e126c900c89d 284
mawk2311 10:e40ad924e935 285 if(dataCol){
mawk2311 10:e40ad924e935 286 if(loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime%3==0){
mawk2311 10:e40ad924e935 287 lineCenters[loopCtr] = approxPos;
mawk2311 10:e40ad924e935 288 times[loopCtr] = printTimer.read_ms();
mawk2311 10:e40ad924e935 289 loopCtr++;
mawk2311 10:e40ad924e935 290 }
ericoneill 9:ad08181ad1cc 291 }
mawk2311 10:e40ad924e935 292
mawk2311 16:79106efd7a57 293 currDir = hardLeft + (approxPos)/((float) 118)*(hardRight-hardLeft);
mawk2311 12:48b76450c4b4 294 prevApproxPos = approxPos;
ericoneill 9:ad08181ad1cc 295
mawk2311 5:20223464f7aa 296 }
mawk2311 16:79106efd7a57 297
mawk2311 16:79106efd7a57 298 if (turnSpeedControl){
mawk2311 16:79106efd7a57 299 //Change speed when turning at different angles
mawk2311 16:79106efd7a57 300 if(approxPos > 0 && approxPos <= 45){
mawk2311 19:d9746cc2ec80 301 motor1.pulsewidth(motorPeriod*(pulsewidth*2.0f));
mawk2311 19:d9746cc2ec80 302 motor2.pulsewidth(motorPeriod*(pulsewidth*2.0f));
mawk2311 19:d9746cc2ec80 303 } else if (approxPos > 45 && approxPos <= 55){
mawk2311 19:d9746cc2ec80 304 motor1.pulsewidth(motorPeriod*pulsewidth*1.5f);
mawk2311 19:d9746cc2ec80 305 motor2.pulsewidth(motorPeriod*pulsewidth*1.5f);
mawk2311 19:d9746cc2ec80 306 } else if (approxPos > 55 && approxPos <= 85){
mawk2311 16:79106efd7a57 307 motor1.pulsewidth(motorPeriod*pulsewidth);
mawk2311 16:79106efd7a57 308 motor2.pulsewidth(motorPeriod*pulsewidth);
mawk2311 19:d9746cc2ec80 309 } else if (approxPos > 85 && approxPos <= 95){
mawk2311 19:d9746cc2ec80 310 motor1.pulsewidth(motorPeriod*pulsewidth*1.5f);
mawk2311 19:d9746cc2ec80 311 motor2.pulsewidth(motorPeriod*pulsewidth*1.5f);
mawk2311 16:79106efd7a57 312 } else {
mawk2311 19:d9746cc2ec80 313 motor1.pulsewidth(motorPeriod*(pulsewidth*2.0f));
mawk2311 19:d9746cc2ec80 314 motor2.pulsewidth(motorPeriod*(pulsewidth*2.0f));
mawk2311 16:79106efd7a57 315 }
mawk2311 16:79106efd7a57 316 }
mawk2311 16:79106efd7a57 317
mawk2311 5:20223464f7aa 318 servo.pulsewidth(currDir);
mawk2311 5:20223464f7aa 319
mawk2311 6:f1d948d2d6c1 320 //Start Velocity control after requisite number of encoder signals have been collected
mawk2311 6:f1d948d2d6c1 321 //if(numInterrupts >= 4){
mawk2311 6:f1d948d2d6c1 322 //velocity_control(0.1f, TUNING_CONSTANT_10);
mawk2311 6:f1d948d2d6c1 323 //}
mawk2311 4:09c68df71785 324
mawk2311 6:f1d948d2d6c1 325 //Save current direction as previous direction
mawk2311 5:20223464f7aa 326 prevDir = currDir;
mawk2311 0:ad375c052b4c 327
mawk2311 6:f1d948d2d6c1 328 //Prepare to start collecting more data
mawk2311 0:ad375c052b4c 329 integrationCounter = 150;
mawk2311 6:f1d948d2d6c1 330
mawk2311 6:f1d948d2d6c1 331 //Disable interrupts
mawk2311 6:f1d948d2d6c1 332 //interrupt.fall(NULL);
mawk2311 6:f1d948d2d6c1 333 //interrupt.rise(NULL);
mawk2311 6:f1d948d2d6c1 334
mawk2311 6:f1d948d2d6c1 335 //Stop timer
mawk2311 6:f1d948d2d6c1 336 //t.stop();
mawk2311 0:ad375c052b4c 337 }
mawk2311 0:ad375c052b4c 338 else{
mawk2311 0:ad375c052b4c 339 clk = 1;
mawk2311 14:888495814f3c 340 wait_us(intTimMod);
mawk2311 3:e867c4e984df 341 ADCdata[integrationCounter - 1] = camData;
mawk2311 0:ad375c052b4c 342 clk = 0;
mawk2311 0:ad375c052b4c 343 }
mawk2311 0:ad375c052b4c 344
mawk2311 0:ad375c052b4c 345 //clk = 0;
mawk2311 0:ad375c052b4c 346 integrationCounter++;
mawk2311 10:e40ad924e935 347 if(dataCol){
mawk2311 10:e40ad924e935 348 loopCounterForModdingSoThatWeCanIncreaseTheRecordingTime++;
mawk2311 10:e40ad924e935 349 }
mawk2311 0:ad375c052b4c 350 //camData.
cheryl_he 25:dbadea3c526d 351
mawk2311 0:ad375c052b4c 352
mawk2311 0:ad375c052b4c 353 }
cheryl_he 24:7fc204a3d013 354 /*
mawk2311 10:e40ad924e935 355 if (dataCol){
mawk2311 10:e40ad924e935 356 //print frame data
mawk2311 10:e40ad924e935 357 pc.printf("printing frame data\n\r");
mawk2311 10:e40ad924e935 358 //int frameSize = frames.size();
mawk2311 10:e40ad924e935 359 //pc.printf("%i",frameSize);
mawk2311 10:e40ad924e935 360 pc.printf("[");
mawk2311 10:e40ad924e935 361 for(int i=0; i<numData; i++){
mawk2311 10:e40ad924e935 362 if(lineCenters > 0){
mawk2311 10:e40ad924e935 363 pc.printf("%i %i,",lineCenters[i], times[i]);
mawk2311 10:e40ad924e935 364 }
ericoneill 7:6d5ddcf12cf3 365 }
mawk2311 10:e40ad924e935 366 pc.printf("]\n\r");
ericoneill 7:6d5ddcf12cf3 367 }
cheryl_he 24:7fc204a3d013 368 */
mawk2311 0:ad375c052b4c 369 }
ericoneill 9:ad08181ad1cc 370