From 40d7446c5a9cfcdc0569fdfa47ecf985c722c749 Mon Sep 17 00:00:00 2001 From: nelolik Date: Tue, 16 Feb 2021 13:28:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=80?= =?UTF-8?q?=D0=B0=D1=81=D1=87=D1=91=D1=82=20=D0=B8=D0=B7=D0=BE=D0=BB=D1=8F?= =?UTF-8?q?=D1=86=D0=B8=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- isolatio.c | 21 ++++++++++----------- isolatio.h | 6 ++++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/isolatio.c b/isolatio.c index 8305c00..4ce5cb3 100644 --- a/isolatio.c +++ b/isolatio.c @@ -16,7 +16,6 @@ OPTOCANAL opt[2]; ISOLATION isolation1 = ISOLATION_DEFAULT; ISOLATION isolation2 = ISOLATION_DEFAULT; -static void calibrateIsolation(); void init_isolation_struct(void); void DCLK(int i, int x) @@ -177,8 +176,8 @@ void timer_Init() -int calibration1 = 0; //ΟΧ 31 - 0; 32 - (-2); 21 - 1 -int calibration2 = 0; //ΟΧ 31 - 3; 32 - (-4); //21 - 1 +int isol_calibration[2] = {0, 0}; //ΟΧ 31 - 0; 32 - (-2); 21 - 1 + //ΟΧ 31 - 3; 32 - (-4); //21 - 1 void init_isolation_struct(void) @@ -260,8 +259,8 @@ void isolation_calc(void) buff[l] = isolation1.buff[k]; k++; } - isolation1.max_val = buff[5]; - isolation1.min_val = buff[IS_BUFF_SIZE - 5]; + isolation1.max_val = buff[4]; + isolation1.min_val = buff[IS_BUFF_SIZE - 4]; k = 0; // while(k < IS_BUFF_SIZE) // { @@ -276,7 +275,7 @@ void isolation_calc(void) tmp_delta = isolation1.max_val - isolation1.min_val; if(!isolation1.f_not_ready) { - isolation1.row_MOms = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + calibration1 + isolation1.row_MOms = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + isol_calibration[0] : isolation1.row_MOms; if (isolation1.row_MOms > isolation1.MOms_x_10) { isolation1.MOms_x_10 += 2; //isolation1.row_MOms; @@ -284,7 +283,7 @@ void isolation_calc(void) else if (isolation1.row_MOms < isolation1.MOms_x_10) {isolation1.MOms_x_10 -= 1;} } else { - isolation1.MOms_x_10 = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + calibration1 + isolation1.MOms_x_10 = tmp_delta ? COEFF_ACP_TO_MOMx10_1 / (tmp_delta << 10) - 200 + isol_calibration[0] : isolation1.MOms_x_10; } if (isolation1.MOms_x_10 > 50) { isolation1.MOms_x_10 = 50;} @@ -337,8 +336,8 @@ void isolation_calc(void) buff[l] = isolation2.buff[k]; k++; } - isolation2.max_val = buff[5]; - isolation2.min_val = buff[IS_BUFF_SIZE - 5]; + isolation2.max_val = buff[4]; + isolation2.min_val = buff[IS_BUFF_SIZE - 4]; // // k = 0; // while(k < IS_BUFF_SIZE) @@ -362,14 +361,14 @@ void isolation_calc(void) // } tmp_delta = isolation2.max_val - isolation2.min_val; if(!isolation2.f_not_ready) { - isolation2.row_MOms = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + calibration2 //1668494131L + isolation2.row_MOms = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + isol_calibration[1] //1668494131L : isolation2.row_MOms; if (isolation2.row_MOms > isolation2.MOms_x_10 ) { isolation2.MOms_x_10 += 2; // isolation2.row_MOms; } else if (isolation2.row_MOms < isolation2.MOms_x_10 ) {isolation2.MOms_x_10 -= 1; } } else { - isolation2.MOms_x_10 = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + calibration2 + isolation2.MOms_x_10 = tmp_delta ? (COEFF_ACP_TO_MOMx10_2) / (tmp_delta << 10) - 200 + isol_calibration[1] : isolation2.MOms_x_10; } if (isolation2.MOms_x_10 > 50) { isolation2.MOms_x_10 = 50;} diff --git a/isolatio.h b/isolatio.h index 2d63e29..f03bc3f 100644 --- a/isolatio.h +++ b/isolatio.h @@ -24,13 +24,15 @@ typedef struct { unsigned int pause_counter; unsigned int pause_time; - unsigned long adc_value; + long long adc_value; }ISOLATION; +#define ISOLATION_DEFAULT {{0,0,0,0,0,0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0} + extern ISOLATION isolation1; extern ISOLATION isolation2; +extern int isol_calibration[2]; -#define ISOLATION_DEFAULT {{0,0,0,0,0,0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0} void isolation_calc(void);