calibrate ec for graphite probe

This commit is contained in:
interfisch 2023-06-20 22:30:29 +02:00
parent 9f489c319f
commit 92ec32304c
5 changed files with 67 additions and 13 deletions

View File

@ -64,9 +64,10 @@ float ec_reference_adc=6016.88; //adc reference value for the calibration resist
//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};
//float ec_calibration_polynom[]={1033.928052655456,-3.8909104921922895,0.005627541436014758,-4.103988840997024e-06,1.7231981870816133e-09,-4.433707707721975e-13,7.203892111369395e-17,-7.406549810844244e-21,4.667420606439905e-25,-1.6439457516812463e-29,2.477292190335455e-34}; //20220505
float ec_calibration_polynom[]={-323.68589929771457,0.5836096440900665,-0.000279737392438965,5.98673062873e-08,-5.4460235093798435e-12,1.8535134644431135e-16}; //20230509
//float ec_calibration_polynom[]={-323.68589929771457,0.5836096440900665,-0.000279737392438965,5.98673062873e-08,-5.4460235093798435e-12,1.8535134644431135e-16}; //20230509
//float ec_calibration_polynom[]={212.6826331524675,-0.6043878865263305,0.000571551634082491,-1.827897106718841e-07,2.682337041246909e-11,-1.8368511021965982e-15,4.8269168538877025e-20}; //20230509 manuell
float ec_calibration_linearize_below_adc=6500; //use linear approximation below this adc value. 0=disable
float ec_calibration_polynom[]={-202.42892340068445,0.3775267988688599,-0.0001603031198536654,3.398964768344757e-08,-3.0277753798278316e-12,1.0137804308289433e-16}; //20230620, graphite electrodes
float ec_calibration_linearize_below_adc=4000; //use linear approximation below this adc value. 0=disable
float ec_calibration_linear_lowADC=746; //x0
float ec_calibration_linear_lowEC=0; //y0
@ -173,7 +174,7 @@ void ec_loop(unsigned long loopmillis) {
}
}else{ //measurement not running, then take calibration readings
if (loopmillis>last_read_ec+EC_CALIB_READ_INTERVAL) { //take reading into array
if (loopmillis>last_read_ec+EC_CALIB_READ_INTERVAL) { //take reading into arraysdf
last_read_ec=loopmillis;
if (loopmillis>ec_last_change_relay+EC_RELAY_SWITCH_SETTLETIME) { //values have settled

View File

@ -8,6 +8,8 @@
#include "wifi_settings.h"
#include "helpfunctions.h"
bool force_ec_measurement=false;
struct mqttValueTiming{
float minchange;
@ -25,7 +27,7 @@ MQTTClient client;
bool sendallnext_flag=false;
bool enableTiming=true;
bool force_ec_measurement=false;
void publishValueTimed(String topic,float value,uint8_t decimals,mqttValueTiming &mqttvt,unsigned long loopmillis);
void publishValue(String topic,float value,uint8_t decimals);

BIN
messung/20230620_NaCl.ods Normal file

Binary file not shown.

View File

@ -0,0 +1,41 @@
time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,ecMeasured
174369,26.75,6026.45,768.41,767.19,15
226453,26.75,6026.3,768.41,767.2,15
254513,26.75,6026.81,768.57,767.31,15
280571,26.75,6027.54,768.12,766.76,15
298621,26.75,6027.7,768.15,766.77,15
393748,26.75,6026.95,866.96,865.51,40
564951,26.75,6026.5,1100.59,1098.84,55
612030,26.75,6026.8,1240.29,1238.25,60
676126,26.75,6026.96,1536.88,1534.3,80
708190,26.75,6027.02,1834.7,1831.62,100
740254,26.75,6027.66,2122.36,2118.56,120
772318,26.75,6027.68,2586.95,2582.31,155
805383,26.75,6027.63,3363.96,3357.96,220
860470,26.75,6027.38,3874.01,3867.26,260
906548,26.75,6027.63,4411.25,4403.39,320
945619,26.78,6027.32,5086.8,5077.99,390
992698,26.8,6026.66,5780.72,5771.34,470
1040778,26.81,6026.3,6346.3,6336.38,560
1095867,26.81,6026.54,6959.73,6948.58,650
1125929,26.81,6026.76,7704.95,7692.32,780
1152988,26.81,6026.91,8014.21,8000.88,850
1184051,26.81,6026.74,8444.22,8430.4,940
1240140,26.85,6026.3,9119.98,9105.73,1120
1286218,26.87,6026.59,9769.52,9753.78,1310
1322286,26.87,6026.39,10601.19,10584.46,1630
1433429,26.88,6026.82,11137.44,11119.07,1890
1463491,26.93,6027.01,11235.27,11216.38,1940
1495555,26.94,6026.65,11451,11432.44,2060
1524616,26.94,6026.15,11627.25,11609.36,2170
1556680,26.94,6026.38,11886.32,11867.59,2340
1590746,26.94,6026.27,12143.11,12124.2,2540
1639827,26.95,6026.5,12335.04,12315.34,2700
1676896,27,6026.65,12505.56,12485.29,2850
1712964,27,6027.25,12673.08,12651.28,3010
1749032,27,6027.5,12956.33,12933.5,3310
1822169,27.02,6026.78,13440.36,13418.28,3940
1853232,27.06,6026.5,13607.09,13585.36,4220
1895306,27.06,6026.53,13765.66,13743.62,4590
1935379,27.06,6026.66,13895.97,13873.41,4860
1967443,27.06,6026.62,13885.23,13862.79,5120
1 time tempReservoir ECadcCalib ECadc ECadcAdjusted ecMeasured
2 174369 26.75 6026.45 768.41 767.19 15
3 226453 26.75 6026.3 768.41 767.2 15
4 254513 26.75 6026.81 768.57 767.31 15
5 280571 26.75 6027.54 768.12 766.76 15
6 298621 26.75 6027.7 768.15 766.77 15
7 393748 26.75 6026.95 866.96 865.51 40
8 564951 26.75 6026.5 1100.59 1098.84 55
9 612030 26.75 6026.8 1240.29 1238.25 60
10 676126 26.75 6026.96 1536.88 1534.3 80
11 708190 26.75 6027.02 1834.7 1831.62 100
12 740254 26.75 6027.66 2122.36 2118.56 120
13 772318 26.75 6027.68 2586.95 2582.31 155
14 805383 26.75 6027.63 3363.96 3357.96 220
15 860470 26.75 6027.38 3874.01 3867.26 260
16 906548 26.75 6027.63 4411.25 4403.39 320
17 945619 26.78 6027.32 5086.8 5077.99 390
18 992698 26.8 6026.66 5780.72 5771.34 470
19 1040778 26.81 6026.3 6346.3 6336.38 560
20 1095867 26.81 6026.54 6959.73 6948.58 650
21 1125929 26.81 6026.76 7704.95 7692.32 780
22 1152988 26.81 6026.91 8014.21 8000.88 850
23 1184051 26.81 6026.74 8444.22 8430.4 940
24 1240140 26.85 6026.3 9119.98 9105.73 1120
25 1286218 26.87 6026.59 9769.52 9753.78 1310
26 1322286 26.87 6026.39 10601.19 10584.46 1630
27 1433429 26.88 6026.82 11137.44 11119.07 1890
28 1463491 26.93 6027.01 11235.27 11216.38 1940
29 1495555 26.94 6026.65 11451 11432.44 2060
30 1524616 26.94 6026.15 11627.25 11609.36 2170
31 1556680 26.94 6026.38 11886.32 11867.59 2340
32 1590746 26.94 6026.27 12143.11 12124.2 2540
33 1639827 26.95 6026.5 12335.04 12315.34 2700
34 1676896 27 6026.65 12505.56 12485.29 2850
35 1712964 27 6027.25 12673.08 12651.28 3010
36 1749032 27 6027.5 12956.33 12933.5 3310
37 1822169 27.02 6026.78 13440.36 13418.28 3940
38 1853232 27.06 6026.5 13607.09 13585.36 4220
39 1895306 27.06 6026.53 13765.66 13743.62 4590
40 1935379 27.06 6026.66 13895.97 13873.41 4860
41 1967443 27.06 6026.62 13885.23 13862.79 5120

View File

@ -6,6 +6,8 @@
bool debug=true; //print Serial information
bool mqtt=false;
bool eccalibrationoutput=false; //serial output for ec calibration
@ -100,8 +102,6 @@ void setup() {
*/
//Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,EC,EC25");
//Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted");
@ -125,15 +125,23 @@ void loop() {
static bool getReading=false;
if (!digitalRead(PIN_BUTTON)) {
if (!eccalibrationoutput && !digitalRead(PIN_BUTTON)) {
valueError=false;
Serial.println("Reset ValueError flag by user");
digitalWrite(PIN_LED,valueError);
delay(100);
}
/*
if (ec_flag_measurement_available && getReading) {
if (eccalibrationoutput && !digitalRead(PIN_BUTTON) && !getReading) {
getReading=true;
force_ec_measurement=true;
ec_flag_measurement_available=false;
digitalWrite(PIN_LED,HIGH);
}
if (eccalibrationoutput && ec_flag_measurement_available && getReading) {
ec_flag_measurement_available=false;
getReading=false;
digitalWrite(PIN_LED,LOW);
@ -143,7 +151,7 @@ void loop() {
Serial.print(ec_adc); Serial.print(",");
Serial.print(ec_adc_adjusted);
Serial.println();
}*/
}
if (loopmillis>last_check+2000) { //check values
@ -161,7 +169,9 @@ void loop() {
}
digitalWrite(PIN_LED,valueError);
if (!eccalibrationoutput) {
digitalWrite(PIN_LED,valueError);
}