code changes for ec calibration measurements
This commit is contained in:
parent
09b090f58f
commit
c9303f8a96
12
include/ec.h
12
include/ec.h
|
@ -16,18 +16,18 @@ bool ec_flag_measurement_available=false;
|
||||||
#define EC_RESOLUTION 8
|
#define EC_RESOLUTION 8
|
||||||
#define EC_FREQUENCY 5000
|
#define EC_FREQUENCY 5000
|
||||||
|
|
||||||
#define EC_CALIB_ARRAY_SIZE 64
|
#define EC_CALIB_ARRAY_SIZE 256
|
||||||
uint16_t ec_calib_array[EC_CALIB_ARRAY_SIZE];
|
uint16_t ec_calib_array[EC_CALIB_ARRAY_SIZE];
|
||||||
uint16_t ec_calib_array_pos=0;
|
uint16_t ec_calib_array_pos=0;
|
||||||
#define EC_CALIB_READ_INTERVAL 100 //interval of reading adc value inside a measurement
|
#define EC_CALIB_READ_INTERVAL 250 //interval of reading adc value inside a measurement
|
||||||
|
|
||||||
#define EC_ARRAY_SIZE 64
|
#define EC_ARRAY_SIZE 256
|
||||||
uint16_t ec_array[EC_ARRAY_SIZE];
|
uint16_t ec_array[EC_ARRAY_SIZE];
|
||||||
uint16_t ec_array_pos=EC_ARRAY_SIZE;
|
uint16_t ec_array_pos=EC_ARRAY_SIZE;
|
||||||
unsigned long last_measurement_ec=0;
|
unsigned long last_measurement_ec=0;
|
||||||
#define EC_MEASUREMENT_INTERVAL 10000 //complete filtered measurement every x ms
|
#define EC_MEASUREMENT_INTERVAL 30000 //complete filtered measurement every x ms
|
||||||
//One filtered measurement takes EC_READ_INTERVAL*EC_ARRAY_SIZE*4
|
//One filtered measurement takes EC_READ_INTERVAL*EC_ARRAY_SIZE*4
|
||||||
#define EC_READ_INTERVAL 5 //interval of reading adc value inside a measurement
|
#define EC_READ_INTERVAL 10 //interval of reading adc value inside a measurement. one reading takes about 9-10ms
|
||||||
|
|
||||||
#define EC_RELAY_SWITCH_SETTLETIME 500 //time until voltage of ec circuit has settled
|
#define EC_RELAY_SWITCH_SETTLETIME 500 //time until voltage of ec circuit has settled
|
||||||
|
|
||||||
|
@ -47,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 ec25; //ec value but temperature adjusted for 25 degC
|
||||||
|
|
||||||
float ec_tempadjust_alpa=0.2; //TODO
|
float ec_tempadjust_alpa=0.2; //TODO
|
||||||
float ec_reference_adc=6011.5; //adc reference value for the calibration resistor measurement.
|
float ec_reference_adc=6016.88; //adc reference value for the calibration resistor measurement.
|
||||||
|
|
||||||
//x^0*p[0] + ... + x^n*p[n]
|
//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[]={691.5992624638029,-1.4015367296761692,0.0008513503472324141,-2.2140576823179093e-07,2.8962580780180067e-11,-1.8577565383307114e-15,4.7162479484903865e-20};
|
||||||
|
|
|
@ -75,7 +75,7 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
//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");
|
Serial.println("time,tempReservoir,ECadcCalib,ECadc,ECadcAdjusted,sm");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ void loop() {
|
||||||
|
|
||||||
//flow_loop(loopmillis);
|
//flow_loop(loopmillis);
|
||||||
|
|
||||||
//sm_loop(loopmillis);
|
sm_loop(loopmillis);
|
||||||
|
|
||||||
|
|
||||||
static bool getReading=false;
|
static bool getReading=false;
|
||||||
|
@ -127,9 +127,10 @@ void loop() {
|
||||||
|
|
||||||
Serial.print(ec_calib_adc); Serial.print(",");
|
Serial.print(ec_calib_adc); Serial.print(",");
|
||||||
Serial.print(ec_adc); Serial.print(",");
|
Serial.print(ec_adc); Serial.print(",");
|
||||||
Serial.print(ec_adc_adjusted); //Serial.print(",");
|
Serial.print(ec_adc_adjusted); Serial.print(",");
|
||||||
//Serial.print(ec); Serial.print(",");
|
//Serial.print(ec); Serial.print(",");
|
||||||
//Serial.print(ec25);
|
//Serial.print(ec25);
|
||||||
|
Serial.print(getMean(sm_mean,SM_SIZE));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue