Mercurial > public > ostc4
diff Discovery/Src/data_exchange_main.c @ 747:df0d43da1614
Added pressure compensation to CO2 detection:
A pressure compensation is needed if the ExplorIR shall be used under extended pressure conditions. The procedure recommended by the application note has been integrated. To keep things simple the focus of the CO2 measurement is not the precision, as it is needed for the decompression calculation, but the indication of a critical increase of CO2 in the breathing loop. That's why only a lookup table with 1000ppm steps has been implemented instead of calculating the polynom for every measurement.
author | Ideenmodellierer |
---|---|
date | Sun, 05 Mar 2023 22:06:47 +0100 |
parents | 190e5814b2f5 |
children | aa6006975e76 |
line wrap: on
line diff
--- a/Discovery/Src/data_exchange_main.c Tue Feb 21 21:19:31 2023 +0100 +++ b/Discovery/Src/data_exchange_main.c Sun Mar 05 22:06:47 2023 +0100 @@ -57,6 +57,7 @@ /* Includes ------------------------------------------------------------------*/ #include <stdlib.h> #include <string.h> // for memcpy +#include <math.h> #include "stm32f4xx_hal.h" #include "stdio.h" #include "ostc.h" @@ -409,6 +410,10 @@ break; case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; break; +#ifdef ENABLE_SENTINEL_MODE + case SENSOR_SENTINEL: SensorActive[SENSOR_SENTINEL] = 1; + break; +#endif default: break; } @@ -428,7 +433,7 @@ } #ifdef ENABLE_SENTINEL_MODE - if(settings->ppo2sensors_source == O2_SENSOR_SOURCE_SENTINEL) + if(SensorActive[SENSOR_SENTINEL]) { externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_SENTINEL; externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON); @@ -829,9 +834,11 @@ uint8_t idx; float meter = 0; SSettings *pSettings; - + +#ifdef ENABLE_EXTERNAL_PRESSURE + float CO2Corr = 0.0; +#endif - // wireless - �ltere daten aufr�umen #if 0 for(int i=0;i<(2*NUM_GASES+1);i++) @@ -1139,8 +1146,14 @@ pStateReal->sensorErrorsRTE = dataIn.sensorErrors; /* data from CO2 sensor */ - pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm; + pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm * 10; /* Scale factor depends on sensor */ pStateReal->lifeData.CO2_data.signalStrength = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_signalStrength; + +#ifdef ENABLE_EXTERNAL_PRESSURE + CO2Corr = 2.811*pow(10,-38)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,6)- 9.817*pow(10,-32)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,5)+1.304*pow(10,-25)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,4) + -8.216*pow(10,-20)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,3)+2.311*pow(10,-14)*pow(pStateReal->lifeData.CO2_data.CO2_ppm,2) - 2.195*pow(10,-9)*pStateReal->lifeData.CO2_data.CO2_ppm - 1.471*pow(10,-3); + pStateReal->lifeData.CO2_data.CO2_ppm = pStateReal->lifeData.CO2_data.CO2_ppm / (1.0 + (CO2Corr * ((stateRealGetPointer()->lifeData.pressure_surface_bar * 1000) - ((stateRealGetPointer()->lifeData.ppO2Sensor_bar[2] *1000))))); +#endif } /* apnea specials