ec calibration measurements 20230502

This commit is contained in:
interfisch 2023-05-03 01:47:42 +02:00
parent 490d890368
commit fe6d4e98fa
2 changed files with 13 additions and 9 deletions

View File

@ -31,7 +31,8 @@ unsigned long last_measurement_ec=0;
#define EC_RELAY_SWITCH_SETTLETIME 500 //time until voltage of ec circuit has settled
const uint16_t ec_centerADCvalue=1909; //adc value when probe resistance is equal to the range resistor (mean of both)
//const uint16_t ec_centerADCvalue=9026; //adc value when probe resistance is equal to the range resistor (mean of both)
//Range Resistor is two parallel 1k2 = 600 Ohm
unsigned long ec_last_change_relay=0; //millis of last relay change
@ -46,7 +47,7 @@ float ec; //ec value after adjustment for reference (at current temperature)
float ec25; //ec value but temperature adjusted for 25 degC
float ec_tempadjust_alpa=0.2; //TODO
float ec_reference_adc=5889; //adc reference value for the calibration resistor measurement
float ec_reference_adc=6011.5; //adc reference value for the calibration resistor measurement.
//x^0*p[0] + ... + x^n*p[n]
float ec_calibration_polynom[]={691.5992624638029,-1.4015367296761692,0.0008513503472324141,-2.2140576823179093e-07,2.8962580780180067e-11,-1.8577565383307114e-15,4.7162479484903865e-20};
@ -82,7 +83,7 @@ void ec_loop(unsigned long loopmillis) {
last_measurement_ec=loopmillis;
ec_startMeasurement();
ec_connectProbe(true);
Serial.println("Measuring EC");
ecstate=MEASURE;
}
break;
@ -90,7 +91,6 @@ void ec_loop(unsigned long loopmillis) {
case MEASURE:
if (ec_measurementReady()) {
ec_releaseRelay();
Serial.println("Finished EC");
ec_adc=getMean(ec_array,EC_ARRAY_SIZE);
if (isValueArrayOK(ec_calib_array,EC_CALIB_ARRAY_SIZE,0)){
ec_calib_adc=getMean(ec_calib_array,EC_CALIB_ARRAY_SIZE);

View File

@ -62,16 +62,20 @@ void setup() {
delay(200);
//Test adc to ec function output
/*
Serial.println();
for (int i=830;i<13300;i+=100) {
float _ec=ec_getECfromADC(i);
Serial.print(i); Serial.print(","); Serial.print(_ec); Serial.println();
}
delay(100000);
*/
Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,EC,EC25");
//Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,EC,EC25");
Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted");
}
@ -120,9 +124,9 @@ void loop() {
Serial.print(ec_calib_adc); Serial.print(",");
Serial.print(ec_adc); Serial.print(",");
Serial.print(ec_adc_adjusted); Serial.print(",");
Serial.print(ec); Serial.print(",");
Serial.print(ec25);
Serial.print(ec_adc_adjusted); //Serial.print(",");
//Serial.print(ec); Serial.print(",");
//Serial.print(ec25);
Serial.println();