Code supports writing to the SD card as well as working with the Volckens group smartphone apps for the mbed HRM1017
Dependencies: ADS1115 BLE_API BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed nRF51822
Fork of UPAS_BLE_and_USB by
Diff: main.cpp
- Revision:
- 81:480f0310ef9a
- Parent:
- 80:5487ba127c82
- Child:
- 82:e01326a63ae9
diff -r 5487ba127c82 -r 480f0310ef9a main.cpp --- a/main.cpp Tue Sep 15 02:29:57 2015 +0000 +++ b/main.cpp Tue Sep 15 23:09:41 2015 +0000 @@ -21,7 +21,7 @@ #define SERIAL_BAUD_RATE 9600 #define SCL 20 #define SDA 22 -//#define Crono 0xD0 //D0 for the chronoDot + uint8_t txPayload[TXRX_BUF_LEN] = {0,}; uint8_t rxPayload[TXRX_BUF_LEN] = {0,}; @@ -90,7 +90,7 @@ float massflow; //g/min float volflow; //L/min float volflowSet = 1.0; //L/min -int logInerval = 10; +int logInerval = 10; //seconds double secondsD = 0; float massflowSet; float deltaVflow = 0.0; @@ -116,7 +116,7 @@ //int refresh_Time = 10; // refresh time in s, note calling read_GPS()(or similar) will still take how ever long it needs(hopefully < 1s) char device_name[] = "---------------"; -char filename[] = "/sd/UPAS0012LOG000000000000---------------.txt"; +char filename[] = "/sd/XXXX0000LOG000000000000---------------.txt"; SDFileSystem sd(SPIS_PSELMOSI, SPIS_PSELMISO, SPIS_PSELSCK, SPIS_PSELSS, "sd"); // I believe this matches Todd's pinout, let me know if this doesn't work. (p12, p13, p15, p14) @@ -219,15 +219,9 @@ vis = lightsensor.getVIS(); ir = lightsensor.getIR(); - //Mount the filesystem - //sd.mount(); FILE *fp = fopen(filename, "a"); fprintf(fp, "%02d,%02d,%02d,%02d,%02d,%02d,%1.3f,%1.3f,%2.2f,%4.2f,%2.1f,%1.3f,%1.3f,%5.1f,%1.1f,%1.1f,%1.1f,%1.1f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%1.3f,%1.3f,%f\r\n",RTC.year, RTC.month,RTC.date,RTC.hour,RTC.minutes,RTC.seconds,omronVolt,massflow,temp,press,rh,atmoRho,volflow,sampledVol,accel_x,accel_y,accel_z,accel_comp,uv,omronReading, vInReading, vBlowerReading, omronDiff,gasG.getAmps(), gasG.getVolts(), gasG.getCharge(),digital_pot_set, deltaMflow, deltaVflow, compass); fclose(fp); - //Unmount the filesystem - //sd.unmount(); - - //wait(1.2); } @@ -294,9 +288,9 @@ - if(volflowSet==1.0) { + if(volflowSet<=1.0) { gainFlow = 100; - } else if(volflowSet==2.0) { + } else if(volflowSet>=2.0) { gainFlow = 25; } else { gainFlow = 25; @@ -310,8 +304,22 @@ atmoRho = ((press-((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)))*100)/(287.0531*(temp+273.15))+((6.1078*pow((float)10,(float)((7.5*temp)/(237.3+temp))))*(rh/100)*100)/(461.4964*(temp+273.15)); massflowSet = volflowSet*atmoRho; //Digtal pot tf from file: UPAS v2 OSU-PrimaryFlowData FullSet 2015-05-29 CQ mods.xlsx + + //--------------------------------------------------------------// + // Calibration value checks // + //--------------------------------------------------------------// + while(1){ + pc.printf("%f,%f,%f,%f,%f\r\n",calibrations.DP4, calibrations.DP3, calibrations.DP2, calibrations.DP1, calibrations.DP0); + pc.printf("%f,%f,%f,%f\r\n",calibrations.omronVMin, calibrations.omronVMax, calibrations.omronMFMin, calibrations.omronMFMax); + pc.printf("%f,%f,%f,%f,%f\r\n",calibrations.MF4, calibrations.MF3, calibrations.MF2, calibrations.MF1, calibrations.MF0); + wait(1); + } + //--------------------------------------------------------------// + //--------------------------------------------------------------// + digital_pot_setpoint = (int)floor(calibrations.DP4*pow(massflowSet,4)+calibrations.DP3*pow(massflowSet,3)+calibrations.DP2*pow(massflowSet,2)+calibrations.DP1*massflowSet+calibrations.DP0); //min = 0x7F, max = 0x00 - + //pc.printf("%d\r\n", digital_pot_setpoint); + if(digital_pot_setpoint>=digitalpotMax) { digital_pot_setpoint = digitalpotMax; } else if(digital_pot_setpoint<=digitalpotMin) { @@ -381,7 +389,7 @@ } } - sprintf(filename, "/sd/UPAS0012LOG_%02d-%02d-%02d_%02d=%02d=%02d_%s.txt",RTC.year,RTC.month,RTC.date,RTC.hour,RTC.minutes,RTC.seconds,device_name); + sprintf(filename, "/sd/UPAS%04dLOG_%02d-%02d-%02d_%02d=%02d=%02d_%s.txt",serial_num,RTC.year,RTC.month,RTC.date,RTC.hour,RTC.minutes,RTC.seconds,device_name); FILE *fp = fopen(filename, "w"); fclose(fp); //pc.printf("%d\r\n",digital_pot_setpoint);