Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ADS1115 BME280 CronoDot SDFileSystem mbed
Fork of Outdoor_UPAS_v1_2_powerfunction by
Diff: main.cpp
- Revision:
- 46:99d129bfdbbd
- Parent:
- 45:5e0942088e31
- Child:
- 47:fe50d72c7adc
--- a/main.cpp Tue May 03 17:57:01 2016 +0000 +++ b/main.cpp Wed May 04 01:33:48 2016 +0000 @@ -174,8 +174,10 @@ int digitalpotMax = 127; int digitalpotMin = 10; -int dutyUp; -int dutyDown; +//int dutyUp; +//int dutyDown; +int dutycycleSecOn; +int dutyCycleI; bool gpsFix; uint8_t gpssatellites = 0; @@ -583,6 +585,16 @@ //pc.printf("%s,%s,%d,%s,%d,%s,%d,%s,%d,%s,%d,%s,%d\r\n", timestr,yrstr,stYr,mostr,stMo,daystr,stDay,hrstr,stHr,minstr,stMin,secstr,stSec); + ///////////////////////////// + ///Dutycycle + //////////////////////////// + if(stSec >= dutycycleSecOn && pumps == 1){ + pumps = 0; + } + else if(stSec < dutycycleSecOn && pumps == 0) { + pumps = 1; + } + //Get Sensor Data except GPS //////////////////////////// press = bmesensor.getPressure(); @@ -607,8 +619,8 @@ //Check for fully charged battery if(bVolt > 1750 && amps > 8191) { - RGB_LED.set_led(0,0,0); - //RGB_LED.set_led(0,1,0); + //RGB_LED.set_led(0,0,0); + RGB_LED.set_led(0,1,0); //Check for battery with ~2 hours left of runtime at 2lpm to remind user to plug in sampler }else if(amps > 8191 && bVolt < 1500) { if(ledOn) { @@ -643,7 +655,7 @@ wait(1); //Turn pumps back on once the sampler is plugged in and charging after pumps shutoff and 3.3V rail drops out } else if(pumps == 0 && amps < 8191) { - pumps = 1; + //pumps = 1; } @@ -684,7 +696,7 @@ fprintf(fp, "%f,%f,%06d,%06d,", gpslatitude, gpslongitude, (long)gps.date, (long)gps.utc); //fprintf(fp, "%f,%d,%f,%f,%d,", gpsspeed, gpssatellites, gpscourse, gpsaltitude, gpsFix); fprintf(fp, "%f,%d,%f,%d,", gpsspeed, gpssatellites, gpsaltitude, gpsFix); - fprintf(fp, "%f,%f,%f,%d,%d\r\n", homeDistance, home2Distance, workDistance, location, pumps == 1); // test and add in speed, etc that Josh added in to match the adafruit GPS + fprintf(fp, "%d,%d\r\n", dutyCycleI, pumps == 1); // test and add in speed, etc that Josh added in to match the adafruit GPS fclose(fp); free(fp); @@ -888,6 +900,16 @@ uint8_t cartridgeID[3] = {0,}; E2PROM.read(0x00070, cartridgeID,3); + //Get the dutycycle information + uint8_t dutycycleStr[3] = {0,}; + E2PROM.read(0x00076, dutycycleStr,3); + dutyCycleI = ((dutycycleStr[0]-48)*100 + (dutycycleStr[1]-48)*10 + (dutycycleStr[2]-48)); + float dutycycleF = ((float)dutyCycleI/100); + dutycycleSecOn = (int)(dutycycleF*60); + + //wait(1); + //pc.printf("%s,%d,%f,%d\r\n", dutycycleStr,dutyCycleI,dutycycleF,dutycycleSecOn); + //Get the proper serial number uint8_t serialBytes[2] = {0,}; E2PROM.read(0x00034,serialBytes,2); @@ -945,6 +967,8 @@ wait(0.5); } + + time_t seconds = time(NULL); strftime(timestr, 32, "%y-%m-%d-%H=%M=%S", localtime(&seconds)); @@ -1072,8 +1096,16 @@ wait(1); RGB_LED.set_led(0,0,0); + while(fmod((double)stSec,10)!=0) { + //pc.printf("%f, %f\r\n", floor(secondsD), floor(lastsecondD)); + time_t seconds = time(NULL); + strftime(secstr, 4, "%S", localtime(&seconds)); + stSec = atoi(secstr); + wait_ms(100); + } + + logg.attach(&log_data, logInerval); stop.attach(&check_stop, 9); // check if we should shut down every 9 number seconds, starting after the start. - logg.attach(&log_data, logInerval); flowCtl.attach(&flowControl, 3); @@ -1086,13 +1118,8 @@ while (1) { // Do other things... - /* - pumps = 1; - wait(5); - pumps = 0; - wait(5); - */ - } + + }