diff --git a/daq b/daq index 2a71f08..bc1781d 100755 Binary files a/daq and b/daq differ diff --git a/daq.c b/daq.c index a1a79d8..e04abd1 100644 --- a/daq.c +++ b/daq.c @@ -18,6 +18,7 @@ #define Rep_Dev_ID "Y\r\n" #define Pulling_Mode "K 2\r\n" #define OX_P_Mode "M 1\r\n" +#define FILnUNFIL "M 6\r\n" #define unf_gas_con "z\r\n" #define fil_gas_con "Z\r\n" #define Temperature "T\r\n" @@ -25,7 +26,6 @@ #define percent_oxigen "%\r\n" #define ppm_oxigen "O\r\n" #define M_zZTHBD "M 14406\r\n" -#define Readings_CM "Q\r\n" #define Readings_OX "A\r\n" @@ -52,6 +52,7 @@ int main(int argc, char *argv[]){ //configuración de sensores printf("Configuring CO2 sensor\n"); sensConf(GC0017, B9600, Pulling_Mode, " K 00002\r\n"); + sensConf(GC0017, B9600, FILnUNFIL, " M 00006\r\n"); printf("Configuring CO sensor\n"); sensConf(CM31911, B9600, Pulling_Mode, "K 00002\r\n"); sensConf(CM31911, B9600, M_zZTHBD, "M 14406\r\n"); @@ -141,15 +142,14 @@ int str2int(unsigned char *ptr){ int DAQ(int t_hrs, int tm_s) { FILE* dfp; // create a file pointer dfp - - int co2, co, o2, temp; - unsigned char co_uf[10]="", co_f[10]="", + //int co2, co, o2, temp; + unsigned char co2_uf[10]="", co2_f[10]="", + co_uf[10]="", co_f[10]="", o2_ppm[10]="", o2_xcent[10]="", co2_temp[10]="", o2_temp[10]="", co2_press[10]="", o2_press[10]="", co2_relH[10]="", DATA[100]=""; - clock_t start_t, end_t; time_t new_time, prev_time, t0; double tm_ms = tm_s*1e6 - 0.20e6; @@ -159,14 +159,12 @@ int DAQ(int t_hrs, int tm_s) dfp = fopen(data_file_path, "w"); // open file for writing time_t curtime; time(&curtime); - fprintf(dfp, "%sStarting DAQ\ntime(s)\tCO2(ppm)\tCO unfil(ppm)\tCO fil(ppm)"\ + fprintf(dfp, "%sStarting DAQ\ntime(s)\tCO2 unfil(ppm)\tCO2 fil(ppm)\tCO unfil(ppm)\tCO fil(ppm)"\ "\tO2(ppm)\tO2(%c)\tTemperaure C02(ºC*10)\tTemperaure 02(ºC)"\ "\tPressure C02(.mBar)\tPresure 02(mBar)\tRelative Humidity(.)\n", ctime(&curtime), '%'); // send the value to the file fclose(dfp); // close the file using the file pointer - - //ciclo t0 = time(NULL) + tm_s; new_time = t0; @@ -181,15 +179,17 @@ int DAQ(int t_hrs, int tm_s) start_t = clock(); new_time = time(NULL); //command transmitions - uartTransmit(CM31911, Readings_CM); + uartTransmit(CM31911, get_readigns); uartTransmit(OX0052, Readings_OX); - uartTransmit(GC0017, unf_gas_con); + uartTransmit(GC0017, get_readigns); //uart receptions uartReceive(OX0052); uartReceive(CM31911); - co2 = read_measure(GC0017, 10, 0); + uartReceive(GC0017); + memcpy(co2_uf, gmeasures(receive[GC0017], 'z', 5), 5); + memcpy(co2_f, gmeasures(receive[GC0017], 'Z', 5), 5); memcpy(co_uf, gmeasures(receive[CM31911], 'z', 5), 5); memcpy(co_f, gmeasures(receive[CM31911], 'Z', 5), 5); memcpy(o2_ppm, gmeasures(receive[OX0052], 'O', 6), 6); @@ -200,11 +200,11 @@ int DAQ(int t_hrs, int tm_s) memcpy(o2_press, gmeasures(receive[OX0052], 'P', 4), 4); memcpy(co2_relH, gmeasures(receive[CM31911], 'H', 5), 5); - sprintf(DATA, "%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", - (int)(new_time-t0), co2, co_uf, co_f, o2_ppm, o2_xcent, + sprintf(DATA, "%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", + (int)(new_time-t0), co2_uf, co2_f, co_uf, co_f, o2_ppm, o2_xcent, co2_temp, o2_temp, co2_press, o2_press, co2_relH); - printf("time(s)\tCO2(ppm)\tCO unfil(ppm)\tCO fil(ppm)"\ + printf("time(s)\tCO2 unfil(ppm)\tCO2 fil(ppm)\tCO unfil(ppm)\tCO fil(ppm)"\ "\tO2(ppm)\tO2(%c)\tTemperaure C02(ºC*10)\tTemperaure 02(ºC)"\ "\tPressure C02(.mBar)\tPresure 02(mBar)\tRelative Humidity(.)\n", '%'); printf("%s\n", DATA);