attempt to fix posible power issues with the sharp
Dependencies: ADS1115 BME280 CronoDot SDFileSystem mbed
Fork of Outdoor_UPAS_v1_2_Tboard by
Revision 60:e434c8c85020, committed 2016-05-24
- Comitter:
- scottkelleher
- Date:
- Tue May 24 23:32:34 2016 +0000
- Parent:
- 59:4221935a12d8
- Commit message:
- different version to attempt to solve sharp issues
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4221935a12d8 -r e434c8c85020 main.cpp --- a/main.cpp Tue May 24 20:52:26 2016 +0000 +++ b/main.cpp Tue May 24 23:32:34 2016 +0000 @@ -73,6 +73,7 @@ int samplingTime = 280; int deltaTime = 40; +int sleepTime= 9680; int sharp1, sharp2, sharp3, sharp4, sharp5, sharp6; float sharpVolt1, sharpVolt2, sharpVolt3, sharpVolt4, sharpVolt5, sharpVolt6; //V @@ -121,50 +122,71 @@ //pc.printf("%f,%f,%f,%f\r\n", temp, press, rh, atmoRho); sharp1LED = 0; - sharp2LED = 0; - sharp3LED = 0; - sharp4LED = 0; - sharp5LED = 0; - sharp6LED = 0; - wait_us(samplingTime); - sharp1 = ads.readADC_SingleEnded(0, 0xC383); // read channel 1 sharpVolt1 = (sharp1*4.096)/(32768*1); + wait_us(deltaTime); + sharp1LED = 1; + wait_us(sleepTime); + + sharp2LED = 0; + wait_us(samplingTime); sharp2 = ads.readADC_SingleEnded(1, 0xD383); // read channel 1 sharpVolt2 = (sharp2*4.096)/(32768*1); + wait_us(deltaTime); + sharp2LED = 1; + wait_us(sleepTime); + + sharp3LED = 0; + wait_us(samplingTime); sharp3 = ads.readADC_SingleEnded(2, 0xE383); // read channel 1 sharpVolt3 = (sharp3*4.096)/(32768*1); + wait_us(deltaTime); + sharp3LED = 1; + wait_us(sleepTime); + + sharp4LED = 0; + wait_us(samplingTime); sharp4 = ads.readADC_SingleEnded(3, 0xF383); // read channel 1 sharpVolt4 = (sharp4*4.096)/(32768*1); + wait_us(deltaTime); + sharp4LED = 1; + wait_us(sleepTime); + sharp5LED = 0; + wait_us(samplingTime); sharp5 = ads2.readADC_SingleEnded(0, 0xC383); // read channel 1 - sharpVolt5 = (sharp4*4.096)/(32768*1); - sharp6 = ads2.readADC_SingleEnded(1, 0xD383); // read channel 1 - sharpVolt6 = (sharp4*4.096)/(32768*1); - - wait_us(deltaTime); + sharpVolt5 = (sharp1*4.096)/(32768*1); + sharp5LED = 1; + wait_us(sleepTime); - sharp1LED = 1; - sharp2LED = 1; - sharp3LED = 1; - sharp4LED = 1; - sharp5LED = 1; + sharp6LED = 0; + wait_us(samplingTime); + sharp6 = ads2.readADC_SingleEnded(0, 0xD383); // read channel 1 + sharpVolt6 = (sharp1*4.096)/(32768*1); sharp6LED = 1; + wait_us(sleepTime); - pc.printf("%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6); + + + + + + + //pc.printf("%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6); + pc.printf("%d,%d\r\n",sharp1, sharp4); //pc.printf("%d,%f,%d,%f,%d,%f,%d,%f\r\n" ,sharp1,sharpVolt1, sharp2, sharpVolt2,sharp3,sharpVolt3, sharp4, sharpVolt4); //pc.printf("%2.2f,%4.2f,%2.1f,%1.3f\r\n", temp,press,rh,atmoRho); //pc.printf("%d,%f,%d,%f\r\n" ,sharp3,sharpVolt3, sharp4, sharpVolt4); - FILE *fp = fopen(filename, "a"); - // fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC_UPAS.year, RTC_UPAS.month,RTC_UPAS.date,RTC_UPAS.hour,RTC_UPAS.minutes,RTC_UPAS.seconds); - //fprintf(fp, "%s,", timestr); + FILE *fp = fopen(filename, "scotttrial"); + fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,",RTC_UPAS.year, RTC_UPAS.month,RTC_UPAS.date,RTC_UPAS.hour,RTC_UPAS.minutes,RTC_UPAS.seconds); + fprintf(fp, "%s,", timestr); fprintf(fp, "%2.2f,%4.2f,%2.1f,%1.3f", temp,press,rh,atmoRho); fprintf(fp, "%d,%f,%d,%f," ,sharp1,sharpVolt1, sharp2, sharpVolt2); fprintf(fp, "%d,%f,%d,%f" ,sharp3,sharpVolt3, sharp4, sharpVolt4); - fprintf("%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6); - fclose(fp); + fprintf(fp, "%d,%f,%d,%f,\r\n" ,sharp5,sharpVolt5, sharp6, sharpVolt6); + fclose(fp); free(fp);